void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null) { return; } final FileEditor fileEditor = e.getData(PlatformCoreDataKeys.FILE_EDITOR); if (fileEditor == null) { return; } final SnippetEditorDecorator.ConfigurationPane config = SnippetEditorDecorator.ConfigurationPane.getJShellConfiguration(fileEditor); if (config == null) { return; } FileDocumentManager.getInstance().saveAllDocuments(); try { JShellHandler handler = config.getJShellHandler(); handler.toFront(); boolean hasDataToEvaluate = false; final Document document = editor.getDocument(); final TextRange selectedRange = EditorUtil.getSelectionInAnyMode(editor); if (selectedRange.isEmpty()) { final PsiElement snippet = getSnippetFromContext(project, e); if (snippet instanceof PsiJShellFile) { for (PsiElement element : ((PsiJShellFile)snippet).getExecutableSnippets()) { hasDataToEvaluate |= scheduleEval(handler, element.getText()); } } else if (snippet != null){ hasDataToEvaluate = scheduleEval(handler, snippet.getText()); } } else { hasDataToEvaluate = scheduleEval(handler, document.getText(selectedRange)); } if (!hasDataToEvaluate) { JShellDiagnostic.notifyInfo(JavaCompilerBundle.message("jshell.nothing.to.execute"), project); } } catch (Exception ex) { Logger.getInstance(ExecuteJShellAction.class).warn(ex); JShellDiagnostic.notifyError(ex, project); } }