MPS 2021.3 Released
We planned to release this version last year, but we didn’t have the level of functionality we desired, so we postponed the release date. This is a special major release as it contains features that the team has been working on for a long time. Read on for more details or watch our release video.
It’s no secret that we have been working on a new typesystem for some years. The path to achieving this hasn’t been easy or straightforward, but we finally have something to show. Coderules is still in Beta, which is why it’s not bundled with MPS.
As this is an entire subsystem, we have prepared an online course that walks you through its fundamentals.
Experimental Kotlin language support
An experimental Kotlin implementation is now bundled with MPS. Although it supports most of the structure elements in the language (and their text generation), it remains only partially supported.
Stubs in common Kotlin code are also supported. On the JVM side, baseLanguage constructs (code and stubs) can be referenced in Kotlin through the jetbrains.mps.kotlin.javaRefs language.
The implementation of the typesystem has been externalized to MPS-Kotlin-Typesystem, which can be installed as a plugin. There is also simple support for types (without inference and generics) and overload resolution that can be used for editing.
Hide revision action in annotate
Some revisions may contain low-level migrations, and when they affect the whole root, it might be undesirable to see them in the ‘annotate’ column. The existing action Annotate previous revision opens the editor in a separate tab for a root at the selected commit. The new action Hide Revision allows you to exclude a revision from the annotation result in-place and show the result in both the editor and gutter. The excluded revisions can be restored with the opposite action Restore Hidden Revisions.
Information about hidden revisions is displayed in the notification panel at the top of the editor. It is also possible to restore hidden revisions by clicking on the corresponding link in the notification panel.
Optimization of Annotate revision action results
The Annotate action in MPS is not as fast as the git blame operation for text files since the annotation result is constructed for the models. Annotate revision and Annotate previous revision actions use the same algorithm for constructing the result as the Annotate action and were slow as well. The result for the Annotate revision and Annotate previous revision actions can be constructed instantly using the result obtained from the initial Annotate actions.
Details dialog in merge roots
The Show Details action has been introduced to give more details about the branches during merging. The action is accessible from the Merge revision window.
Short change descriptions in tooltips in Diff dialog
We’ve introduced a new action that can change the description of the changes in the Diff dialog tooltips. The description is shorter and more readable.
Enhanced editor tooltips
Now it’s possible to click on the links inside the tooltips, and the tooltips popup window stays inside the main application window. You can also scroll inside a tooltip if it has a lot of text.
New diff algorithm in the merge process
A new algorithm for calculating changes between two models was introduced in v2020.3. The algorithm allows you to detect node movements and define new change types. Since node movement is often a result of wrapping the node with a new parent node, new change types were introduced for wrapping changes, as well.
The new algorithm was developed to find conflicting, non-conflicting, and symmetric changes for changes of new types. We’ve introduced a UI mechanism for switching between the algorithms with and without node movement tracking in the Merge window.
Nested wrapping and unwrapping changes detected in diff dialog
Even though it was previously possible to detect internal insertions, deletions, and moves inside the wrapping or unwrapping change, nested wrapping changes were not detected. Now it is possible to detect nested wrapping and unwrapping changes.
Reorganized VCS settings
VCS settings have been reorganized to make them more discoverable and usable. In Preferences / Settings | Version Control you will now find a list of the available settings to configure your VCS. Additionally, we’ve added a separate node for Directory mappings, and the background operations are now switched on by default.
If you go to the Git node, you’ll notice that we have divided the settings into sections that account for the most important processes: Commit, Push, and Update.
Generation of compatible closures into Java lambdas
MPS closures are now generated into Java lambda expressions if they are compatible. Incompatibilities include the usage of:
- Yield operations
- “Functional” abstract classes
- Local variables conflicting with parent scope
Some issues may arise from this change:
- Ambiguous calls: undetected in MPS, the Java compiler will report such issues with closures generated as lambdas.
- Closure instances: as a lambda, a closure will create a single instance at runtime, as opposed to anonymous classes that create a new instance every time it’s called (see screenshot below).
Mapping label for tuples
We’ve introduced experimental functionality to use a pair of nodes as a key for the mapping, ‘node<>, node<> –> node<>’. This is useful in situations where you need to support two source concepts. If you would like to give it a try, it’s used the same way you use labels with one key node. You only need to add the second key by typing ‘,’ to get the second field.
Then, restore a reference by get output by label and input, with 2 relevant nodes as shown below:
For many years MPS has stuck to labeled ‘node<> –> node<>’ mappings. The whole generator subsystem is built around the idea of passing a single node as an input, and most operations assume a mostly single-node context. With this feature, we aim to explore different ways to make the generator more flexible, so we would really appreciate your feedback on it.
Access all values of two key mappings in generators
Besides the Mapping label for tuples feature, we now support a query to access all known mappings for given two keys, genContext.get output list LABEL for (node1, node2).
Performance trace reports time spent resolving dynamic references
Because of numerous scope evaluations, resolving dynamic references often slows down model-to-model transformation. Performance trace hides this vital piece of information under a vague “restoring references” title. Now, the time spent restoring dynamic references is reported separately from time spent restoring regular or static references.
Project migration improvements
In previous versions of MPS, for project migrations you had to create an ApplicationComponent class and register it in the plugin.xml. This was quite tricky, as you had to modify the folder structure of the plugin folder and copy over some files manually.
We have simplified the process of creating project migrations in this release. You only need to create a plugin solution, write the migration and application plugin root, and include this plugin solution with the build script.
Ant <migrate> task improvements
The Ant <migrate> task now supports multiple project specifications and can migrate several projects at once. You can either use nested <project path=””/> elements or regular Ant’s <dirset> to enumerate project locations for the task.
You can now use method references for baseLanguage methods with the jetbrains.mps.baseLanguage.methodReferences language. Like closures, they can be used as substitute for functional interfaces, function types, and functional abstract classes.
Closure untyped parameters
Closure parameters’ types can now be specified as “var”, which means the type can be inferred automatically. Partial support for this already existed with SmartClosureParameterDeclaration (for collection language and simple function calls), but the new notation can be used in any context where closures are supported.
Checkout and Rebase onto Current for remote branches
The action to Checkout and Rebase onto Current lets you check out the selected branch and rebase it on top of a branch that is currently checked out. This was possible only for local branches before, but in MPS 2021.3 you can use it with remote branches as well.
New Changes tool window
In MPS 2021.3, the IDE shows the difference between commits in a separate Changes tool window located on the left of the editor.
New Push All up to Here action
This feature allows you to push only the commits you are confident about and leave the rest for later. To use it, pick the commit you want to stop at, right-click on it to call the context menu, and select the new Push All up to Here action.
As with every release, we have prepared the Migration guide for a smooth transition from an older version. And for all newcomers, we have added descriptions to our sample projects. We have also fixed a bunch of bugs to make the product more stable. If you encounter more bugs, please report them to our issue tracker.
Have a great day!
Your JetBrains MPS team
The Drive to Develop