void (@NotNull DomElement element, final @NotNull DomElementAnnotationHolder holder, @NotNull DomHighlightingHelper helper) { if (element instanceof AntDomProject project) { TargetResolver.validateDuplicateTargets(project.getContextAntProject(), new TargetResolver.TargetSink() { @Override public void duplicateTargetDetected(AntDomTarget existingTarget, AntDomTarget duplicatingTarget, String targetEffectiveName) { final AntDomProject existingTargetProj = existingTarget.getAntProject(); final AntDomProject duplucatingTargetProj = duplicatingTarget.getAntProject(); final boolean isFromDifferentFiles = !Comparing.equal(existingTargetProj, duplucatingTargetProj); if (project.equals(existingTargetProj)) { final String duplicatedMessage = isFromDifferentFiles? AntBundle.message("target.is.duplicated.in.imported.file", targetEffectiveName, duplucatingTargetProj != null? duplucatingTargetProj.getName() : "") : AntBundle.message("target.is.duplicated", targetEffectiveName); holder.createProblem(existingTarget.getName(), duplicatedMessage); } if (project.equals(duplucatingTargetProj)) { final String duplicatedMessage = isFromDifferentFiles? AntBundle.message("target.is.duplicated.in.imported.file", targetEffectiveName, existingTargetProj != null? existingTargetProj.getName() : "") : AntBundle.message("target.is.duplicated", targetEffectiveName); holder.createProblem(duplicatingTarget.getName(), duplicatedMessage); } } }); } }