title: Xtext typesafe variable qualifier
body: <p>I have an xtext grammar for a modelling language that has multiple types of variables. In some cases I want to delimit the type a variable can have.
  The current workflow is to just use a VariableQualifier (like in the grammar below) and use a validator to only permit the type I want. Then every time I access the reference I have to explicitly cast it. </p>
  
  <p>Is there a better solution?</p>
  
  <pre><code>VariableReference:
      ref=[Variable]
  ;
  VariableQualifier:
      (namespace+=NamespaceReference '.')* element=VariableReference
  ;
  EnumerationReference:
      ref=[Enumeration]
  ;
  EnumerationQualifier:
      (namespace+=NamespaceReference '.')* element=EnumerationReference
  ;
  NamespaceReference:
      ref=[Namespace]
  ;
  </code></pre>