private @Nullable T checkOrCreate(String newName, PsiDirectory directory, String templateName) throws IncorrectOperationException {
    PsiDirectory dir = directory;
    String className = removeExtension(templateName, newName);

    if (className.contains(".")) {
      String[] names = className.split("\\.");

      for (int i = 0; i < names.length - 1; i++) {
        dir = CreateFileAction.findOrCreateSubdirectory(dir, names[i]);
      }

      className = names[names.length - 1];
    }

    DumbService service = DumbService.getInstance(dir.getProject());
    PsiDirectory finalDir = dir;
    String finalClassName = className;
    return service.computeWithAlternativeResolveEnabled(() ->
      doCreate(finalDir, finalClassName, templateName));
  }
private @Nullable T checkOrCreate(String newName, PsiDirectory directory, String templateName)