Closed bkolb closed 11 years ago
I added a class that you can use to listen for node deletions. In TestCase_Editor you will find this example:
ModelChangeManager.instance().setNodeDeletionListener(
var,
node.values.findFirst({~it => it.variable == var; }),
{node<> deletedNode =>
node.values.removeWhere({~it => it.variable == var; });
});
The first parameter is the node you want to listen on. The second parameter is a key that ensures, that you do not add the same listener multiple times. You usually want to use the node here, that is modified by your handler. The third parameter is you handler.
I have created a table for testing functions. Each column in the table should stand for a function argument, the last column represents the return value
The table has table entries and a table entry consists of a list of expressions The table determines the amount of columns based on the size of the expression list in a table entry.
If I create a new parameter everything works as expected.
But if I delete a parameter I am running into an IndexOutOfBounds Exception. The reason for that is that the table entry still contains the expressions for the just deleted parameter. So I need a way to clean up the deleted parameters (before the editor redraw happens, this is why auto-quick fixes do not work)
I have now a workaround which returns in case I would run into the IOOB Exception a newly created node which is not part of the model and a auto quickfix does the model cleanup.
Do you have a better / cleaner way to implement that? Is there a way of listening for delete events? If so, it would be nice if I could register a delete handler for a given node