private static boolean isSourceLevelAccessible(PsiElement context,
                                                 @NotNull PsiClass psiClass,
                                                 boolean pkgContext,
                                                 @Nullable PsiClass qualifierClass) {
    if (!JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().isAccessible(psiClass, context, qualifierClass)) {
      return false;
    }

    if (pkgContext) {
      PsiClass topLevel = PsiUtil.getTopLevelClass(psiClass);
      if (topLevel != null) {
        String fqName = topLevel.getQualifiedName();
        return fqName == null || !StringUtil.isEmpty(StringUtil.getPackageName(fqName));
      }
    }

    return true;
  }
private static boolean isSourceLevelAccessible(PsiElement context,
                                                 @NotNull PsiClass psiClass,
                                                 boolean pkgContext,
                                                 @Nullable PsiClass qualifierClass)