One of the primary goals for MPS is to serve Java developers so that they could seamlessly combine DSLs with Java code as an integrated part of their Java projects. Various database queries, business rules, hardware-specific code, system configuration or any other code in languages developed by language vendors as well as those developed yourself can participate in Java projects and be used from Java IDEs directly. This user guide describes MPS from the Java developer's perspective and provides the essential information needed to jump-start coding with DSLs in IntelliJ IDEA.
Before you start
Other user guides
- User Guide for Language Designers - if you want to learn how to create languages of your own in MPS
- MPS user guide for Java developers (IntelliJ IDEA) - if you are a Java developer and look for ways to seamlessly combine MPS-based languages with Java
- Standalone IDE user guide - covers the topic of using MPS-based standalone IDEs
- Basic notions of MPS: nodes, concepts, and languages
- MPS project structure
- Default keymap reference
Setting things up
To get started, you first need to install the essential MPS plugins into IntelliJ IDEA:
- MPS core
- MPS BaseLanguage support (in order to edit BaseLanguage in IDEA)
- MPS Version Control support (in order to use VCSs for MPS models in IDEA)
Both Community and Ultimate editions of IntelliJ IDEA will work. Once you have done that, pick a DSL that you want to use and install it into IntelliJ IDEA, as well. This will allow you to use MPS-based DSLs inside IntelliJ IDEA and interoperate between the MPS code od the rest of your project.
We've described all the steps required to get up and running at the Using MPS inside IntelliJ IDEA page. Check it out for details.
The clever projectional editor in MPS is slightly different from what you may be used to. Since the editor is the most visible element, which you'll get to know as soon as you start interacting with your code, we prepared a short introductory document - Comanding the editor.
Resolving difficulties, understanding reported errors
The Finding your way out of a problem page should give you a hand whenever you run into a problem.
Where to find language plugins
Languages come packaged as ordinary zip files, which you unzip into the IntelliJ IDEA plugin directory and which IDEA will load upon restart. Additionally, many of the plugins have been shared through the IntelliJ IDEA plugin repository and so can be comfortably downloaded through the IDEA's plugin manager. The Using MPS inside IntelliJ IDEA page further details the necessary steps.
- BaseLanguage is a projectional clone of Java, which allows you to write code in a language that you are familiar with, yet benefit from many advantages that MPS brings.
- Build language provides a comfortable and fully declarative build abstraction over Ant. This is the language we use internally to build MPS. You can use it, for example, to create build scripts for your Java projects or to compile and package your MPS-based languages. Check out the documentation for details.
On top of Base Language, which is merely a copy of Java 6 (defined using the MPS language-definition aspects), MPS provides several useful language additions that aim at making Java development much more efficient and enjoyable:
- Collections language
- Dates language
- Regex language
- Type Extension Methods
- XML language
- Other languages
IDE integration - Java interoperability, cross-navigation, joint compilation
The MPS IDEA plugin integrates your MPS code tightly into the rest of the Java project. MPS code will seamlessly participate in IDEA's build and make, you can cross-navigate to usages or definitions between Java and BaseLanguage as well as refactorings will correctly include all the sources.
Being projectional in the world that has been built on text brings about some challenges. Integration with VCS systems is one of them. In order to be able to standard VCS systems, such as Subversion or Git, MPS provides an add-on that hooks into the important VCS events and gives you a projectional way to merge code and resolve conflicts. With this add-on installed IntelliJ IDEA will give you the experience you expect from a VCS for your projectional code. 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.
Check out the details at the Version Control page.
It is not yet possible to directly run a program represented by an MPS node - the generated code should be used to execute the program instead. However, we've already implemented the ability to set a breakpoint directly inside the DSL code and so the IntelliJ IDEA debugger will be stopped in the appropriate place allowing you to explore the stack trace and the variables.