Child pages
  • Shapes - an introductory MPS tutorial

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Navigate (using Tab) to the "<none>" text in the implements section and specify INamedConcept (either type it in or use Control + Space). INamedConcept is a Concept Interface that Canvas will now implement. Concept Interfaces can also , just like Concepts, add new capabilities to Concepts that implements implement them. INamedConcept in our case enriches Canvas with the name property, so Canvas instances (called Nodes) will have a name property so the user can easily distinguish between them.

...

Be careful here. If you have selected a different layout than vertical, the shapes will not be nicely organised one below another, but perhaps one next to another on the same line, which, while quite innovative, may not be the most intuitive way to use your language..

Image RemovedImage Added

You need to bind the red cell to the shapes child collection of Canvas.Image Removed

Image Added


Image RemovedImage Added
Now, to place the collection below the name of the Canvas, you should use the Alt + Enter shortcut (or the light-bulb symbol) the bring up the intention pop up menu and pick "Add On New Line".

Image RemovedImage Added
You'll get the final editor definition:

Image RemovedImage Added

If you version looks different, there may be several reasons:

...

It is the same code (AST), but it is organized on the screen differently. While previously it was an ugly tree-like text with lots of curly braces, now the code reflects the editor definition that we provided to MPS.

If your view is different, revisit the three editors. Given that they are fairly small, feel free to delete then and do them over, if needed. You can delete a whole editor definition if you locate it in the Project view under the Editor aspect model and press Delete or right-click and choose delete in the context menu. Alternatively, you may keep pressing the Delete and Backspace buttons inside the editor definition until you remove all the suspiciously looking code.

...

An editor is also needed:

Pre-defined colors

Now, rebuild your project. The Color concept that we have just added needs to be compiled, so that we can use it to create some colors. We need to provide concrete nodes of the Color concept, which will represent the individual color constants and which the user of our language will be able to refer to from their Canvasses. We will utilize Accessory models for this. Accessory models are models inside a language definition that hold arbitrary nodes, which become part of the language and are visible to the language users.

...

We do not need to change anything here, so let's continue by clicking the OK button.

Info

If you, at any point when working with MPS, cannot type the code that we propose in the tutorial, most likely you have not properly set the dependencies. So please pay attention to the places, where the tutorial mentions dependencies and suggest that you should add a dependency or import a language.

...