Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText cross referencing scoping
XText cross referencing scoping [message #898816] Fri, 27 July 2012 18:26 Go to next message
Pooyan Behnamghader is currently offline Pooyan BehnamghaderFriend
Messages: 7
Registered: July 2012
Junior Member
I have some problems with xtext cross referencing.
Here is a very simple grammer:

Model: block=Block? cs+=Company* ;
Block: '{' g=[Employee] '}';
Company: 'Company' name=ID
'{' es+= Employee* '}';
Employee: 'Employee' name=ID ';' ;

and it is my dsl :

{ Pooyan }
Company Sony{
Employee Pooyan;
Employee John;
}

It is always shown that "Couldn't resolve reference to Employee 'Pooyan'." Could anyone please help me? I have no idea...
Re: XText cross referencing scoping [message #898818 is a reply to message #898816] Fri, 27 July 2012 18:40 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1162
Registered: July 2009
Senior Member
Hi,

by default the name of an object is composed by the name of its parent combined with its simple name. That is, the fully qualified name of Pooyan will be
Sony.Pooyan
This is why Pooyan alone cannot be resolved. You will also get no code completion for the employee reference in Block, as you want to reference by an ID (not a qualified name) and there are no employees visible via their simple name only.

Note that you can "browse" the objects referable in Xtext models via the Open-Model-Element-Dialog (Shift-Ctrl-F3). There you will see all objects with their type and their name.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: XText cross referencing scoping [message #898829 is a reply to message #898818] Fri, 27 July 2012 20:18 Go to previous messageGo to next message
Pooyan Behnamghader is currently offline Pooyan BehnamghaderFriend
Messages: 7
Registered: July 2012
Junior Member
Hi Alex.

Thank you for your quick and kind answer.
I use Sony.Pooyan but it makes no difference. I've spend 1 complete day to solve this problem but I couldn't solve it! I don't know why. I also check the types in OMED but Employee is just Employee...

my complete grammar is :

grammar org.xtext.example.mydsl1.Test with org.eclipse.xtext.common.Terminals
generate test "link"

Model: cs+=Company* block=Block;
Block: '{' g=[Employee] '}';
Company: 'Company' name=ID
'{' es+= Employee* '}';
Employee: 'Employee' name=ID ';' ;

and my testing model is : ( i want this one to be correct but it is not )
Company Sony{
Employee Pooyan;
Employee John;
}
{
Sony.Pooyan
}

I've attached the picture of employee type in OMED

I was wondering if you could please tell me how to solve it.

[Sorry if it is a silly problem...]

  • Attachment: Employee.png
    (Size: 28.33KB, Downloaded 75 times)
Re: XText cross referencing scoping [message #898835 is a reply to message #898829] Fri, 27 July 2012 21:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6552
Registered: July 2009
Senior Member
Hi,

you screenshot does not show the "Open Model Element Dialog" Crtl+Shift+F3

you have basically two options

(1) publish employees under a simple name (by custom IQualifiedNameProvider)
(2) change the grammar to allow qualified names

Block: '{' g=[Employee|FQN] '}'; FQN: ID ("." ID)*;


~Christian
Re: XText cross referencing scoping [message #898836 is a reply to message #898835] Fri, 27 July 2012 21:12 Go to previous message
Pooyan Behnamghader is currently offline Pooyan BehnamghaderFriend
Messages: 7
Registered: July 2012
Junior Member
Hi Cristian,

Thank you so much. It works Smile
Thank you Smile

Pooyan
Previous Topic:Escaping keywords with a QualifiedNameValueConverter?
Next Topic:JUnit test not using current validator
Goto Forum:
  


Current Time: Mon Dec 22 22:11:30 GMT 2014

Powered by FUDForum. Page generated in 0.01769 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software