Scoping question, references to sub-elements of auto-imported elements [message #813401] |
Mon, 05 March 2012 08:10 |
William Brodie-Tyrrell Messages: 4 Registered: March 2012 |
Junior Member |
|
|
Hi,
Bit of a n00b question, sorry. I have a DSL that contains things similar to the following:
Dsl_Type:
'Dsl_Type' name = ID body = (Enumeration_Type | Integer_Type | etc) ';'
;
Enumeration_Type:
'Enumerated' '(' enums += Enum_Val (',' enums += Enum_Val)* ')'
;
Enum_Val:
name = ID
;
Check_Type:
'Check_Type' ref = [Dsl_Type] ';'
;
Enum_Ref:
'Check_Enum' ref = [Enum_Val] ';'
;
And I might have in one file:
Dsl_Type the_enum Enumerated ( foo, bar, smith );
And in the other:
Check_Type the_enum;
Check_Enum foo;
My MWE2 has:
fragment = scoping.ImportNamespacesScopingFragment { ignoreCase = true }
My problem is that Check_Type works but Check_Enum fails to link. I've been building up a custom MyDslScopeProvider that (successfully) does custom scoping work in other parts of the DSL but so far it only has needed to traverse the parse tree within a single source file. I've found that my ScopeProvider's superclass (AbstraceDeclarativeScopeProvider) has a delegate which is an ImportedNamespaceAwareLocalScopeProvider, and that that delegate is successfully finding the names of all top-level objects in all files in the project. Therefore, Check_Type works without any effort on my part because the delegate can find the names of all the types declared throughout the project.
The problem is that it doesn't find all the Enum_Vals because they're buried a couple of layers deeper.
How do I (presumably in MyDslScopeProvider) obtain a project-global list of all top-level objects? If I had that, I could find all of my enum types and therefore build a scope containing all of the Enum_Val names.
I tried the obvious (to me) path of repeatedly calling eContainer() on context inside getScope() to get to the root, but that only works if the enum is declared in the same file as the Check_Enum because eContainer() halts at the top of the current file. I need to get the global set of Dsl_Type, just like the default mechanism is managing to do.
thanks...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02733 seconds