@Override
  public VirtualFile findFile(@NotNull RootType rootType, @NotNull String pathName, @NotNull Option option) throws IOException {
    ApplicationManager.getApplication().assertReadAccessAllowed();

    LocalFileSystem fileSystem = LocalFileSystem.getInstance();
    String fullPath = getRootPath(rootType) + "/" + pathName;
    if (option != Option.create_new_always) {
      VirtualFile file = fileSystem.findFileByPath(fullPath);
      if (file != null && !file.isDirectory()) {
        return file;
      }
      if (option == Option.existing_only) {
        return null;
      }
    }
    String fileName = PathUtil.getFileName(pathName);
    return WriteAction.compute(() -> {
      VirtualFile dir = VfsUtil.createDirectories(PathUtil.getParentPath(fullPath));
      if (option == Option.create_new_always) {
        return dir.createChildData(fileSystem, ScratchImplUtil.getNextAvailableName(dir, fileName));
      }
      else if (option == Option.create_if_missing && rootType instanceof ScratchRootType && fileName.startsWith("buffer")) {
        VirtualFile file = ScratchImplUtil.findFileIgnoreExtension(dir, fileName);
        if (file != null && !file.getName().equals(fileName)) {
          file.rename(this, fileName);
        }
        return file != null ? file : dir.findOrCreateChildData(fileSystem, fileName);
      }
      else {
        return dir.findOrCreateChildData(fileSystem, fileName);
      }
    });
  }
@Override
  public VirtualFile findFile(@NotNull RootType rootType, @NotNull String pathName, @NotNull Option option)