2

I have an XText project setup with multiple grammars and am able to edit each grammar with cross-linking within the IDE generated by the mwe2 workflow. When I run the example web editor, the first grammar defined in the mwe2 workflow functions correctly.

If I change the the generated index.html to use one of the alternate grammar extensions the editor no longer functions, and I get an error message that looks like:

Xtext service 'occurrences' failed: Unable to identify the Xtext language for resource 3c05cdd1.ed

I'd like to understand what is wrong in order to better understand how I can begin minimal integration of editors for the grammars into our existing console.

Thanks!

Pierre Padovani

P.S. I've posted this same question on the Eclipse Community Forums, but my post seems to be stuck in a moderator queue.

ppadovani
  • 41
  • 3
  • how do you package the webapp together? see org.xtext.example.mydsl2.web.MyDslServlet.init() – Christian Dietrich Nov 14 '18 at 13:40
  • @ChristianDietrich I don't package anything at the moment. I run the ServerLauncher from the generated .web project. In that project there are two *Servlet files, each with an init(). My assumption is that these classes are injected into the overall running application. – ppadovani Nov 14 '18 at 14:17

1 Answers1

1

Having found the thread which @ppadovani mentions, it seems that the only necessary change is to ignore all the generated Servlet.xtend files except the one whose grammar is working.

In that one which works, it is necessary to initialise run the WebSetup for the other languages.

override init() {
    super.init()

    // call createInjectorAndDoEMFRegistration for each WebSetup
    new DerivedDslWebSetup().createInjectorAndDoEMFRegistration

    // keep the rest as-is
    val injector = new CoreDslWebSetup().createInjectorAndDoEMFRegistration()
    disposableRegistry = injector.getInstance(DisposableRegistry)
}

Reference: https://www.eclipse.org/forums/index.php?t=msg&th=1096166&goto=1798287&#msg_1798287

Tomasz Pluskiewicz
  • 3,622
  • 1
  • 19
  • 42