Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Disabling inter-file Cross referencing
Disabling inter-file Cross referencing [message #1833882] Mon, 26 October 2020 21:11 Go to next message
Denis Kuniß is currently offline Denis KunißFriend
Messages: 15
Registered: March 2015
Junior Member
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 23:41]

Report message to a moderator

Re: Disabling inter-file Cross referencing [message #1833883 is a reply to message #1833882] Mon, 26 October 2020 21:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Mon, 26 October 2020 21:16]

Report message to a moderator

Re: Disabling inter-file Cross referencing [message #1834044 is a reply to message #1833883] Fri, 30 October 2020 22:31 Go to previous messageGo to next message
Denis Kuniß is currently offline Denis KunißFriend
Messages: 15
Registered: March 2015
Junior Member
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 06:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Sat, 31 October 2020 06:02]

Report message to a moderator

Re: Disabling inter-file Cross referencing [message #1834785 is a reply to message #1834049] Tue, 17 November 2020 21:44 Go to previous messageGo to next message
Denis Kuniß is currently offline Denis KunißFriend
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!
Re: Disabling inter-file Cross referencing [message #1834795 is a reply to message #1834785] Wed, 18 November 2020 07:06 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
@Denis do ypu have details on the NPE?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:TemplateProposalProvider for webapplication
Next Topic:JVM Inferrer -- Possible to generate two declared types that reference each other?
Goto Forum:
  


Current Time: Tue Dec 03 17:07:38 GMT 2024

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

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

Back to the top