void () { final DependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), myForwardScope); builder.setTotalFileCount(myTotalFileCount); builder.analyze(); subtractScope(builder, getScope()); final PsiManager psiManager = PsiManager.getInstance(getProject()); psiManager.runInBatchFilesMode(() -> { final int fileCount = getScope().getFileCount(); final boolean includeTestSource = getScope().isIncludeTestSource(); getScope().accept(virtualFile -> { if (!includeTestSource && TestSourcesFilter.isTestSources(virtualFile, getProject())) { return true; } ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { if (indicator.isCanceled()) { throw new ProcessCanceledException(); } indicator.setText(AnalysisBundle.message("package.dependencies.progress.text")); indicator.setText2(getRelativeToProjectPath(virtualFile)); if (fileCount > 0) { indicator.setFraction(((double)++myFileCount) / myTotalFileCount); } } ApplicationManager.getApplication().runReadAction(() -> { PsiFile file = psiManager.findFile(virtualFile); if (file != null) { final PsiElement navigationElement = file.getNavigationElement(); if (navigationElement instanceof PsiFile) { file = (PsiFile)navigationElement; } final Map<PsiFile, Set<PsiFile>> dependencies = builder.getDependencies(); for (final PsiFile psiFile : dependencies.keySet()) { if (dependencies.get(psiFile).contains(file)) { Set<PsiFile> fileDeps = getDependencies().computeIfAbsent(file, __ -> new HashSet<>()); fileDeps.add(psiFile); } } psiManager.dropResolveCaches(); } }); return true; }); return null; }); }