private static void createModuleFixes(@NotNull PsiPolyVariantReference reference,
                                        @NotNull Module currentModule,
                                        @NotNull DependencyScope scope,
                                        @NotNull List<? super @NotNull LocalQuickFix> result) {
    ProjectFileIndex index = ProjectRootManager.getInstance(currentModule.getProject()).getFileIndex();
    List<PsiElement> targets = Stream.of(reference.multiResolve(true))
      .map(ResolveResult::getElement)
      .filter(Objects::nonNull).toList();

    PsiElement statement = reference.getElement().getParent();
    boolean exported = statement instanceof PsiRequiresStatement &&
                       ((PsiRequiresStatement)statement).hasModifierProperty(PsiModifier.TRANSITIVE);

    Set<Module> modules = targets.stream()
      .map(e -> !(e instanceof PsiCompiledElement) ? e.getContainingFile() : null)
      .map(f -> f != null ? f.getVirtualFile() : null)
      .filter(vf -> vf != null && index.isInSource(vf))
      .map(vf -> index.getModuleForFile(vf))
      .filter(m -> m != null && m != currentModule)
      .collect(Collectors.toSet());
    if (!modules.isEmpty()) {
      result.add(0, new AddModuleDependencyFix(reference, currentModule, modules, scope, exported));
    }

    Set<Library> libraries = targets.stream()
      .map(e -> e instanceof LightJavaModule ? ((LightJavaModule)e).getRootVirtualFile() : null)
      .flatMap(vf -> vf != null ? index.getOrderEntriesForFile(vf).stream() : Stream.empty())
      .map(e -> e instanceof LibraryOrderEntry ? ((LibraryOrderEntry)e).getLibrary() : null)
      .filter(Objects::nonNull)
      .collect(Collectors.toSet());
    if (!libraries.isEmpty()) {
      result.add(new AddLibraryDependencyFix(reference, currentModule,
                                             ContainerUtil.map2Map(libraries, library -> Pair.create(library, "")), scope, exported));
    }
  }
private static void createModuleFixes(@NotNull PsiPolyVariantReference reference,
                                        @NotNull Module currentModule,
                                        @NotNull DependencyScope scope,
                                        @NotNull List<? super @NotNull LocalQuickFix> result)