Search in sources :

Example 6 with ValueMarkup

use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.

the class XValueNodeImpl method updateText.

private void updateText() {
    myText.clear();
    XValueMarkers<?, ?> markers = myTree.getValueMarkers();
    if (markers != null) {
        ValueMarkup markup = markers.getMarkup(getValueContainer());
        if (markup != null) {
            myText.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
        }
    }
    appendName();
    buildText(myValuePresentation, myText);
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup)

Example 7 with ValueMarkup

use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.

the class CodeFragmentFactoryContextWrapper method wrapContext.

private PsiElement wrapContext(Project project, final PsiElement originalContext) {
    if (project.isDefault())
        return originalContext;
    //TODO [egor] : does not work for anything other than java anyway, see IDEA-132677
    if (!(myDelegate instanceof DefaultCodeFragmentFactory)) {
        return originalContext;
    }
    PsiElement context = originalContext;
    XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    if (session != null) {
        XValueMarkers<?, ?> markers = ((XDebugSessionImpl) session).getValueMarkers();
        Map<?, ValueMarkup> markupMap = markers != null ? markers.getAllMarkers() : null;
        //final Map<ObjectReference, ValueMarkup> markupMap = ValueDescriptorImpl.getMarkupMap(process);
        if (!ContainerUtil.isEmpty(markupMap)) {
            final Pair<String, Map<String, ObjectReference>> markupVariables = createMarkupVariablesText(markupMap);
            int offset = markupVariables.getFirst().length() - 1;
            final TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.CODE_BLOCK, markupVariables.getFirst(), "", myDelegate.getFileType());
            final JavaCodeFragment codeFragment = myDelegate.createCodeFragment(textWithImports, context, project);
            codeFragment.accept(new JavaRecursiveElementVisitor() {

                public void visitLocalVariable(PsiLocalVariable variable) {
                    final String name = variable.getName();
                    variable.putUserData(LABEL_VARIABLE_VALUE_KEY, markupVariables.getSecond().get(name));
                }
            });
            final PsiElement newContext = codeFragment.findElementAt(offset);
            if (newContext != null) {
                context = newContext;
            }
        }
    }
    return context;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) PsiLocalVariable(com.intellij.psi.PsiLocalVariable) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup) HashMap(java.util.HashMap) Map(java.util.Map) JavaCodeFragment(com.intellij.psi.JavaCodeFragment) JavaRecursiveElementVisitor(com.intellij.psi.JavaRecursiveElementVisitor) PsiElement(com.intellij.psi.PsiElement) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 8 with ValueMarkup

use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.

the class CodeFragmentFactoryContextWrapper method createMarkupVariablesText.

private static Pair<String, Map<String, ObjectReference>> createMarkupVariablesText(Map<?, ValueMarkup> markupMap) {
    final Map<String, ObjectReference> reverseMap = new HashMap<>();
    final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
    try {
        for (Map.Entry<?, ValueMarkup> entry : markupMap.entrySet()) {
            ObjectReference objectRef = (ObjectReference) entry.getKey();
            final ValueMarkup markup = entry.getValue();
            String labelName = markup.getText();
            if (!StringUtil.isJavaIdentifier(labelName)) {
                continue;
            }
            try {
                final String typeName = objectRef.type().name();
                labelName += DEBUG_LABEL_SUFFIX;
                if (buffer.length() > 0) {
                    buffer.append("\n");
                }
                buffer.append(typeName).append(" ").append(labelName).append(";");
                reverseMap.put(labelName, objectRef);
            } catch (ObjectCollectedException e) {
            //it.remove();
            }
        }
        buffer.append(" ");
        return Pair.create(buffer.toString(), reverseMap);
    } finally {
        StringBuilderSpinAllocator.dispose(buffer);
    }
}
Also used : ObjectCollectedException(com.sun.jdi.ObjectCollectedException) HashMap(java.util.HashMap) ObjectReference(com.sun.jdi.ObjectReference) HashMap(java.util.HashMap) Map(java.util.Map) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup)

Example 9 with ValueMarkup

use of com.intellij.xdebugger.impl.ui.tree.ValueMarkup in project intellij-community by JetBrains.

the class JavaFramesListRenderer method customizePresentation.

public void customizePresentation(StackFrameDescriptorImpl descriptor, @NotNull ColoredTextContainer component, StackFrameDescriptorImpl selectedDescriptor) {
    component.setIcon(descriptor.getIcon());
    //final Object selectedValue = list.getSelectedValue();
    final boolean shouldHighlightAsRecursive = isOccurrenceOfSelectedFrame(selectedDescriptor, descriptor);
    final ValueMarkup markup = descriptor.getValueMarkup();
    if (markup != null) {
        component.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
    }
    boolean needSeparator = false;
    //if (index > 0) {
    //  final int currentFrameIndex = descriptor.getUiIndex();
    //  final Object elementAt = list.getModel().getElementAt(index - 1);
    //  if (elementAt instanceof StackFrameDescriptorImpl) {
    //    StackFrameDescriptorImpl previousDescriptor = (StackFrameDescriptorImpl)elementAt;
    //    final int previousFrameIndex = previousDescriptor.getUiIndex();
    //    needSeparator = (currentFrameIndex - previousFrameIndex != 1);
    //  }
    //}
    //if (selected) {
    //  setBackground(UIUtil.getListSelectionBackground());
    //}
    //else {
    //  Color bg = descriptor.getBackgroundColor();
    //  if (bg == null) bg = UIUtil.getListBackground();
    //  if (shouldHighlightAsRecursive) bg = myColorScheme.getColor(DebuggerColors.RECURSIVE_CALL_ATTRIBUTES);
    //  setBackground(bg);
    //}
    //
    //if (needSeparator) {
    //  final MatteBorder border = BorderFactory.createMatteBorder(1, 0, 0, 0, JBColor.GRAY);
    //  setBorder(border);
    //}
    //else {
    //  setBorder(null);
    //}
    final String label = descriptor.getLabel();
    final int openingBrace = label.indexOf("{");
    final int closingBrace = (openingBrace < 0) ? -1 : label.indexOf("}");
    final SimpleTextAttributes attributes = getAttributes(descriptor);
    if (openingBrace < 0 || closingBrace < 0) {
        component.append(label, attributes);
    } else {
        component.append(label.substring(0, openingBrace - 1), attributes);
        component.append(" (" + label.substring(openingBrace + 1, closingBrace) + ")", SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
        component.append(label.substring(closingBrace + 1, label.length()), attributes);
        if (shouldHighlightAsRecursive && descriptor.isRecursiveCall()) {
            component.append(" [" + descriptor.getOccurrenceIndex() + "]", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
        }
    }
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup)

Aggregations

ValueMarkup (com.intellij.xdebugger.impl.ui.tree.ValueMarkup)9 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)3 Map (java.util.Map)3 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)2 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)2 HashMap (com.intellij.util.containers.HashMap)2 XDebugSession (com.intellij.xdebugger.XDebugSession)2 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)2 HashMap (java.util.HashMap)2 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 TreeBuilder (com.intellij.debugger.ui.impl.tree.TreeBuilder)1 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)1 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)1 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)1 ValueDescriptorImpl (com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 Pair (com.intellij.openapi.util.Pair)1