PomTarget (DomElement parent, XmlName xmlName) { if (!(parent instanceof AntDomElement parentElement)) { return null; } final AntDomProject antDomProject = parentElement.getAntProject(); if (antDomProject == null) { return null; } final CustomAntElementsRegistry registry = CustomAntElementsRegistry.getInstance(antDomProject); final AntDomElement declaringElement = registry.findDeclaringElement(parentElement, xmlName); if (declaringElement == null) { return null; } DomTarget target = DomTarget.getTarget(declaringElement); if (target == null && declaringElement instanceof AntDomTypeDef typedef) { final GenericAttributeValue<PsiFileSystemItem> resource = typedef.getResource(); if (resource != null) { target = DomTarget.getTarget(declaringElement, resource); } if (target == null) { final GenericAttributeValue<PsiFileSystemItem> file = typedef.getFile(); if (file != null) { target = DomTarget.getTarget(declaringElement, file); } } } return target; }