Won’t go into the solution as it’s pretty similar to the approach I outlined in a previous post, but I did learn something interesting along the way.

When you declare a custom scope resolution function, if you return IScope.NULLSCOPE, Xtext treats it as no variables being present inside that scope. On the other hand, if you return null, Xtext will treat it as your function not handling variables for that scope, and will use its own scope resolution instead. Pretty neat!