add trigger reason to protocol

This commit is contained in:
Jesse Trinity
2020-04-14 13:17:19 -07:00
parent d45f0d0c9f
commit bac046573f
5 changed files with 25 additions and 9 deletions

View File

@@ -546,7 +546,15 @@ namespace ts.server.protocol {
command: CommandTypes.GetApplicableRefactors;
arguments: GetApplicableRefactorsRequestArgs;
}
export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs;
export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs & {
triggerReason?: RefactorTriggerReason;
};
export type RefactorTriggerReason = RefactorInvokedReason;
export interface RefactorInvokedReason {
kind: 'invoked';
}
/**
* Response is a list of available refactorings.

View File

@@ -1970,7 +1970,7 @@ namespace ts.server {
private getApplicableRefactors(args: protocol.GetApplicableRefactorsRequestArgs): protocol.ApplicableRefactorInfo[] {
const { file, project } = this.getFileAndProject(args);
const scriptInfo = project.getScriptInfoForNormalizedPath(file)!;
return project.getLanguageService().getApplicableRefactors(file, this.extractPositionOrRange(args, scriptInfo), this.getPreferences(file));
return project.getLanguageService().getApplicableRefactors(file, this.extractPositionOrRange(args, scriptInfo), this.getPreferences(file), args.triggerReason);
}
private getEditsForRefactor(args: protocol.GetEditsForRefactorRequestArgs, simplifiedResult: boolean): RefactorEditInfo | protocol.RefactorEditInfo {