Intentions are a very useful mechanism providing fast access to the most used operations with syntactical constructions, such as "negate boolean," "invert if condition," etc. If you've ever used IntelliJ IDEA's intentions, you will find MPS intentions very familiar, because they are really the same thing.
Using intentions

Like in IDEA, if you have some avaliable intentions at the current position in your code, a light bulb is shown. To view the list of avaliable intentions, press Alt+Enter or click the light bulb. To apply an intention, either click it or select it and press Enter.
Intentions can be disabled/enabled (press "D" or right-click the intention in the list). "Disabled" means that you will be no longer notified if this intention is applicable. However, a disabled intention will be visible in the popup menu and thus can be used or re-enabled. If there are only disabled intentions for the current place in the code, the light bulb will not be shown, but you can still invoke the intentions list with Alt+Enter.
Example: list of applicable intentions
Where to store my intentions?
You can create intentions in any model by importing the intentions language. However, MPS collects intentions only from Intentions language aspects. If you want your intentions to be used by the MPS intentions subsystem, it must be stored in the Intentions aspect of your language.
Intention structure
Examples
You can find some intentions examples in jetbrains.mps.baseLanguage.intentions.
You can also see all intentions by going to the IntentionDeclaration concept (press Ctrl+N, type "IntentionDeclaration", press ENTER) and finding all instances of this concept (pres Alt+F7, check instances, check Global Scope).
Add Comment