Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Disabling inter-file Cross referencing
Disabling inter-file Cross referencing [message #1833882] Mon, 26 October 2020 17:11 Go to next message
Eclipse UserFriend
Hi all.

Cross referencing across resources in a resource set is the default in xtext since quite some minor versions now.
I'm wondering how I may disable this. Does anyone has a hint?

The only hint on that, I found is https://stackoverflow.com/questions/36751250/how-to-turn-off-global-scope-in-xtext-2-9.
But it is quite old and does not work for me.

Thanks in advance!

[Updated on: Mon, 26 October 2020 19:41] by Moderator

Re: Disabling inter-file Cross referencing [message #1833883 is a reply to message #1833882] Mon, 26 October 2020 17:13 Go to previous messageGo to next message
Eclipse UserFriend
You should implement a global scope Provider that returns iscope.nullscope

(Or customized importednamespaceawarelocslscopeprovider In that regard
Or if you wüdont have implicit local imports replace it completely

[Updated on: Mon, 26 October 2020 17:16] by Moderator

Re: Disabling inter-file Cross referencing [message #1834044 is a reply to message #1833883] Fri, 30 October 2020 18:31 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Mon, 26 October 2020 21:13
You should implement a global Or if you wüdont have implicit local imports replace it completely


What do you mean with that? Replace with what?

Thanks in advance.
Re: Disabling inter-file Cross referencing [message #1834049 is a reply to message #1834044] Sat, 31 October 2020 02:01 Go to previous messageGo to next message
Eclipse UserFriend
Implement as new global scope provider

You can also change the call to global scope provider in imported namespace aware local scopeprovide
If you also don't want local implicit imports also adapt imported name space aware local scope,provider with respect to that

[Updated on: Sat, 31 October 2020 02:02] by Moderator

Re: Disabling inter-file Cross referencing [message #1834785 is a reply to message #1834049] Tue, 17 November 2020 16:44 Go to previous messageGo to next message
Eclipse UserFriend
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!
Re: Disabling inter-file Cross referencing [message #1834795 is a reply to message #1834785] Wed, 18 November 2020 02:06 Go to previous message
Eclipse UserFriend
@Denis do ypu have details on the NPE?
Previous Topic:TemplateProposalProvider for webapplication
Next Topic:JVM Inferrer -- Possible to generate two declared types that reference each other?
Goto Forum:
  


Current Time: Sat Apr 19 21:41:00 EDT 2025

Powered by FUDForum. Page generated in 0.05070 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top