@Nullable
  public static PsiClass correctClassByScope(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope resolveScope) {
    String qualifiedName = psiClass.getQualifiedName();
    if (qualifiedName == null) {
      return psiClass;
    }

    PsiFile file = psiClass.getContainingFile();
    if (file == null || !file.getViewProvider().isPhysical()) {
      return psiClass;
    }

    final VirtualFile vFile = file.getVirtualFile();
    if (vFile == null) {
      return psiClass;
    }

    final FileIndexFacade index = FileIndexFacade.getInstance(file.getProject());
    if (!index.isInSource(vFile) && !index.isInLibrary(vFile)) {
      return psiClass;
    }

    PsiClass aClass = JavaPsiFacade.getInstance(psiClass.getProject()).findClass(qualifiedName, resolveScope);
    VirtualFile mappedVFile = PsiUtilCore.getVirtualFile(aClass);
    if (mappedVFile != null) {
      Module module = index.getModuleForFile(vFile);
      if (module != null && module == index.getModuleForFile(mappedVFile)) {
        return psiClass;
      }
    }
    return aClass;
  }
@Nullable
  public static PsiClass correctClassByScope(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope resolveScope)