@Override
  public CommonProblemDescriptor @Nullable [] checkElement(@NotNull RefEntity refEntity,
                                                           @NotNull AnalysisScope scope,
                                                           @NotNull InspectionManager manager,
                                                           @NotNull GlobalInspectionContext globalContext) {
    if (refEntity instanceof RefJavaModule refJavaModule) {
      RefModule refModule = refJavaModule.getModule();
      PsiJavaModule psiJavaModule = refJavaModule.getPsiElement();
      if (refModule != null && psiJavaModule != null) {
        Set<String> moduleImportedPackages = refModule.getUserData(IMPORTED_JAVA_PACKAGES);
        if (moduleImportedPackages != null) {
          List<RefJavaModule.RequiredModule> requiredModules = refJavaModule.getRequiredModules();
          if (!requiredModules.isEmpty()) {
            List<CommonProblemDescriptor> descriptors = new ArrayList<>();
            for (RefJavaModule.RequiredModule requiredModule : requiredModules) {
              if (requiredModule.isTransitive()) continue;
              String requiredModuleName = requiredModule.moduleName();

              boolean isJavaBase = PsiJavaModule.JAVA_BASE.equals(requiredModuleName);
              if (isJavaBase ||
                  isDependencyUnused(requiredModule.packagesExportedByModule(), moduleImportedPackages, refJavaModule.getName())) {
                PsiRequiresStatement requiresStatement = ContainerUtil.find(
                  psiJavaModule.getRequires(), statement -> requiredModuleName.equals(statement.getModuleName()));
                if (requiresStatement != null && !isSuppressedFor(requiresStatement)) {
                  PsiJavaModule dependentModule = requiresStatement.resolve();
                  DeleteRedundantRequiresStatementFix requiresStatementFix =
                    new DeleteRedundantRequiresStatementFix(requiredModuleName, moduleImportedPackages, dependentModule, psiJavaModule);
                  String message = JavaAnalysisBundle.message("inspection.redundant.requires.statement.description", requiredModuleName) + " ";
                  if (isJavaBase) {
                    message += JavaAnalysisBundle.message("inspection.redundant.requires.statement.message.java.base.implicitly.required");
                  }
                  else if (!requiresStatementFix.hasReexportedDependencies()) {
                    message += JavaAnalysisBundle.message("inspection.redundant.requires.statement.message.module.unused");
                  }
                  else {
                    message += JavaAnalysisBundle.message("inspection.redundant.requires.statement.message.transitive.dependencies.on.can.be.used.directly",
                                                          StringUtil.join(requiresStatementFix.myDependencies, "', '"));
                  }
                  CommonProblemDescriptor descriptor = manager.createProblemDescriptor(
                    requiresStatement,
                    message,
                    requiresStatementFix,
                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
                  descriptors.add(descriptor);
                }
              }
            }
            if (!ContainerUtil.isEmpty(descriptors)) {
              return descriptors.toArray(CommonProblemDescriptor.EMPTY_ARRAY);
            }
          }
        }
      }
    }
    return null;
  }
@Override
  public CommonProblemDescriptor @Nullable [] checkElement(@NotNull RefEntity refEntity,
                                                           @NotNull AnalysisScope scope,
                                                           @NotNull InspectionManager manager,
                                                           @NotNull GlobalInspectionContext globalContext)