|
|
Re: limit scoping of first fragment of qualified name? [message #808138 is a reply to message #807559] |
Mon, 27 February 2012 12:52 |
Phil R Messages: 99 Registered: September 2011 |
Member |
|
|
Hi Meinte Boersma
it does not work with importnamespace now.
It is just "simple names" now, it doesn't matter which namespace is used. How to add qualified name functionality?
example of use:
vocname::vocelement // works
vocelement // works not with vocname imported
public IScope scope_SymbolDeclaration(final Model model, EReference reference) {
IScope unfilteredScope = scopeProvider.getScope(model, reference);
Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
System.out.println(model.eResource().getURI().lastSegment() + "==" + input.getQualifiedName().getFirstSegment());
// keep the owning resource
if (model.eResource().getURI().lastSegment() != null) {
if (model.eResource().getURI().lastSegment().equals(input.getQualifiedName().getFirstSegment())) {
return true;
}
}
// keep the included resources
for (IncludeFile file : model.getIncludes()) {
if (input.getQualifiedName().getFirstSegment().equals(file.getImportedNamespace())) {
return true;
}
}
return false;
}
};
return new FilteringScope(unfilteredScope, filter);
}
EDIT ::
got it fixed, dunno why not scope_SymbolDeclaration(model,..) could be used
It works as below:
public IScope scope_SymbolDeclaration(final EObject context, EReference reference) {
IScope unfilteredScope = super.delegateGetScope(context, reference);
Predicate<IEObjectDescription> filter = new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
// keep the owning resource
if (context.eResource().getURI().lastSegment() != null) {
if (context.eResource().getURI().lastSegment().equals(input.getQualifiedName().getFirstSegment())) {
return true;
}
}
// keep the included resources
EObject model = context;
while (!(model instanceof Model)) model = model.eContainer();
if (model instanceof Model) {
for (IncludeFile file : ((Model)model).getIncludes()) {
if (input.getQualifiedName().getFirstSegment().equals(file.getImportedNamespace())) {
return true;
}
}
}
return false;
}
};
return new FilteringScope(unfilteredScope, filter);
}
Any improvements?
Regards,
Phi
[Updated on: Mon, 27 February 2012 18:04] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02586 seconds