Dont understand some Editor behavior
If I have a Method declaration like
private void foo(){
<statement>
}
It is not always clear to me what happens when I trigger a "delete" on the method ( via keyboard), because sometimes it gets deleted and sometimes a PLACEHoldermember appears instead. I tried to "catch" all delete actions in an Editor i wrote but it seems that I am not able to catch whatever makes the swap between a node and the placeholder.
Any ideas?
Please sign in to leave a comment.
If I have understood your question properly.
I would suggest you to use ctrl+up/ctrl+down keys select /deselect and then trigger delete action. In my initial days I too faced similar problem. But now I am enjoying dealing with this projectional editor.
As I see MPS works on nodes & have a projectional editor, when you select something in you editor, you have to check whether you have selected a node or the content of the node or something else.
If you are talking about BaseLanguage, then it is DeleteClassifierMember action map that triggers the replacement of method declaration with an empty line (PlaceholderMember).
Thank your very much, I indeed was looking for DeleteClassifierMember. Now that I understand Editor behavior a bit better I have written my own custom cell.
(editorContext, node)->AbstractCellProvider {
AbstractCellProvider provider = new AbstractCellProvider() {
public EditorCell createEditorCell(EditorContext p0) {
EditorCell_Collection enclosincCell = EditorCell_Collection.createVertical(p0, node);
vp.fragmentIntermediates.forEach({~it => enclosincCell.addEditorCell(p0.createNodeCell(blabla)); });
foreach cell in enclosincCell.getCells() {
cell.setAction(CellActionType.DELETE, new CellAction() {
public String getDescriptionText() {
"foo";
}
public boolean executeInCommand() {
true;
}
public boolean canExecute(EditorContext p0) {
true;
}
public void execute(EditorContext p0) {
warn "Whatever";
}
});
}
warn enclosincCell.firstContentCell().getAvailableActions().toString();
warn " ALL : ";
foreach cell in enclosincCell.getCells() {
warn cell.getAvailableActions().toString();
}
warn "Node : " + node.getPresentation();
return enclosincCell;
}
};
return provider;
}
I am trying to register a Delete Action on the Cells because right now, the behavior of the cell is not like I want it. When I delete the cell in the editor, not the cell gets removed, but its parent. I would guess that, the event is not caught by the cell and passed on to the parent.
But registering the DeleteAction like in the code above doesnt help me, because the "delete event" is still not caught and the parent still gets deleted. Any idea what I am doing wrong?
Solved my Problem. Mistook the "Delete" action for the "Backspace" action, registering a "Backspace" action solved it.