Search in sources :

Example 21 with ObjectReference

use of com.sun.jdi.ObjectReference 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 22 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class InstancesTree method getSelectedReference.

@Nullable
ObjectReference getSelectedReference() {
    TreePath selectionPath = getSelectionPath();
    Object selectedItem = selectionPath != null ? selectionPath.getLastPathComponent() : null;
    if (selectedItem instanceof XValueNodeImpl) {
        XValueNodeImpl xValueNode = (XValueNodeImpl) selectedItem;
        XValue valueContainer = xValueNode.getValueContainer();
        if (valueContainer instanceof NodeDescriptorProvider) {
            NodeDescriptor descriptor = ((NodeDescriptorProvider) valueContainer).getDescriptor();
            if (descriptor instanceof ValueDescriptor) {
                Value value = ((ValueDescriptor) descriptor).getValue();
                if (value instanceof ObjectReference)
                    return (ObjectReference) value;
            }
        }
    }
    return null;
}
Also used : NodeDescriptorProvider(com.intellij.debugger.ui.impl.watch.NodeDescriptorProvider) TreePath(javax.swing.tree.TreePath) ObjectReference(com.sun.jdi.ObjectReference) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor) Value(com.sun.jdi.Value) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with ObjectReference

use of com.sun.jdi.ObjectReference in project intellij-community by JetBrains.

the class InstanceValueDescriptor method getDescriptorEvaluation.

@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext debuggerContext) throws EvaluateException {
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myProject).getElementFactory();
    ObjectReference ref = ((ObjectReference) getValue());
    String name = NamesUtils.getUniqueName(ref).replace("@", "");
    String presentation = String.format("%s_DebugLabel", name);
    return elementFactory.createExpressionFromText(presentation, ContextUtil.getContextElement(debuggerContext));
}
Also used : ObjectReference(com.sun.jdi.ObjectReference) PsiElementFactory(com.intellij.psi.PsiElementFactory)

Aggregations

ObjectReference (com.sun.jdi.ObjectReference)23 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)5 Project (com.intellij.openapi.project.Project)5 ReferenceType (com.sun.jdi.ReferenceType)5 Value (com.sun.jdi.Value)5 Field (com.sun.jdi.Field)4 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 XDebugSession (com.intellij.xdebugger.XDebugSession)3 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)3 BooleanValue (com.sun.jdi.BooleanValue)3 Nullable (org.jetbrains.annotations.Nullable)3 SourcePosition (com.intellij.debugger.SourcePosition)2 MemoryViewDebugProcessData (com.intellij.debugger.memory.component.MemoryViewDebugProcessData)2 StepIntoBreakpoint (com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint)2 IntegerValue (com.sun.jdi.IntegerValue)2 InvocationException (com.sun.jdi.InvocationException)2 Method (com.sun.jdi.Method)2 StringReference (com.sun.jdi.StringReference)2 ThreadReference (com.sun.jdi.ThreadReference)2 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1