how to access cell content in error state for useful intentions ?

Hi,

In intellij, we have intentions to create a variable if it doesn't exist.
Thus it supports what is called intentional programming : you write your intent, and the ide propose you intentions according to the context.
I want to do the same for one language which accepts expressions from baseLanguage.
The user can enter a text, which is not a correct expression (not a variable etc) and I want to propose an intention to create a correct node from this incorrect expression.
I can activate my intention with editorContext.getContextCell().isErrorState().
Wand now the question is how do I access the content of the expression which is wrong ?
For example :
var toto = titi;
titi doesn't exist, I want an intention to create a new variable called titi, how do I access the titi string ?

Thanks for your attention.
4 comments
Comment actions Permalink
I guess you may use ((EditorCell_Label) editorContext.getSelectedCell()).getText()
0
Comment actions Permalink
Yes that is what I was looking for. But I don't know what to import to be able to write this statement.
I found this class is in jetbrains.mps.nodeEditor.cells package.
The language containing this intention already depends on MPS.Editor.
What dependency is needed or what used language ?
Thanks for your help.
0
Comment actions Permalink
You need the interface from j.m.openapi.editor.cells.
You either use Control + M to import the model, or Control + R and type the name of the interface, the model of which to import.

Vaclav
0
Comment actions Permalink
Thank you very much. It works nicely now !
0

Please sign in to leave a comment.