Ref. node list cell: element action map - DELETE action failure
I have been hacking on robot_Kaja and I do not know how to implement an enhancement. Take the 'Maze' script as an example. It requires the Common and PlaygroundDefinition libraries. Then it calls 'buildMaze', which is defined in PlaygroundDefinition. My enhancement is simple: indicate an error if the user removes the 'require PlaygroundDefinition' command, but leaves the call to 'buildMaze'.
My approach has been to trap the removal of a command via action map. The action map works if the user removes one command at a time. It fails if the user selects multiple commands and deletes them all in one action. So, I've come here today to ask the following:
Is the action map expected to work for the case where the user selects multiple lines?
Is there a better approach?
Please sign in to leave a comment.
Might be related to this: https://youtrack.jetbrains.com/issue/MPS-26781
Also, since I do not know the robot_Kaja example by heart: are you sure you have set your action mal at all the correct places in the editor?
Thanks for the suggestions Robert. I can only assume that my action map is correct; it does work if the user removes one command at a time. Of course, I have tried it in many places. The one place where it seems necessary is called 'element action map' in the CellModel_RefNodeList of the CommandList_Editor (the 'commands' child). Is there some other place I should try?
Thanks again.
This kind of enhancement is usually implemented using scoping rules for references (in this case see RoutineCall_Constraints where scope for link 'definition' is defined). If you remove the 'require' the scoping error should be shown automatically and is in fact shown for me.
Sergej:
I think this approach (using scoping rules) makes the most sense. I tried it first and noticed that the scoping rule was not always invoked as I removed commands from a CommandList. I am not certain if this is by design or not. Perhaps it is the best one can do, regardless.
Thank you for your suggestion.
Error highlighting is performed in a background thread and sometimes may not detect changes accurately (though it's a bug then). You can press F5 in an editor to force rehighlighting, this should make the scope error definitely appear.
Ah! Can confirm: F5 does the trick.
Open robot_Kaja and edit the 'Maze' script in the sandbox.
Select the two lines:
require PlaygroundDefinition
require Common
Hit backspace or delete, thereby removing the 2 lines
A red Intention icon appears next to the line:
buildMaze Library call
Hit F5
Red underlines appear under 'buildMaze' and 'turnRight' library calls.
Shall I report a defect?
Thanks again, Sergej.