Configure single Language Server with multiple grammars (IResourceServiceProvider) [message #1799990] |
Tue, 18 December 2018 10:23  |
Eclipse User |
|
|
|
Hi,
we are working on migrating an existing Xtext project from an Eclipse application to a Language Server solution.
The project has multiple grammars/languages in separate sub-projects. Currently only the language(s) of one sub-project are integrated with the language server.
How can we integrate languages from other subprojects into the Language Server so their ISetup is loaded?
Details
Existing setup (based on "New Project Wizard" and existing code base):
- org.example.mylang
- MyLangA.xtext
- MyLangB.xtext
- GenerateMyLang.mwe2
- generates infrastructure for MyLangA.xtext and MyLangB.xtext. Uses standard XtextGenerator as created by the wizard with 2 custom language = XtextGeneratorLanguage for MyLangA and MyLangB
- genericIde generates META-INF/services/org.eclipse.xtext.ISetup file with MyLangAIdeSetup and MyLangBIdeSetup in org.example.mylang.ide
- StandaloneSetup bean does registerGenModelFile and registerGeneratedEPackage for platform:/resource/org.example.other/model/generated/Other.genmodel
- org.example.mylang.ide
- Gradle mainClassName = "org.eclipse.xtext.ide.server.ServerLauncher"
- org.example.other
- Other.xtext
- GenerateOther.mwe2
- generates infrastructure for Other.xtext
- No genericIde / org.example.other.ide
The org.eclipse.xtext.ISetup implementations for the org.example.mylang languages (MyLangAIdeSetup, MyLangBIdeSetup) are loaded by the language server's ResourceServiceProviderServiceLoader so the correct IResourceServiceProviders are registered for their respective file extensions (e.g. langa and langb).
The generated OtherStandaloneSetupGenerated implementation registers to the IResourceServiceProvider.Registry.INSTANCE which is different from the IResourceServiceProvider.Registry created by ResourceServiceProviderServiceLoader. Thus the Other language does not work.
What would be the recommended Xtext MWE2 workflow configuration and project configuration so that:
- META-INF/services/org.eclipse.xtext.ISetup is generated containing the service providers for all languages (MyLangA, MyLangB, Other)
- the ResourceServiceProviderServiceLoader of a single Language Server loads these ISetup implementations for all languages
Cheers
Goan
PS:
Manually adding OtherStandaloneSetup to the org.example.mylang.ide project's META-INF/services/org.eclipse.xtext.ISetup configuration file makes the Other language work. But this seems like a hack, as the file seems usually to be generated by Xtext when genericIde is configured in the workflow. At the moment I can envision these options:
- Create a org.example.other.ide project and add genericIde config to the org.example.other project's GenerateOther.mwe2.
Use the org.example.other.ide and the org.example.mylang.ide projects in a new org.example.mylang.server project where a META-INF/services/org.eclipse.xtext.ISetup (manually?) configures all ISetup implementations (MyLangAIdeSetup, MyLangBIdeSetup, OtherIdeSetup) for the language server. org.example.mylang.server would replace org.example.mylang.ide as the language server entry.
- Use a single GenerateAll.mwe2 workflow for all languages so a single XtextGenerator (output of multiple ones seem to overwrite/delete each other) can generate the META-INF/services/org.eclipse.xtext.ISetup for all languages in a single org.example.mylang.ide project. Not sure where to put this workflow (in org.example.mylang?) and if the org.example.other sub-project can be kept or needs to be integrated into the one containing the workflow (e.g. org.example.mylang)?
- Configure a workflow to be able to control which setup classes end up META-INF/services/org.eclipse.xtext.ISetup so all are present / merged. Not sure if this is possible as multiple XtextGenerator seem to conflict when targeting the same org.example.mylang.ide project.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04541 seconds