Beispiel #1
0
 private boolean canExecute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   if (ListSequence.fromList(selectedNodes).count() != 1) {
     return false;
   }
   if (SNodeOperations.getAncestorWhereConceptInList(
           node,
           new String[] {
             "jetbrains.mps.lang.generator.structure.TemplateDeclaration",
             "jetbrains.mps.lang.generator.structure.InlineTemplateWithContext_RuleConsequence"
           },
           false,
           false)
       == null) {
     return false;
   }
   if (ListSequence.fromList(SNodeOperations.getAncestors(node, null, false))
       .where(
           new IWhereFilter<SNode>() {
             public boolean accept(SNode it) {
               return SNodeOperations.isAttribute(it);
             }
           })
       .isNotEmpty()) {
     return false;
   }
   if (QueriesUtil.isInsideTemplateFragment(node)) {
     return false;
   }
   return true;
 }
Beispiel #2
0
 private void execute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   SNode nodeMacro = QueriesUtil.addNodeMacro(node);
   // set caret
   editorContext.selectAndSetCaret(nodeMacro, 1);
 }
Beispiel #3
0
 private boolean canExecute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   if (ListSequence.fromList(selectedNodes).count() != 1) {
     return false;
   }
   return QueriesUtil.isPropertyMacroApplicable(node, editorContext.getSelectedCell());
 }
Beispiel #4
0
 private boolean canExecute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   if (ListSequence.fromList(selectedNodes).count() != 1) {
     return false;
   }
   return QueriesUtil.isReferenceMacroApplicable(
       node, (jetbrains.mps.nodeEditor.cells.EditorCell) editorContext.getSelectedCell());
 }
Beispiel #5
0
 private void execute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   SNode propertyMacro = QueriesUtil.addPropertyMacro(node, editorContext.getSelectedCell());
   // set caret
   editorContext.selectAndSetCaret(propertyMacro, 0);
   EditorInspector inspector = editorContext.getInspector();
   assert inspector != null;
   inspector.activate();
 }
Beispiel #6
0
 private void execute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   SNode referenceMacro =
       QueriesUtil.addReferenceMacro(
           node, (jetbrains.mps.nodeEditor.cells.EditorCell) editorContext.getSelectedCell());
   // set caret
   editorContext.selectAndSetCaret(referenceMacro, 2);
   EditorInspector inspector = editorContext.getInspector();
   assert inspector != null;
   inspector.activate();
 }
Beispiel #7
0
 private void execute_internal(
     final KeyEvent keyEvent,
     final EditorContext editorContext,
     final SNode node,
     final List<SNode> selectedNodes) {
   // do not hang <TF> on other attributes
   SNode applyToNode =
       ListSequence.fromList(SNodeOperations.getAncestors(node, null, true))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return !(SNodeOperations.isAttribute(it));
                 }
               })
           .first();
   QueriesUtil.createTemplateFragment(applyToNode);
 }