Cache (final Project project) { final Cache cache = new Cache(); try { String className = getClassName(); Pair<PsiElement, PsiType> psiClassAndType = DebuggerUtilsImpl.getPsiClassAndType(className, project); PsiElement context = psiClassAndType.first; if (context == null) { throw EvaluateExceptionUtil.createEvaluateException(JavaDebuggerBundle.message("evaluation.error.cannot.find.source", className)); } 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; 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; } else { throw ex; } } } catch (EvaluateException e) { cache.myException = e; } myCache = new SoftReference<>(cache); return cache; }