@Nullable
  public VirtualFile createScratchFile(@Nullable Project project,
                                       @NotNull String fileName,
                                       @Nullable Language language,
                                       @NotNull String text,
                                       @NotNull ScratchFileService.Option option) {
    try {
      return
        WriteCommandAction.writeCommandAction(project).withName(UIBundle.message("file.chooser.create.new.scratch.file.command.name"))
                          .withGlobalUndo().shouldRecordActionForActiveDocument(false)
                          .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION).compute(() -> {
          ScratchFileService fileService = ScratchFileService.getInstance();
          VirtualFile file = fileService.findFile(this, fileName, option);
          // save text should go before any other manipulations that load document,
          // otherwise undo will be broken
          VfsUtil.saveText(file, text);
          if (language != null) {
            Language fileLanguage = LanguageUtil.getFileLanguage(file);
            fileService.getScratchesMapping().setMapping(file, fileLanguage == null || language == fileLanguage ? null : language);
          }
          return file;
        });
    }
    catch (IOException e) {
      Messages.showMessageDialog(UIBundle.message("create.new.file.could.not.create.file.error.message", fileName),
                                 UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
      return null;
    }
  }
@Nullable
  public VirtualFile createScratchFile(@Nullable Project project,
                                       @NotNull String fileName,
                                       @Nullable Language language,
                                       @NotNull String text,
                                       @NotNull ScratchFileService.Option option)