|
|
|
|
Re: Disabling inter-file Cross referencing [message #1834785 is a reply to message #1834049] |
Tue, 17 November 2020 21:44 |
Denis Kuniß Messages: 15 Registered: March 2015 |
Junior Member |
|
|
Just to complete this topic, here comes what worked for me following Christians recommendation.
Added a global scope provider implementation:
public class DisabledGlobalScopeProvider implements IGlobalScopeProvider {
@Override
public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
return IScope.NULLSCOPE;
}
}
Registered it at RuntimeModule:
public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
return DisabledGlobalScopeProvider.class;
}
Finally registered a simpler scope provider delegate at the RuntimeModule:
public void configureIScopeProviderDelegate(Binder binder) {
binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
.to(SimpleLocalScopeProvider.class);
}
Works well now. No references from other files leak into a particular source file.
Needs to be mentioned that I was misguided by a testing approach taken (maybe wrongly by me) from Lorenzo Bettinis book "Implementing DSLs with Xtext and Xtend" on how to test scopes.
This test helper
def private assertScope(EObject context, EReference reference, CharSequence expected) {
expected.toString.assertEquals(context.getScope(reference).allElements.map[name].join(", "))
}
always result in a NullPointerException for the same implementation above, which caused me to ask the question here.
After switching to
resourceSet.assertError(EpsilonPackage.eINSTANCE.formalParam, Diagnostic.LINKING_DIAGNOSTIC, "Couldn't resolve reference to MetaRule 'N'.")
instead, all went well.
Thanks again, Christian!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03708 seconds