MPS 2021.2 Help

Custom Aspect

Alongside the usual language aspects, such as StructureEditorType-system, etc., it is possible for language authors to create custom language aspects (e.g. interpreter, alternative type-system, etc.), have them generated into a language runtime and then use these generated aspects from code.

 

What is a custom aspect?

Screen shot 2015 09 30 at 20 37 45

Language definitions in MPS can be thought of as a collection of aspects: structure, editor, type-system, generator (1)

Each aspect of a language is defined in a separate aspect model. For example, the editor aspect of language L is defined in the L.editor model.

The aspect can be generated into a language's aspect runtime (2), which represents this aspect at runtime, in other words, when the language is being used inside MPS. The generated classes are then obtained by the corresponding subsystem through (3)  LanguageRuntime.getAspect() and can be used further (4).

Custom Aspect Descriptor

The IDE part of a language aspect is described by a SimpleLanguageAspectDescriptor, which can be created in the plugin model of a language.

aspect name

The name of an aspect. It will be possible to create a model with this name in other languages and the model will be considered as the model of this aspect for the given other language.

main languages

Aspect's "main" languages are automatically imported into models describing this aspect and concepts from these languages are shown on top of the "new node" menu.

additional languages

Not currently implemented. These are the languages that the user might want to use in an aspect model of this kind (but might not). They will be shown in some "hint" on an aspect. This is only for discoverability purposes, e.g. editor.tables language might be such an "additional language" for the "editor" aspect.

help url

This URL is used to show context help for this concept.

icon

Icon to show in the logical view near an aspect model of this kind.

Cookbook 

The SimpleLanguageAspectDescriptor concept covers only the IDE integration of this aspect. Please refer to Custom language aspect cookbook to learn how to implement the generator part to generate a runtime for your aspects and how to use the generated code from the corresponding subsystems.

 

Last modified: 26 August 2021