private void checkAddImport(PsiJavaFile file, String fqn, String... expectedOrder) {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    ImportHelper importHelper = new ImportHelper(settings);

    PsiClass psiClass =
        JavaPsiFacade.getInstance(getProject())
            .findClass(fqn, GlobalSearchScope.allScope(getProject()));
    boolean b = importHelper.addImport(file, psiClass);
    assertTrue(b);

    assertOrder(file, expectedOrder);
  }
  public static boolean isSourceLevelAccessible(
      PsiElement context, PsiClass psiClass, final boolean pkgContext) {
    if (!JavaPsiFacade.getInstance(psiClass.getProject())
        .getResolveHelper()
        .isAccessible(psiClass, context, null)) {
      return false;
    }

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

    return true;
  }
 private boolean isIdentifier(String name) {
   return JavaPsiFacade.getInstance(myProject)
       .getNameHelper()
       .isIdentifier(name, LanguageLevel.HIGHEST);
 }