mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user