Generic support for commenting out nodes in MPS
MPS now provides a universal way to comment out nodes in models. In previous versions this functionality had to be implemented in all languages separately, either through node attributes or dedicated “comment” nodes. In 3.3 the information about a node being commented out is stored in the model in a generic way. The smodel language ignores commented out nodes by default so that your queries do not have to filter out commented out nodes explicitly.
Additionally, actions have been created to comment/uncomment out a node.
How to use it
You can select any node in MPS, except roots, and press ctrl/cmd + “/”. That node will be commented out.
Let’s watch some examples.
You can comment out an IfStatement’s condition
a method parameter
a variable type
an editor cell
In fact, every single node can be commented out.
To uncomment the node you simply press ctrl/cmd + “/” on commented node.
How does it work in the model
When one comments out the node, it is placed as a child (wrapped) in a special “child attribute”, called BaseCommentAttribute. Then the instance of this attribute is attached to the commented node’s link in the former parent of the commented node.
The child attribute is the same as the link attribute, but the child attribute is attached to the aggregation link.
So the commented nodes are not stored as the usual children, and they won’t appear in queries like node.children, node.descendants, etc.
But the MPS editor knows about comments and it will draw both children and the commented nodes, in this role.
By default every commented node is drawn surrounded by /* */ . You can define a custom commented editor for the concept.
Just define the usual editor with the hint “comment”.
Note that the children of the commented node should be drawn with their usual editor so you need to remove the comment hint in child cells
Also you can override the comment action in the editor.
For example, we don’t want the %expression% in the ExpressionStatement to be commented out ever. We want the whole statement to be commented out instead.
So we define the action map for the ExpressionStatement and attach it to the child %expression% cell.
Since can execute block returns false, the COMMENT action will not be executed on %expression% cell. MPS will try to execute the COMMENT action on parent cell, and then the whole statement will be commented out.
Subscribe to Blog updates
The Early Access Program for MPS 2021.3 is open
Our release of MPS 2021.3 will be delayed until next year. That said, we can’t finish the year without giving you a glimpse of what you can look forward to. DOWNLOAD MPS 2021.3 EAP Experimental Kotlin language support An experimental Kotlin implementation is now bundled with MPS. While it supports m…
Feature Freeze for MPS 2021.1
Today we’re rolling out the last build in the Early Access Program for MPS 2021.1, and these are the last few features that will be included in the release. Try them out. Zoom in and Zoom out The font size can be quickly adjusted in the currently open editor window by holding Control/Command and rol…
MPS 2021.1 EAP3 is now ready for you to try
We are getting ready for the major release of MPS 2021.1, and the Early Access Program (EAP) is our way of sharing with you the new functionality that we have been working on in recent months. Here are the new features we’ve implemented in this version. Model viewer in diff dialog The MPS model view…
Early Access Program of MPS 2021.1 is open
The Early Access Program is an important part of our product development process for identifying critical issues with the new release features. If you encounter any problems, please report them to our issue tracker. Check out the new functionality that we have prepared for you. Improved access to $L…