Hi,
i have a problem with my implementation of scoping, i want to list unique IDs from different scopes with their parent names to ensure they are unique in the list but it does not work.
Here is an example DSL with the problem:
grammar org.xtext.scopeproblem.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl ".../scopeproblem/mydsl/MyDsl"
Model:
summeries=Summary
collections=Collection;
Summary:
'summery' name=ID 'collection' collection=[Collection|ID]'{'
fileTypeList=FileTypeList?
'}';
FileTypeList:
'filetypes' '{'
fileTypes+=[FileType|ID] (',' fileTypes+=[FileType|ID])*
'}';
Collection:
'Collection' name=ID '{'
files+=File+
'}';
File:
'file' name=ID '{'
fileTypes+=FileType';' (fileTypes+=FileType';')*
'}';
FileType:
name=ID;
And here is the scope provider:
class MyDslScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider {
def IScope scope_FileTypeList_fileTypes(FileTypeList context, EReference reference){
val sum = context.eContainer
if (sum instanceof Summary) {
val mod = sum.eContainer
if (mod instanceof Model) {
var LinkedList<FileType> filetypeList = new LinkedList<FileType>()
for( File file : (mod as Model).collections.files) {
filetypeList.addAll(file.fileTypes)
}
return Scopes.scopeFor(filetypeList, Scopes.scopeFor((mod as Model).collections.files))
}
}
return IScope.NULLSCOPE
}
}
And this is the model:
summery sum collection collect1 {
filetypes {
f1,
f2,
f3
}
}
Collection collect1 {
file files1 {
f1;
f2;
}
file files2 {
f1;
f3;
}
}
The problem is, f1 in collect1 referes to f1 in files1, it is not possible to make a reference to f1 from files2.
How can i tell the scoping to use the full qualified name like "collect1.files2.f1"?
Thank you