private void visit(@NotNull PsiFile file, @NotNull ProjectFileIndex fileIndex, @NotNull PsiManager psiManager) {
    final FileViewProvider viewProvider = file.getViewProvider();
    if (viewProvider.getBaseLanguage() != file.getLanguage()) return;

    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    final VirtualFile virtualFile = file.getVirtualFile();
    if (indicator != null) {
      if (indicator.isCanceled()) {
        throw new ProcessCanceledException();
      }
      indicator.setText(AnalysisBundle.message("package.dependencies.progress.text"));

      if (virtualFile != null) {
        indicator.setText2(getRelativeToProjectPath(virtualFile));
      }
      if ( myTotalFileCount > 0 && myStarted.add(virtualFile)) {
        indicator.setFraction(((double)++ myFileCount) / myTotalFileCount);
      }
    }

    final boolean isInLibrary =  virtualFile == null || fileIndex.isInLibrary(virtualFile);
    final Set<PsiFile> collectedDeps = new HashSet<>();
    collectedDeps.add(file);
    int depth = 0;
    Set<PsiFile> processed = new HashSet<>();
    do {
      if (depth++ > getTransitiveBorder()) return;
      for (PsiFile psiFile : new HashSet<>(collectedDeps)) {
        final VirtualFile vFile = psiFile.getVirtualFile();
        if (vFile != null) {

          if (indicator != null) {
            indicator.setText2(getRelativeToProjectPath(vFile));
          }

          if (!isInLibrary && fileIndex.isInLibrary(vFile)) {
            processed.add(psiFile);
          }
        }
        if (processed.add(psiFile)) {
          Set<PsiFile> found = new HashSet<>();
          analyzeFileDependencies(psiFile, (place, dependency) -> {
            PsiFile dependencyFile = dependency.getContainingFile();
            if (dependencyFile != null) {
              if (viewProvider == dependencyFile.getViewProvider()) return;
              final VirtualFile depFile = dependencyFile.getVirtualFile();
              if (depFile != null
                  && (fileIndex.isInContent(depFile) || fileIndex.isInLibrary(depFile))
                  && (myTargetScope == null || myTargetScope.contains(depFile))) {
                final PsiElement navigationElement = dependencyFile.getNavigationElement();
                PsiFile navigationFile = navigationElement instanceof PsiFile ? (PsiFile)navigationElement : dependencyFile;
                if (navigationFile.isPhysical()) {
                  found.add(navigationFile);
                }
              }
            }
          });
          Set<PsiFile> deps = getDependencies().computeIfAbsent(file, __ -> new HashSet<>());
          deps.addAll(found);

          getDirectDependencies().put(psiFile, new HashSet<>(found));

          collectedDeps.addAll(found);

          psiManager.dropResolveCaches();
          InjectedLanguageManager.getInstance(file.getProject()).dropFileCaches(psiFile);
        }
      }
      collectedDeps.removeAll(processed);
    }
    while (isTransitive() && !collectedDeps.isEmpty());
  }
private void visit(@NotNull PsiFile file, @NotNull ProjectFileIndex fileIndex, @NotNull PsiManager psiManager)