use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class JavaValue method calculateEvaluationExpression.
@NotNull
@Override
public Promise<XExpression> calculateEvaluationExpression() {
if (evaluationExpression != null) {
return Promise.resolve(evaluationExpression);
} else {
final AsyncPromise<XExpression> res = new AsyncPromise<>();
myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {
@Override
public Priority getPriority() {
return Priority.HIGH;
}
@Override
public void contextAction() throws Exception {
evaluationExpression = ApplicationManager.getApplication().runReadAction(new Computable<XExpression>() {
@Override
public XExpression compute() {
try {
PsiElement psiExpression = getDescriptor().getTreeEvaluation(JavaValue.this, getDebuggerContext());
if (psiExpression != null) {
XExpression res = TextWithImportsImpl.toXExpression(new TextWithImportsImpl(psiExpression));
// add runtime imports if any
Set<String> imports = psiExpression.getUserData(DebuggerTreeNodeExpression.ADDITIONAL_IMPORTS_KEY);
if (imports != null && res != null) {
if (res.getCustomInfo() != null) {
imports.add(res.getCustomInfo());
}
res = new XExpressionImpl(res.getExpression(), res.getLanguage(), StringUtil.join(imports, ","), res.getMode());
}
return res;
}
} catch (EvaluateException e) {
LOG.info(e);
}
return null;
}
});
res.setResult(evaluationExpression);
}
});
return res;
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class LambdaAsyncMethodFilter method onReached.
@Override
public int onReached(SuspendContextImpl context, RequestHint hint) {
try {
StackFrameProxyImpl proxy = context.getFrameProxy();
if (proxy != null) {
Value lambdaReference = ContainerUtil.getOrElse(proxy.getArgumentValues(), myParamNo, null);
if (lambdaReference instanceof ObjectReference) {
final SourcePosition pos = myMethodFilter.getBreakpointPosition();
if (pos != null) {
Project project = context.getDebugProcess().getProject();
long lambdaId = ((ObjectReference) lambdaReference).uniqueID();
StepIntoBreakpoint breakpoint = new LambdaInstanceBreakpoint(project, lambdaId, pos, myMethodFilter);
ClassInstanceMethodFilter.setUpStepIntoBreakpoint(context, breakpoint, hint);
return RequestHint.RESUME;
}
}
}
} catch (EvaluateException ignore) {
}
return RequestHint.STOP;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class RequestHint method getNextStepDepth.
public int getNextStepDepth(final SuspendContextImpl context) {
try {
final StackFrameProxyImpl frameProxy = context.getFrameProxy();
// smart step feature stop check
if (myMethodFilter != null && frameProxy != null && !(myMethodFilter instanceof BreakpointStepMethodFilter) && myMethodFilter.locationMatches(context.getDebugProcess(), frameProxy.location()) && !isTheSameFrame(context)) {
myTargetMethodMatched = true;
return myMethodFilter.onReached(context, this);
}
if ((myDepth == StepRequest.STEP_OVER || myDepth == StepRequest.STEP_INTO) && myPosition != null) {
SourcePosition locationPosition = ContextUtil.getSourcePosition(context);
if (locationPosition != null) {
Integer resultDepth = ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
public Integer compute() {
if (myPosition.getFile().equals(locationPosition.getFile()) && isTheSameFrame(context) && !mySteppedOut) {
return isOnTheSameLine(locationPosition) ? myDepth : STOP;
}
return null;
}
});
if (resultDepth != null) {
return resultDepth.intValue();
}
}
}
// Now check filters
final DebuggerSettings settings = DebuggerSettings.getInstance();
if ((myMethodFilter != null || (settings.SKIP_SYNTHETIC_METHODS && !myIgnoreFilters)) && frameProxy != null) {
final Location location = frameProxy.location();
if (location != null) {
if (DebuggerUtils.isSynthetic(location.method())) {
return myDepth;
}
}
}
if (!myIgnoreFilters) {
if (settings.SKIP_GETTERS) {
boolean isGetter = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
PsiElement contextElement = ContextUtil.getContextElement(context);
return contextElement != null && DebuggerUtils.isInsideSimpleGetter(contextElement);
}
}).booleanValue();
if (isGetter) {
return StepRequest.STEP_OUT;
}
}
if (frameProxy != null) {
if (settings.SKIP_CONSTRUCTORS) {
final Location location = frameProxy.location();
if (location != null) {
final Method method = location.method();
if (method != null && method.isConstructor()) {
return StepRequest.STEP_OUT;
}
}
}
if (settings.SKIP_CLASSLOADERS) {
final Location location = frameProxy.location();
if (location != null && DebuggerUtilsEx.isAssignableFrom("java.lang.ClassLoader", location.declaringType())) {
return StepRequest.STEP_OUT;
}
}
}
for (ExtraSteppingFilter filter : ExtraSteppingFilter.EP_NAME.getExtensions()) {
try {
if (filter.isApplicable(context))
return filter.getStepRequestDepth(context);
} catch (Exception | AssertionError e) {
LOG.error(e);
}
}
}
// smart step feature
if (myMethodFilter != null && !mySteppedOut) {
return StepRequest.STEP_OUT;
}
} catch (VMDisconnectedException ignored) {
} catch (EvaluateException e) {
LOG.error(e);
}
return STOP;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class ClassLoadingUtils method defineClass.
public static void defineClass(String name, byte[] bytes, EvaluationContext context, DebugProcess process, ClassLoaderReference classLoader) throws EvaluateException {
try {
VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl) process.getVirtualMachineProxy();
Method defineMethod = ((ClassType) classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
StringReference nameObj = proxy.mirrorOf(name);
DebuggerUtilsEx.keep(nameObj, context);
process.invokeMethod(context, classLoader, defineMethod, Arrays.asList(nameObj, mirrorOf(bytes, context, process), proxy.mirrorOf(0), proxy.mirrorOf(bytes.length)));
} catch (Exception e) {
throw new EvaluateException("Error during class " + name + " definition: " + e, e);
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class DebuggerContextImpl method createEvaluationContext.
@Nullable
public EvaluationContextImpl createEvaluationContext() {
DebuggerManagerThreadImpl.assertIsManagerThread();
StackFrameProxyImpl frameProxy = getFrameProxy();
ObjectReference objectReference;
try {
objectReference = frameProxy != null ? frameProxy.thisObject() : null;
} catch (EvaluateException e) {
LOG.info(e);
objectReference = null;
}
SuspendContextImpl context = getSuspendContext();
return context != null ? new EvaluationContextImpl(context, frameProxy, objectReference) : null;
}
Aggregations