Skip to content

Commit

Permalink
move WorkspaceEdit api additions to vscode.d.ts #10659
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 26, 2018
1 parent 7e421ef commit 4c5c941
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 71 deletions.
49 changes: 42 additions & 7 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2707,13 +2707,15 @@ declare module 'vscode' {
}

/**
* A workspace edit represents textual and files changes for
* A workspace edit is a collection of textual and files changes for
* multiple resources and documents.
*
* Use the [applyEdit](#workspace.applyEdit)-function to apply a workspace edit.
*/
export class WorkspaceEdit {

/**
* The number of affected resources.
* The number of affected resources of textual or resource changes.
*/
readonly size: number;

Expand Down Expand Up @@ -2744,7 +2746,8 @@ declare module 'vscode' {
delete(uri: Uri, range: Range): void;

/**
* Check if this edit affects the given resource.
* Check if a text edit for a resource exists.
*
* @param uri A resource identifier.
* @return `true` if the given resource will be touched by this edit.
*/
Expand All @@ -2766,6 +2769,33 @@ declare module 'vscode' {
*/
get(uri: Uri): TextEdit[];

/**
* Create a regular file.
*
* @param uri Uri of the new file..
* @param options Defines if an existing file should be overwritten or be
* ignored. When overwrite and ignoreIfExists are both set overwrite wins.
*/
createFile(uri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }): void;

/**
* Delete a file or folder.
*
* @param uri The uri of the file that is to be deleted.
*/
deleteFile(uri: Uri, options?: { recursive?: boolean, ignoreIfNotExists?: boolean }): void;

/**
* Rename a file or folder.
*
* @param oldUri The existing file.
* @param newUri The new location.
* @param options Defines if existing files should be overwritten or be
* ignored. When overwrite and ignoreIfExists are both set overwrite wins.
*/
renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }): void;


/**
* Get all text edits grouped by resource.
*
Expand Down Expand Up @@ -7173,12 +7203,17 @@ declare module 'vscode' {
export function saveAll(includeUntitled?: boolean): Thenable<boolean>;

/**
* Make changes to one or many resources as defined by the given
* Make changes to one or many resources or create, delete, and rename resources as defined by the given
* [workspace edit](#WorkspaceEdit).
*
* When applying a workspace edit, the editor implements an 'all-or-nothing'-strategy,
* that means failure to load one document or make changes to one document will cause
* the edit to be rejected.
* All changes of a workspace edit are applied in the same order in which they have been added. If
* multiple textual inserts are made at the same position, these strings appear in the resulting text
* in the order the 'inserts' were made. Invalid sequences like 'delete file a' -> 'insert text in file a'
* cause failure of the operation.
*
* When applying a workspace edit that consists only of text edits an 'all-or-nothing'-strategy is used.
* A workspace edit with resource creations or deletions aborts the operation, e.g. consective edits will
* not be attempted, when a single edit fails.
*
* @param edit A workspace edit.
* @return A thenable that resolves when the edit could be applied.
Expand Down
64 changes: 0 additions & 64 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,70 +697,6 @@ declare module 'vscode' {

//#endregion

//#region joh: https://github.com/Microsoft/vscode/issues/10659

/**
* A workspace edit is a collection of textual and files changes for
* multiple resources and documents.
*
* Use the [applyEdit](#workspace.applyEdit)-function to apply a workspace edit.
*/
export interface WorkspaceEdit {

/**
* The number of affected resources of textual or resource changes.
*/
readonly size: number;

/**
* Create a regular file.
*
* @param uri Uri of the new file..
* @param options Defines if an existing file should be overwritten or be
* ignored. When overwrite and ignoreIfExists are both set overwrite wins.
*/
createFile(uri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }): void;

/**
* Delete a file or folder.
*
* @param uri The uri of the file that is to be deleted.
*/
deleteFile(uri: Uri, options?: { recursive?: boolean, ignoreIfNotExists?: boolean }): void;

/**
* Rename a file or folder.
*
* @param oldUri The existing file.
* @param newUri The new location.
* @param options Defines if existing files should be overwritten or be
* ignored. When overwrite and ignoreIfExists are both set overwrite wins.
*/
renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }): void;
}

export namespace workspace {

/**
* Make changes to one or many resources or create, delete, and rename resources.
*
* All changes of a workspace edit are applied in the same order in which they have been added. If
* multiple textual inserts are made at the same position, these strings appear in the resulting text
* in the order the 'inserts' were made. Invalid sequences like 'delete file a' -> 'insert text in file a'
* cause failure of the operation.
*
* When applying a workspace edit that consists only of text edits an 'all-or-nothing'-strategy is used.
* A workspace edit with resource creations or deletions aborts the operation, e.g. consective edits will
* not be attempted, when a single edit fails.
*
* @param edit A workspace edit.
* @return A thenable that resolves when the edit could be applied.
*/
export function applyEdit(edit: WorkspaceEdit): Thenable<boolean>;
}

//#endregion

//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
export interface FileRenameEvent {
readonly oldUri: Uri;
Expand Down

0 comments on commit 4c5c941

Please sign in to comment.