Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [XBase] XBaseScopeProvider and declarative scoping
[XBase] XBaseScopeProvider and declarative scoping [message #695291] Mon, 11 July 2011 12:39 Go to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hello,

I use the XBaseScopeProvider from the examples project.
Is it possible to integrate declarative Scope Methods like IScope scope_[EClassName]_[EReferenceName](MyType context, EReference ref) from
AbstractDeclarativeScopeProvider. Or, how can both IScopeProviders co-exists?

One question further, is it possible to get a JvmType from a String. For example: createJvmTypeFromString("com.foo.BarClass")

Thanks in advance,
Markus
Re: [XBase] XBaseScopeProvider and declarative scoping [message #695465 is a reply to message #695291] Mon, 11 July 2011 20:07 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Am 7/11/11 2:39 PM, schrieb Markus Schindler:
> Hello,
>
> I use the XBaseScopeProvider from the examples project.
> Is it possible to integrate declarative Scope Methods like IScope
> scope_[EClassName]_[EReferenceName](MyType context, EReference ref) from
> AbstractDeclarativeScopeProvider. Or, how can both IScopeProviders
> co-exists?

The AbstractDeclaratziveScopeProvider is provided with a delegate socpe
provider, which could be the XbaseScopeProvider.

public void configureIScopeProviderDelegate(com.google.inject.Binder
binder) {
binder.bind(IScopeProvider.class)
.annotatedWith(Names
.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
.to(XbaseScoepProvider.class);
}


>
> One question further, is it possible to get a JvmType from a String. For
> example: createJvmTypeFromString("com.foo.BarClass")

org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(String, Notifier,
JvmTypeReference...)

To use it let TypeReferences be injected into your class.
The notifier needs to be any EObject, Resource or ResourceSet being
(contained in) a correctly configured ResourceSet.

Sven


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: [XBase] XBaseScopeProvider and declarative scoping [message #696092 is a reply to message #695465] Wed, 13 July 2011 08:39 Go to previous messageGo to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hello Sven,

Thanks, for your answer, but now I got a stack overflow, because the MyScopeProvider (extends AbstractDeclarativeScopeProvider) has a delegate to the
MyXBaseScopeProvider (extends XBaseScopeProvider) and this gets a delegate to itself.
This happens because both classes has a "@Inject @Named(NAMED_DELEGATE) private IScopeProvider delegate;" in there superclasses, so the
XBaseScopeProvider gets a delegate to itself via this injection.

How should I handle this?

Regards,
Markus

Am 11.07.2011 22:07, schrieb Sven Efftinge:
> Am 7/11/11 2:39 PM, schrieb Markus Schindler:
>> Hello,
>>
>> I use the XBaseScopeProvider from the examples project.
>> Is it possible to integrate declarative Scope Methods like IScope
>> scope_[EClassName]_[EReferenceName](MyType context, EReference ref) from
>> AbstractDeclarativeScopeProvider. Or, how can both IScopeProviders
>> co-exists?
>
> The AbstractDeclaratziveScopeProvider is provided with a delegate socpe
> provider, which could be the XbaseScopeProvider.
>
> public void configureIScopeProviderDelegate(com.google.inject.Binder
> binder) {
> binder.bind(IScopeProvider.class)
> .annotatedWith(Names
> .named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
> .to(XbaseScoepProvider.class);
> }
>
>
>>
>> One question further, is it possible to get a JvmType from a String. For
>> example: createJvmTypeFromString("com.foo.BarClass")
>
> org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(String, Notifier,
> JvmTypeReference...)
>
> To use it let TypeReferences be injected into your class.
> The notifier needs to be any EObject, Resource or ResourceSet being
> (contained in) a correctly configured ResourceSet.
>
> Sven
>
>
Re: [XBase] XBaseScopeProvider and declarative scoping [message #699503 is a reply to message #696092] Thu, 21 July 2011 16:42 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi,

I also have the problem, is there a known solution to it?

Thank you Smile
Re: [XBase] XBaseScopeProvider and declarative scoping [message #699515 is a reply to message #699503] Thu, 21 July 2011 17:10 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Hi again,

I made my own AbstractDeclarativeScopeProvider and I changed the name of the NAMED_DELEGATE in order to prevent recursion.

The problem now is that it seems that the XBaseScopeProvider is relying on the fact that the IScope provider is a XBaseScopeProvider altough it is an AbstractDeclarativeScopeProvider (since now my DSLScopeProvider extends AbstractDeclarativeScopeProvider):

!STACK 0
java.lang.ClassCastException: fr.irit.smac.may.spead.scoping.SpeADLScopeProvider cannot be cast to org.eclipse.xtext.xbase.scoping.XbaseScopeProvider
	at org.eclipse.xtext.xbase.ui.contentassist.XbaseProposalProvider.getScopeProvider(XbaseProposalProvider.java:213)
	at org.eclipse.xtext.xbase.ui.contentassist.XbaseProposalProvider.lookupCrossReference(XbaseProposalProvider.java:334)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.lookupCrossReference(AbstractJavaBasedContentProposalProvider.java:202)
	at org.eclipse.xtext.xbase.ui.contentassist.XbaseProposalProvider.lookupCrossReference(XbaseProposalProvider.java:219)
	at fr.irit.smac.may.spead.ui.contentassist.AbstractSpeADLProposalProvider.completeInfraInstanceBinding_From(AbstractSpeADLProposalProvider.java:171)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.invokeMethod(AbstractJavaBasedContentProposalProvider.java:268)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.completeAssignment(AbstractJavaBasedContentProposalProvider.java:182)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:66)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(AbstractContentProposalProvider.java:1)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:164)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:70)
	at org.eclipse.xtext.util.XtextSwitch.doSwitch(XtextSwitch.java:58)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.accept(AbstractContentProposalProvider.java:71)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractContentProposalProvider.createProposals(AbstractContentProposalProvider.java:108)
	at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.createProposals(AbstractJavaBasedContentProposalProvider.java:243)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:51)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:1)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:86)
	at org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor.computeCompletionProposals(XtextContentAssistProcessor.java:69)
	at org.eclipse.xtext.ui.editor.contentassist.RepeatedContentAssistProcessor.computeCompletionProposals(RepeatedContentAssistProcessor.java:74)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1830)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1656)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:926)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1534)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1531)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1257)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1294)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:730)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3019)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:734)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5016)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4408)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8394)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1245)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2258)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3207)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Re: [XBase] XBaseScopeProvider and declarative scoping [message #699517 is a reply to message #699515] Thu, 21 July 2011 17:12 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 13659
Registered: July 2009
Senior Member
Hi,

yes you have to change your stuff to extend from XpaseScopeProvider

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XBase] XBaseScopeProvider and declarative scoping [message #699521 is a reply to message #699515] Thu, 21 July 2011 17:20 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Ok, I finally workarounded it with:

a class DSLDeclarativeScopeProvider extends MyAbstractDeclarativeScopeProvider

MyAbstractDeclarativeScopeProvider is a copy of AbstractDeclarativeScopeProvider modified with
	public final static String NAMED_DELEGATE = "...MyAbstractDeclarativeScopeProvider.delegate";


DSLScopeProvider extends XbaseScopeProvider

And in the Runtime Module:
	public void configureIScopeProviderDelegate2(com.google.inject.Binder binder) {
		binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(DSLDeclarativeScopeProvider.class);
	}
	
	// contributed by org.eclipse.xtext.generator.xbase.XbaseGeneratorFragment
	@Override
	public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
		binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(Names.named(MyAbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(org.eclipse.xtext.xbase.scoping.XbaseImportedNamespaceScopeProvider.class);
	}
Re: [XBase] XBaseScopeProvider and declarative scoping [message #1059556 is a reply to message #699521] Mon, 20 May 2013 12:49 Go to previous messageGo to next message
Joey Mink is currently offline Joey MinkFriend
Messages: 87
Registered: July 2009
Location: Centreville, VA, USA
Member

@Victor Mising name:

Thanks for documenting your solution to this. I just updated my Xtext DSL grammar to extend Xbase, which resulted in confusing scoping functionality.

It's been a few years since your post, but I thought I'd bump it to let people know that the issue you ran into still exists (Xtext 2.3.1) and your solution still works!
Re: [XBase] XBaseScopeProvider and declarative scoping [message #1230843 is a reply to message #1059556] Mon, 13 January 2014 07:58 Go to previous message
Uwe Maurer is currently offline Uwe MaurerFriend
Messages: 1
Registered: December 2013
Junior Member
Hi,
based on Victors Workaround we have implemented a simpler solution which eliminates the need to copy AbstractDeclarativeScopeProvider. Instead AbstractDeclarativeScopeProvider is extended and setDelegate() and getDelegate() is overwritten:
public abstract class MyAbstractDeclarativeScopeProvider extends AbstractDeclarativeScopeProvider {

    public final static String NAMED_DELEGATE = "...dsl.scoping.MyAbstractDeclarativeScopeProvider.delegate";

    @Inject
    @Named(NAMED_DELEGATE)
    private IScopeProvider myDelegate;

    @Override
    public void setDelegate(IScopeProvider delegate) {
        this.myDelegate = delegate;
    }

    @Override
    public IScopeProvider getDelegate() {
        return myDelegate;
    }
}


As in Victors solution out custom DSLScopeProvider extends the custom MyAbstractDeclarativeScopeProvider

class DSLScopeProvider extends MyAbstractDeclarativeScopeProvider {
    ...
    }    
}


To configure the framework, the RuntimeModule looks like in Victors solution:
public class DomainModelRuntimeModule extends ....dsl.AbstractDomainModelRuntimeModule {
    ...
    public void configureIScopeProviderDelegate2(com.google.inject.Binder binder) {
        binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
                .to(DSLScopeProvider.class);
    }

    // contributed by org.eclipse.xtext.generator.xbase.XbaseGeneratorFragment
    @SuppressWarnings({ "restriction", "deprecation" })
    @Override
    public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
        binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class)
                .annotatedWith(Names.named(MyAbstractDeclarativeScopeProvider.NAMED_DELEGATE))
                .to(org.eclipse.xtext.xbase.scoping.XbaseImportedNamespaceScopeProvider.class);
    }
    ...
}


I have tested this with Xtext 2.4.3.

Previous Topic:Xtext (Xbase) QualifiedName not parsed completely
Next Topic:Force reparsing of an Xtext resource possible?
Goto Forum:
  


Current Time: Tue Nov 24 21:17:05 GMT 2020

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

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

Back to the top