@Override
  public void computeChildren(@NotNull final XCompositeNode node) {
    if (node.isObsolete()) return;
    XStackFrame xFrame = getDescriptor().getXStackFrame();
    if (xFrame != null) {
      xFrame.computeChildren(node);
      return;
    }
    myDebugProcess
        .getManagerThread()
        .schedule(
            new DebuggerContextCommandImpl(
                myDebugProcess.getDebuggerContext(), myDescriptor.getFrameProxy().threadProxy()) {
              @Override
              public Priority getPriority() {
                return Priority.NORMAL;
              }

              @Override
              public void threadAction() {
                if (node.isObsolete()) return;
                XValueChildrenList children = new XValueChildrenList();
                buildVariablesThreadAction(getFrameDebuggerContext(), children, node);
                node.addChildren(children, true);
              }
            });
  }
Exemplo n.º 2
0
 @Override
 public void computeChildren(@NotNull final XCompositeNode node) {
   final XValueChildrenList childrenList = new XValueChildrenList(myFields.size());
   for (DartVMValue field : myFields) {
     childrenList.add(field.getName(), field);
   }
   node.addChildren(childrenList, true);
 }
  // copied from DebuggerTree
  private void buildVariablesThreadAction(
      DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
    try {
      final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
      if (evaluationContext == null) {
        return;
      }
      if (!debuggerContext.isEvaluationPossible()) {
        node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
        // myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE,
        // evaluationContext));
      }

      final Location location = myDescriptor.getLocation();

      final ObjectReference thisObjectReference = myDescriptor.getThisObject();
      if (thisObjectReference != null) {
        ValueDescriptorImpl thisDescriptor =
            myNodeManager.getThisDescriptor(null, thisObjectReference);
        children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
      } else if (location != null) {
        StaticDescriptorImpl staticDecriptor =
            myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
        if (staticDecriptor.isExpandable()) {
          children.addTopGroup(
              new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
        }
      }

      DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
      if (debugProcess == null) {
        return;
      }

      // add last method return value if any
      final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
      if (methodValuePair != null) {
        ValueDescriptorImpl returnValueDescriptor =
            myNodeManager.getMethodReturnValueDescriptor(
                myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
        children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
      }
      // add context exceptions
      for (Pair<Breakpoint, Event> pair :
          DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
        final Event debugEvent = pair.getSecond();
        if (debugEvent instanceof ExceptionEvent) {
          final ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
          if (exception != null) {
            final ValueDescriptorImpl exceptionDescriptor =
                myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, exception);
            children.add(JavaValue.create(exceptionDescriptor, evaluationContext, myNodeManager));
          }
        }
      }

      try {
        buildVariables(
            debuggerContext,
            evaluationContext,
            debugProcess,
            children,
            thisObjectReference,
            location);
        // if (classRenderer.SORT_ASCENDING) {
        //  Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
        // }
      } catch (EvaluateException e) {
        node.setErrorMessage(e.getMessage());
        // myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
      }
    } catch (InvalidStackFrameException e) {
      LOG.info(e);
      // myChildren.clear();
      // notifyCancelled();
    } catch (InternalException e) {
      if (e.errorCode() == 35) {
        node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
        // myChildren.add(
        //  myNodeManager.createMessageNode(new
        // MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
      } else {
        throw e;
      }
    }
  }