Skip to content

Commit

Permalink
remove CancelationTokens, #48527
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Apr 26, 2018
1 parent 98fa486 commit 96a1994
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
24 changes: 8 additions & 16 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5007,66 +5007,59 @@ declare module 'vscode' {
* in case the file does not exist.
*
* @param uri The uri of the file to retrieve meta data about.
* @param token A cancellation token.
* @return The file metadata about the file.
*/
stat(uri: Uri, options: { /*future: followSymlinks*/ }, token: CancellationToken): FileStat | Thenable<FileStat>;
stat(uri: Uri, options: { /*future: followSymlinks*/ }): FileStat | Thenable<FileStat>;

/**
* Retrieve the meta data of all entries of a [directory](#FileStat.isDirectory)
*
* @param uri The uri of the folder.
* @param token A cancellation token.
* @return A thenable that resolves to an array of tuples of file names and files stats.
*/
readDirectory(uri: Uri, options: { /*future: onlyType?*/ }, token: CancellationToken): [string, FileType][] | Thenable<[string, FileType][]>;
readDirectory(uri: Uri, options: { /*future: onlyType?*/ }): [string, FileType][] | Thenable<[string, FileType][]>;

/**
* Create a new directory. *Note* that new files are created via `write`-calls.
*
* @param uri The uri of the *new* folder.
* @param token A cancellation token.
*/
createDirectory(uri: Uri, options: { /*future: permissions?*/ }, token: CancellationToken): FileStat | Thenable<FileStat>;
createDirectory(uri: Uri, options: { /*future: permissions?*/ }): FileStat | Thenable<FileStat>;

/**
* Read the entire contents of a file.
*
* @param uri The uri of the file.
* @param token A cancellation token.
* @return A thenable that resolves to an array of bytes.
*/
readFile(uri: Uri, options: FileOptions, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
readFile(uri: Uri, options: FileOptions): Uint8Array | Thenable<Uint8Array>;

/**
* Write data to a file, replacing its entire contents.
*
* @param uri The uri of the file.
* @param content The new content of the file.
* @param token A cancellation token.
*/
writeFile(uri: Uri, content: Uint8Array, options: FileOptions, token: CancellationToken): void | Thenable<void>;
writeFile(uri: Uri, content: Uint8Array, options: FileOptions): void | Thenable<void>;

/**
* Delete a file.
*
* @param uri The resource that is to be deleted
* @param options Options bag for future use
* @param token A cancellation token.
*/
delete(uri: Uri, options: { /*future: useTrash?, followSymlinks?*/ }, token: CancellationToken): void | Thenable<void>;
delete(uri: Uri, options: { /*future: useTrash?, followSymlinks?*/ }): void | Thenable<void>;

/**
* Rename a file or folder.
*
* @param oldUri The existing file or folder.
* @param newUri The target location.
* @param options Defines if existing files should be overwriten.
* @param token A cancellation token.
* @throws [`FileNotFound`](FileSystemError.FileNotFound) when `oldUri` doesn't exist
* @throws [`FileExists`](FileSystemError.FileExists) when `newUri` exists and when the `overwrite` option is not `true`.
*/
rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }, token: CancellationToken): FileStat | Thenable<FileStat>;
rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): FileStat | Thenable<FileStat>;

/**
* Copy files or folders. Implementing this function is optional but it will speedup
Expand All @@ -5075,11 +5068,10 @@ declare module 'vscode' {
* @param source The existing file or folder.
* @param destination The destination location.
* @param options Defines if existing files should be overwriten.
* @param token A cancellation token.
* @throws [`FileNotFound`](FileSystemError.FileNotFound) when `source` doesn't exist
* @throws [`FileExists`](FileSystemError.FileExists) when `destination` exists and when the `overwrite` option is not `true`.
*/
copy?(source: Uri, destination: Uri, options: { overwrite: boolean }, token: CancellationToken): FileStat | Thenable<FileStat>;
copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): FileStat | Thenable<FileStat>;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/vs/workbench/api/node/extHostFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,39 +249,39 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
}

$stat(handle: number, resource: UriComponents): TPromise<files.IStat, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).stat(URI.revive(resource), {}, token)).then(ExtHostFileSystem._asIStat);
return asWinJsPromise(token => this._fsProvider.get(handle).stat(URI.revive(resource), {})).then(ExtHostFileSystem._asIStat);
}

$readdir(handle: number, resource: UriComponents): TPromise<[string, files.FileType][], any> {
return asWinJsPromise(token => this._fsProvider.get(handle).readDirectory(URI.revive(resource), {}, token));
return asWinJsPromise(token => this._fsProvider.get(handle).readDirectory(URI.revive(resource), {}));
}

$readFile(handle: number, resource: UriComponents, opts: files.FileOptions): TPromise<string> {
return asWinJsPromise(token => {
return this._fsProvider.get(handle).readFile(URI.revive(resource), opts, token);
return this._fsProvider.get(handle).readFile(URI.revive(resource), opts);
}).then(data => {
return Buffer.isBuffer(data) ? data.toString('base64') : Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString('base64');
});
}

$writeFile(handle: number, resource: UriComponents, base64Content: string, opts: files.FileOptions): TPromise<void, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).writeFile(URI.revive(resource), Buffer.from(base64Content, 'base64'), opts, token));
return asWinJsPromise(token => this._fsProvider.get(handle).writeFile(URI.revive(resource), Buffer.from(base64Content, 'base64'), opts));
}

$delete(handle: number, resource: UriComponents): TPromise<void, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).delete(URI.revive(resource), {}, token));
return asWinJsPromise(token => this._fsProvider.get(handle).delete(URI.revive(resource), {}));
}

$rename(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise<files.IStat, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts, token)).then(ExtHostFileSystem._asIStat);
return asWinJsPromise(token => this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts)).then(ExtHostFileSystem._asIStat);
}

$copy(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise<files.IStat, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts, token)).then(ExtHostFileSystem._asIStat);
return asWinJsPromise(token => this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts)).then(ExtHostFileSystem._asIStat);
}

$mkdir(handle: number, resource: UriComponents): TPromise<files.IStat, any> {
return asWinJsPromise(token => this._fsProvider.get(handle).createDirectory(URI.revive(resource), {}, token)).then(ExtHostFileSystem._asIStat);
return asWinJsPromise(token => this._fsProvider.get(handle).createDirectory(URI.revive(resource), {})).then(ExtHostFileSystem._asIStat);
}

$watch(handle: number, session: number, resource: UriComponents, opts: files.IWatchOptions): void {
Expand Down

0 comments on commit 96a1994

Please sign in to comment.