com.intellij.xdebugger.frame.XValue Java Examples

The following examples show how to use com.intellij.xdebugger.frame.XValue. 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: ArrayWeaveValue.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void computeChildren(@NotNull XCompositeNode node)
{
    final XValueChildrenList list = new XValueChildrenList();
    final DebuggerValue[] innerElements = debuggerValue.values();
    int i = 0;
    for (DebuggerValue innerElement : innerElements)
    {
        final XValue value = WeaveValueFactory.create(innerElement);
        if (value != null)
        {
            list.add("[" + i + "]", value);
        }
        i++;
    }
    node.addChildren(list, false);
    super.computeChildren(node);
}
 
Example #2
Source File: ObjectWeaveValue.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void computeChildren(@NotNull XCompositeNode node)
{
    final XValueChildrenList list = new XValueChildrenList();
    final FieldDebuggerValue[] innerElements = debuggerValue.fields();
    for (FieldDebuggerValue innerElement : innerElements)
    {
        final XValue value = innerElement.key().attr().length > 0 ? WeaveValueFactory.create(innerElement) : WeaveValueFactory.create(innerElement.value());
        if (value != null)
        {
            list.add(innerElement.key().name(), value);
        }
    }
    node.addChildren(list, false);
    super.computeChildren(node);
}
 
Example #3
Source File: XInspectDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public XInspectDialog(@Nonnull Project project,
                      XDebuggerEditorsProvider editorsProvider,
                      XSourcePosition sourcePosition,
                      @Nonnull String name,
                      @Nonnull XValue value,
                      XValueMarkers<?, ?> markers) {
  super(project, false);

  setTitle(XDebuggerBundle.message("inspect.value.dialog.title", name));
  setModal(false);

  Pair<XValue, String> initialItem = Pair.create(value, name);
  XDebuggerTreeCreator creator = new XDebuggerTreeCreator(project, editorsProvider, sourcePosition, markers);
  myDebuggerTreePanel = new DebuggerTreeWithHistoryPanel<Pair<XValue, String>>(initialItem, creator, project);
  init();
}
 
Example #4
Source File: EvaluatingExpressionRootNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void computeChildren(@Nonnull final XCompositeNode node) {
  myDialog.startEvaluation(new XEvaluationCallbackBase() {
    @Override
    public void evaluated(@Nonnull final XValue result) {
      String name = UIUtil.removeMnemonic(XDebuggerBundle.message("xdebugger.evaluate.result"));
      node.addChildren(XValueChildrenList.singleton(name, result), true);
      myDialog.evaluationDone();
    }

    @Override
    public void errorOccurred(@Nonnull final String errorMessage) {
      node.setErrorMessage(errorMessage);
      myDialog.evaluationDone();
    }
  });
}
 
Example #5
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 #6
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 #7
Source File: XTestCompositeNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addChildren(@Nonnull XValueChildrenList children, boolean last) {
  final List<XValue> list = new ArrayList<XValue>();
  for (int i = 0; i < children.size(); i++) {
    list.add(children.getValue(i));
  }
  addChildren(list, last);
}
 
Example #8
Source File: WeaveValueFactory.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
public static XValue create(DebuggerValue value)
{
    if (value instanceof ArrayDebuggerValue)
    {
        return new ArrayWeaveValue((ArrayDebuggerValue) value);
    }
    else if (value instanceof ObjectDebuggerValue)
    {
        return new ObjectWeaveValue((ObjectDebuggerValue) value);
    }
    else if (value instanceof FieldDebuggerValue)
    {
        return new FieldWeaveValue((FieldDebuggerValue) value);
    }
    else if (value instanceof DebuggerFunction)
    {
        return new FunctionWeaveValue((DebuggerFunction) value);
    }
    else if (value instanceof OperatorDebuggerValue)
    {
        return new OperatorWeaveValue((OperatorDebuggerValue) value);
    }
    else if (value instanceof SimpleDebuggerValue)
    {
        return new SimpleWeaveValue((SimpleDebuggerValue) value);
    }

    throw new RuntimeException("Debugger value not supported ");
}
 
Example #9
Source File: XValueMarkers.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void unmarkValue(@Nonnull XValue value) {
  //noinspection unchecked
  final V v = (V)value;
  M m = myProvider.getMarker(v);
  if (m != null) {
    myProvider.unmarkValue(v, m);
    myMarkers.remove(m);
  }
}
 
Example #10
Source File: XValueMarkers.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public ValueMarkup getMarkup(@Nonnull XValue value) {
  Class<V> valueClass = myProvider.getValueClass();
  if (!valueClass.isInstance(value)) return null;

  V v = valueClass.cast(value);
  if (!myProvider.canMark(v)) return null;

  M m = myProvider.getMarker(v);
  if (m == null) return null;

  return myMarkers.get(m);
}
 
Example #11
Source File: DebuggerUIUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if value has evaluation expression ready, or calculation is pending
 */
public static boolean hasEvaluationExpression(@Nonnull XValue value) {
  AsyncResult<XExpression> promise = value.calculateEvaluationExpression();
  if (promise.isDone()) {
    return promise.getResult() != null;
  }
  return true;
}
 
Example #12
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 #13
Source File: XMarkObjectActionHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isMarked(@Nonnull Project project, @Nonnull AnActionEvent event) {
  XValueMarkers<?, ?> markers = getValueMarkers(project);
  if (markers == null) return false;

  XValue value = XDebuggerTreeActionBase.getSelectedValue(event.getDataContext());
  return value != null && markers.getMarkup(value) != null;
}
 
Example #14
Source File: XMarkObjectActionHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isEnabled(@Nonnull Project project, AnActionEvent event) {
  XValueMarkers<?, ?> markers = getValueMarkers(project);
  if (markers == null) return false;

  XValue value = XDebuggerTreeActionBase.getSelectedValue(event.getDataContext());
  return value != null && markers.canMarkValue(value);
}
 
Example #15
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 #16
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 #17
Source File: DartVmServiceListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private String evaluateExpression(final @NotNull String isolateId,
                                  final @Nullable Frame vmTopFrame,
                                  final @Nullable XExpression xExpression) {
  final String evalText = xExpression == null ? null : xExpression.getExpression();
  if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null;

  final Ref<String> evalResult = new Ref<>();
  final Semaphore semaphore = new Semaphore();
  semaphore.down();

  myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() {
    @Override
    public void evaluated(@NotNull final XValue result) {
      if (result instanceof DartVmServiceValue) {
        evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef()));
      }
      semaphore.up();
    }

    @Override
    public void errorOccurred(@NotNull final String errorMessage) {
      evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage);
      semaphore.up();
    }
  });

  semaphore.waitFor(1000);
  return evalResult.get();
}
 
Example #18
Source File: DartVmServiceListener.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
private String evaluateExpression(final @NotNull String isolateId,
                                  final @Nullable Frame vmTopFrame,
                                  final @Nullable XExpression xExpression) {
  final String evalText = xExpression == null ? null : xExpression.getExpression();
  if (vmTopFrame == null || StringUtil.isEmptyOrSpaces(evalText)) return null;

  final Ref<String> evalResult = new Ref<>();
  final Semaphore semaphore = new Semaphore();
  semaphore.down();

  myDebugProcess.getVmServiceWrapper().evaluateInFrame(isolateId, vmTopFrame, evalText, new XDebuggerEvaluator.XEvaluationCallback() {
    @Override
    public void evaluated(@NotNull final XValue result) {
      if (result instanceof DartVmServiceValue) {
        evalResult.set(getSimpleStringPresentation(((DartVmServiceValue)result).getInstanceRef()));
      }
      semaphore.up();
    }

    @Override
    public void errorOccurred(@NotNull final String errorMessage) {
      evalResult.set("Failed to evaluate log expression [" + evalText + "]: " + errorMessage);
      semaphore.up();
    }
  });

  semaphore.waitFor(1000);
  return evalResult.get();
}
 
Example #19
Source File: XJumpToTypeSourceAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
  value.computeTypeSourcePosition(navigatable);
}
 
Example #20
Source File: XDebuggerTreeCreator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getTitle(@Nonnull Pair<XValue, String> descriptor) {
  return descriptor.getSecond();
}
 
Example #21
Source File: XTestEvaluationCallback.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Pair<XValue, String> waitFor(long timeoutInMilliseconds) throws InterruptedException {
  Assert.assertTrue("timed out", XDebuggerTestUtil.waitFor(myFinished, timeoutInMilliseconds));
  return Pair.create(myResult, myErrorMessage);
}
 
Example #22
Source File: XTestEvaluationCallback.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void evaluated(@Nonnull XValue result) {
  myResult = result;
  myFinished.release();
}
 
Example #23
Source File: JumpToSourceAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
  // This case only typically works for Function objects where the source
  // position is available.
  value.computeSourcePosition(navigatable);
}
 
Example #24
Source File: XValueMarkers.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void markValue(@Nonnull XValue value, @Nonnull ValueMarkup markup) {
  //noinspection unchecked
  M m = myProvider.markValue((V)value);
  myMarkers.put(m, markup);
}
 
Example #25
Source File: XValueMarkers.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean canMarkValue(@Nonnull XValue value) {
  Class<V> valueClass = myProvider.getValueClass();
  if (!valueClass.isInstance(value)) return false;

  return myProvider.canMark(valueClass.cast(value));
}
 
Example #26
Source File: JumpToTypeSourceAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
  value.computeTypeSourcePosition(navigatable);
}
 
Example #27
Source File: XValueMarkers.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static <V extends XValue, M> XValueMarkers<V, M> createValueMarkers(@Nonnull XValueMarkerProvider<V, M> provider) {
  return new XValueMarkers<V, M>(provider);
}
 
Example #28
Source File: XValueHint.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void showTree(@Nonnull XValue value) {
  XValueMarkers<?,?> valueMarkers = ((XDebugSessionImpl)myDebugSession).getValueMarkers();
  XDebuggerTreeCreator creator = new XDebuggerTreeCreator(myDebugSession.getProject(), myDebugSession.getDebugProcess().getEditorsProvider(),
                                                          myDebugSession.getCurrentPosition(), valueMarkers);
  showTreePopup(creator, Pair.create(value, myValueName));
}
 
Example #29
Source File: JumpToSourceAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
  // This case only typically works for Function objects where the source
  // position is available.
  value.computeSourcePosition(navigatable);
}
 
Example #30
Source File: XJumpToSourceAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
  value.computeSourcePosition(navigatable);
}