Promise<String> (DataContext dataContext, XDebugSession session) { final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor == null) { return Promises.resolvedPromise(null); } String text = editor.getSelectionModel().getSelectedText(); if (text != null) { return Promises.resolvedPromise(StringUtil.nullize(text, true)); } XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator(); if (evaluator != null) { return XDebuggerEvaluateActionHandler.getExpressionText(evaluator, editor.getProject(), editor).then(s -> StringUtil.nullize(s, true)); } return Promises.resolvedPromise(null); }