private static PsiDirectory createSubdirectory(
    @NotNull Project project,
    @NotNull PsiDirectory oldDirectory,
    @NotNull String name
  ) throws IncorrectOperationException {
    final PsiDirectory[] psiDirectory = new PsiDirectory[1];
    final IncorrectOperationException[] exception = new IncorrectOperationException[1];

    CommandProcessor.getInstance().executeCommand(project, () -> psiDirectory[0] = ApplicationManager.getApplication().runWriteAction(
      (Computable<PsiDirectory>)() -> {
        try {
          return oldDirectory.createSubdirectory(name);
        }
        catch (IncorrectOperationException e) {
          exception[0] = e;
          return null;
        }
      }), JavaBundle.message("command.create.new.subdirectory"), null);

    if (exception[0] != null) throw exception[0];

    return psiDirectory[0];
  }
private static PsiDirectory createSubdirectory(
    @NotNull Project project,
    @NotNull PsiDirectory oldDirectory,
    @NotNull String name
  )