Highlight origin of reference on click


I would like to highlight the referred node automatically when I select the reference. So something similar to pressing Cntr+Shift+F7 (Highlight Usages).

I see that there is an action called CLICK but not RELEASE. Or just a FOCUS action would be nice.

Is there something like that so that the user of the language does not need to press the shortcut?

Official comment


Unfortunately, there is no such action in the action map declaration.

However, you could implement it via API.

Here are the steps to do it:

1) Create the plugin solution and the project plugin there (https://confluence.jetbrains.com/display/MPSD20181/Plugin)

2) Subscribe to the editor component creation in the init block of the project plugin:

myMessageBusConnection = project.getProject().getMessageBus().connect();
myMessageBusConnection.subscribe(EditorComponentCreateListener.EDITOR_COMPONENT_CREATION, myEditorComponentCreationHandler);

3) Define the 


as follows:

When the editor component is created, add the selection listener to its selection manager;


In the selection listener, you can find all the references of the selected node and highlight them:

editor.getHighlightManager().mark(message, this));

In order to remove the messages, use


It's worth mentioning it is quite complicated task and we have this feature in our plan

Hey Semen,

thanks for your reply. Yes, looks costly. I think I will wait for an official implementation since it is not an important feature.


Hello Semen,

we have another use case for this RELEASE (or similar) action, so this feature would indeed be very useful!

Kind regards, Andreas


Please sign in to leave a comment.