private static int getClassesCount(@NotNull InspectionManager manager, RefEntity owner) {
    return ReadAction.compute(() -> {
      final Project project = manager.getProject();
      final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(owner.getQualifiedName());
      if (aPackage == null || aPackage.getSubPackages().length > 0) {
        return -1;
      }
      return aPackage.getClasses(GlobalSearchScope.projectScope(project)).length;
    });
  }
private static int getClassesCount(@NotNull InspectionManager manager, RefEntity owner)