Skip to content

IntelliJ SDK

The best place to learn more about the IntelliJ platform is the IntelliJ Platform SDK documentation ⧉. Two additional resources are also helpful if you want to understand how IntelliJ plugins are written (Introduction to creating IntelliJ IDEA plugins) and how the IDEA threading model works (Advanced guide to creating IntelliJ IDEA plugins ⧉).

Some parts of MPS are different from the IntelliJ platform, so those chapters are irrelevant: PSI + all text editor-specific code and custom languages support ⧉.

Where can you find a list of all IntelliJ registry entries?

You find them in registry.properties ⧉.

How can I access the recent projects list more easily?

How can I create a class/component that MPS loads on demand?

Create a lightweight service ⧉ using the @Service ⧉ annotation. An example service MyService could then be accessed through ApplicationManager.getApplication().getService(MyService.class)

How do you add a custom action to a toolbar?

It is assumed that this is a toolbar group that is populated with custom actions. There is an addJavaAction that can be used in the ActionGroupDeclaration (example from IETS3), which lets you add objects of type AnAction like the ToggleAction in the example. You can circumvent the MPS action declarations this way.

It is enough to extend AnAction and implement CustomComponentAction for custom swing components. Before implementing this, search the IntelliJ/MPS code base for such classes. There are, for example, TextFieldAction and JButtonAction ⧉. Search for [Button|Text|..]Action in MPS to find such instances and look for existing components in the UI that look like the ones you need.

Actions | IntelliJ Platform Plugin SDK ⧉ contains the general documentation for IntelliJ actions.

How to make messages in the messages view ⧉ clickable?

Technically, the messages view is an MPS tool unrelated to the IntelliJ platform. The message statement has a throwable parameter that you can used to attach exceptions. In the generator, there is genContext.show error <messageText> -> <node> which takes a message and a node. In MPS 2022.3, there is also support for a hintObject in the message statement so you can jump directly to a node, model, or module.

Message Bus and Listeners (Message Interface)

Reference:

You can use a message bus to listen for IntelliJ or custom events and send out events. You connect and subscribe to different topics through listeners. You don't have to store and remove each listener you added; you can disconnect from the bus. Find topics on the MPS console with the following code:

1
2
3
4
#nodes<scope = global>.ofConcept<StaticFieldDeclaration>.where(
    {~it => it.type.isInstanceOf(ClassifierType) && it.type:ClassifierType.?classifier.?name.?equals("Topic"); 
    }
)

Example:

class MessageBusExample {
    void connect() {
      this.busConnection = ideaProject.getMessageBus().connect();
      FileEditorManagerListener myListener = new FileEditorManagerListener() { // implement listener (1)
        @Override
        public void selectionChanged(@NotNull() FileEditoManagerEvent event) {
          // code
        }
      };
      this.busConnection.subscribe(FileEditorManagerListener.FILE_EDITOR.MANAGER, myListener);       
    }
}
  1. You have to implement selectionChanged for this listener.

Comments