BuildTask (final String taskName) { final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile); final AntDomProject domProject = AntSupport.getAntDomProject(psiFile); if (domProject != null) { final AntDomTarget antTarget = domProject.findDeclaredTarget(myName); if (antTarget != null) { final Ref<AntDomElement> result = new Ref<>(null); antTarget.accept(new AntDomRecursiveVisitor() { @Override public void visitAntDomElement(AntDomElement element) { if (result.get() != null) { return; } if (element.isTask() && taskName.equals(element.getXmlElementName())) { result.set(element); return; } super.visitAntDomElement(element); } }); final AntDomElement task = result.get(); if (task != null) { return new BuildTask(this, task); } } } return null; }