private void addLocationBreakpoint(ILocationBreakpoint breakpoint) {
   SNode node = breakpoint.getLocation().getSNode();
   if (node != null) {
     SNode root = node.getContainingRoot();
     if (root != null) {
       SNodePointer rootPointer = new SNodePointer(root);
       Set<ILocationBreakpoint> breakpointsForRoot = myRootsToBreakpointsMap.get(rootPointer);
       if (breakpointsForRoot == null) {
         breakpointsForRoot = new HashSet<ILocationBreakpoint>();
         myRootsToBreakpointsMap.put(rootPointer, breakpointsForRoot);
       }
       //  check the following assumption: one breakpoint for one node
       for (ILocationBreakpoint breakpointForRoot : breakpointsForRoot) {
         if (breakpointForRoot
             .getLocation()
             .getNodePointer()
             .equals(breakpoint.getLocation().getNodePointer())) {
           LOG.error(
               "Trying to add a second breakpoint for node",
               breakpointForRoot.getLocation().getSNode());
           break;
         }
       }
       breakpointsForRoot.add(breakpoint);
     }
   }
 }
  public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
    try {
      NodeHighlightManager highlightManager =
          ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
              .getHighlightManager();
      EditorMessageOwner messageOwner =
          ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
              .getHighlightMessagesOwner();

      Set<SNode> usages =
          FindUsagesManager.getInstance()
              .findUsages(
                  Collections.singleton(
                      SNodeOperations.getConceptDeclaration(
                          ((SNode) MapSequence.fromMap(_params).get("node")))),
                  SearchType.INSTANCES,
                  new ModelsOnlyScope(
                      ((SModelDescriptor) MapSequence.fromMap(_params).get("model"))),
                  null);
      for (SNode ref : SetSequence.fromSet(usages)) {
        if (ref.getContainingRoot()
            == ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
                .getRootCell()
                .getSNode()
                .getContainingRoot()) {
          highlightManager.mark(ref, HighlightConstants.INSTANCES_COLOR, "usage", messageOwner);
        }
      }
      highlightManager.repaintAndRebuildEditorMessages();
    } catch (Throwable t) {
      if (log.isErrorEnabled()) {
        log.error("User's action execute method failed. Action:" + "HighlightInstances", t);
      }
    }
  }
 private void removeLocationBreakpoint(ILocationBreakpoint breakpoint) {
   SNode node = breakpoint.getLocation().getSNode();
   if (node != null) {
     SNode root = node.getContainingRoot();
     if (root != null) {
       SNodePointer rootPointer = new SNodePointer(root);
       Set<ILocationBreakpoint> breakpointsForRoot = myRootsToBreakpointsMap.get(rootPointer);
       if (breakpointsForRoot != null) {
         breakpointsForRoot.remove(breakpoint);
       }
     }
   }
 }
示例#4
0
 public List<Pair<SNode, Integer>> getBookmarks(SNode root) {
   if (root == null) return Collections.emptyList();
   List<Pair<SNode, Integer>> result = new ArrayList<Pair<SNode, Integer>>();
   for (int i = 0; i <= 9; i++) {
     SNodePointer nodePointer = myBookmarks[i];
     if (nodePointer != null) {
       SNode node = nodePointer.getNode();
       if (node != null && node.getContainingRoot() == root) {
         result.add(new Pair<SNode, Integer>(node, i));
       }
     }
   }
   for (SNodePointer nodePointer : myUnnumberedBookmarks) {
     if (nodePointer != null) {
       SNode node = nodePointer.getNode();
       if (node != null && node.getContainingRoot() == root) {
         result.add(new Pair<SNode, Integer>(node, -1));
       }
     }
   }
   return result;
 }