Can the copy-paste handler be inherited?
I've implemented some copy-paste handler for my abstract concept, that does some common logic (identifiers renumbering). But the handler does not apply to the child concept.
Is it a correct behavior? If so, how can I work around this?
Thanks,
Alexey
Is it a correct behavior? If so, how can I work around this?
Thanks,
Alexey
Please sign in to leave a comment.
Thanks,
Alexey
I have some abstract concept, e.g. IMyStatement. It has behavior method renumerate() that should be invoked, when IMyStatement is being copied. My colleague Vasily creates a concrete concept VStatement that implements IMyStatement. Vasily is really sad because he should to specify handler for VStatement and call the method renumerate() – he even doesn't know, what is renumerate() for.
My goal is to specify handler for IMyStatement so Vasily can develop his VStatement without thinking about some technical details...
The logic of proper PasteWrapper lookup is: we are looking for first existing paste wrapper assigned to node's concept or one of it's super-concept. See jetbrains.mps.baselanguage.actions.wrappers root keeping a PastWrapper applicable for Expression and transforming it to a statement.
This Wrapper will be executed then you are trying to paste _ANY_ expression (Expression concept itself is abstract, so it can hardly have any reasonable instances).
So, answering your question - you can create PastWrapper for IMyStatement interface and this wrapped will be used for all sub-concepts of this interface unless you define concrete wrapper for concrete sub-copncept of IMyStatement interface.
Thanks!
I've created a node factory for IdAware, that generates a new elementId for newly created node. And it works: I can add new nodes and ids generated correctly.
Also I've created a paste handler for IdAware that creates the new elementId for just pasted node. But it does not work: elements are copied with their ids. When I've changed applicable concept for paste handler from IdAware to ElementA, it worked correct.
test.zip (12KB)
Project was created and tested on MPS2.0 M5
Thanks,
Alexey