public void actionPerformed(AnActionEvent e) {
    final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) {
      return;
    }
    DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();

    final DebuggerSession session = context.getDebuggerSession();
    if (session != null && session.isAttached()) {
      final DebugProcessImpl process = context.getDebugProcess();
      process
          .getManagerThread()
          .invoke(
              new DebuggerCommandImpl() {
                protected void action() throws Exception {
                  final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
                  vm.suspend();
                  try {
                    final List<ThreadState> threads = buildThreadStates(vm);
                    ApplicationManager.getApplication()
                        .invokeLater(
                            new Runnable() {
                              public void run() {
                                XDebugSession xSession = session.getProcess().getXDebugSession();
                                if (xSession != null) {
                                  DebuggerSessionTab.addThreadDump(
                                      project, threads, xSession.getUI(), session);
                                }
                              }
                            },
                            ModalityState.NON_MODAL);
                  } finally {
                    vm.resume();
                  }
                }
              });
    }
  }
Beispiel #2
0
  public void actionPerformed(AnActionEvent e) {
    final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) {
      return;
    }
    DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();

    if (context.getDebuggerSession() != null) {
      final DebugProcessImpl process = context.getDebugProcess();
      process
          .getManagerThread()
          .invoke(
              new DebuggerCommandImpl() {
                protected void action() throws Exception {
                  final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
                  vm.suspend();
                  try {
                    final List<ThreadState> threads = buildThreadStates(vm);
                    ApplicationManager.getApplication()
                        .invokeLater(
                            new Runnable() {
                              public void run() {
                                final DebuggerSessionTab sessionTab =
                                    DebuggerPanelsManager.getInstance(project).getSessionTab();
                                if (sessionTab != null) {
                                  sessionTab.addThreadDump(threads);
                                }
                              }
                            },
                            ModalityState.NON_MODAL);
                  } finally {
                    vm.resume();
                  }
                }
              });
    }
  }
  protected void evaluateAndShowHint() {
    final DebuggerContextImpl debuggerContext =
        DebuggerManagerEx.getInstanceEx(getProject()).getContext();

    final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
    if (debuggerSession == null || !debuggerSession.isPaused()) return;

    try {

      final ExpressionEvaluator evaluator = getExpressionEvaluator(debuggerContext);
      if (evaluator == null) return;

      debuggerContext
          .getDebugProcess()
          .getManagerThread()
          .schedule(
              new DebuggerContextCommandImpl(debuggerContext) {
                public Priority getPriority() {
                  return Priority.HIGH;
                }

                public void threadAction() {
                  try {
                    final EvaluationContextImpl evaluationContext =
                        debuggerContext.createEvaluationContext();

                    final String expressionText =
                        ApplicationManager.getApplication()
                            .runReadAction(
                                new Computable<String>() {
                                  public String compute() {
                                    return myCurrentExpression.getText();
                                  }
                                });
                    final TextWithImports text =
                        new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
                    final Value value =
                        myValueToShow != null
                            ? myValueToShow
                            : evaluator.evaluate(evaluationContext);

                    final WatchItemDescriptor descriptor =
                        new WatchItemDescriptor(getProject(), text, value);
                    if (!isActiveTooltipApplicable(value)
                        || getType() == ValueHintType.MOUSE_OVER_HINT) {
                      if (getType() == ValueHintType.MOUSE_OVER_HINT) {
                        // force using default renderer for mouse over hint in order to not to call
                        // accidentally methods while rendering
                        // otherwise, if the hint is invoked explicitly, show it with the right
                        // "auto" renderer
                        descriptor.setRenderer(DebugProcessImpl.getDefaultRenderer(value));
                      }
                      descriptor.updateRepresentation(
                          evaluationContext,
                          new DescriptorLabelListener() {
                            public void labelChanged() {
                              if (getCurrentRange() != null) {
                                if (getType() != ValueHintType.MOUSE_OVER_HINT
                                    || descriptor.isValueValid()) {
                                  final SimpleColoredText simpleColoredText =
                                      DebuggerTreeRenderer.getDescriptorText(
                                          debuggerContext, descriptor, true);
                                  if (isActiveTooltipApplicable(value)) {
                                    simpleColoredText.append(
                                        " ("
                                            + DebuggerBundle.message("active.tooltip.suggestion")
                                            + ")",
                                        SimpleTextAttributes.GRAYED_ATTRIBUTES);
                                  }
                                  showHint(simpleColoredText, descriptor);
                                }
                              }
                            }
                          });
                    } else {
                      final InspectDebuggerTree tree = getInspectTree(descriptor);
                      showTreePopup(
                          tree,
                          debuggerContext,
                          expressionText,
                          new ValueHintTreeComponent(ValueHint.this, tree, expressionText));
                    }
                  } catch (EvaluateException e) {
                    LOG.debug(e);
                  }
                }
              });
    } catch (EvaluateException e) {
      LOG.debug(e);
    }
  }