Registering both relative and fully qualified name in Scope [message #1785684] |
Wed, 18 April 2018 07:05  |
Eclipse User |
|
|
|
Hello ,
I am facing an issue with my scoping right now ,
Given 2 files
file1.myDSL
module myModule{
typedef long myLong;
}
file2.myDSL
#include "file1.myDSL"
module myModule{
typedef myLong myLong2; //Not Working but should work
typedef myModule.myLong myLong3; //Working
}
I would like to be able to reference an object from an imported file, both with its RelativeQualifiedName and FullyQualifiedName .
My idea was , given a context (here , typedef myLong myLong2)
if its container's full qualified name(FQN) is present in the scope,
then each element of the scope registered with a name starting with that fqn shall also be registered with their relative qname(container's FQN - object FQN)
Any tips on how to solve that ?
Erwann
|
|
|
|
|
|
|
Re: Registering both relative and fully qualified name in Scope [message #1785742 is a reply to message #1785684] |
Thu, 19 April 2018 05:07  |
Eclipse User |
|
|
|
That worked , thanks a lot Christian !
Here I share the snippet of code, just in case someone looks for the same answer :
if(scope instanceof ImportScope){
Module module = EcoreUtil2.getContainerOfType(context, Module.class);
//Module is the qualifying element
if(module != null){
QualifiedName qname = qualifiedNameProvider.getFullyQualifiedName(module);
if(qname != null){
ImportNormalizer importNormalizer = new ImportNormalizer(qname, true, true);
scope = new ImportScope(Collections.singletonList(importNormalizer), scope, null, reference.eClass(), false);
}
}
}
}
Thanks for your help !
Erwann
|
|
|
Powered by
FUDForum. Page generated in 0.08591 seconds