boolean (@NotNull InspectionManager manager, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { GlobalJavaInspectionContext javaInspectionContext = globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT); if (javaInspectionContext != null) { final RefManager refManager = globalContext.getRefManager(); Map<String, Set<String>> to2FromCandidatePairsToRemove = new HashMap<>(); for (Module module : ModuleManager.getInstance(refManager.getProject()).getModules()) { RefModule refModule = refManager.getRefModule(module); CommonProblemDescriptor[] descriptions = problemDescriptionsProcessor.getDescriptions(Objects.requireNonNull(refModule)); if (descriptions != null) { String sourceModuleName = module.getName(); for (CommonProblemDescriptor description : descriptions) { QuickFix<?>[] fixes = description.getFixes(); if (fixes != null) { Arrays.stream(fixes) .map(fix -> fix instanceof RemoveModuleDependencyFix ? ((RemoveModuleDependencyFix)fix).myDependency : null) .filter(Objects::nonNull) .forEach(targetName -> to2FromCandidatePairsToRemove.computeIfAbsent(targetName, k -> new HashSet<>()).add(sourceModuleName)); } } } } refManager.iterate(new RefJavaVisitor() { @Override public void visitClass(@NotNull RefClass aClass) { if (aClass.isAnonymous() || aClass.isLocalClass()) return; RefModule toModule = aClass.getModule(); if (toModule == null) return; String toModuleName = toModule.getName(); if (!to2FromCandidatePairsToRemove.containsKey(toModuleName)) return; if (PsiModifier.PRIVATE.equals(aClass.getAccessModifier())) return; javaInspectionContext.enqueueClassUsagesProcessor(aClass, reference -> { PsiFile containingFile = reference.getElement().getContainingFile(); if (!(containingFile instanceof PsiClassOwner)) { RefElement refFrom = refManager.getReference(containingFile); if (refFrom != null) { RefModule fromModule = refFrom.getModule(); if (fromModule != null) { CommonProblemDescriptor[] descriptions = problemDescriptionsProcessor.getDescriptions(fromModule); if (descriptions != null) { LinkedHashSet<CommonProblemDescriptor> problemDescriptors = new LinkedHashSet<>(Arrays.asList(descriptions)); boolean removed = problemDescriptors.removeIf(descriptor -> { QuickFix<?>[] fixes = descriptor.getFixes(); return fixes != null && ContainerUtil.exists(fixes, fix -> fix instanceof RemoveModuleDependencyFix && toModuleName.equals(((RemoveModuleDependencyFix)fix).myDependency)); }); if (removed) { problemDescriptionsProcessor.ignoreElement(fromModule); if (!problemDescriptors.isEmpty()) { problemDescriptionsProcessor.addProblemElement(fromModule, problemDescriptors.toArray(CommonProblemDescriptor[]::new)); } } } } } } return true; }); } }); } return false; }