[Xtext 2.0] Problem referencing sub entities [message #695050] |
Sun, 10 July 2011 21:42 |
Sebastian Herold Messages: 5 Registered: July 2011 |
Junior Member |
|
|
Hi,
I was experimenting with Xtext and got stuck in referencing sub entities. Here my simple grammar:
Model:
(classes+=Class)+
(refs+=Reference)*
;
Class:
'class' name=ID '{'
(fields+=Field)*
'}'
;
Field:
'field' name=ID
;
Reference:
'set' name=ID from=[Field]
;
Now, I started with a short exmaple model:
class Test {
field name
field code
field size
}
But I had problems to define a Reference-rule. I typed:
but got no suggestion for the referencing field in the editor. Then, I typed:
and got a quick-fix to change "name" to "Test.name". I confirmed, but now I have a syntax error in line:
Is there any other solution to reference sub-entities?
[Updated on: Sun, 10 July 2011 21:45] Report message to a moderator
|
|
|
Re: [Xtext 2.0] Problem referencing sub entities [message #695053 is a reply to message #695050] |
Sun, 10 July 2011 21:50 |
|
Hi,
you are stumbling over qualified names. by default these are built like ...grandparentname.parentname.name.
in your case for a field Test.name, Test.code and Test.size
so you can change this default behaviour by registering a custom IQualifiedNameProvider (e.g subclass of DefaultDeclarativeQualifiedNameProvider)
or to allow the qualified name in your grammar:
Reference:
'set' name=ID from=[Field|FQN]
;
FQN: ID ("." ID)*;
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04016 seconds