Exemplo n.º 1
0
 private void selectBraces(final EditorCell selectedCell) {
   final Pair<EditorCell, String> pair = getMatchingLabelAndCell(selectedCell);
   if (pair != null) {
     final EditorCell matchigCell = pair.o1;
     EditorCell validCellForNode =
         ((EditorComponent) matchigCell.getEditorComponent())
             .getBigValidCellForNode(matchigCell.getSNode());
     if (validCellForNode != null) {
       EditorCell editorCell =
           CellFinderUtil.findChildByCondition(
               validCellForNode,
               new Condition<EditorCell>() {
                 @Override
                 public boolean met(EditorCell cell) {
                   return cell != matchigCell
                       && cell.getSNode() == matchigCell.getSNode()
                       && pair.o2.equals(cell.getStyle().get(StyleAttributes.MATCHING_LABEL));
                 }
               },
               true);
       if (editorCell != null) {
         if (editorCell.getY() != matchigCell.getY()) {
           ((EditorComponent) matchigCell.getEditorComponent())
               .leftHighlightCells(
                   (jetbrains.mps.nodeEditor.cells.EditorCell) matchigCell,
                   (jetbrains.mps.nodeEditor.cells.EditorCell) editorCell,
                   BRACES_LEFT_HIGHTLIGHT_COLOR);
         }
         hightlightCell(editorCell);
         hightlightCell(matchigCell);
       }
     }
   }
 }
Exemplo n.º 2
0
  public void execute(EditorContext editorContext) {
    EditorCell selectedCell = editorContext.getSelectedCell();
    if (selectedCell == null) {
      return;
    }
    final String cellId = selectedCell.getCellId();
    SNode actualSelectedNode = selectedCell.getSNode();
    boolean isLabel = selectedCell instanceof EditorCell_Label;
    int startPosition = (isLabel ? ((EditorCell_Label) selectedCell).getSelectionStart() : -1);
    int endPosition = (isLabel ? ((EditorCell_Label) selectedCell).getSelectionEnd() : -1);
    SNode nodeToSelect = CommentUtil.commentOut(myNode);
    editorContext.flushEvents();
    if (cellId != null) {
      EditorCell newNodeCell = editorContext.getEditorComponent().findNodeCell(actualSelectedNode);
      if (newNodeCell != null) {
        EditorCell cellToSelect =
            CellFinderUtil.findChildByCondition(
                newNodeCell,
                new Condition<EditorCell>() {
                  public boolean met(EditorCell cell) {
                    return eq_9lx3n0_a0a0a0a1a0a0b0j0h(cell.getCellId(), cellId);
                  }
                },
                true,
                true);
        if (cellToSelect != null) {
          if (isLabel) {
            editorContext
                .getSelectionManager()
                .setSelection(actualSelectedNode, cellId, startPosition, endPosition);
          } else {
            editorContext.getSelectionManager().setSelection(actualSelectedNode, cellId);
          }

          return;
        }
      }
    }
    SelectionUtil.selectCell(editorContext, nodeToSelect, SelectionManager.LAST_EDITABLE_CELL);
  }