private void buildProvidesReferences(@NotNull PsiJavaModule javaModule) {
    for (PsiProvidesStatement statement : javaModule.getProvides()) {
      final PsiJavaCodeReferenceElement interfaceReference = statement.getInterfaceReference();
      final PsiReferenceList implementationList = statement.getImplementationList();
      if (interfaceReference != null && implementationList != null) {
        final PsiElement providerInterface = interfaceReference.resolve();
        if (providerInterface instanceof PsiClass) {
          final RefElement refInterface = getRefManager().getReference(providerInterface);
          if (refInterface instanceof RefClassImpl) {
            if (myServiceInterfaces == null) myServiceInterfaces = new HashSet<>();
            myServiceInterfaces.add((RefClass)refInterface);

            for (PsiJavaCodeReferenceElement implementationReference : implementationList.getReferenceElements()) {
              final PsiElement implementationClass = implementationReference.resolve();
              if (implementationClass instanceof PsiClass psiClass) {
                RefElement refTargetElement = null;
                PsiElement targetElement = JavaServiceUtil.findServiceProviderMethod(psiClass);

                if (targetElement == null) {
                  final RefElement refElement = getRefManager().getReference(psiClass);
                  if (refElement instanceof RefClassImpl refClass) {
                    refClass.initializeIfNeeded();
                    if (myServiceImplementations == null) myServiceImplementations = new HashSet<>();
                    myServiceImplementations.add(refClass);

                    final RefMethod refConstructor = refClass.getDefaultConstructor();
                    if (refConstructor != null) {
                      final PsiElement constructorElement = refConstructor.getPsiElement();
                      if (constructorElement instanceof PsiModifierListOwner && ((PsiModifierListOwner)constructorElement).hasModifierProperty(PsiModifier.PUBLIC)) {
                        refTargetElement = refConstructor;
                        targetElement = constructorElement;
                      }
                    }
                  }
                }
                if (targetElement == null) {
                  targetElement = psiClass;
                }
                if (refTargetElement == null) {
                  refTargetElement = getRefManager().getReference(targetElement);
                }
                if (refTargetElement != null) {
                  final UDeclaration element = UastContextKt.toUElement(providerInterface, UDeclaration.class);
                  if (element != null) {
                    ((RefClassImpl)refInterface).addReference(refTargetElement, targetElement, element, false, true, null);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
private void buildProvidesReferences(@NotNull PsiJavaModule javaModule)