public static void checkCreateClassOrInterface(@NotNull PsiDirectory directory, String name) throws IncorrectOperationException {
    PsiUtil.checkIsIdentifier(directory.getManager(), name);

    String fileName = name + "." + JavaFileType.INSTANCE.getDefaultExtension();
    directory.checkCreateFile(fileName);

    PsiNameHelper helper = PsiNameHelper.getInstance(directory.getProject());
    PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
    String qualifiedName = aPackage == null ? null : aPackage.getQualifiedName();
    if (!StringUtil.isEmpty(qualifiedName) && !helper.isQualifiedName(qualifiedName)) {
      throw new IncorrectOperationException("Cannot create class in invalid package: '"+qualifiedName+"'");
    }
  }
public static void checkCreateClassOrInterface(@NotNull PsiDirectory directory, String name)