Community
Participate
Working Groups
Build Identifier: I20100312-1448 http://www.eclipse.org/forums/index.php?t=msg&goto=530561&#msg_530561 This grammar rule produces a cyclic resolution but does its job well: Reference: '(ref)' refChild=[Child] (':'{NestedRef.left=current} refChild=[Child])* ; Goal is to adress a child like child1:child2:child3 Sources: grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model: (def+=Definition)+ ; Definition: '(def)'name=ID ':' (child+=Child) (ref+=Reference)? ; Child: '(child)'name=ID ':' link=[Definition]? ; Reference: '(ref)' refChild=[Child] (':'{NestedRef.left=current} refChild=[Child])* ; ================================ import org.eclipse.xtext.EcoreUtil2; import org.eclipse.xtext.scoping.IScope; import org.eclipse.xtext.scoping.Scopes; import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider; import org.xtext.example.mydsl.myDsl.Child; import org.xtext.example.mydsl.myDsl.Definition; import org.xtext.example.mydsl.myDsl.NestedRef; import org.xtext.example.mydsl.myDsl.Reference; /** * This class contains custom scoping description. * * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping * on how and when to use it * */ public class MyDslScopeProvider extends AbstractDeclarativeScopeProvider { public IScope scope_Reference_refChild(NestedRef context, EReference ref) { EList<Child> childList = null; Child child = context.getLeft().getRefChild(); childList = child.getLink().getChild(); IScope newScope = Scopes.scopeFor(childList); return newScope; } public IScope scope_Reference_refChild(Reference context, EReference ref) { Definition localClass = null; EList<Child> childList = null; localClass = EcoreUtil2.getContainerOfType(context, Definition.class); childList = localClass.getChild(); IScope newScope = Scopes.scopeFor(childList); return newScope; } } =================================== /************************************/ (def) local : (child) local_Child : def_depth1 (ref) local_Child:depth1_Child: /************************************/ (def) def_depth1 : (child) depth1_Child : def_depth2 /************************************/ (def) def_depth2 : (child) depth2_Child : Reproducible: Always Steps to Reproduce: 1. new Xtext Project 2. replace with attached grammar 3. replace ScopeProvider 4. try to lookup references in testfile (project->clean sometimes needed)
I have added a test case using the code snippets you have provided. Tests are green. The problem has already been fixed in a previous milestone (M6). Please reopen if the problem still exists.
Closing bug which were set to RESOLVED before Eclipse Neon.0.