com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl Java Examples

The following examples show how to use com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XCopyWatchAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void perform(@Nonnull AnActionEvent e, @Nonnull XDebuggerTree tree, @Nonnull final XWatchesView watchesView) {
  final XDebuggerTreeNode root = tree.getRoot();
  for (final XValueNodeImpl node : getSelectedNodes(tree, XValueNodeImpl.class)) {
    node.getValueContainer().calculateEvaluationExpression().doWhenDone(new Consumer<XExpression>() {
      @Override
      public void accept(XExpression expr) {
        final XExpression watchExpression = expr != null ? expr : XExpressionImpl.fromText(node.getName());
        if (watchExpression != null) {
          DebuggerUIUtil.invokeLater(new Runnable() {
            @Override
            public void run() {
              watchesView.addWatchExpression(watchExpression, node instanceof WatchNode ? root.getIndex(node) + 1 : -1, true);
            }
          });
        }
      }
    });
  }
}
 
Example #2
Source File: XMarkObjectActionHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void perform(@Nonnull Project project, AnActionEvent event) {
  XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
  if (session == null) return;

  XValueMarkers<?, ?> markers = ((XDebugSessionImpl)session).getValueMarkers();
  XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(event.getDataContext());
  if (markers == null || node == null) return;
  XValue value = node.getValueContainer();

  ValueMarkup existing = markers.getMarkup(value);
  if (existing != null) {
    markers.unmarkValue(value);
  }
  else {
    ValueMarkerPresentationDialog dialog = new ValueMarkerPresentationDialog(node.getName());
    dialog.show();
    ValueMarkup markup = dialog.getConfiguredMarkup();
    if (dialog.isOK() && markup != null) {
      markers.markValue(value, markup);
    }
  }
  session.rebuildViews();
}
 
Example #3
Source File: SetValueInplaceEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private SetValueInplaceEditor(final XValueNodeImpl node, @Nonnull final String nodeName) {
  super(node, "setValue");
  myValueNode = node;
  myModifier = myValueNode.getValueContainer().getModifier();

  SimpleColoredComponent nameLabel = new SimpleColoredComponent();
  nameLabel.getIpad().right = 0;
  nameLabel.getIpad().left = 0;
  nameLabel.setIcon(myNode.getIcon());
  nameLabel.append(nodeName, XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
  XValuePresentation presentation = node.getValuePresentation();
  if (presentation != null) {
    XValuePresentationUtil.appendSeparator(nameLabel, presentation.getSeparator());
  }
  myNameOffset = nameLabel.getPreferredSize().width;
  myEditorPanel = JBUI.Panels.simplePanel(myExpressionEditor.getComponent());
}
 
Example #4
Source File: XJumpToSourceActionBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void perform(final XValueNodeImpl node, @Nonnull final String nodeName, final AnActionEvent e) {
  XValue value = node.getValueContainer();
  XNavigatable navigatable = new XNavigatable() {
    public void setSourcePosition(@Nullable final XSourcePosition sourcePosition) {
      if (sourcePosition != null) {
        AppUIUtil.invokeOnEdt(new Runnable() {
          public void run() {
            Project project = node.getTree().getProject();
            if (project.isDisposed()) return;

            sourcePosition.createNavigatable(project).navigate(true);
          }
        });
      }
    }
  };
  startComputingSourcePosition(value, navigatable);
}
 
Example #5
Source File: XDebuggerTreeActionBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static List<XValueNodeImpl> getSelectedNodes(DataContext dataContext) {
  XDebuggerTree tree = XDebuggerTree.getTree(dataContext);
  if (tree == null) return Collections.emptyList();

  TreePath[] paths = tree.getSelectionPaths();
  if (paths == null || paths.length == 0) {
    return Collections.emptyList();
  }
  List<XValueNodeImpl> result = new ArrayList<>();
  for (TreePath path : paths) {
    Object lastPathComponent = path.getLastPathComponent();
    if(lastPathComponent instanceof XValueNodeImpl) {
      result.add((XValueNodeImpl)lastPathComponent);
    }
  }
  return result;
}
 
Example #6
Source File: XFetchValueActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected boolean isEnabled(@Nonnull AnActionEvent event, @Nonnull XValueNodeImpl node) {
  if (node instanceof WatchNodeImpl || node.isComputed()) {
    event.getPresentation().setEnabled(true);
    return true;
  }
  return false;
}
 
Example #7
Source File: EvaluateInConsoleFromTreeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void perform(XValueNodeImpl node, @Nonnull String nodeName, AnActionEvent e) {
  ConsoleExecuteAction action = getConsoleExecuteAction(e);
  if (action != null) {
    String expression = node.getValueContainer().getEvaluationExpression();
    if (expression != null) {
      action.execute(null, expression, null);
    }
  }
}
 
Example #8
Source File: XFetchValueActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  List<XValueNodeImpl> nodes = XDebuggerTreeActionBase.getSelectedNodes(e.getDataContext());
  if (nodes.isEmpty()) {
    return;
  }

  ValueCollector valueCollector = createCollector(e);
  for (XValueNodeImpl node : nodes) {
    addToCollector(nodes, node, valueCollector);
  }
  valueCollector.processed = true;
  valueCollector.finish();
}
 
Example #9
Source File: XFetchValueActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void addToCollector(@Nonnull List<XValueNodeImpl> paths, @Nonnull XValueNodeImpl valueNode, @Nonnull ValueCollector valueCollector) {
  if (paths.size() > 1) { // multiselection - copy the whole node text, see IDEA-136722
    valueCollector.add(valueNode.getText().toString(), valueNode.getPath().getPathCount());
  }
  else {
    XFullValueEvaluator fullValueEvaluator = valueNode.getFullValueEvaluator();
    if (fullValueEvaluator == null || !fullValueEvaluator.isShowValuePopup()) {
      valueCollector.add(StringUtil.notNullize(DebuggerUIUtil.getNodeRawValue(valueNode)));
    }
    else {
      new CopyValueEvaluationCallback(valueNode, valueCollector).startFetchingValue(fullValueEvaluator);
    }
  }
}
 
Example #10
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
@Override
public Object getData(@NotNull String dataId) {
  if (InspectorTree.INSPECTOR_KEY.is(dataId)) {
    return this;
  }
  if (PlatformDataKeys.PREDEFINED_TEXT.is(dataId)) {
    final XValueNodeImpl[] selectedNodes = getSelectedNodes(XValueNodeImpl.class, null);
    if (selectedNodes.length == 1 && selectedNodes[0].getFullValueEvaluator() == null) {
      return DebuggerUIUtil.getNodeRawValue(selectedNodes[0]);
    }
  }
  return null;
}
 
Example #11
Source File: XInspectAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void perform(XValueNodeImpl node, @Nonnull final String nodeName, AnActionEvent e) {
  XDebuggerTree tree = node.getTree();
  XValue value = node.getValueContainer();
  XInspectDialog dialog = new XInspectDialog(tree.getProject(), tree.getEditorsProvider(), tree.getSourcePosition(), nodeName, value,
                                             tree.getValueMarkers());
  dialog.show();
}
 
Example #12
Source File: XDebuggerTreeActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(final AnActionEvent e) {
  XValueNodeImpl node = getSelectedNode(e.getDataContext());
  if (node != null) {
    String nodeName = node.getName();
    if (nodeName != null) {
      perform(node, nodeName, e);
    }
  }
}
 
Example #13
Source File: XDebuggerTreeActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static XValueNodeImpl getSelectedNode(final DataContext dataContext) {
  XDebuggerTree tree = XDebuggerTree.getTree(dataContext);
  if (tree == null) return null;

  TreePath path = tree.getSelectionPath();
  if (path == null) return null;

  Object node = path.getLastPathComponent();
  return node instanceof XValueNodeImpl ? (XValueNodeImpl)node : null;
}
 
Example #14
Source File: XDebuggerTreeRestorer.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean checkExtendedModified(RestorableStateNode treeNode) {
  if (treeNode instanceof XValueNodeImpl) {
    XValuePresentation presentation = ((XValueNodeImpl)treeNode).getValuePresentation();
    if (presentation instanceof XValueExtendedPresentation) {
      if (((XValueExtendedPresentation)presentation).isModified()) {
        treeNode.markChanged();
      }
      return true;
    }
  }
  return false;
}
 
Example #15
Source File: SetValueInplaceEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void show(final XValueNodeImpl node, @Nonnull final String nodeName) {
  final SetValueInplaceEditor editor = new SetValueInplaceEditor(node, nodeName);

  if (editor.myModifier != null) {
    editor.myModifier.calculateInitialValueEditorText(initialValue -> AppUIUtil.invokeOnEdt(() -> {
      if (editor.getTree().isShowing()) {
        editor.show(initialValue);
      }
    }));
  }
  else {
    editor.show(null);
  }
}
 
Example #16
Source File: DebuggerUIUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static String getNodeRawValue(@Nonnull XValueNodeImpl valueNode) {
  if (valueNode.getValueContainer() instanceof XValueTextProvider) {
    return ((XValueTextProvider)valueNode.getValueContainer()).getValueText();
  }
  else {
    return valueNode.getRawValue();
  }
}
 
Example #17
Source File: XVariablesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public synchronized List<XValueNodeImpl> get(@Nonnull VirtualFile file, int line, long currentTimestamp) {
  long timestamp = myTimestamps.get(file);
  if (timestamp == -1 || timestamp < currentTimestamp) {
    return null;
  }
  Set<Entry> entries = myData.get(Pair.create(file, line));
  if (entries == null) return null;
  return ContainerUtil.map(entries, entry -> entry.myNode);
}
 
Example #18
Source File: XVariablesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(Entry o) {
  if (myNode == o.myNode) return 0;
  int res = Comparing.compare(myOffset, o.myOffset);
  if (res == 0) {
    return XValueNodeImpl.COMPARATOR.compare(myNode, o.myNode);
  }
  return res;
}
 
Example #19
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
@Override
public Object getData(@NotNull String dataId) {
  if (InspectorTree.INSPECTOR_KEY.is(dataId)) {
    return this;
  }
  if (PlatformDataKeys.PREDEFINED_TEXT.is(dataId)) {
    final XValueNodeImpl[] selectedNodes = getSelectedNodes(XValueNodeImpl.class, null);
    if (selectedNodes.length == 1 && selectedNodes[0].getFullValueEvaluator() == null) {
      return DebuggerUIUtil.getNodeRawValue(selectedNodes[0]);
    }
  }
  return null;
}
 
Example #20
Source File: HaxeDebugRunner.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private void internalComputeChildren(@NotNull Obsolescent node) {
  // mWaitingforChildrenResults tells us wether a request for
  // the children is already in flight.  In the case that one
  // is, we do NOT want to call node.addChildren(list,true),
  // because that tells the UI that we have computed all of the
  // children for this node.
  //
  // mChildrenComputationRequested notifies the fetchValue
  // callback that the UI has attempted to draw any elements
  // and won't request them again, so the callback should
  // notify the UI that new children are available (by calling
  // this function again).

  if (mChildren == null || mWaitingForChildrenResults) {
    mChildrenComputationRequested = true;
    return;
  }
  mChildrenComputationRequested = false;

  XValueChildrenList childrenList =
    new XValueChildrenList(mChildren.size());
  for (Value child : mChildren) {
    childrenList.add(child.mName, child);
  }

  // Stupid hack to get around the fact that we're abusing the APIs.
  if (node instanceof XValueNodeImpl) {
    ((XValueNodeImpl)node).addChildren(childrenList, true);
  } else if(node instanceof XCompositeNode) {
    ((XCompositeNode)node).addChildren(childrenList, true);
  } else {
    error("Unexpected node type in debugger screen: " +
          node.getClass().toString());
  }
}
 
Example #21
Source File: XSetValueAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(final AnActionEvent e) {
  super.update(e);
  XValueNodeImpl node = getSelectedNode(e.getDataContext());
  Presentation presentation = e.getPresentation();
  if (node instanceof WatchNode) {
    presentation.setVisible(false);
    presentation.setEnabled(false);
  }
  else {
    presentation.setVisible(true);
  }
}
 
Example #22
Source File: XDebuggerTreeCreator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Tree createTree(@Nonnull Pair<XValue, String> descriptor) {
  XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  tree.setRoot(new XValueNodeImpl(tree, null, descriptor.getSecond(), descriptor.getFirst()), true);
  return tree;
}
 
Example #23
Source File: XAddToWatchesTreeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void perform(final XValueNodeImpl node, @Nonnull final String nodeName, final AnActionEvent e) {
  final XWatchesView watchesView = getWatchesView(e);
  if (watchesView != null) {
    node.getValueContainer().calculateEvaluationExpression().doWhenDone(expression -> {
      if (expression != null) {
        watchesView.addWatchExpression(expression, -1, true);
      }
    });
  }
}
 
Example #24
Source File: XDebuggerTreeCreator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void createDescriptorByNode(Object node, ResultConsumer<Pair<XValue, String>> resultConsumer) {
  if (node instanceof XValueNodeImpl) {
    XValueNodeImpl valueNode = (XValueNodeImpl)node;
    resultConsumer.onSuccess(Pair.create(valueNode.getValueContainer(), valueNode.getName()));
  }
}
 
Example #25
Source File: XDebuggerTreePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Pair<Image, Point> createDraggedImage(final DnDAction action, final Point dragOrigin) {
  XValueNodeImpl[] nodes = getNodesToDrag();
  if (nodes.length == 1) {
    return DnDAwareTree.getDragImage(myTree, nodes[0].getPath(), dragOrigin);
  }
  return DnDAwareTree.getDragImage(myTree, XDebuggerBundle.message("xdebugger.drag.text.0.elements", nodes.length), dragOrigin);
}
 
Example #26
Source File: ShowReferringObjectsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void perform(XValueNodeImpl node, @Nonnull String nodeName, AnActionEvent e) {
  XReferrersProvider referrersProvider = node.getValueContainer().getReferrersProvider();
  if (referrersProvider != null) {
    XDebuggerTree tree = XDebuggerTree.getTree(e.getDataContext());
    XInspectDialog dialog = new XInspectDialog(tree.getProject(),
                                               tree.getEditorsProvider(),
                                               tree.getSourcePosition(),
                                               nodeName,
                                               referrersProvider.getReferringObjectsValue(),
                                               tree.getValueMarkers());
    dialog.setTitle(XDebuggerBundle.message("showReferring.dialog.title", nodeName));
    dialog.show();
  }
}
 
Example #27
Source File: XFetchValueActionBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  for (XValueNodeImpl node : XDebuggerTreeActionBase.getSelectedNodes(e.getDataContext())) {
    if (isEnabled(e, node)) {
      return;
    }
  }
  e.getPresentation().setEnabled(false);
}
 
Example #28
Source File: XDebuggerTreeActionBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static XValue getSelectedValue(@Nonnull DataContext dataContext) {
  XValueNodeImpl node = getSelectedNode(dataContext);
  return node != null ? node.getValueContainer() : null;
}
 
Example #29
Source File: XVariablesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Entry(long offset, @Nonnull XValueNodeImpl node) {
  myOffset = offset;
  myNode = node;
}
 
Example #30
Source File: XVariablesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public synchronized void put(@Nonnull VirtualFile file, @Nonnull XSourcePosition position, @Nonnull XValueNodeImpl node, long timestamp) {
  myTimestamps.put(file, timestamp);
  Pair<VirtualFile, Integer> key = Pair.create(file, position.getLine());
  myData.computeIfAbsent(key, k -> new TreeSet<>()).add(new Entry(position.getOffset(), node));
}