-
I'm trying to implement a generator from my language to html, and have created a Generator interface and a corresponding implementation that is included in the language's added services. My generator is invoked by a command (extension), first it parses the text in the active editor, then it calls the generator's generate method and finally the resulting html is written to a file. The command is triggered correctly and the generator itself works, the problem is parsing the editor's document. I've defined my generator so it gets the parser injected, but in that process the GrammarAccess tries to load the grammar.json file from a path computed in the constructor as follows: Another issue I discovered when trying to auto-generate when a language file changes, is that the creation of the file watcher uses a faulty glob. In my case the call was |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
My guess is that In the domainmodel example I found the following in the
Also needed a devDependency: This creates a copy of the grammar.json where it will be found during injection in the extension, when you regenerate after making a grammar change. This should work out-of-the-box in my opinion. |
Beta Was this translation helpful? Give feedback.
-
Hi @hallvard, glad to hear you are using Langium. Regarding your first issue: The easiest way would probably just to add another call to the webpack An alternative would be to direct the A more involved alternative would be to call the Thanks for the other issue, that seems to be a bug in our yeoman generator. |
Beta Was this translation helpful? Give feedback.
Hi @hallvard, glad to hear you are using Langium.
Regarding your first issue: The easiest way would probably just to add another call to the webpack
CopyPlugin
to add another copy of thegrammar.json
to your output directory. You would add something like the following to thevscodeConfig
and point theto
property to theout
directory.https://github.com/langium/langium/blob/ba581331bd65733ff1f74a5950320fbbad523ce3/packages/generator-langium/langium-template/webpack.config.js#L49-L58
An alternative would be to direct the
main.js
bundle with thegrammar.json
to theout
directory instead ofout/language-server
. Beware that you have to remove one../
from thedevtoolModuleFilenameTemplate
of …