Bundle fileName with CodeActionCommand (#19881)

* Bundle fileName with CodeActionCommand

* Update test

* Fix API tests

* Add new overloads in services

* Fix overload

* Update API baselines
This commit is contained in:
Andy
2017-11-17 14:16:38 -08:00
committed by GitHub
parent 0c0f4b81ae
commit e7adb1ce79
10 changed files with 46 additions and 20 deletions

View File

@@ -585,7 +585,7 @@ namespace ts.server.protocol {
errorCodes?: number[];
}
export interface ApplyCodeActionCommandRequestArgs extends FileRequestArgs {
export interface ApplyCodeActionCommandRequestArgs {
/** May also be an array of commands. */
command: {};
}

View File

@@ -1569,15 +1569,14 @@ namespace ts.server {
}
private applyCodeActionCommand(commandName: string, requestSeq: number, args: protocol.ApplyCodeActionCommandRequestArgs): void {
const { file, project } = this.getFileAndProject(args);
const output = (success: boolean, message: string) => this.doOutput({}, commandName, requestSeq, success, message);
const command = args.command as CodeActionCommand | CodeActionCommand[]; // They should be sending back the command we sent them.
project.getLanguageService().applyCodeActionCommand(file, command).then(
result => {
output(/*success*/ true, isArray(result) ? result.map(res => res.successMessage).join(`${this.host.newLine}${this.host.newLine}`) : result.successMessage);
},
error => { output(/*success*/ false, error); });
const commands = args.command as CodeActionCommand | CodeActionCommand[]; // They should be sending back the command we sent them.
for (const command of toArray(commands)) {
const { project } = this.getFileAndProject(command);
const output = (success: boolean, message: string) => this.doOutput({}, commandName, requestSeq, success, message);
project.getLanguageService().applyCodeActionCommand(command).then(
result => { output(/*success*/ true, result.successMessage); },
error => { output(/*success*/ false, error); });
}
}
private getStartAndEndPosition(args: protocol.FileRangeRequestArgs, scriptInfo: ScriptInfo) {