void () { final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(getProject()).getFileIndex(); getScope().accept(new PsiRecursiveElementVisitor() { @Override public void visitFile(@NotNull PsiFile file) { if (file instanceof PsiJavaFile psiJavaFile) { if (getScope().contains(psiJavaFile)) { final PsiPackage aPackage = findPackage(psiJavaFile.getPackageName()); if (aPackage != null) { myPackages.put(psiJavaFile.getPackageName(), aPackage); } } final Set<PsiPackage> packs = getPackageHierarchy(psiJavaFile.getPackageName()); final ForwardDependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), new AnalysisScope(psiJavaFile)); builder.setTotalFileCount(getScope().getFileCount()); builder.setInitialFileCount(++myFileCount); builder.analyze(); final Set<PsiFile> psiFiles = builder.getDependencies().get(psiJavaFile); if (psiFiles == null) return; for (PsiPackage pack : packs) { Set<PsiPackage> pack2Packages = myPackageDependencies.computeIfAbsent(pack, __ -> new HashSet<>()); for (PsiFile psiFile : psiFiles) { if (!(psiFile instanceof PsiJavaFile) || !projectFileIndex.isInSourceContent(psiFile.getVirtualFile()) || !getScope().contains(psiFile)) { continue; } // construct dependent packages final String packageName = ((PsiJavaFile)psiFile).getPackageName(); //do not depend on parent packages if (packageName.startsWith(pack.getQualifiedName())) { continue; } final PsiPackage depPackage = findPackage(packageName); if (depPackage == null) { //not from analyze scope continue; } pack2Packages.add(depPackage); constractFilesInDependenciesPackagesMap(pack, depPackage, psiFile, myFilesInDependentPackages); constractFilesInDependenciesPackagesMap(depPackage, pack, psiJavaFile, myBackwardFilesInDependentPackages); constractWholeDependenciesMap(psiJavaFile, psiFile); } } } } }); ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { ProgressIndicatorUtils.checkCancelledEvenWithPCEDisabled(indicator); indicator.setText(JavaBundle.message("cyclic.dependencies.progress.text")); indicator.setText2(""); indicator.setIndeterminate(true); } myCyclicDependencies = getCycles(myPackages.values()); }