MPS 2022.2 Help

Editor Actions

MPS editor has quite sensible defaults in completion actions, node creation policy. But when you want to customize them, you have to work with the actions language.

Node Factories

When a node is replaced with another one, it may be useful to parametrize the process of creation of the replacing node with values held by the node that is being replaced, or perhaps also to reflect the future position of the replacing node in the model. Node Factories give you exactly that. You write a set of handlers that get invoked whenever a new node needs to be created in a substitution action or through one of the new initialized node<>set new initialized node<>add new initialized node<>replace with new initialized node<> and new initialized instance<> methods.

In brief, Node Factories allow you to customize instantiation of new nodes. In order to create node factory, you first have to create a new Node Factories root node. Inside of this root you can create node factories for concepts. Each node factory consists of node creation block which has the following parameters: newNode (the created node), sampleNode (the currently substituted node; can be null), enclosing node (a node which will be the parent of newNode in the model), and a model. The node factory handler is invoked before the new node gets inserted into the model.

You can leverage the concept inheritance hierarchy in Node Factories to reduce repetition.

Ac6

Paste wrappers

These allow you to customize pasting of nodes into other contexts. For example, if you copy a LocalVariableDeclaration in BaseLanguage and paste it into a ClassConcept to make it a field of the class, a simple transformation must be triggered that will create a new FieldDeclaration out of the LocalVariableDeclaration.

Ac10

Copy-paste handlers

These give you the possibility to customize the part of the models that is being copied to or pasted from the clipboard.

Ac11

The copy parameter in a copy pre processor block gets contains an exact deep copy of the original parameter node. Unlike originalcopy is detached from the model and so has no parent node.

Ac12

The task for the paste post processor typically is to re-resolve references so that they point to declarations valid in the new context.

 

Last modified: 27 May 2021