RunCurrentFileActionStatus (@NotNull AnActionEvent e, boolean resetCache) { Project project = Objects.requireNonNull(e.getProject()); VirtualFile[] files = FileEditorManager.getInstance(project).getSelectedFiles(); if (files.length == 1) { // There's only one visible editor, let's use the file from this editor, even if the editor is not in focus. PsiFile psiFile = PsiManager.getInstance(project).findFile(files[0]); if (psiFile == null) { String tooltip = ExecutionBundle.message("run.button.on.toolbar.tooltip.current.file.not.runnable"); return RunCurrentFileActionStatus.createDisabled(tooltip, myExecutor.getIcon()); } return getRunCurrentFileActionStatus(psiFile, resetCache, e); } Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null) { String tooltip = ExecutionBundle.message("run.button.on.toolbar.tooltip.current.file.no.focused.editor"); return RunCurrentFileActionStatus.createDisabled(tooltip, myExecutor.getIcon()); } PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); VirtualFile vFile = psiFile != null ? psiFile.getVirtualFile() : null; if (psiFile == null || vFile == null || !ArrayUtil.contains(vFile, files)) { // This is probably a special editor, like Python Console, which we don't want to use for the 'Run Current File' feature. String tooltip = ExecutionBundle.message("run.button.on.toolbar.tooltip.current.file.no.focused.editor"); return RunCurrentFileActionStatus.createDisabled(tooltip, myExecutor.getIcon()); } return getRunCurrentFileActionStatus(psiFile, resetCache, e); }