Hierarchical refactorings (#41975)

* add hierarchical refactoring strings

* fourslash tests

* extractSymbol filters returned actions

* move refactorKind check to utilities

* rename parameters

* messaging for addOrRemoveBracesToArrowFunction

* fix up inferFunctionReturnType

* fix up convertArrowFunctionOrFunctionExpression

* add preferences to fourslash method

* fix up convert string

* fix up moveToNewFile

* fix lint errors

* remove extra arrow braces diagnostics

* break out tests

* add refactor helpers

* refactor refactors

* keep list of actions

* address PR comments

* response protocol

* address more comments
This commit is contained in:
Jesse Trinity
2020-12-23 12:50:03 -08:00
committed by GitHub
parent d1ac4515c8
commit 8bbef818ed
37 changed files with 627 additions and 325 deletions

View File

@@ -566,7 +566,8 @@ namespace ts.server.protocol {
arguments: GetApplicableRefactorsRequestArgs;
}
export type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs & {
triggerReason?: RefactorTriggerReason
triggerReason?: RefactorTriggerReason;
kind?: string;
};
export type RefactorTriggerReason = "implicit" | "invoked";
@@ -626,6 +627,11 @@ namespace ts.server.protocol {
* the current context.
*/
notApplicableReason?: string;
/**
* The hierarchical dotted name of the refactor action.
*/
kind?: string;
}
export interface GetEditsForRefactorRequest extends Request {

View File

@@ -2129,7 +2129,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), args.triggerReason);
return project.getLanguageService().getApplicableRefactors(file, this.extractPositionOrRange(args, scriptInfo), this.getPreferences(file), args.triggerReason, args.kind);
}
private getEditsForRefactor(args: protocol.GetEditsForRefactorRequestArgs, simplifiedResult: boolean): RefactorEditInfo | protocol.RefactorEditInfo {