title: Xtext cross reference using custom terminal rule
body: <p>I'm trying to get cross-references to work in my DSL. Here's a stripped down version of the grammar (a modified version of the standard example DSL):</p>
  
  <pre><code>grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
  
  generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
  
  Releases:
      releases+=Release*
  ;
  
  terminal VERSION    : ('0'..'9')+'.'('0'..'9')+('.'('0'..'9'|'x')+)?;
  
  Release:
      'release' version = VERSION ('extends' parent = [Release|VERSION])?
      ;
  </code></pre>
  
  <p>Since I'm not using the standard <code>name = ID</code> pattern, I followed <a href="http://christiandietrich.wordpress.com/2011/07/16/iqualifiednameproviders-in-xtext-2-0/" rel="nofollow">this blog post</a> about how to create my own <code>IQualifiedNameProvider</code>:</p>
  
  <pre><code>public class MyDslQNP extends DefaultDeclarativeQualifiedNameProvider {
      QualifiedName qualifiedName(Release e) {
          Package p = (Package) e.eContainer();
          return QualifiedName.create(p.getName(), e.getVersion());
      }
  }
  </code></pre>
  
  <p>From another answer on SO, I gathered that I should implement my own scope provider:</p>
  
  <pre><code>public class MyDslScopeProvider extends AbstractDeclarativeScopeProvider {
      IScope scope_Release_parent(Release release, EReference ref) {
          Releases releases = (Releases) release.eContainer();
          return Scopes.scopeFor(releases.getReleases());
      }
  }
  </code></pre>
  
  <p>I've also bound these in the runtime module:</p>
  
  <pre><code>public class MyDslRuntimeModule extends
          org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
      @Override
      public Class&lt;? extends IQualifiedNameProvider&gt; bindIQualifiedNameProvider() {
          return MyDslQNP.class;
      }
  
      @Override
      public Class&lt;? extends IScopeProvider&gt; bindIScopeProvider() {
          return MyDslScopeProvider.class;
      }
  
  }
  </code></pre>
  
  <p>When running the generated editor I create a file which looks like this:</p>
  
  <pre><code>release 1.2.3
  release 1.2.2 extends 1.2.3
  </code></pre>
  
  <p>The problem is that (1) the editor won't autocomplete on the 'extends' clause, and (2) the editor shows an error message <code>Couldn't resolve reference to Release '1.2.3'</code>.</p>
  
  <p>What am I missing?</p>