void (@NotNull AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = e.getProject(); if (project != null) { final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (files != null) { for (VirtualFile file : files) { final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (!(psiFile instanceof XmlFile xmlFile)) { continue; } final XmlDocument document = xmlFile.getDocument(); if (document == null) { continue; } final XmlTag rootTag = document.getRootTag(); if (rootTag == null) { continue; } if (!"project".equals(rootTag.getName())) { continue; } if (AntConfigurationBase.getInstance(project).getAntBuildFile(psiFile) != null) { continue; } // found at least one candidate file enable(presentation); return; } } } disable(presentation); }