void (@NotNull PsiJavaModule module, @NotNull PsiFile file, @NotNull Consumer<? super HighlightInfo.Builder> errorSink) { Module host = ModuleUtilCore.findModuleForFile(file); if (host == null) { return; } List<PsiProvidesStatement> provides = JBIterable.from(module.getProvides()).toList(); if (!provides.isEmpty()) { Set<String> exports = JBIterable.from(module.getExports()).map(PsiPackageAccessibilityStatement::getPackageName).filter(Objects::nonNull).toSet(); Set<String> uses = JBIterable.from(module.getUses()).map(st -> qName(st.getClassReference())).filter(Objects::nonNull).toSet(); for (PsiProvidesStatement statement : provides) { PsiJavaCodeReferenceElement ref = statement.getInterfaceReference(); if (ref != null) { PsiElement target = ref.resolve(); if (target instanceof PsiClass && ModuleUtilCore.findModuleForFile(target.getContainingFile()) == host) { String className = qName(ref); String packageName = StringUtil.getPackageName(className); if (!exports.contains(packageName) && !uses.contains(className)) { String message = JavaErrorBundle.message("module.service.unused"); HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(range(ref)).descriptionAndTooltip(message); ModCommandAction action1 = new AddExportsDirectiveFix(module, packageName, ""); info.registerFix(action1, null, null, null, null); ModCommandAction action = new AddUsesDirectiveFix(module, className); info.registerFix(action, null, null, null, null); errorSink.accept(info); } } } } } }