Skip to content

Instantly share code, notes, and snippets.

@gorkem
Created December 8, 2017 16:22
Show Gist options
  • Save gorkem/04471c2ca1cdba7f8aba70c4b1423a2a to your computer and use it in GitHub Desktop.
Save gorkem/04471c2ca1cdba7f8aba70c4b1423a2a to your computer and use it in GitHub Desktop.

File Level Operations

A workspace edit represents changes to many resources managed in the workspace. The edit should either provide changes or documentChanges. If the client can handle versioned document edits and if documentChanges are present, the latter are preferred over changes.

A workspace edit can optionally provide resource changes. If present resource changes are applies after the changes/documentChanges has been applied.

interface  WorkspaceEdit{
  TextEdit[] changes 
  TextDocumentEdit[] documentChanges 
  ResourceChange[] resourceChanges
}

ResourceChange

Changes to a folder or document on the workspace.

interface ResourceChange{

  /**
  * The resource change operation type
  */
  ResourceChangeType changeType
  
  /**
  * The resource. 
  * 
  * If change type is CREATE a new file is created on the uri with the given content.
  * The operation is ignored if uri is pointing to a folder. 
  * This will overwrite any existing files on this uri.
  * 
  * If change type is DELETE the resource is deleted if it exists. If the 
  * uri is a folder this operation deletes all its children too.
  * 
  * If change type is MOVE this uri is considered the source resource for the 
  * move and must point to an existing resource
  */ 
  Uri path
  
  /**
  * The new uri for the resource pointed by path.  
  * Used only if change type is MOVE. Must be compatible with the path 
  * uri ie. must be a file uri if path is a file uri.
  * 
  */
  Uri newPath
  
  /**
  * Required only if change type is CREATE
  */
  string content
}

enum ResourceChangeType{
  CREATE
  DELETE
  MOVE
}

@gorkem
Copy link
Author

gorkem commented Dec 21, 2017

@tsmaeder Yes I did think about not having an explicit move. I decided to do an explicit one because it is easier to implement on the client especially for folders. Also I want to enhance FileChangeTypes in the future to make it easier to detect moves and renames, wanted to have some compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment