Skip to main content



      Home
Home » Modeling » TMF (Xtext) » XText cross referencing scoping
XText cross referencing scoping [message #898816] Fri, 27 July 2012 14:26 Go to next message
Eclipse UserFriend
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 14:40 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: XText cross referencing scoping [message #898829 is a reply to message #898818] Fri, 27 July 2012 16:18 Go to previous messageGo to next message
Eclipse UserFriend
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 195 times)
Re: XText cross referencing scoping [message #898835 is a reply to message #898829] Fri, 27 July 2012 17:04 Go to previous messageGo to next message
Eclipse UserFriend
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 17:12 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 05:33:32 EDT 2025

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

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

Back to the top