Child pages
  • MPS plugin for IntelliJ IDEA

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

MPS 2.5 can be run as a plugin for IntelliJ IDEA enabling MPS-based DSLs to be used directly in a Java IDE and so interoperate , interoperating tightly with other elements of the project. This document will guide you through the details of how to setup IntelliJ IDEA so that you can use the MPS plugin aongside your Java code.

Integration with the IntelliJ IDEA Project structure.

To enable the MPS features inside a particular java project module, you simply add the MPS facet to the module through the Module Settings dialog:

Image Removed

We recommend you to create a dedicated Java Source Root folder to store the MPS model files.  Use the Add Model Root button on the Soures tab of the MPS Facet configuration page:

Image Removed

Model root folders look just like any other source roots in IntelliJ IDEA. In addition to the the regular source roots it is possible to create MPS models in Model Roots:

Image Removed

When creating a new model, you have to specify its name and choose one of the available model Kinds through the Create New Model dialog:

Image Removed

Each model Kind in this case represents a preconfigured set of used languages for the model. This is a convenient shorthand that still allows you to tune the list of used languages manually at any time through the Model Properties dialog by pressing Alt+Enter on the model node inside the Project Tree:

Image Removed

Model Node in Project View represents MPS model contents and just like in MPS this it is similar to java package, so you can create model elements (Roots) inside it:

Image Removed

Similar to new model dialog you can specify new root name and kind (Concept) here:

Image Removed

Model root nodes are represented in Project View and looks very similar to other files in IDEA. Projectional editor can be opened by double-click on root node:

Image Removed

Code Generation.

The code will be generated for MPS models as a part of make/rebuild project actions:

Image Removed

It's possible to configure where to store generated sources inside MPS facet settings. Generated code can be used only during the compilation process and not saved on local disk, saved in another source folder of this module or saved in any other directory:

Image Removed

All generation-time errors are prorated into the Messages view just like any other compilation problems with possibility to navigate to corresponding model elements:

<create screenshot here>

Debugger.

Unfortunately it's not possible to run program using MPS nodes right node - generated code should be used to execute program, but it is possible to set a breakpoint directly inside DSL so IDEA debugger will be stopped in appropriate place to explore stack trace and variables:

Image Removed

Version Control

Just like in MPS you can use structural diff/merge tool working upon MPS models and rendering model content in domain specific rather then Although you need MPS in its entirety to create languages, IntelliJ IDEA represents a convenient additional channel for DSL distribution.

Image Added

Editor

Enabling MPS inside a Java module is as simple as adding the MPS facet to it. Just like in MPS you can create models, import any MPS languages and start instantiating the root nodes. The root nodes are displayed in the Project View together with the other project sources and files. The projectional editor for the root nodes opens directly in IntelliJ IDEA so all your code stays within a single IDE.

Image Added

Code Generation

The code generation process of MPS models is tied to the IntelliJ IDEA's make/rebuild project actions and so will be triggerred automatically. You hit Compile in IDEA and your MPS code gets generated and compiled as well. No need for extra steps.

The generation-time errors are propagated into the Messages View alongside all other compilation problems. You also have the possibility to navigate to the corresponding model elements by clicking on the displayed error:

Image Added

Version Control

When comparing versions or resolving conflicts in MPS models, you can rely on the MPS structural diff/merge tool, just like in MPS. The tool will render the model content in a domain specific rather then the persistence-specific way:

Actions

Most of the common MPS actions/refactorings/intentions are available in IDEA plugin from now and accessible with usual shortcuts like Ctrl+L for importing language:

Image Removed

Distribution

Debugger Integration

The MPS debugger has been integrated into IntelliJ IDEA as well. When debugging your Java code you can set breakpoints directly inside the DSL code and so the IntelliJ IDEA debugger will be stopped at the appropriate place allowing you to explore the stack trace and the variables.

Distribution

The MPS plugin distribution contains 4 separate plugins now, so some at the moment. Some of the MPS functionality can be easily switched off by disabling the corresponding plugins in the Plugins configuration dialog. At the same time, user-specific DSLs can also be packaged as a separate plugins and potentially distributed together with the MPS plugins to provide IDEA developers with deliver your own powerful DSL features to the IntelliJ IDEA developers.

Image Removed