Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » IScopeProvider interface improvement
IScopeProvider interface improvement [message #714850] Thu, 11 August 2011 15:40 Go to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
I wanted to make a suggestion regarding the IScopeProvider interface. Currently, this interface just consists of:
IScope getScope(EObject context, EReference reference);

However, in the DefaultLinkingService there is this code:
protected void registerImportedNamesAdapter(IScopeProvider scopeProvider, EObject context) {
		if (scopeProvider instanceof AbstractGlobalScopeDelegatingScopeProvider) {
			AbstractGlobalScopeDelegatingScopeProvider provider = (AbstractGlobalScopeDelegatingScopeProvider) scopeProvider;
			ImportedNamesAdapter adapter = getImportedNamesAdapter(context);
			provider.setWrapper(adapter);
		} else if (scopeProvider instanceof AbstractDeclarativeScopeProvider) {
			AbstractDeclarativeScopeProvider declarativeScopeProvider = (AbstractDeclarativeScopeProvider) scopeProvider;
			registerImportedNamesAdapter(declarativeScopeProvider.getDelegate(), context);
		}
	}

This code is responsible for enabling figuring out what the IEObjectDescription dependencies between resources are during linking. If you just implement a new IScopeProvider based on the interface none of the above code will be triggered and incremental linking will be broken.

So, to me it seems that it never makes sense to implement an IScopeProvider without deriving it from AbstractGlobalScopeDelegatingScopeProvider or AbstractDeclarativeScopeProvider.

I would suggest to add to the IScopeProvider a method to obtain the delegate (or null if it doesn't exist) and to introduce a IGlobalScopeProvider with a setWrapper method. That should lead future implementations along the right path.

---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: IScopeProvider interface improvement [message #714878 is a reply to message #714850] Thu, 11 August 2011 16:08 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mark,

there is already an IScopeProviderDelegate in the 2.1 stream which is
used in the instanceof checks instead of the concrete implementation
classes.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 11.08.11 17:40, Mark Christiaens wrote:
> I wanted to make a suggestion regarding the IScopeProvider interface.
> Currently, this interface just consists of:
>
> IScope getScope(EObject context, EReference reference);
>
> However, in the DefaultLinkingService there is this code:
>
> protected void registerImportedNamesAdapter(IScopeProvider
> scopeProvider, EObject context) {
> if (scopeProvider instanceof AbstractGlobalScopeDelegatingScopeProvider) {
> AbstractGlobalScopeDelegatingScopeProvider provider =
> (AbstractGlobalScopeDelegatingScopeProvider) scopeProvider;
> ImportedNamesAdapter adapter = getImportedNamesAdapter(context);
> provider.setWrapper(adapter);
> } else if (scopeProvider instanceof AbstractDeclarativeScopeProvider) {
> AbstractDeclarativeScopeProvider declarativeScopeProvider =
> (AbstractDeclarativeScopeProvider) scopeProvider;
> registerImportedNamesAdapter(declarativeScopeProvider.getDelegate(),
> context);
> }
> }
>
> This code is responsible for enabling figuring out what the
> IEObjectDescription dependencies between resources are during linking.
> If you just implement a new IScopeProvider based on the interface none
> of the above code will be triggered and incremental linking will be broken.
> So, to me it seems that it never makes sense to implement an
> IScopeProvider without deriving it from
> AbstractGlobalScopeDelegatingScopeProvider or
> AbstractDeclarativeScopeProvider.
> I would suggest to add to the IScopeProvider a method to obtain the
> delegate (or null if it doesn't exist) and to introduce a
> IGlobalScopeProvider with a setWrapper method. That should lead future
> implementations along the right path.
> ---
> Mark Christiaens
> Discover the Future of VHDL Design
> Go to http://www.sigasi.com
>
Re: IScopeProvider interface improvement [message #739347 is a reply to message #714878] Mon, 17 October 2011 11:24 Go to previous messageGo to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
Would it not be a good idea to also change:
protected void registerImportedNamesAdapter(IScopeProvider scopeProvider, EObject context) {
		if (scopeProvider instanceof AbstractGlobalScopeDelegatingScopeProvider) {
			AbstractGlobalScopeDelegatingScopeProvider provider = (AbstractGlobalScopeDelegatingScopeProvider) scopeProvider;
			ImportedNamesAdapter adapter = getImportedNamesAdapter(context);
			provider.setWrapper(adapter);
		} else if (scopeProvider instanceof IDelegatingScopeProvider) {
			IDelegatingScopeProvider delegatingScopeProvider = (IDelegatingScopeProvider) scopeProvider;
			registerImportedNamesAdapter(delegatingScopeProvider.getDelegate(), context);
		}
	}

to
protected void registerImportedNamesAdapter(IScopeProvider scopeProvider, EObject context) {
		if (scopeProvider instanceof IWrapableScopeProvider) {
			...
		} else if (scopeProvider instanceof IDelegatingScopeProvider) {
			...
		}
	}

I just ran into this issue. I'm deriving my local scope provider from AbstractDeclarativeScopeProvider and it doesn't get wrapped.

As a matter of fact, I'm wondering if both the "delegating" and the "wrapping" functionality should be present in all scope providers or something similar instead of introducing many new interfaces?
---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: IScopeProvider interface improvement [message #739736 is a reply to message #739347] Mon, 17 October 2011 20:00 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mark,

please file an enhancement request. We won't change the IScopeProvider
but introducing something like IImportedNamesAwareScopeProvider sounds
like a good idea.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 17.10.11 13:24, Mark Christiaens wrote:
> Would it not be a good idea to also change:
> protected void registerImportedNamesAdapter(IScopeProvider
> scopeProvider, EObject context) {
> if (scopeProvider instanceof AbstractGlobalScopeDelegatingScopeProvider) {
> AbstractGlobalScopeDelegatingScopeProvider provider =
> (AbstractGlobalScopeDelegatingScopeProvider) scopeProvider;
> ImportedNamesAdapter adapter = getImportedNamesAdapter(context);
> provider.setWrapper(adapter);
> } else if (scopeProvider instanceof IDelegatingScopeProvider) {
> IDelegatingScopeProvider delegatingScopeProvider =
> (IDelegatingScopeProvider) scopeProvider;
> registerImportedNamesAdapter(delegatingScopeProvider.getDelegate(),
> context);
> }
> }
>
> to
> protected void registerImportedNamesAdapter(IScopeProvider
> scopeProvider, EObject context) {
> if (scopeProvider instanceof IWrapableScopeProvider) {
> ...
> } else if (scopeProvider instanceof IDelegatingScopeProvider) {
> ...
> }
> }
>
> I just ran into this issue. I'm deriving my local scope provider from
> AbstractDeclarativeScopeProvider and it doesn't get wrapped.
> As a matter of fact, I'm wondering if both the "delegating" and the
> "wrapping" functionality should be present in all scope providers or
> something similar instead of introducing many new interfaces?
> ---
> Mark Christiaens
> Discover the Future of VHDL Design
> Go to http://www.sigasi.com
Re: IScopeProvider interface improvement [message #740168 is a reply to message #739736] Tue, 18 October 2011 08:22 Go to previous message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
Done: Bug 361216
Previous Topic:A simple way to test Eclipse-based editors
Next Topic:Guice provision errors: Class 'EClass' is not found or is abstract.
Goto Forum:
  


Current Time: Wed Apr 24 13:41:53 GMT 2024

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

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

Back to the top