mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 06:35:35 -05:00
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:
@@ -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: {};
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user