From 7194bce52f57b092d813b1b79ca69936e88260bf Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 18 Jun 2018 11:52:52 +0200 Subject: [PATCH] debt - remove unused IFileService#rename() method --- src/vs/platform/files/common/files.ts | 6 ------ .../services/files/electron-browser/fileService.ts | 6 ------ .../files/electron-browser/remoteFileService.ts | 9 --------- .../files/test/electron-browser/fileService.test.ts | 12 ++++++------ src/vs/workbench/test/workbenchTestServices.ts | 4 ---- 5 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index b59c623ee3c..24188ef8c4d 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -127,12 +127,6 @@ export interface IFileService { */ createFolder(resource: URI): TPromise; - /** - * Renames the provided file to use the new name. The returned promise - * will have the stat model object as a result. - */ - rename(resource: URI, newName: string): TPromise; - /** * Deletes the provided file. The optional useTrash parameter allows to * move the file to trash. diff --git a/src/vs/workbench/services/files/electron-browser/fileService.ts b/src/vs/workbench/services/files/electron-browser/fileService.ts index cacc1dc7a68..d8501eb66b0 100644 --- a/src/vs/workbench/services/files/electron-browser/fileService.ts +++ b/src/vs/workbench/services/files/electron-browser/fileService.ts @@ -847,12 +847,6 @@ export class FileService implements IFileService { )); } - public rename(resource: uri, newName: string): TPromise { - const newPath = paths.join(paths.dirname(resource.fsPath), newName); - - return this.moveFile(resource, uri.file(newPath)); - } - public moveFile(source: uri, target: uri, overwrite?: boolean): TPromise { return this.moveOrCopyFile(source, target, false, overwrite); } diff --git a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts index a79a41a04f9..0dca336c1a7 100644 --- a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts +++ b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts @@ -537,15 +537,6 @@ export class RemoteFileService extends FileService { } } - rename(resource: URI, newName: string): TPromise { - if (resource.scheme === Schemas.file) { - return super.rename(resource, newName); - } else { - const target = resource.with({ path: posix.join(resource.path, '..', newName) }); - return this._doMoveWithInScheme(resource, target, false); - } - } - moveFile(source: URI, target: URI, overwrite?: boolean): TPromise { if (source.scheme !== target.scheme) { return this._doMoveAcrossScheme(source, target); diff --git a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts index 822b9dc356d..d9a7806a66d 100644 --- a/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts +++ b/src/vs/workbench/services/files/test/electron-browser/fileService.test.ts @@ -157,7 +157,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'index.html')); return service.resolveFile(resource).then(source => { - return service.rename(source.resource, 'other.html').then(renamed => { + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), 'other.html'))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.equal(fs.existsSync(source.resource.fsPath), false); @@ -181,7 +181,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'index.html')); return service.resolveFile(resource).then(source => { - return service.rename(source.resource, renameToPath).then(renamed => { + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), renameToPath))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.equal(fs.existsSync(source.resource.fsPath), false); @@ -202,7 +202,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'deep')); return service.resolveFile(resource).then(source => { - return service.rename(source.resource, 'deeper').then(renamed => { + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), 'deeper'))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.equal(fs.existsSync(source.resource.fsPath), false); @@ -226,7 +226,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'deep')); return service.resolveFile(resource).then(source => { - return service.rename(source.resource, renameToPath).then(renamed => { + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), renameToPath))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.equal(fs.existsSync(source.resource.fsPath), false); @@ -246,7 +246,7 @@ suite('FileService', () => { const resource = uri.file(path.join(testDir, 'index.html')); return service.resolveFile(resource).then(source => { - return service.rename(source.resource, 'INDEX.html').then(renamed => { + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), 'INDEX.html'))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.equal(path.basename(renamed.resource.fsPath), 'INDEX.html'); @@ -430,7 +430,7 @@ suite('FileService', () => { test('copyFile - MIX CASE', function () { return service.resolveFile(uri.file(path.join(testDir, 'index.html'))).then(source => { - return service.rename(source.resource, 'CONWAY.js').then(renamed => { // index.html => CONWAY.js + return service.moveFile(source.resource, uri.file(path.join(path.dirname(source.resource.fsPath), 'CONWAY.js'))).then(renamed => { assert.equal(fs.existsSync(renamed.resource.fsPath), true); assert.ok(fs.readdirSync(testDir).some(f => f === 'CONWAY.js')); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 118195794c4..461dcf4daf8 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -840,10 +840,6 @@ export class TestFileService implements IFileService { return TPromise.as(null); } - rename(resource: URI, newName: string): TPromise { - return TPromise.as(null); - } - onDidChangeFileSystemProviderRegistrations = Event.None; registerProvider(scheme: string, provider) { -- GitLab