mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-174238 New debugger feature: Collection filter expression does not accept groovy
This commit is contained in:
@@ -16,9 +16,15 @@
|
||||
package com.intellij.debugger.ui.tree.render;
|
||||
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.engine.evaluation.*;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentFactory;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
||||
import com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsImpl;
|
||||
import com.intellij.debugger.ui.impl.watch.CompilingEvaluatorImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
@@ -26,12 +32,6 @@ import com.intellij.reference.SoftReference;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class CachedEvaluator {
|
||||
private final CodeFragmentFactory myDefaultFragmentFactory;
|
||||
|
||||
public CachedEvaluator() {
|
||||
myDefaultFragmentFactory = new CodeFragmentFactoryContextWrapper(DefaultCodeFragmentFactory.getInstance());
|
||||
}
|
||||
|
||||
private static class Cache {
|
||||
protected ExpressionEvaluator myEvaluator;
|
||||
protected EvaluateException myException;
|
||||
@@ -60,16 +60,26 @@ public abstract class CachedEvaluator {
|
||||
final Cache cache = new Cache();
|
||||
try {
|
||||
Pair<PsiElement, PsiType> psiClassAndType = DebuggerUtilsImpl.getPsiClassAndType(getClassName(), project);
|
||||
if (psiClassAndType.first == null) {
|
||||
PsiElement context = psiClassAndType.first;
|
||||
if (context == null) {
|
||||
throw EvaluateExceptionUtil.CANNOT_FIND_SOURCE_CLASS;
|
||||
}
|
||||
cache.myPsiChildrenExpression = null;
|
||||
JavaCodeFragment codeFragment =
|
||||
myDefaultFragmentFactory.createCodeFragment(myReferenceExpression, overrideContext(psiClassAndType.first), project);
|
||||
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(myReferenceExpression, context);
|
||||
JavaCodeFragment codeFragment = factory.createCodeFragment(myReferenceExpression, overrideContext(context), project);
|
||||
codeFragment.setThisType(psiClassAndType.second);
|
||||
DebuggerUtils.checkSyntax(codeFragment);
|
||||
cache.myPsiChildrenExpression = codeFragment instanceof PsiExpressionCodeFragment ? ((PsiExpressionCodeFragment)codeFragment).getExpression() : null;
|
||||
cache.myEvaluator = myDefaultFragmentFactory.getEvaluatorBuilder().build(codeFragment, null);
|
||||
|
||||
try {
|
||||
cache.myEvaluator = factory.getEvaluatorBuilder().build(codeFragment, null);
|
||||
}
|
||||
catch (UnsupportedExpressionException ex) {
|
||||
ExpressionEvaluator eval = CompilingEvaluatorImpl.create(project, context, element -> codeFragment);
|
||||
if (eval != null) {
|
||||
cache.myEvaluator = eval;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
cache.myException = e;
|
||||
|
||||
Reference in New Issue
Block a user