boolean (AnActionEvent event, boolean checkAvailable) { final Project project = event.getProject(); if (project == null) { // no active project return false; } Editor editor = event.getData(CommonDataKeys.EDITOR); if (editor == null) { return false; } // do we have an xml file? final PsiDocumentManager cem = PsiDocumentManager.getInstance(project); final PsiFile psiFile = cem.getPsiFile(editor.getDocument()); // this is also true for DTD documents... if (!(psiFile instanceof XmlFile) || psiFile.getLanguage() == StdFileTypes.DTD.getLanguage()) { return false; } return !checkAvailable || isEnabledAt((XmlFile)psiFile, editor.getCaretModel().getOffset()); }