提交 7194bce5 编写于 作者: B Benjamin Pasero

debt - remove unused IFileService#rename() method

上级 a322ea9a
......@@ -127,12 +127,6 @@ export interface IFileService {
*/
createFolder(resource: URI): TPromise<IFileStat>;
/**
* 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<IFileStat>;
/**
* Deletes the provided file. The optional useTrash parameter allows to
* move the file to trash.
......
......@@ -847,12 +847,6 @@ export class FileService implements IFileService {
));
}
public rename(resource: uri, newName: string): TPromise<IFileStat> {
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<IFileStat> {
return this.moveOrCopyFile(source, target, false, overwrite);
}
......
......@@ -537,15 +537,6 @@ export class RemoteFileService extends FileService {
}
}
rename(resource: URI, newName: string): TPromise<IFileStat, any> {
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<IFileStat> {
if (source.scheme !== target.scheme) {
return this._doMoveAcrossScheme(source, target);
......
......@@ -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'));
......
......@@ -840,10 +840,6 @@ export class TestFileService implements IFileService {
return TPromise.as(null);
}
rename(resource: URI, newName: string): TPromise<IFileStat> {
return TPromise.as(null);
}
onDidChangeFileSystemProviderRegistrations = Event.None;
registerProvider(scheme: string, provider) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册