Writing an importer: The basics

NOTE: Due to an error, only a single paragraph was sent by e-mail from the first post in this series. I apologize for any inconvenience caused and hope it will work better this time. Continuing from our last post, let’s have a brief look at the data and the language we are going to work with and set things up. Remember, the code is available on GitHub. The language I have created a very small language for this tutorial, called game....

Writing an importer: Introduction

What do you do if you have some data that you want to import into MPS? There is no built-in importer in MPS, nor is there a ready-to-use framework, so it can be overwhelming for a beginning MPS language developer to piece together all the required knowledge of MPS subsystems. That’s why I want to start a series of beginner-level posts to cover the process of writing an importer. I will assume you have experience programming in Java but are just starting with MPS....

MPS Office Hours

As mentioned on Twitter, I would like to offer MPS Office Hours to the community. This will be a recurring one-hour meeting via Zoom where we talk about MPS and I offer my help with your MPS problems. You can either describe your problem in words, you can do a screen share, or I can do a screen share. If you are interested, I have prepared a form below where you can sign up to get notified about the whereabouts of the future meetings....

Making intentions visible

Intentions are a signature feature of the entire family of JetBrains IDEs, including MPS. An intention is defined in the eponymous language aspect. In order for an intention to be visible, the user has to import the language into their model. If you want to add an intention to an existing language (for example, adding a great new refactoring to base language, to be invoked via an intention), you could define a new language extending the original language and add the intention there....

Running MPS code from command line

You can execute MPS code not only from within MPS but also from command line. This can come useful for batch processing or when exporting models from MPS. There are two options for running code from command line: Using an MPS-provided Ant task. Writing custom code using MPS libraries. Using MPS-provided Ant task This approach is documented in the JetBrains MPS Help. It’s quite simple to set up so you can be up and running quickly....

Announcing Build Script Notifier

Since my last post in September, I have been working on a plugin to help solve a problem that annoys professional MPS users and used to bother some of my colleagues as well. Is it something for you? If your reaction to phrases such as “dependencies should be extracted into build script” and “reload modules from disk” is one of aversion and pain, then you know the problem: MPS makes you do routine mundane work that it could well do itself, interrupting you and distracting you from things (and thoughts) that matter....

More clickable URL links

Last time we looked at a simple way to create hyperlinks in MPS. As a reminder, it involved using a constant cell, adding styles to decorate it like a link and creating an action map with a CLICK action. In reaction to my post, Bernd Kolb has tweeted a much simpler way of creating hyperlinks: using the url style attribute. And Niko Stotz reminded me of the existence of the hyperlink language, com....

Creating clickable URL links in the editor

Today we’ll create a hyperlink cell in the MPS editor that will open a URL in the browser when clicked: The final result The link cell is in fact a customized constant cell. We need to modify two things: make the cell clickable, and make it blue and underlined. To make a cell clickable I use a cell action map and define a handler for the CLICK action:...

Use notification balloons instead of message boxes

Sometimes we need to display an error message to the user to let them know that something went wrong. Our first instinct in these cases is often to reach for a simple Swing message box: Showing a Swing message box While quick enough to write, the actual message box looks rather ugly: Swing message box in action And it can easily get you in trouble:...

Evolving your language gracefully

When you make changes to language concepts, make them backward-compatible. Don’t remove anything right away. Instead, deprecate features and make them optional first. Remove them when they have been deprecated for a while and the users have migrated not only their master branch but any work-in-progress they may have on other branches. Until you remove them, leave the deprecated features in the editor. Show them conditionally (show if), only when they have a value....