Skip to content

Intentions for custom selections

Language Namespace : de.itemis.mps.selection.intentions

This language adds support for adding intentions for selections. Normally, you want to use the class NodeRangeSelection which is the default type of selection in MPS. If you have implemented a custom selection, you can of course use it instead (example: TableRangeSelection in tables). Use one of the get methods of the selection variable to return the selected nodes or cells. There are some other methods in the class AbstractMultipleSelection that you may find useful as well.

Example

intention SurroundListWithIndent for selection NodeRangeSelection {                                                                                                                                                                                       
    description(selection)->string { 
      "Surround with Indent Collection"; 
    }                                                                                                                                                                                                                                           
    isApplicable(selection)->boolean { 
      selection.getFirstNode().isInstanceOfConcept(concept/IText/); 
    }                                                                                                                                
    execute(selection)->void { 
      nlist<IText> nodes = (nlist<IText>) selection.getSelectedNodes(); 
      node<IText> ile = nodes.first; 
      node<SpaceIndentedText> parent = ile.replace with new(SpaceIndentedText); 
      nodes.forEach({~it => parent.lines.add(it); }); 

}