EditorComponent from generator aspect

Hello to everyone. I need some help with generator aspect.

The main idea: I have a solution with some nodes. Nodes presented by editors with a lot of logic (like "show if", alternation cells and so on).

I would like to create generator that create xml with content "like in editor" and don't want to create the same logic (like in editor) twice.

I found "HeadlessEditorComponent" but it doesn't work.

I am trying do something like this:

But unfortunately MPS show me the exception:

java.lang.IllegalStateException: Multiple sessions not supported
at jetbrains.mps.typechecking.backend.DefaultTypecheckingController.requestSession(DefaultTypecheckingController.java:66)
at jetbrains.mps.typechecking.backend.TypecheckingSessionHandler.requestNewSession(TypecheckingSessionHandler.java:50)
at jetbrains.mps.nodeEditor.EditorComponent.lambda$editNode$5(EditorComponent.java:1054)
at jetbrains.mps.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:73)
at jetbrains.mps.smodel.ModelAccessBase.runReadAction(ModelAccessBase.java:54)
at jetbrains.mps.nodeEditor.EditorComponent.editNode(EditorComponent.java:1020)
at jetbrains.mps.editor.runtime.HeadlessEditorComponent.<init>(HeadlessEditorComponent.java:22)

I want to get EditorContext as a result to render cells.

Comment actions Permalink

Have a look at the TextGenGen plugin: https://plugins.jetbrains.com/plugin/11061-textgengen/. It won't keep the generator in sync with the editor automatically but at least you can generate the generator from the editor.

Comment actions Permalink

Sergej Koščejev, thanks. Currently I forced to create own plugin as a part of my language to call some generation methods from plugin.

Plugin can be inoked on node and try to find out which behaviors methods are annotated with custom annotation from my plugin. If plugin will find methods - these methods will be invoked with Headless editor that will be "injected" from plugin =)

Yes, it sounds weird, but unfortunately I can't find another solution )


Please sign in to leave a comment.