Cross reference to multiple names in the same grammar rule

505 views Asked by At

In my DSL, I have two different rules that can be used to define entities:

First way is by a preset word followed by the name of the entity:

Actor Bob

Actor Alice

Second way is by creating a relation between two entities:

Bob -> Alice

Which would be the same as writing

Actor Bob -> Actor Alice

Now I have a question when it comes to the cross referencing of these entities. Creating a cross reference to the Actors are easy, as I just reference the rule

Actor: 
'Actor' name = ID

But what happens when I have two ID's in the same rule? How would I go about cross referencing

Arrow:
'Actor'? name+=ID '->' 'Actor'? name+=ID

Since there are several names in the same rule?

Thanks!

1

There are 1 answers

9
Christian Dietrich On BEST ANSWER

to change how elements are indexed you have to adapt org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy.createEObjectDescriptions(EObject, IAcceptor<IEObjectDescription>) and add the elements under all names to the index.

if you want to do this for local definitions as well you have to adapt org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetAllDescriptions(Resource)