Skip to content

Commit 2ed98bf

Browse files
committed
no implicit stat objects, microsoft#48527
1 parent 520d075 commit 2ed98bf

6 files changed

Lines changed: 33 additions & 28 deletions

File tree

src/vs/platform/files/common/files.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ export interface IFileSystemProvider {
199199
watch(resource: URI, opts: IWatchOptions): IDisposable;
200200

201201
stat(resource: URI): TPromise<IStat>;
202-
mkdir(resource: URI): TPromise<IStat>;
202+
mkdir(resource: URI): TPromise<void>;
203203
readdir(resource: URI): TPromise<[string, FileType][]>;
204204
delete(resource: URI): TPromise<void>;
205205

206-
rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<IStat>;
207-
copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<IStat>;
206+
rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
207+
copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise<void>;
208208

209209
readFile?(resource: URI): TPromise<Uint8Array>;
210210
writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): TPromise<void>;

src/vs/vscode.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5005,8 +5005,9 @@ declare module 'vscode' {
50055005
* @returns Metadata about the created directory or a thenable that resolves to such.
50065006
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist.
50075007
* @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists.
5008+
* @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
50085009
*/
5009-
createDirectory(uri: Uri): FileStat | Thenable<FileStat>;
5010+
createDirectory(uri: Uri): void | Thenable<void>;
50105011

50115012
/**
50125013
* Read the entire contents of a file.
@@ -5026,6 +5027,7 @@ declare module 'vscode' {
50265027
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist and `create` is not set.
50275028
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist and `create` is set.
50285029
* @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists and `overwrite` is set.
5030+
* @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
50295031
*/
50305032
writeFile(uri: Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void | Thenable<void>;
50315033

@@ -5035,6 +5037,7 @@ declare module 'vscode' {
50355037
* @param uri The resource that is to be deleted.
50365038
* @param options Defines if deletion of folders is recursive.
50375039
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
5040+
* @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
50385041
*/
50395042
delete(uri: Uri, options: { recursive: boolean }): void | Thenable<void>;
50405043

@@ -5048,8 +5051,9 @@ declare module 'vscode' {
50485051
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `oldUri` doesn't exist.
50495052
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `newUri` doesn't exist
50505053
* @throws [`FileExists`](#FileSystemError.FileExists) when `newUri` exists and when the `overwrite` option is not `true`.
5054+
* @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
50515055
*/
5052-
rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): FileStat | Thenable<FileStat>;
5056+
rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): void | Thenable<void>;
50535057

50545058
/**
50555059
* Copy files or folders. Implementing this function is optional but it will speedup
@@ -5062,8 +5066,9 @@ declare module 'vscode' {
50625066
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `source` doesn't exist
50635067
* @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `destination` doesn't exist
50645068
* @throws [`FileExists`](#FileSystemError.FileExists) when `destination` exists and when the `overwrite` option is not `true`.
5069+
* @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
50655070
*/
5066-
copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): FileStat | Thenable<FileStat>;
5071+
copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable<void>;
50675072
}
50685073

50695074
/**

src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,19 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
111111
return this._proxy.$delete(this._handle, resource);
112112
}
113113

114-
mkdir(resource: URI): TPromise<IStat, any> {
114+
mkdir(resource: URI): TPromise<void, any> {
115115
return this._proxy.$mkdir(this._handle, resource);
116116
}
117117

118118
readdir(resource: URI): TPromise<[string, FileType][], any> {
119119
return this._proxy.$readdir(this._handle, resource);
120120
}
121121

122-
rename(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise<IStat, any> {
122+
rename(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise<void, any> {
123123
return this._proxy.$rename(this._handle, resource, target, opts);
124124
}
125125

126-
copy(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise<IStat, any> {
126+
copy(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise<void, any> {
127127
return this._proxy.$copy(this._handle, resource, target, opts);
128128
}
129129
}

src/vs/workbench/api/node/extHost.protocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ export interface ExtHostFileSystemShape {
585585
$readdir(handle: number, resource: UriComponents): TPromise<[string, FileType][]>;
586586
$readFile(handle: number, resource: UriComponents): TPromise<string>;
587587
$writeFile(handle: number, resource: UriComponents, base64Encoded: string, opts: FileWriteOptions): TPromise<void>;
588-
$rename(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise<IStat>;
589-
$copy(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise<IStat>;
590-
$mkdir(handle: number, resource: UriComponents): TPromise<IStat>;
588+
$rename(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise<void>;
589+
$copy(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise<void>;
590+
$mkdir(handle: number, resource: UriComponents): TPromise<void>;
591591
$delete(handle: number, resource: UriComponents): TPromise<void>;
592592
$watch(handle: number, session: number, resource: UriComponents, opts: IWatchOptions): void;
593593
$unwatch(handle: number, session: number): void;

src/vs/workbench/api/node/extHostFileSystem.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class FileSystemProviderShim implements vscode.FileSystemProvider {
7878
stat(resource: vscode.Uri): Thenable<vscode.FileStat> {
7979
return this._delegate.stat(resource).then(stat => FileSystemProviderShim._modernizeFileStat(stat));
8080
}
81-
rename(oldUri: vscode.Uri, newUri: vscode.Uri): Thenable<vscode.FileStat> {
82-
return this._delegate.move(oldUri, newUri).then(stat => FileSystemProviderShim._modernizeFileStat(stat));
81+
rename(oldUri: vscode.Uri, newUri: vscode.Uri): Thenable<void> {
82+
return this._delegate.move(oldUri, newUri).then(stat => void 0);
8383
}
8484
readDirectory(resource: vscode.Uri): Thenable<[string, vscode.FileType][]> {
8585
return this._delegate.readdir(resource).then(tuples => {
@@ -135,8 +135,8 @@ class FileSystemProviderShim implements vscode.FileSystemProvider {
135135
}
136136
});
137137
}
138-
createDirectory(resource: vscode.Uri): Thenable<vscode.FileStat> {
139-
return this._delegate.mkdir(resource).then(stat => FileSystemProviderShim._modernizeFileStat(stat));
138+
createDirectory(resource: vscode.Uri): Thenable<void> {
139+
return this._delegate.mkdir(resource).then(stat => void 0);
140140
}
141141

142142
// --- read/write
@@ -272,16 +272,16 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
272272
return asWinJsPromise(token => this._fsProvider.get(handle).delete(URI.revive(resource), { recursive: true }));
273273
}
274274

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

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

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

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

src/vs/workbench/services/files/electron-browser/remoteFileService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ export class RemoteFileService extends FileService {
516516
return super.createFolder(resource);
517517
} else {
518518
return this._withProvider(resource).then(provider => {
519-
return provider.mkdir(resource).then(stat => {
520-
return toIFileStat(provider, [resource, stat]);
519+
return provider.mkdir(resource).then(() => {
520+
return this.resolveFile(resource);
521521
});
522522
}).then(fileStat => {
523523
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
@@ -552,8 +552,8 @@ export class RemoteFileService extends FileService {
552552
: TPromise.as(null);
553553

554554
return prepare.then(() => this._withProvider(source)).then(provider => {
555-
return provider.rename(source, target, { overwrite }).then(stat => {
556-
return toIFileStat(provider, [target, stat]);
555+
return provider.rename(source, target, { overwrite }).then(() => {
556+
return this.resolveFile(target);
557557
}).then(fileStat => {
558558
this._onAfterOperation.fire(new FileOperationEvent(source, FileOperation.MOVE, fileStat));
559559
return fileStat;
@@ -587,8 +587,8 @@ export class RemoteFileService extends FileService {
587587

588588
if (source.scheme === target.scheme && (provider.capabilities & FileSystemProviderCapabilities.FileFolderCopy)) {
589589
// good: provider supports copy withing scheme
590-
return provider.copy(source, target, { overwrite }).then(stat => {
591-
return toIFileStat(provider, [target, stat]);
590+
return provider.copy(source, target, { overwrite }).then(() => {
591+
return this.resolveFile(target);
592592
}).then(fileStat => {
593593
this._onAfterOperation.fire(new FileOperationEvent(source, FileOperation.COPY, fileStat));
594594
return fileStat;

0 commit comments

Comments
 (0)