What’s New in MPS 3.0
IntelliJ IDEA Plugin
With MPS 3.0 plugin you can extend your existing Java applications with the power of MPS DSLs, without leaving IntelliJ IDEA.
Using MPS DSLs from Java
With the version 3.0, MPS provides seamless integration between MPS BaseLanguage and Java within IntelliJ IDEA. As with Kotlin and Groovy, you can reference BaseLanguage classes and libraries from the native Java code and back, and use the full power of IntelliJ IDEA refactorings and navigation.
Switching from Java to MPS BaseLanguage
MPS 3.0 allows you to convert selected Java classes to BaseLanguage classes. Your Java code will be parsed, transformed into BaseLanguage and saved to MPS model. All references will be re-resolved automatically. From this moment you’ll be able to use DSL extensions within the converted classes.
You can also paste Java code into BaseLanguage class body, and it'll be parsed and converted as well.
Adding MPS modules as libraries in IntelliJ IDEA
You can now add dependencies from any project module in IntelliJ IDEA to the packaged MPS modules using MPS Modules Library.
MPS generator uses IntelliJ IDEA out-of-process make
MPS DSL generator performance was improved by switching to IntelliJ IDEA out-of-process make.
Multiple editors, default editor, and more. See Editor cookbook for more details.
Multiple editors for concept
From version 3.0, MPS allows language designers to define more than one editor for the concepts within their DSLs. The user of that DSLs will then be able to choose the editor which suits their needs the best, via popup menu. It's even possible to have several editors open at the same time. The contents of these editors will be updated synchronously.
Overriding editor components
Editors are frequently composed of reusable editor components. Extending languages can now override some of these components defined in the extended language, while reusing the other components and preserving the overall editor layout.
New way of handling editor selection
It's now possible to customise the behaviour of cursor positioning in editor.
It can be done in two steps:
- (Optionally) tag any editor cell with the Custom ID;
- Use node.select operation in action handler to precisely position the cursor.
If no editor is defined for a concept, MPS is now using a so-called default editor, which allows to view and edit node hierarchy as a tree structure. This editor is also used as a fall-back solution in case of any problems with the user-defined editors.
MPS 3.0 introduces the Open API, which provides read-only access to the whole project and models structure. This API is now used everywhere across MPS, and is also intended to be used by any MPS extension.
See documentation for more information on Open API: Open API — accessing models from code
Custom persistence API
MPS models are now well separated from the underlying data storage, allowing for custom formats. These can be provided through Open API and alter the way models get persisted. Two types of persistent formats come bundled with MPS:
- the traditional XML format;
- a new, more efficient binary format.
See more at Custom Persistence Cookbook
Simplified BaseLanguage language structure
BaseLanguage was refactored in order to provide better flexibility and extensibility. All children of BaseLanguage Classifier node were moved under the same role member, allowing for improved editing user experience.
Improved BaseLanguage editing experience
Editing has become much closer to the conventional text editing:
- Internal class layout is not fixed anymore;
- Empty placeholders have been removed to eliminate visual clutter;
- Side transformations and substitution rules were greatly improved, allowing to switch between BaseLanguage concepts by simply changing the keyword.
For more details, please see the Smoothened BaseLanguage editor screencast.
New improved import from Java
As with IntelliJ IDEA Plugin, you can convert any Java program to MPS BaseLanguage from within MPS itself. Your Java code will be parsed, transformed into BaseLanguage and saved to MPS model. All references will be re-resolved automatically.
Structure language changes
Structure definition language has been updated with the following changes:
static virtual behaviour methods
Concept declaration modifiers
Concept editor has been updated with respect to the changes above.
see more: Structure
Type system changes
- Type system now takes "optimistic" approach in calculating node types during the model generation, and assumes there are no implicit type dependencies between nodes;
- If the type of a node depends on another node's type, such dependency should be declared explicitly by the typeOf instruction within the type rule.
Type system trace usability improvements
- Fine-grained type checking steps are now moved in a tree structure under the major steps;
- Nodes used in the selected type system step are highlighted in the currently open editor;
- When a node is selected in the editor, all irrelevant type system steps are dimmed in the trace.
Some information on using this tool can be found in this post: Typesystem Debugging.
Console is a convenient tool, which allows iterating over MPS nodes, references, models and modules, and executing specific commands on them.
It consists of two parts:
- Console window, which allows line-by-line execution of any DSL construction in the realtime;
New Console DSL based on BaseLanguage, allowing to:
- find usages with ability to show the results in the MPS usages view;
- calculate stats and analyse broken references;
- print to the console, with navigable results.
Build Language improvements
Two new targets were added into build scripts:
- generate — generates modules in the script;
- cleanSources — cleans generated files;
makeDependents — unlike buildDependents, calls generate before assemble for every dependent module.
buildDependents target now calls assemble target not only for the nearest script dependencies, but for their whole transient closure. Each script is guaranteed to be called only once and only after all its dependencies have been built;
Each model is automatically converted into binary format (.mpb file) before packaging in order to save space and improve performance;
Startup time for generate task improved by loading a stripped-down version of MPS core;
A new aspect for running module tests on packaged modules from build script.
The popular Darcula color scheme known from IntelliJ IDEA 12 has been adopted for MPS.
Your custom concept editor colours will appear inverted by default, but you can decide to re-use standard colours from the IntelliJ IDEA Platform to make your editor more adaptable to the current UI theme.
MPS 3.0 keeps the history of your changes, keeping revisions between any saves to the local file system. You can then browse the history, compare versions of your code and selectively revert parts of your code, may you need to.
New UI for model/module properties
The configurations dialogs for module and model properties have undergone a major facelift in order to provide more intuitive way to configure your project structure.
Version Control UI improvements
- You can now diff and merge model properties in human readable format;
- All changes in a model are presented in a single dialog window.