use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class NodeManagerImpl method getContextKeyForFrame.
@Nullable
public static String getContextKeyForFrame(final StackFrameProxyImpl frame) {
if (frame == null) {
return null;
}
try {
final Location location = frame.location();
final Method method = DebuggerUtilsEx.getMethod(location);
if (method == null) {
return null;
}
final ReferenceType referenceType = location.declaringType();
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
return builder.append(referenceType.signature()).append("#").append(method.name()).append(method.signature()).toString();
} finally {
StringBuilderSpinAllocator.dispose(builder);
}
} catch (EvaluateException ignored) {
} catch (InternalException ie) {
if (ie.errorCode() != 23) {
// INVALID_METHODID
throw ie;
}
}
return null;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ValueDescriptorImpl method calcRepresentation.
@Override
protected String calcRepresentation(EvaluationContextImpl context, DescriptorLabelListener labelListener) {
DebuggerManagerThreadImpl.assertIsManagerThread();
final NodeRenderer renderer = getRenderer(context.getDebugProcess());
final EvaluateException valueException = myValueException;
myIsExpandable = (valueException == null || valueException.getExceptionFromTargetVM() != null) && renderer.isExpandable(getValue(), context, this);
try {
setValueIcon(renderer.calcValueIcon(this, context, labelListener));
} catch (EvaluateException e) {
LOG.info(e);
setValueIcon(null);
}
String label;
if (valueException == null) {
try {
label = renderer.calcLabel(this, context, labelListener);
} catch (EvaluateException e) {
label = setValueLabelFailed(e);
}
} else {
label = setValueLabelFailed(valueException);
}
setValueLabel(label);
// we have overridden getLabel
return "";
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class DebuggerTreeNodeExpression method substituteThis.
@Nullable
public static PsiExpression substituteThis(@Nullable PsiElement expressionWithThis, PsiExpression howToEvaluateThis, Value howToEvaluateThisValue) throws EvaluateException {
if (expressionWithThis == null)
return null;
PsiExpression result = (PsiExpression) expressionWithThis.copy();
PsiClass thisClass = PsiTreeUtil.getContextOfType(result, PsiClass.class, true);
boolean castNeeded = true;
if (thisClass != null) {
PsiType type = howToEvaluateThis.getType();
if (type != null) {
if (type instanceof PsiClassType) {
PsiClass psiClass = ((PsiClassType) type).resolve();
if (psiClass != null && (psiClass == thisClass || psiClass.isInheritor(thisClass, true))) {
castNeeded = false;
}
} else if (type instanceof PsiArrayType) {
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expressionWithThis);
if (thisClass == JavaPsiFacade.getInstance(expressionWithThis.getProject()).getElementFactory().getArrayClass(languageLevel)) {
castNeeded = false;
}
}
}
}
if (castNeeded) {
howToEvaluateThis = castToRuntimeType(howToEvaluateThis, howToEvaluateThisValue);
}
ChangeContextUtil.encodeContextInfo(result, false);
PsiExpression psiExpression;
try {
psiExpression = (PsiExpression) ChangeContextUtil.decodeContextInfo(result, thisClass, howToEvaluateThis);
} catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("evaluation.error.invalid.this.expression", result.getText(), howToEvaluateThis.getText()), null);
}
try {
PsiExpression res = JavaPsiFacade.getInstance(howToEvaluateThis.getProject()).getElementFactory().createExpressionFromText(psiExpression.getText(), howToEvaluateThis.getContext());
res.putUserData(ADDITIONAL_IMPORTS_KEY, howToEvaluateThis.getUserData(ADDITIONAL_IMPORTS_KEY));
return res;
} catch (IncorrectOperationException e) {
throw new EvaluateException(e.getMessage(), e);
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class LocalVariableDescriptorImpl method getModifier.
@Override
public XValueModifier getModifier(JavaValue value) {
return new JavaValueModifier(value) {
@Override
protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
final LocalVariableProxyImpl local = LocalVariableDescriptorImpl.this.getLocalVariable();
if (local != null) {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
set(expression, callback, debuggerContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType()));
update(debuggerContext);
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader());
}
});
}
}
};
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ColorObjectRenderer method calcValueIcon.
public Icon calcValueIcon(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
final Value value = descriptor.getValue();
if (value instanceof ObjectReference) {
try {
final ObjectReference objRef = (ObjectReference) value;
final ReferenceType refType = objRef.referenceType();
final Field valueField = refType.fieldByName("value");
if (valueField != null) {
final Value rgbValue = objRef.getValue(valueField);
if (rgbValue instanceof IntegerValue) {
@SuppressWarnings("UseJBColor") final Color color = new Color(((IntegerValue) rgbValue).value(), true);
return JBUI.scale(new ColorIcon(16, 12, color, true));
}
}
} catch (Exception e) {
throw new EvaluateException(e.getMessage(), e);
}
}
return null;
}
Aggregations