@NotNull
  private Collection<PsiReference> getUnresolvedReferencesToAnnotate(PsiReference[] references) {
    Map<TextRange, PsiReference> unresolvedReferences = new HashMap<>();
    for (PsiReference reference : references) {
      if (!needToCheckRef(reference)) {
        continue;
      }

      if (!checkRanges()) {
        if (XmlHighlightVisitor.hasBadResolve(reference, false)) {
          unresolvedReferences.put(reference.getRangeInElement(), reference);
        }
        continue;
      }

      TextRange elementRange = reference.getElement().getTextRange();
      if (elementRange == null || elementRange.isEmpty()) {
        continue;
      }

      TextRange rangeInElement = reference.getRangeInElement();
      if (unresolvedReferences.containsKey(rangeInElement) && unresolvedReferences.get(rangeInElement) == null) {
        continue;
      }

      if (XmlHighlightVisitor.hasBadResolve(reference, true)) {
        if (!reference.isSoft()) {
          unresolvedReferences.putIfAbsent(rangeInElement, reference);
        }
      }
      else {
        // the specific range has at least one resolved reference
        // no need to check any other references from that range
        unresolvedReferences.put(rangeInElement, null);
      }
    }

    return ContainerUtil.skipNulls(unresolvedReferences.values());
  }
@NotNull
  private Collection<PsiReference> getUnresolvedReferencesToAnnotate(PsiReference[] references)