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);
}
}
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;
}
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));
}
Aggregations