XText cross-reference to rule containing a cross-reference [message #1377158] |
Fri, 23 May 2014 15:09  |
Eclipse User |
|
|
|
The following is a simple representation of an xtext grammar with cross references.
There are two entities - a container and an object - and operations on each. I would like to be able to refer to an object either by it's own name, or qualified with the container name. I would like cross-references to be available in either case.
The grammar I have is:
Model:
operations+=Operation*;
ContainerEntity:
name=ID;
ObjectEntity:
(first=[ContainerEntity] '.')? name=ID
;
Operation:
CreateContainer | CreateObject | ContainerOp | ObjectOp
;
CreateContainer:
'Container' container=ContainerEntity ';'
;
CreateObject:
'Object' object=ObjectEntity ';'
;
ContainerOp:
'ContainerOp' name=[ContainerEntity] ';'
;
ObjectOp:
'ObjectOp' name=[ObjectEntity] ';'
;
And the editor statements are:
// Define a container and object
Container c;
Object o;
// Can define an object using container name qualifier
Object c.o2;
// Operations
ContainerOp c;
ObjectOp o;
// Cannot use object operation with container name
ObjectOp c.o; // ERROR: Couldn't resolve reference to ObjectEntity 'c'.
Note that it does not recognize "c" as a ContainerEntity. What can I do to make this work the way I described?
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06065 seconds