use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class NodeDescriptorFactoryImpl method createDescriptorTree.
private static DescriptorTree createDescriptorTree(final StackFrameProxy frameProxy, final DescriptorTree fromTree) {
int frameCount = -1;
int frameIndex = -1;
if (frameProxy != null) {
try {
final ThreadReferenceProxy threadReferenceProxy = frameProxy.threadProxy();
frameCount = threadReferenceProxy.frameCount();
frameIndex = frameProxy.getFrameIndex();
} catch (EvaluateException e) {
// ignored
}
}
final boolean isInitial = !fromTree.frameIdEquals(frameCount, frameIndex);
DescriptorTree descriptorTree = new DescriptorTree(isInitial);
descriptorTree.setFrameId(frameCount, frameIndex);
return descriptorTree;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class DebuggerTreeRenderer method getDescriptorText.
private static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor, EditorColorsScheme colorScheme, boolean multiline, boolean appendValue) {
SimpleColoredText descriptorText = new SimpleColoredText();
String text;
String nodeName;
if (descriptor == null) {
text = "";
nodeName = null;
} else {
text = descriptor.getLabel();
nodeName = descriptor.getName();
}
if (text.equals(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE)) {
descriptorText.append(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES);
return descriptorText;
}
if (descriptor instanceof ValueDescriptor) {
final ValueMarkup markup = ((ValueDescriptor) descriptor).getMarkup(debuggerContext.getDebugProcess());
if (markup != null) {
descriptorText.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
}
}
String[] strings = breakString(text, nodeName);
if (strings[0] != null) {
if (descriptor instanceof MessageDescriptor && ((MessageDescriptor) descriptor).getKind() == MessageDescriptor.SPECIAL) {
descriptorText.append(strings[0], SPECIAL_NODE_ATTRIBUTES);
} else {
descriptorText.append(strings[0], DEFAULT_ATTRIBUTES);
}
}
if (strings[1] != null) {
descriptorText.append(strings[1], XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
}
if (strings[2] != null) {
if (descriptor instanceof ValueDescriptorImpl) {
if (multiline && strings[2].indexOf('\n') >= 0) {
strings = breakString(strings[2], "=");
if (strings[2] != null) {
strings[2] = strings[0] + strings[1] + "\n" + strings[2];
}
}
ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl) descriptor;
String valueLabel = valueDescriptor.getValueLabel();
strings = breakString(strings[2], valueLabel);
if (strings[0] != null) {
descriptorText.append(strings[0], DEFAULT_ATTRIBUTES);
}
if (appendValue && strings[1] != null) {
if (valueLabel != null && StringUtil.startsWithChar(valueLabel, '{') && valueLabel.indexOf('}') > 0 && !StringUtil.endsWithChar(valueLabel, '}')) {
int idx = valueLabel.indexOf('}');
String objectId = valueLabel.substring(0, idx + 1);
valueLabel = valueLabel.substring(idx + 1);
descriptorText.append(objectId, OBJECT_ID_HIGHLIGHT_ATTRIBUTES);
}
valueLabel = DebuggerUtilsEx.truncateString(valueLabel);
final SimpleTextAttributes valueLabelAttribs;
if (valueDescriptor.isDirty()) {
valueLabelAttribs = XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES;
} else {
TextAttributes attributes = null;
if (valueDescriptor.isNull()) {
attributes = colorScheme.getAttributes(JavaHighlightingColors.KEYWORD);
} else if (valueDescriptor.isString()) {
attributes = colorScheme.getAttributes(JavaHighlightingColors.STRING);
}
valueLabelAttribs = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : DEFAULT_ATTRIBUTES;
}
final EvaluateException exception = descriptor.getEvaluateException();
if (exception != null) {
final String errorMessage = exception.getMessage();
if (valueLabel.endsWith(errorMessage)) {
appendValueTextWithEscapesRendering(descriptorText, valueLabel.substring(0, valueLabel.length() - errorMessage.length()), valueLabelAttribs, colorScheme);
descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
} else {
appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
}
} else {
if (valueLabel.equals(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE)) {
descriptorText.append(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES);
} else {
appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
}
}
}
} else {
descriptorText.append(strings[2], DEFAULT_ATTRIBUTES);
}
}
return descriptorText;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ArrayElementDescriptorImpl method getModifier.
@Override
public XValueModifier getModifier(JavaValue value) {
return new JavaValueModifier(value) {
@Override
protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
final ArrayElementDescriptorImpl elementDescriptor = ArrayElementDescriptorImpl.this;
final ArrayReference array = elementDescriptor.getArray();
if (array != null) {
if (VirtualMachineProxyImpl.isCollected(array)) {
// will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG
Messages.showWarningDialog(getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value"));
//node.getParent().calcValue();
return;
}
final ArrayType arrType = (ArrayType) array.referenceType();
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
set(expression, callback, debuggerContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType()));
update(debuggerContext);
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader());
}
});
}
}
};
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class DebuggerTreeNodeExpression method createEvaluationText.
public static TextWithImports createEvaluationText(final DebuggerTreeNodeImpl node, final DebuggerContextImpl context) throws EvaluateException {
final EvaluateException[] ex = new EvaluateException[] { null };
final TextWithImports textWithImports = PsiDocumentManager.getInstance(context.getProject()).commitAndRunReadAction((Computable<TextWithImports>) () -> {
try {
final PsiExpression expressionText = getEvaluationExpression(node, context);
if (expressionText != null) {
return new TextWithImportsImpl(expressionText);
}
} catch (EvaluateException e) {
ex[0] = e;
}
return null;
});
if (ex[0] != null) {
throw ex[0];
}
return textWithImports;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ExpressionChildrenRenderer method buildChildren.
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
final NodeManager nodeManager = builder.getNodeManager();
try {
final ValueDescriptor parentDescriptor = builder.getParentDescriptor();
final Value childrenValue = evaluateChildren(evaluationContext.createEvaluationContext(value), parentDescriptor);
NodeRenderer renderer = getChildrenRenderer(childrenValue, parentDescriptor);
renderer.buildChildren(childrenValue, builder, evaluationContext);
} catch (final EvaluateException e) {
List<DebuggerTreeNode> errorChildren = new ArrayList<>();
errorChildren.add(nodeManager.createMessageNode(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + e.getMessage()));
builder.setChildren(errorChildren);
}
}
Aggregations