Skip to content

Refactorings Aspect¶ ⧉

You can write simple refactorings using the language jetbrains.mps.lang.refactoring.

MPS documentation

The following questions are related to the old refactoring declarations. Use refactoring participants instead. They are explained in the documentation.

Is this aspect widely used?

No, there are just a few use cases, even in MPS languages.

Can you link to an example that demonstrates this aspect?

Rename ⧉ implements the refactoring. RenameNode ⧉ implements the action. The action is part of the group CoreNodeRefactorings ⧉ which belongs to the NodeRefactoring group. Base Language has its group called RefactoringAdditions ⧉.

Can you change the concept of a node while keeping all properties, references, and children?

Yes, call RefactoringRuntime.replaceWithNewConcept ⧉ with your node and new concept as parameters. In this class, there are other handy methods, such as changePropertyInstance(node, oldProp, newProp) and changeReferenceLinkInstances(node, oldLink, newLink) ⧉.

Changing the concept of a node ⧉ (Specific Languages' blog)

What should I put in the applicable block of the refactoring and its action?

For the action, you can use is applicable refactoring<YourRefactoring>(). By default, refactorings are not disabled for read-only editors. Consult the update block of the MoveNodes ⧉ action for more information.