@Override
  public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, final @NotNull ProcessingContext context) {
    final PsiElement parent = element.getParent();
    if (!(parent instanceof XmlAttribute attribute)) return PsiReference.EMPTY_ARRAY;
    final String localName = attribute.getLocalName();

    if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
      return PsiReference.EMPTY_ARRAY;
    }

    String text = ElementManipulators.getValueText(element);
    int offset = ElementManipulators.getValueTextRange(element).getStartOffset();

    final XmlTag tag = attribute.getParent();
    PsiReference[] refs = PsiReference.EMPTY_ARRAY;
    if (FOR_ATTR_NAME.equalsIgnoreCase(localName) || LABELLEDBY.equals(localName)) {
      refs = new PsiReference[] { new HtmlIdRefReference(element, offset)};
    } else
    if (MicrodataUtil.ITEM_REF.equalsIgnoreCase(localName)) {
      final XmlAttributeValue value = attribute.getValueElement();
      refs = MicrodataUtil.getReferencesForAttributeValue(value, (token, offset1) -> new HtmlIdRefReference(value, offset1));
    } else
    if(ColorReference.BG_COLOR_ATTR_NAME.equalsIgnoreCase(localName) ||
             ColorReference.COLOR_ATTR_NAME.equalsIgnoreCase(localName) ||
             ColorReference.TEXT_ATTR_NAME.equalsIgnoreCase(localName) ||
             ColorReference.LINK_ATTR_NAME.equalsIgnoreCase(localName) ||
             ColorReference.VLINK_ATTR_NAME.equalsIgnoreCase(localName) ||
             ColorReference.ALINK_ATTR_NAME.equalsIgnoreCase(localName)
    ) {
      refs = new PsiReference[] { new ColorReference(element, offset)};
    } else
    if(ContentTypeReference.TYPE_ATTR_NAME.equalsIgnoreCase(localName)) {
      refs = new PsiReference[] { new ContentTypeReference(element)};
    } else if (SizeReference.WIDTH_ATTR_NAME.equalsIgnoreCase(localName) ||
             SizeReference.HEIGHT_ATTR_NAME.equalsIgnoreCase(localName)) {
      refs = new PsiReference[] { new SizeReference(element, offset)};
    } else {
      if (HtmlUtil.ID_ATTRIBUTE_NAME.equalsIgnoreCase(localName)) {
        refs = new PsiReference[] { new HtmlIdSelfReference(element, offset) };
      }
      else if (NAME_ATTR_LOCAL_NAME.equalsIgnoreCase(localName)) {
        refs = new PsiReference[] { new AttributeValueSelfReference(element, offset)};
      }
      else if (HtmlUtil.CLASS_ATTRIBUTE_NAME.equalsIgnoreCase(localName)) {
        List<PsiReference> references = new ArrayList<>(1);
        int ndx = 0;
        for (String token : HtmlUtil.splitClassNames(text)) {
          ndx = text.indexOf(token, ndx);
          references.add(new AttributeValueSelfReference(element, new TextRange(offset + ndx, offset + ndx + token.length())));
          ndx += token.length();
        }
        references.toArray(refs = new PsiReference[references.size()]);
      }
      else if (SRC_ATTR_NAME.equalsIgnoreCase(localName) && SizeReference.IMAGE_TAG_NAME.equalsIgnoreCase(tag.getName())) {
        refs = PathReferenceManager.getInstance().createReferences(element, false, false, true, IMAGE_FILE_TYPES.get());
      }
      else if (("srcset".equalsIgnoreCase(localName) &&
                (SizeReference.IMAGE_TAG_NAME.equalsIgnoreCase(tag.getName()) || "source".equals(tag.getName())) &&
                  PsiTreeUtil.getChildOfType(element, OuterLanguageElement.class) == null))
      {
        final List<PsiReference> result = new ArrayList<>();
        int index = offset;
        for (String imageAndSize : StringUtil.tokenize(text, ",")) {
          int innerIndex = 0;
          while (innerIndex < imageAndSize.length() && Character.isWhitespace(imageAndSize.charAt(innerIndex))) innerIndex++;
          if (innerIndex < imageAndSize.length()) {
            final String image = imageAndSize.substring(innerIndex).split(" ", 2)[0];
            Collections.addAll(result, new FileReferenceSet(image, element, index + innerIndex, null, true, false,
                                                            IMAGE_FILE_TYPES.get()).getAllReferences());
          }
          index += imageAndSize.length() + 1;
        }
        refs = result.toArray(PsiReference.EMPTY_ARRAY);
      } else if (("data".equals(localName) && "object".equalsIgnoreCase(tag.getName())) ||
               ("poster".equals(localName) && "video".equalsIgnoreCase(tag.getName()))) {
        refs = PathReferenceManager.getInstance().createReferences(element, false, false, true);
      }
      else if ((HREF_ATTRIBUTE_NAME.equalsIgnoreCase(localName) || "to".equalsIgnoreCase(localName)) &&
               (StringUtil.endsWithIgnoreCase(tag.getName(), "link"))) {
        if (!HtmlUtil.hasHtmlPrefix(text)) {
          FileType[] fileTypes = findFileTypeByRel(tag.getAttributeValue("rel"));
          String typeValue = tag.getAttributeValue("type");
          fileTypes = fileTypes == null ? findFileType(typeValue == null ? "text/css" : typeValue) : fileTypes;
          if (!text.startsWith("data:")) {
            refs = PathReferenceManager.getInstance().createReferences(element, false, false, true, fileTypes);
          }
        }
      }
      else if (SRC_ATTR_NAME.equalsIgnoreCase(localName) && HtmlUtil.isScriptTag(tag)) {
        if (!HtmlUtil.hasHtmlPrefix(text)) {
          final String typeValue = tag.getAttributeValue("type");
          refs = PathReferenceManager.getInstance().createReferences(element, false, false, true, findFileType(typeValue));
        }
      }
      else if (!StringUtil.startsWithIgnoreCase(text, JAVASCRIPT_PREFIX) &&
               !GlobalPathReferenceProvider.startsWithAllowedPrefix(text)) {
        refs = PathReferenceManager.getInstance().createReferences(element, false, false, true);
      }
    }

    return refs;
  }
@Override
  public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, final @NotNull ProcessingContext context)