Embedded Xtext editor with only a sub part of the Grammar of my DSL [message #1746939] |
Mon, 07 November 2016 21:22  |
|
Hi,
I have a rather complex DSL which is used in several places of my RCP 4diac. Now I have the task that I would like to have an editor which allows to edit only a sub part of my language.
Therefore my question would be if it is possible to set for an xtext editor (in my case an embedded editor) the root parser rule for the allowed grammar?
One solution I had in mind is to extract the grammar parts in questions into a separate xtext project and reference this new xtext project from the old. The drawback for this is that for the user it would look like to languages in the preferences. This is not really intuitive therefore I would prefer a single language solution.
Thanks in advance for any support.
BR,
Alois
|
|
|
|
|
Re: Embedded Xtext editor with only a sub part of the Grammar of my DSL [message #1747034 is a reply to message #1746958] |
Tue, 08 November 2016 17:20  |
|
After a colleague and I spent some time today to better understand how parsers and editors are setup in current Xtext we came to a solution which is also working with the current Xtext 2.10. You can overwrite the parser and the ui parser generated by xtext and let it inject the new parser in the module of your sublanguage. Furthermore you need to set an own file extension and configure resource providers in the ui plugin.xml. You can see the required changes in this commit [1] of 4diac-ide. I think it is easier to look at the code then that I explain here all the steps.
For me this seams also pretty maintainable as with the injections and the inheritance that we applied the generated code would just be updated and be available for both languages.
[1] https://sourceforge.net/p/fordiac/fordiac-ide/ci/ab0b1ed84057c2c3a26716bbe88412e1e965fbc9/tree/
|
|
|
Powered by
FUDForum. Page generated in 0.01694 seconds