void (@NotNull PsiElement element, @NotNull XEvaluationCallback callback) { myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext(), myStackFrame.getStackFrameProxy().threadProxy()) { @Override public Priority getPriority() { return Priority.NORMAL; } @Override public void threadAction(@NotNull SuspendContextImpl suspendContext) { if (DebuggerUIUtil.isObsolete(callback)) { return; } JavaDebugProcess process = myDebugProcess.getXdebugProcess(); if (process == null) { callback.errorOccurred(JavaDebuggerBundle.message("error.no.debug.process")); return; } DebuggerContextImpl debuggerContext = myStackFrame.getFrameDebuggerContext(getDebuggerContext()); EvaluationContextImpl evalContext = debuggerContext.createEvaluationContext(); if (evalContext == null) { callback.errorOccurred(JavaDebuggerBundle.message("error.context.not.available")); return; } try { Project project = myDebugProcess.getProject(); Ref<TextWithImportsImpl> text = new Ref<>(); ExpressionEvaluator evaluator = ReadAction.compute(() -> { text.set(new TextWithImportsImpl(element)); CodeFragmentFactory factory = DebuggerUtilsEx.getCodeFragmentFactory(element, null); try { return factory.getEvaluatorBuilder().build(element, ContextUtil.getSourcePosition(evalContext)); } catch (UnsupportedExpressionException ex) { PsiElement context = PositionUtil.getContextElement(debuggerContext); ExpressionEvaluator eval = CompilingEvaluatorImpl.create(project, context, e -> factory.createCodeFragment(text.get(), context, project)); if (eval != null) { return eval; } throw ex; } }); WatchItemDescriptor descriptor = new WatchItemDescriptor(project, text.get()) { @Override protected @NotNull ExpressionEvaluator getEvaluator(EvaluationContextImpl evaluationContext) { return evaluator; } }; descriptor.setContext(evalContext); callback.evaluated(JavaValue.create(null, descriptor, evalContext, process.getNodeManager(), true)); } catch (EvaluateException e) { callback.errorOccurred(e.getMessage()); } } }); }