@Override
  public final void runInspection(@NotNull AnalysisScope scope,
                                  @NotNull InspectionManager manager,
                                  @NotNull GlobalInspectionContext globalContext,
                                  @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) {
    if (((RefManagerImpl)globalContext.getRefManager()).isDeclarationsFound()) {
      // if reference graph is available, use it.
      super.runInspection(scope, manager, globalContext, problemDescriptionsProcessor);
    }
    else {
      final AnalysisScope analysisScope = globalContext.getRefManager().getScope();
      assert analysisScope != null;
      myJobDescriptor.setTotalAmount(analysisScope.getFileCount());
      final Set<String> packages = new HashSet<>();
      final IntRef current = new IntRef();
      analysisScope.accept(file -> {
        current.inc();
        if (file.isDirectory()) return true;
        String packageName = ReadAction.nonBlocking(() -> {
          if (!scope.contains(file)) return null;
          final PsiFile element = PsiManager.getInstance(scope.getProject()).findFile(file);
          if (!(element instanceof PsiClassOwner classOwner)) return null;
          return classOwner.getPackageName();
        }).executeSynchronously();
        if (packageName == null) {
          return true;
        }
        do {
          if (!packages.add(packageName)) {
            return true;
          }
          myJobDescriptor.setDoneAmount(current.get());
          globalContext.incrementJobDoneAmount(myJobDescriptor,
                                               InspectionGadgetsBundle.message("progress.text.analyzing.package.0", packageName));
          final RefPackage aPackage = (RefPackage)globalContext.getRefManager().getReference(RefJavaManager.PACKAGE, packageName);
          if (aPackage == null) return true;
          CommonProblemDescriptor[] descriptors = checkPackage(aPackage, scope, manager, globalContext);
          if (descriptors != null) {
            problemDescriptionsProcessor.addProblemElement(aPackage, descriptors);
          }
          packageName = StringUtil.getPackageName(packageName);
        }
        while (!packageName.isEmpty()); // the default package is not visited
        return true;
      });
    }
  }
@Override
  public final void runInspection(@NotNull AnalysisScope scope,
                                  @NotNull InspectionManager manager,
                                  @NotNull GlobalInspectionContext globalContext,
                                  @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor)