use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class RuntimeTypeEvaluator method evaluate.
@Nullable
protected PsiType evaluate(final EvaluationContextImpl evaluationContext) throws EvaluateException {
Project project = evaluationContext.getProject();
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable<ExpressionEvaluator>() {
public ExpressionEvaluator compute() throws EvaluateException {
return EvaluatorBuilderImpl.getInstance().build(myElement, position);
}
});
final Value value = evaluator.evaluate(evaluationContext);
if (value != null) {
return getCastableRuntimeType(project, value);
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.surrounded.expression.null"));
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class BasicStepMethodFilter method locationMatches.
public boolean locationMatches(final DebugProcessImpl process, final Location location) throws EvaluateException {
Method method = location.method();
String name = method.name();
if (!myTargetMethodName.equals(name)) {
if (DebuggerUtilsEx.isLambdaName(name)) {
SourcePosition position = process.getPositionManager().getSourcePosition(location);
return ReadAction.compute(() -> {
PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
if (psiMethod instanceof PsiLambdaExpression) {
PsiType type = ((PsiLambdaExpression) psiMethod).getFunctionalInterfaceType();
PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(type);
if (type != null && interfaceMethod != null && myTargetMethodName.equals(interfaceMethod.getName())) {
try {
return InheritanceUtil.isInheritor(type, myDeclaringClassName.getName(process).replace('$', '.'));
} catch (EvaluateException e) {
LOG.info(e);
}
}
}
return false;
});
}
return false;
}
if (myTargetMethodSignature != null && !signatureMatches(method, myTargetMethodSignature.getName(process))) {
return false;
}
if (method.isBridge()) {
// skip bridge methods
return false;
}
return DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ClassInstanceMethodFilter method onReached.
@Override
public int onReached(SuspendContextImpl context, RequestHint hint) {
StackFrameProxyImpl proxy = context.getFrameProxy();
if (proxy != null) {
try {
ObjectReference reference = proxy.thisObject();
if (reference != null) {
StepIntoBreakpoint breakpoint = DebuggerManagerEx.getInstanceEx(context.getDebugProcess().getProject()).getBreakpointManager().addStepIntoBreakpoint(myMethodFilter);
if (breakpoint != null) {
breakpoint.addInstanceFilter(reference.uniqueID());
breakpoint.setInstanceFiltersEnabled(true);
setUpStepIntoBreakpoint(context, breakpoint, hint);
return RequestHint.RESUME;
}
}
} catch (EvaluateException ignored) {
}
}
return RequestHint.STOP;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class LocalVariablesUtil method setValue.
public static void setValue(StackFrame frame, int slot, Value value) throws EvaluateException {
try {
final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
final VirtualMachine vm = frame.virtualMachine();
final Method stateMethod = vm.getClass().getDeclaredMethod("state");
stateMethod.setAccessible(true);
Object slotInfoArray = createSlotInfoArraySet(slot, value);
Object ps;
final Object vmState = stateMethod.invoke(vm);
synchronized (vmState) {
ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
}
ourWaitForReplyMethodSet.invoke(null, vm, ps);
} catch (Exception e) {
throw new EvaluateException("Unable to set value", e);
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class StackFrameProxyImpl method getValue.
public Value getValue(LocalVariableProxyImpl localVariable) throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
InvalidStackFrameException error = null;
for (int attempt = 0; attempt < 2; attempt++) {
try {
Map<LocalVariable, Value> values = getAllValues();
LocalVariable variable = localVariable.getVariable();
if (values.containsKey(variable)) {
return values.get(variable);
} else {
// try direct get
return getStackFrame().getValue(variable);
}
} catch (InvalidStackFrameException e) {
error = e;
clearCaches();
} catch (InternalException e) {
if (e.errorCode() == 35 || e.errorCode() == 101) {
throw new EvaluateException(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()), e);
} else
throw e;
}
}
throw new EvaluateException(error.getMessage(), error);
}
Aggregations