MPS 2024.1 Help

Extension support

Extensions provide a possibility to extend certain aspects of a solution or a language, which are not covered by the standard language aspects and the plugin mechanisms. Typically you may need your language to slightly alter its behavior depending on the distribution model - MPS plugin, IntelliJ IDEA plugin or a standalone IDE. In such cases you define your extension points as interfaces to which then different implementations will be provided in different distributions.

Support for extensions exists in

  • languages

  • plugin solutions

Quick howto

  1. Create an extension point

  2. Create one or more extensions

  3. Both the extension point and the extension must be in the plugin model

    1. Each extension must provide a get method, returning an object

    2. Each extension may opt to receive the activate/deactivate notifications

    3. An extension may declare fields, just like classes can

Extension language

The language jetbrains.mps.lang.extension declares concepts necessary for building extensions.

Extension point

The ExtensionPointDeclaration concept represents an extension point. The extension object type must be specified as a parameter.

extensionpoint.png

Extension

The Extension concept is used to create a concrete extension.

extension.png

Accessing extension point

An extension point can be accessed by reference using extension point expression.

extensionpointexpr.png

Accessing extension objects

An extension point includes a way to access all objects provided by its extensions.

extensionobjects.png

Java API

public interface Extension<T> { String getExtensionPointId (); T get (); void activate (); void deactivate (); } public class ExtensionPoint<T> { public static <T> ExtensionPoint<T> generify(ExtensionPoint raw) { ... } public ExtensionPoint(String id) { ... } public String getId() { ... } }

Extension points and extensions are managed by the ExtensionRegistry core component.

Last modified: 11 February 2024