I have created a simple grammar using xtext called unit. The main concept is that everything is a unit. Units are constructed from units (Struct/Class equivalent). A unit value is pair of a 'unit type reference' and an 'instance name'.

primitives are a special case of units and this allows me to have a unified unit system where everything is a unit

for more details please look at full grammar and full code snippet attached below

so, everything works great... well, almost everything
I'm having trouble with the validation/scoping/autocomplete of the following code:

I have used the following scoping methods to reduce list of unit values in the 'this' rule to values that only belong to this. And a scoping method to reduce unit values in case of recursive ref, and suggest the values for next from the values in prev