From 205fc517dfec78350562a0f40f43fe400222aa56 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 11 Feb 2016 13:26:11 +0300 Subject: [PATCH] IDEA-151452 any exception with condition constantly says "Cannot find source class for current stack frame" --- .../intellij/debugger/engine/JavaValueModifier.java | 13 ++++++++----- .../evaluation/expression/EvaluatorBuilderImpl.java | 11 ++++------- .../debugger/ui/breakpoints/Breakpoint.java | 12 ++++++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java index 8bf95abd4b03..4be3d1a80986 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValueModifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import com.intellij.debugger.impl.DebuggerSession; import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl; import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl; import com.intellij.openapi.progress.util.ProgressWindowWithNotification; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.xdebugger.frame.XValueModifier; import com.sun.jdi.*; @@ -216,12 +217,14 @@ public abstract class JavaValueModifier extends XValueModifier { public void threadAction() { ExpressionEvaluator evaluator; try { - evaluator = DebuggerInvocationUtil - .commitAndRunReadAction(evaluationContext.getProject(), new EvaluatingComputable() { + final Project project = evaluationContext.getProject(); + evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable() { public ExpressionEvaluator compute() throws EvaluateException { return EvaluatorBuilderImpl - .build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression), ContextUtil.getContextElement(evaluationContext), - ContextUtil.getSourcePosition(evaluationContext)); + .build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression), + ContextUtil.getContextElement(evaluationContext), + ContextUtil.getSourcePosition(evaluationContext), + project); } }); diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index 4d27346b6c41..3ae196e8d84b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -59,13 +59,10 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { return ourInstance; } - public static ExpressionEvaluator build(final TextWithImports text, @Nullable PsiElement contextElement, final SourcePosition position) throws EvaluateException { - if (contextElement == null) { - throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS; - } - - final Project project = contextElement.getProject(); - + public static ExpressionEvaluator build(final TextWithImports text, + @Nullable PsiElement contextElement, + @Nullable final SourcePosition position, + @NotNull Project project) throws EvaluateException { CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, contextElement); PsiCodeFragment codeFragment = factory.createCodeFragment(text, contextElement, project); if (codeFragment == null) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java index 171f7f25a4cf..90a21b251329 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/Breakpoint.java @@ -269,10 +269,13 @@ public abstract class Breakpoint

implements final TextWithImports expressionToEvaluate = getLogMessage(); try { - ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(getProject(), new EvaluatingComputable() { + ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable() { @Override public ExpressionEvaluator compute() throws EvaluateException { - return EvaluatorBuilderImpl.build(expressionToEvaluate, ContextUtil.getContextElement(context), ContextUtil.getSourcePosition(context)); + return EvaluatorBuilderImpl.build(expressionToEvaluate, + ContextUtil.getContextElement(context), + ContextUtil.getSourcePosition(context), + myProject); } }); final Value eval = evaluator.evaluate(context); @@ -353,7 +356,8 @@ public abstract class Breakpoint

implements } try { - ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(context.getProject(), new EvaluatingComputable() { + final Project project = context.getProject(); + ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable() { @Override public ExpressionEvaluator compute() throws EvaluateException { final SourcePosition contextSourcePosition = ContextUtil.getSourcePosition(context); @@ -364,7 +368,7 @@ public abstract class Breakpoint

implements if (contextPsiElement == null) { contextPsiElement = getEvaluationElement(); // as a last resort } - return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition); + return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition, project); } }); Object value = UnBoxingEvaluator.unbox(evaluator.evaluate(context), context);