isEnabledForFile() removed

This commit is contained in:
Dmitry Avdeev
2010-09-02 16:41:46 +04:00
parent 3eea77f579
commit abda833b86
2 changed files with 3 additions and 12 deletions
@@ -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() {
@@ -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);