public WatchLastMethodReturnValueAction() {
   super("", DebuggerBundle.message("action.watch.method.return.value.description"), null);
   myWatchesReturnValues = DebuggerSettings.getInstance().WATCH_RETURN_VALUES;
   myText = DebuggerBundle.message("action.watches.method.return.value.enable");
   myTextUnavailable =
       DebuggerBundle.message("action.watches.method.return.value.unavailable.reason");
 }
  public String getEventMessage(LocatableEvent event) {
    final Location location = event.location();
    final String locationQName = location.declaringType().name() + "." + location.method().name();
    String locationFileName = "";
    try {
      locationFileName = location.sourceName();
    } catch (AbsentInformationException e) {
      locationFileName = "";
    }
    final int locationLine = location.lineNumber();

    if (event instanceof MethodEntryEvent) {
      MethodEntryEvent entryEvent = (MethodEntryEvent) event;
      final Method method = entryEvent.method();
      return DebuggerBundle.message(
          "status.method.entry.breakpoint.reached",
          method.declaringType().name() + "." + method.name() + "()",
          locationQName,
          locationFileName,
          locationLine);
    }

    if (event instanceof MethodExitEvent) {
      MethodExitEvent exitEvent = (MethodExitEvent) event;
      final Method method = exitEvent.method();
      return DebuggerBundle.message(
          "status.method.exit.breakpoint.reached",
          method.declaringType().name() + "." + method.name() + "()",
          locationQName,
          locationFileName,
          locationLine);
    }
    return "";
  }
 public AutoVarsSwitchAction() {
   super(
       DebuggerBundle.message("action.auto.variables.mode"),
       DebuggerBundle.message("action.auto.variables.mode.description"),
       null);
   myAutoModeEnabled = DebuggerSettings.getInstance().AUTO_VARIABLES_MODE;
 }
  @Override
  public String getEventMessage(LocatableEvent event) {
    final Location location = event.location();
    String sourceName;
    try {
      sourceName = location.sourceName();
    } catch (AbsentInformationException e) {
      sourceName = getFileName();
    }

    final boolean printFullTrace = Registry.is("debugger.breakpoint.message.full.trace");

    StringBuilder builder = new StringBuilder();
    if (printFullTrace) {
      builder.append(
          DebuggerBundle.message(
              "status.line.breakpoint.reached.full.trace",
              DebuggerUtilsEx.getLocationMethodQName(location)));
      try {
        final List<StackFrame> frames = event.thread().frames();
        renderTrace(frames, builder);
      } catch (IncompatibleThreadStateException e) {
        builder.append("Stacktrace not available: ").append(e.getMessage());
      }
    } else {
      builder.append(
          DebuggerBundle.message(
              "status.line.breakpoint.reached",
              DebuggerUtilsEx.getLocationMethodQName(location),
              sourceName,
              getLineIndex() + 1));
    }
    return builder.toString();
  }
 /* Remoting */
 private static void checkTargetJPDAInstalled(JavaParameters parameters)
     throws ExecutionException {
   final Sdk jdk = parameters.getJdk();
   if (jdk == null) {
     throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
   }
   final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
   String versionString = jdk.getVersionString();
   if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) {
     throw new ExecutionException(
         DebuggerBundle.message("error.unsupported.jdk.version", versionString));
   }
   if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) {
     final VirtualFile homeDirectory = jdk.getHomeDirectory();
     if (homeDirectory == null || !homeDirectory.isValid()) {
       throw new ExecutionException(
           DebuggerBundle.message("error.invalid.jdk.home", versionString));
     }
     //noinspection HardCodedStringLiteral
     File dllFile =
         new File(
             homeDirectory.getPath().replace('/', File.separatorChar)
                 + File.separator
                 + "bin"
                 + File.separator
                 + "jdwp.dll");
     if (!dllFile.exists()) {
       GetJPDADialog dialog = new GetJPDADialog();
       dialog.show();
       throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing"));
     }
   }
 }
  protected JComponent createCenterPanel() {
    JPanel contentPanel = new JPanel(new BorderLayout());

    Box mainPanel = Box.createHorizontalBox();

    myClassFilterEditor =
        new ClassFilterEditor(
            myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
    myClassFilterEditor.setPreferredSize(new Dimension(400, 200));
    myClassFilterEditor.setBorder(
        IdeBorderFactory.createTitledBorder(
            DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"),
            false,
            false,
            true));
    mainPanel.add(myClassFilterEditor);

    myClassExclusionFilterEditor =
        new ClassFilterEditor(
            myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
    myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200));
    myClassExclusionFilterEditor.setBorder(
        IdeBorderFactory.createTitledBorder(
            DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"),
            false,
            false,
            true));
    mainPanel.add(myClassExclusionFilterEditor);

    contentPanel.add(mainPanel, BorderLayout.CENTER);

    return contentPanel;
  }
Exemplo n.º 7
0
 public String getColumnName(int columnIndex) {
   switch (columnIndex) {
     case NAME_TABLE_COLUMN:
       return DebuggerBundle.message("label.compound.renderer.configurable.table.header.name");
     case EXPRESSION_TABLE_COLUMN:
       return DebuggerBundle.message(
           "label.compound.renderer.configurable.table.header.expression");
     default:
       return "";
   }
 }
  private String getDisplayInfoInternal(boolean showPackageInfo, int totalTextLength) {
    if (isValid()) {
      final int lineNumber = myXBreakpoint.getSourcePosition().getLine() + 1;
      String className = getClassName();
      final boolean hasClassInfo = className != null && className.length() > 0;
      final String methodName = getMethodName();
      final String displayName = methodName != null ? methodName + "()" : null;
      final boolean hasMethodInfo = displayName != null && displayName.length() > 0;
      if (hasClassInfo || hasMethodInfo) {
        final StringBuilder info = StringBuilderSpinAllocator.alloc();
        try {
          boolean isFile = myXBreakpoint.getSourcePosition().getFile().getName().equals(className);
          String packageName = null;
          if (hasClassInfo) {
            final int dotIndex = className.lastIndexOf(".");
            if (dotIndex >= 0 && !isFile) {
              packageName = className.substring(0, dotIndex);
              className = className.substring(dotIndex + 1);
            }

            if (totalTextLength != -1) {
              if (className.length() + (hasMethodInfo ? displayName.length() : 0)
                  > totalTextLength + 3) {
                int offset = totalTextLength - (hasMethodInfo ? displayName.length() : 0);
                if (offset > 0 && offset < className.length()) {
                  className = className.substring(className.length() - offset);
                  info.append("...");
                }
              }
            }

            info.append(className);
          }
          if (hasMethodInfo) {
            if (isFile) {
              info.append(":");
            } else if (hasClassInfo) {
              info.append(".");
            }
            info.append(displayName);
          }
          if (showPackageInfo && packageName != null) {
            info.append(" (").append(packageName).append(")");
          }
          return DebuggerBundle.message(
              "line.breakpoint.display.name.with.class.or.method", lineNumber, info.toString());
        } finally {
          StringBuilderSpinAllocator.dispose(info);
        }
      }
      return DebuggerBundle.message("line.breakpoint.display.name", lineNumber);
    }
    return DebuggerBundle.message("status.breakpoint.invalid");
  }
 public EditClassFiltersDialog(Project project, ClassFilter filter) {
   super(project, true);
   myChooserFilter = filter;
   myProject = project;
   setTitle(DebuggerBundle.message("class.filters.dialog.title"));
   init();
 }
  public static String renderLocation(final Location location) {
    String sourceName;
    try {
      sourceName = location.sourceName();
    } catch (Throwable e) {
      sourceName = "Unknown Source";
    }

    final StringBuilder methodName = new StringBuilder();
    try {
      methodName.append(location.declaringType().name());
    } catch (Throwable e) {
      methodName.append(e.getMessage());
    }
    methodName.append(".");
    try {
      methodName.append(location.method().name());
    } catch (Throwable e) {
      methodName.append(e.getMessage());
    }

    int lineNumber;
    try {
      lineNumber = location.lineNumber();
    } catch (Throwable e) {
      lineNumber = -1;
    }
    return DebuggerBundle.message(
        "export.threads.stackframe.format", methodName.toString(), sourceName, lineNumber);
  }
 public AlternativeSourceNotificationPanel(
     ComboBoxClassElement[] alternatives,
     final PsiClass aClass,
     final Project project,
     final VirtualFile file) {
   setText(
       DebuggerBundle.message(
           "editor.notification.alternative.source", aClass.getQualifiedName()));
   final ComboBox switcher = new ComboBox(alternatives);
   switcher.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           FileEditorManager.getInstance(project).closeFile(file);
           PsiClass item = ((ComboBoxClassElement) switcher.getSelectedItem()).myClass;
           item = (PsiClass) item.getNavigationElement(); // go through compiled
           DebuggerUtilsEx.setAlternativeSource(file, item.getContainingFile().getVirtualFile());
           item.navigate(true);
           XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
           if (session != null) {
             session.updateExecutionPosition();
           }
         }
       });
   myLinksPanel.add(switcher);
 }
  protected JComponent createCenterPanel() {
    final JPanel panel = new JPanel(new BorderLayout());

    final JPanel exprPanel = new JPanel(new BorderLayout());
    exprPanel.add(
        new JLabel(DebuggerBundle.message("label.evaluate.dialog.expression")), BorderLayout.WEST);
    exprPanel.add(getExpressionCombo(), BorderLayout.CENTER);
    final JLabel help =
        new JLabel(
            "Press Enter to Evaluate or Control+Enter to evaluate and add to the Watches",
            SwingConstants.RIGHT);
    help.setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 6, 0));
    UIUtil.applyStyle(UIUtil.ComponentStyle.MINI, help);
    help.setForeground(UIUtil.getInactiveTextColor());
    exprPanel.add(help, BorderLayout.SOUTH);

    final JPanel resultPanel = new JPanel(new BorderLayout());
    // resultPanel.add(new JLabel(DebuggerBundle.message("label.evaluate.dialog.result")),
    // BorderLayout.NORTH);
    resultPanel.add(getEvaluationPanel(), BorderLayout.CENTER);

    panel.add(exprPanel, BorderLayout.NORTH);
    panel.add(resultPanel, BorderLayout.CENTER);

    return panel;
  }
Exemplo n.º 13
0
 protected static String calcLabel(ValueDescriptor descriptor) {
   final ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl) descriptor;
   final Value value = valueDescriptor.getValue();
   if (value instanceof ObjectReference) {
     if (value instanceof StringReference) {
       return ((StringReference) value).value();
     } else if (value instanceof ClassObjectReference) {
       ReferenceType type = ((ClassObjectReference) value).reflectedType();
       return (type != null) ? type.name() : "{...}";
     } else {
       final ObjectReference objRef = (ObjectReference) value;
       final Type type = objRef.type();
       if (type instanceof ClassType && ((ClassType) type).isEnum()) {
         final String name = getEnumConstantName(objRef, (ClassType) type);
         if (name != null) {
           return name;
         } else {
           return type.name();
         }
       } else {
         return "";
       }
     }
   } else if (value == null) {
     //noinspection HardCodedStringLiteral
     return "null";
   } else {
     return DebuggerBundle.message("label.undefined");
   }
 }
  private void applyTo(ArrayRenderer renderer, boolean showBigRangeWarning)
      throws ConfigurationException {
    int newStartIndex = getInt(myStartIndex);
    int newEndIndex = getInt(myEndIndex);
    int newLimit = getInt(myEntriesLimit);

    if (newStartIndex < 0) {
      throw new ConfigurationException(
          DebuggerBundle.message("error.array.renderer.configurable.start.index.less.than.zero"));
    }

    if (newEndIndex < newStartIndex) {
      throw new ConfigurationException(
          DebuggerBundle.message("error.array.renderer.configurable.end.index.less.than.start"));
    }

    if (newStartIndex >= 0 && newEndIndex >= 0) {
      if (newStartIndex > newEndIndex) {
        int currentStartIndex = renderer.START_INDEX;
        int currentEndIndex = renderer.END_INDEX;
        newEndIndex = newStartIndex + (currentEndIndex - currentStartIndex);
      }

      if (newLimit <= 0) {
        newLimit = 1;
      }

      if (showBigRangeWarning && (newEndIndex - newStartIndex > 10000)) {
        final int answer =
            Messages.showOkCancelDialog(
                myPanel.getRootPane(),
                DebuggerBundle.message(
                    "warning.range.too.big", ApplicationNamesInfo.getInstance().getProductName()),
                DebuggerBundle.message("title.range.too.big"),
                Messages.getWarningIcon());
        if (answer != Messages.OK) {
          return;
        }
      }
    }

    renderer.START_INDEX = newStartIndex;
    renderer.END_INDEX = newEndIndex;
    renderer.ENTRIES_LIMIT = newLimit;
  }
Exemplo n.º 15
0
    public String getName(DebugProcessImpl process) throws EvaluateException {
      List<ReferenceType> allClasses = process.getPositionManager().getAllClasses(mySourcePosition);
      if (!allClasses.isEmpty()) {
        return allClasses.get(0).name();
      }

      throw EvaluateExceptionUtil.createEvaluateException(
          DebuggerBundle.message("error.class.not.loaded", getDisplayName(process)));
    }
  private void processException(Throwable e) {
    if (e.getMessage() != null) {
      myProgress.addMessage(myDebuggerSession, MessageCategory.ERROR, e.getMessage());
    }

    if (e instanceof ProcessCanceledException) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.INFORMATION,
          DebuggerBundle.message("error.operation.canceled"));
      return;
    }

    if (e instanceof UnsupportedOperationException) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.operation.not.supported.by.vm"));
    } else if (e instanceof NoClassDefFoundError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.def.not.found", e.getLocalizedMessage()));
    } else if (e instanceof VerifyError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.verification.error", e.getLocalizedMessage()));
    } else if (e instanceof UnsupportedClassVersionError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.unsupported.class.version", e.getLocalizedMessage()));
    } else if (e instanceof ClassFormatError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.format.error", e.getLocalizedMessage()));
    } else if (e instanceof ClassCircularityError) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message("error.class.circularity.error", e.getLocalizedMessage()));
    } else {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.ERROR,
          DebuggerBundle.message(
              "error.exception.while.reloading", e.getClass().getName(), e.getLocalizedMessage()));
    }
  }
 public static String renderObject(ObjectReference monitor) {
   String monitorTypeName;
   try {
     monitorTypeName = monitor.referenceType().name();
   } catch (Throwable e) {
     monitorTypeName = "Error getting object type: '" + e.getMessage() + "'";
   }
   return DebuggerBundle.message(
       "threads.export.attribute.label.object-id",
       Long.toHexString(monitor.uniqueID()),
       monitorTypeName);
 }
 @Override
 public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
   PsiElementFactory elementFactory =
       JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
   try {
     return elementFactory.createExpressionFromText(
         getName(), PositionUtil.getContextElement(context));
   } catch (IncorrectOperationException e) {
     throw new EvaluateException(
         DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
   }
 }
Exemplo n.º 19
0
  public boolean processLocatableEvent(
      final SuspendContextCommandImpl action, final LocatableEvent event)
      throws EventProcessingException {
    final SuspendContextImpl context = action.getSuspendContext();
    if (!isValid()) {
      context.getDebugProcess().getRequestsManager().deleteRequest(this);
      return false;
    }

    final String[] title = {DebuggerBundle.message("title.error.evaluating.breakpoint.condition")};

    try {
      final StackFrameProxyImpl frameProxy = context.getThread().frame(0);
      if (frameProxy == null) {
        // might be if the thread has been collected
        return false;
      }

      final EvaluationContextImpl evaluationContext =
          new EvaluationContextImpl(
              action.getSuspendContext(), frameProxy, getThisObject(context, event));

      if (!evaluateCondition(evaluationContext, event)) {
        return false;
      }

      title[0] = DebuggerBundle.message("title.error.evaluating.breakpoint.action");
      runAction(evaluationContext, event);
    } catch (final EvaluateException ex) {
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        System.out.println(ex.getMessage());
        return false;
      }

      throw new EventProcessingException(title[0], ex.getMessage(), ex);
    }

    return true;
  }
Exemplo n.º 20
0
 private static String renderLocation(final Location location) {
   String sourceName;
   try {
     sourceName = location.sourceName();
   } catch (AbsentInformationException e) {
     sourceName = "Unknown Source";
   }
   return DebuggerBundle.message(
       "export.threads.stackframe.format",
       location.declaringType().name() + "." + location.method().name(),
       sourceName,
       location.lineNumber());
 }
Exemplo n.º 21
0
  private void runAction(final EvaluationContextImpl context, LocatableEvent event) {
    if (LOG_ENABLED || LOG_EXPRESSION_ENABLED) {
      final StringBuilder buf = StringBuilderSpinAllocator.alloc();
      try {
        if (LOG_ENABLED) {
          buf.append(getEventMessage(event));
          buf.append("\n");
        }
        final DebugProcessImpl debugProcess = context.getDebugProcess();
        final TextWithImports expressionToEvaluate = getLogMessage();
        if (LOG_EXPRESSION_ENABLED
            && expressionToEvaluate != null
            && !"".equals(expressionToEvaluate.getText())) {
          if (!debugProcess.isAttached()) {
            return;
          }

          try {
            ExpressionEvaluator evaluator =
                DebuggerInvocationUtil.commitAndRunReadAction(
                    getProject(),
                    new EvaluatingComputable<ExpressionEvaluator>() {
                      public ExpressionEvaluator compute() throws EvaluateException {
                        return EvaluatorBuilderImpl.build(
                            expressionToEvaluate,
                            ContextUtil.getContextElement(context),
                            ContextUtil.getSourcePosition(context));
                      }
                    });
            final Value eval = evaluator.evaluate(context);
            final String result =
                eval instanceof VoidValue ? "void" : DebuggerUtils.getValueAsString(context, eval);
            buf.append(result);
          } catch (EvaluateException e) {
            buf.append(DebuggerBundle.message("error.unable.to.evaluate.expression"));
            buf.append(" \"");
            buf.append(expressionToEvaluate);
            buf.append("\"");
            buf.append(" : ");
            buf.append(e.getMessage());
          }
          buf.append("\n");
        }
        if (buf.length() > 0) {
          debugProcess.printToConsole(buf.toString());
        }
      } finally {
        StringBuilderSpinAllocator.dispose(buf);
      }
    }
  }
 public String getDisplayName() {
   if (!isValid()) {
     return DebuggerBundle.message("status.breakpoint.invalid");
   }
   final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
   try {
     buffer.append(myClassPattern);
     buffer.append(".");
     buffer.append(myMethodName);
     buffer.append("()");
     return buffer.toString();
   } finally {
     StringBuilderSpinAllocator.dispose(buffer);
   }
 }
  private <B extends XBreakpoint<?>> XLineBreakpoint createXLineBreakpoint(
      Class<? extends XBreakpointType<B, ?>> typeCls, Element breakpointNode)
      throws InvalidDataException {
    final String url = breakpointNode.getAttributeValue("url");
    VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
    if (vFile == null) {
      throw new InvalidDataException(
          DebuggerBundle.message("error.breakpoint.file.not.found", url));
    }
    final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
    if (doc == null) {
      throw new InvalidDataException(
          DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
    }

    final int line;
    try {
      //noinspection HardCodedStringLiteral
      line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
    } catch (Exception e) {
      throw new InvalidDataException("Line number is invalid for breakpoint");
    }
    return addXLineBreakpoint(typeCls, doc, line);
  }
 private void reportProblem(final String qualifiedName, @Nullable Exception ex) {
   String reason = null;
   if (ex != null) {
     reason = ex.getLocalizedMessage();
   }
   if (reason == null || reason.length() == 0) {
     reason = DebuggerBundle.message("error.io.error");
   }
   final StringBuilder buf = StringBuilderSpinAllocator.alloc();
   try {
     buf.append(qualifiedName).append(" : ").append(reason);
     myProgress.addMessage(myDebuggerSession, MessageCategory.ERROR, buf.toString());
   } finally {
     StringBuilderSpinAllocator.dispose(buf);
   }
 }
Exemplo n.º 25
0
  @Override
  public void buildChildren(
      final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    final ValueDescriptorImpl parentDescriptor =
        (ValueDescriptorImpl) builder.getParentDescriptor();
    final NodeManager nodeManager = builder.getNodeManager();
    final NodeDescriptorFactory nodeDescriptorFactory = builder.getDescriptorManager();

    List<DebuggerTreeNode> children = new ArrayList<>();
    if (value instanceof ObjectReference) {
      final ObjectReference objRef = (ObjectReference) value;
      final ReferenceType refType = objRef.referenceType();
      // default ObjectReference processing
      List<Field> fields = refType.allFields();
      if (!fields.isEmpty()) {
        Set<String> names = new HashSet<>();
        for (Field field : fields) {
          if (shouldDisplay(evaluationContext, objRef, field)) {
            FieldDescriptor fieldDescriptor =
                createFieldDescriptor(
                    parentDescriptor, nodeDescriptorFactory, objRef, field, evaluationContext);
            String name = fieldDescriptor.getName();
            if (names.contains(name)) {
              fieldDescriptor.putUserData(FieldDescriptor.SHOW_DECLARING_TYPE, Boolean.TRUE);
            } else {
              names.add(name);
            }
            children.add(nodeManager.createNode(fieldDescriptor, evaluationContext));
          }
        }

        if (children.isEmpty()) {
          children.add(
              nodeManager.createMessageNode(
                  DebuggerBundle.message("message.node.class.no.fields.to.display")));
        } else if (XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
          children.sort(NodeManagerImpl.getNodeComparator());
        }
      } else {
        children.add(
            nodeManager.createMessageNode(MessageDescriptor.CLASS_HAS_NO_FIELDS.getLabel()));
      }
    }
    builder.setChildren(children);
  }
Exemplo n.º 26
0
 public static String getThreadStatusText(int statusId) {
   switch (statusId) {
     case ThreadReference.THREAD_STATUS_MONITOR:
       return DebuggerBundle.message("status.thread.monitor");
     case ThreadReference.THREAD_STATUS_NOT_STARTED:
       return DebuggerBundle.message("status.thread.not.started");
     case ThreadReference.THREAD_STATUS_RUNNING:
       return DebuggerBundle.message("status.thread.running");
     case ThreadReference.THREAD_STATUS_SLEEPING:
       return DebuggerBundle.message("status.thread.sleeping");
     case ThreadReference.THREAD_STATUS_UNKNOWN:
       return DebuggerBundle.message("status.thread.unknown");
     case ThreadReference.THREAD_STATUS_WAIT:
       return DebuggerBundle.message("status.thread.wait");
     case ThreadReference.THREAD_STATUS_ZOMBIE:
       return DebuggerBundle.message("status.thread.zombie");
     default:
       return DebuggerBundle.message("status.thread.undefined");
   }
 }
Exemplo n.º 27
0
  @Override
  public PsiElement getChildValueExpression(DebuggerTreeNode node, DebuggerContext context)
      throws EvaluateException {
    FieldDescriptor fieldDescriptor = (FieldDescriptor) node.getDescriptor();

    PsiElementFactory elementFactory =
        JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
    try {
      return elementFactory.createExpressionFromText(
          "this." + fieldDescriptor.getField().name(),
          DebuggerUtils.findClass(
              fieldDescriptor.getObject().referenceType().name(),
              context.getProject(),
              context.getDebugProcess().getSearchScope()));
    } catch (IncorrectOperationException e) {
      throw new EvaluateException(
          DebuggerBundle.message("error.invalid.field.name", fieldDescriptor.getField().name()),
          null);
    }
  }
  public ExpressionEvaluationDialog(Project project, TextWithImports defaultExpression) {
    super(project, defaultExpression);
    setTitle(DebuggerBundle.message("evaluate.expression.dialog.title"));

    final KeyStroke expressionStroke = KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.ALT_MASK);
    final KeyStroke resultStroke = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_MASK);

    final JRootPane rootPane = getRootPane();

    final AnAction anAction =
        new AnAction() {
          public void actionPerformed(AnActionEvent e) {
            getExpressionCombo().requestFocus();
          }
        };
    anAction.registerCustomShortcutSet(new CustomShortcutSet(expressionStroke), rootPane);
    addDisposeRunnable(
        new Runnable() {
          public void run() {
            anAction.unregisterCustomShortcutSet(rootPane);
          }
        });

    final AnAction anAction2 =
        new AnAction() {
          public void actionPerformed(AnActionEvent e) {
            getEvaluationPanel().getWatchTree().requestFocus();
          }
        };
    anAction2.registerCustomShortcutSet(new CustomShortcutSet(resultStroke), rootPane);
    addDisposeRunnable(
        new Runnable() {
          public void run() {
            anAction2.unregisterCustomShortcutSet(rootPane);
          }
        });

    init();
  }
  @Nullable
  protected static RangeHighlighter createHighlighter(
      @NotNull Project project, @NotNull Document document, int lineIndex) {
    if (lineIndex < 0 || lineIndex >= document.getLineCount()) {
      return null;
    }

    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    TextAttributes attributes = scheme.getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);

    RangeHighlighter highlighter =
        ((MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true))
            .addPersistentLineHighlighter(
                lineIndex, DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, attributes);
    if (highlighter == null || !highlighter.isValid()) {
      return null;
    }
    highlighter.putUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY, Boolean.TRUE);
    highlighter.setErrorStripeTooltip(
        DebuggerBundle.message("breakpoint.tooltip.text", lineIndex + 1));
    return highlighter;
  }
Exemplo n.º 30
0
  public EvaluationDialog(Project project, TextWithImports text) {
    super(project, true);
    myProject = project;
    setModal(false);
    setCancelButtonText(CommonBundle.message("button.close"));
    setOKButtonText(DebuggerBundle.message("button.evaluate"));

    myEvaluationPanel = new MyEvaluationPanel(myProject);

    myEditor = createEditor(DefaultCodeFragmentFactory.getInstance());

    setDebuggerContext(getDebuggerContext());
    initDialogData(text);

    myContextListener =
        new DebuggerContextListener() {
          public void changeEvent(DebuggerContextImpl newContext, int event) {
            boolean close = true;
            for (DebuggerSession session :
                DebuggerManagerEx.getInstanceEx(myProject).getSessions()) {
              if (!session.isStopped()) {
                close = false;
                break;
              }
            }

            if (close) {
              close(CANCEL_EXIT_CODE);
            } else {
              setDebuggerContext(newContext);
            }
          }
        };
    DebuggerManagerEx.getInstanceEx(myProject).getContextManager().addListener(myContextListener);

    setHorizontalStretch(1f);
    setVerticalStretch(1f);
  }