private static @Nullable ReferenceType determineReferenceType(PsiElement element) {
    final XmlAttribute attribute = PsiTreeUtil.getParentOfType(element, XmlAttribute.class);
    if (attribute == null) {
      return null;
    }
    final XmlTag tag = attribute.getParent();
    final String localName = tag.getLocalName();
    final String attributeLocalName = attribute.getLocalName();

    return switch (attributeLocalName) {
      case SchemaReferencesProvider.REF_ATTR_NAME, SchemaReferencesProvider.SUBSTITUTION_GROUP_ATTR_NAME -> switch (localName) {
        case SchemaReferencesProvider.GROUP_TAG_NAME -> ReferenceType.GroupReference;
        case SchemaReferencesProvider.ATTRIBUTE_GROUP_TAG_NAME -> ReferenceType.AttributeGroupReference;
        case SchemaReferencesProvider.ELEMENT_TAG_NAME -> ReferenceType.ElementReference;
        case SchemaReferencesProvider.ATTRIBUTE_TAG_NAME -> ReferenceType.AttributeReference;
        default -> null;
      };
      case SchemaReferencesProvider.TYPE_ATTR_NAME, SchemaReferencesProvider.BASE_ATTR_NAME, 
        SchemaReferencesProvider.MEMBER_TYPES_ATTR_NAME, SchemaReferencesProvider.ITEM_TYPE_ATTR_NAME -> ReferenceType.TypeReference;
      default -> null;
    };
  }
private static @Nullable ReferenceType determineReferenceType(PsiElement element)