Search code examples
customizationxtextxtend

Xtext 2.9 RuntimeModule


I am trying to implement implicit import mechanism in my dsl (named ADSL). To do this I am following the approach applied to SmallJava example some 3 years ago, which is available here: SmallJava source folder. My dsl is very similar to SmallJava, so you might consider that I'm now trying to do essentially the same thing done in SmallJava.

I have defined a library (similar to the one of smalljava) and tried to implement the implicit import for it. To do this I need to customize ADSLRuntimeModule class, in a similar way to SmallJavaRuntimeModule.java. However, I notice that in Xtext 2.9 in the source folder my ADSLRuntimeModule is xtend, not java file.

So, when I try to update my ADSLRuntimeModule.xtend I experience syntactic mistakes, as you can see in the screenshot ADSLRuntimeModule.xtend. It states that @Override is disallowed for this location.

Could someone please explain why I am facing this error and what is the correct way to do this customization?

Thanks a lot


Solution

  • You have pasted Java code into an Xtend file. The equivalent Xtend syntax is this:

    class ADSLRuntimeModule extends AbstractADSLRuntimeModule {
    
        override configureIScopeProviderDelegate(Binder binder) {
            binder.bind(IScopeProvider)
                .annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
                .to(ADSLImportedNamespaceAwareLocalScopeProvider)
        }
    
    }