diff --git a/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java b/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java index 108f65530532..3540ab780e3f 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java @@ -87,22 +87,13 @@ public abstract class CodeInsightAction extends AnAction { } final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); - if (file == null || !isValidForFile(project, editor, file)) { - presentation.setEnabled(false); - } - else { - presentation.setEnabled(isEnabledForFile(project, editor, file)); - } + presentation.setEnabled(file != null && isValidForFile(project, editor, file)); } protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) { return true; } - protected boolean isEnabledForFile(Project project, Editor editor, final PsiFile file) { - return true; - } - protected abstract CodeInsightActionHandler getHandler(); protected String getCommandName() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/ShowErrorDescriptionAction.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/ShowErrorDescriptionAction.java index dc0da992b94b..7f0799f3445b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/ShowErrorDescriptionAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/ShowErrorDescriptionAction.java @@ -45,10 +45,10 @@ public class ShowErrorDescriptionAction extends BaseCodeInsightAction implements } protected boolean isValidForFile(Project project, Editor editor, PsiFile file) { - return DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file); + return DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file) && isEnabledForFile(project, editor, file); } - protected boolean isEnabledForFile(Project project, Editor editor, PsiFile file) { + private static boolean isEnabledForFile(Project project, Editor editor, PsiFile file) { DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project); HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(editor.getDocument(), editor.getCaretModel().getOffset(), false);