Search in sources :

Example 1 with UnsupportedExpressionException

use of com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException in project intellij-community by JetBrains.

the class EvaluationDescriptor method calcValue.

public final Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
    try {
        PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(() -> {
        });
        EvaluationContextImpl thisEvaluationContext = getEvaluationContext(evaluationContext);
        SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
        PsiElement psiContext = ContextUtil.getContextElement(evaluationContext, position);
        ExpressionEvaluator evaluator = ReadAction.compute(() -> {
            PsiCodeFragment code = getEvaluationCode(thisEvaluationContext);
            try {
                return DebuggerUtilsEx.findAppropriateCodeFragmentFactory(getEvaluationText(), psiContext).getEvaluatorBuilder().build(code, position);
            } catch (UnsupportedExpressionException ex) {
                ExpressionEvaluator eval = CompilingEvaluatorImpl.create(myProject, code.getContext(), element -> code);
                if (eval != null) {
                    return eval;
                }
                throw ex;
            }
        });
        if (!thisEvaluationContext.getDebugProcess().isAttached()) {
            throw EvaluateExceptionUtil.PROCESS_EXITED;
        }
        StackFrameProxyImpl frameProxy = thisEvaluationContext.getFrameProxy();
        if (frameProxy == null) {
            throw EvaluateExceptionUtil.NULL_STACK_FRAME;
        }
        Value value = evaluator.evaluate(thisEvaluationContext);
        DebuggerUtilsEx.keep(value, thisEvaluationContext);
        myModifier = evaluator.getModifier();
        setLvalue(myModifier != null);
        return value;
    } catch (final EvaluateException ex) {
        throw new EvaluateException(ex.getLocalizedMessage(), ex);
    } catch (ObjectCollectedException ex) {
        throw EvaluateExceptionUtil.OBJECT_WAS_COLLECTED;
    }
}
Also used : StackFrameContext(com.intellij.debugger.engine.StackFrameContext) Modifier(com.intellij.debugger.engine.evaluation.expression.Modifier) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ContextUtil(com.intellij.debugger.engine.ContextUtil) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) ReadAction(com.intellij.openapi.application.ReadAction) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator) XValueModifier(com.intellij.xdebugger.frame.XValueModifier) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) JavaValueModifier(com.intellij.debugger.engine.JavaValueModifier) EvaluateExceptionUtil(com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil) JavaValue(com.intellij.debugger.engine.JavaValue) Nullable(org.jetbrains.annotations.Nullable) DebuggerContext(com.intellij.debugger.DebuggerContext) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) com.sun.jdi(com.sun.jdi) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) SourcePosition(com.intellij.debugger.SourcePosition) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) SourcePosition(com.intellij.debugger.SourcePosition) JavaValue(com.intellij.debugger.engine.JavaValue) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)

Aggregations

DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 DebuggerContext (com.intellij.debugger.DebuggerContext)1 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1 SourcePosition (com.intellij.debugger.SourcePosition)1 ContextUtil (com.intellij.debugger.engine.ContextUtil)1 JavaValue (com.intellij.debugger.engine.JavaValue)1 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)1 StackFrameContext (com.intellij.debugger.engine.StackFrameContext)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 EvaluateExceptionUtil (com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil)1 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)1 TextWithImports (com.intellij.debugger.engine.evaluation.TextWithImports)1 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)1 Modifier (com.intellij.debugger.engine.evaluation.expression.Modifier)1 UnsupportedExpressionException (com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 DebuggerUtilsEx (com.intellij.debugger.impl.DebuggerUtilsEx)1 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)1 ReadAction (com.intellij.openapi.application.ReadAction)1 Project (com.intellij.openapi.project.Project)1