[XBase] XBaseScopeProvider and declarative scoping [message #695291] |
Mon, 11 July 2011 08:39  |
Eclipse User |
|
|
|
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 16:07   |
Eclipse User |
|
|
|
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 04:39   |
Eclipse User |
|
|
|
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 #1230843 is a reply to message #1059556] |
Mon, 13 January 2014 02:58  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.04821 seconds