mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Make getCombinedCodeFix API public (#21234)
This commit is contained in:
@@ -558,8 +558,7 @@ namespace ts.server {
|
||||
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
|
||||
const response = this.processResponse<protocol.CodeFixResponse>(request);
|
||||
|
||||
// TODO: GH#20538 shouldn't need cast
|
||||
return (response.body as ReadonlyArray<protocol.CodeFixAction>).map(({ description, changes, fixId }) => ({ description, changes: this.convertChanges(changes, file), fixId }));
|
||||
return response.body.map(({ description, changes, fixId }) => ({ description, changes: this.convertChanges(changes, file), fixId }));
|
||||
}
|
||||
|
||||
getCombinedCodeFix = notImplemented;
|
||||
|
||||
@@ -102,8 +102,6 @@ namespace ts.server.protocol {
|
||||
GetCodeFixes = "getCodeFixes",
|
||||
/* @internal */
|
||||
GetCodeFixesFull = "getCodeFixes-full",
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
GetCombinedCodeFix = "getCombinedCodeFix",
|
||||
/* @internal */
|
||||
GetCombinedCodeFixFull = "getCombinedCodeFix-full",
|
||||
@@ -557,15 +555,11 @@ namespace ts.server.protocol {
|
||||
arguments: CodeFixRequestArgs;
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface GetCombinedCodeFixRequest extends Request {
|
||||
command: CommandTypes.GetCombinedCodeFix;
|
||||
arguments: GetCombinedCodeFixRequestArgs;
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface GetCombinedCodeFixResponse extends Response {
|
||||
body: CombinedCodeActions;
|
||||
}
|
||||
@@ -622,15 +616,11 @@ namespace ts.server.protocol {
|
||||
errorCodes?: ReadonlyArray<number>;
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface GetCombinedCodeFixRequestArgs {
|
||||
scope: GetCombinedCodeFixScope;
|
||||
fixId: {};
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface GetCombinedCodeFixScope {
|
||||
type: "file";
|
||||
args: FileRequestArgs;
|
||||
@@ -1619,7 +1609,7 @@ namespace ts.server.protocol {
|
||||
|
||||
export interface CodeFixResponse extends Response {
|
||||
/** The code actions that are available */
|
||||
body?: CodeAction[]; // TODO: GH#20538 CodeFixAction[]
|
||||
body?: CodeFixAction[];
|
||||
}
|
||||
|
||||
export interface CodeAction {
|
||||
@@ -1631,15 +1621,11 @@ namespace ts.server.protocol {
|
||||
commands?: {}[];
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileCodeEdits>;
|
||||
commands?: ReadonlyArray<{}>;
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface CodeFixAction extends CodeAction {
|
||||
/**
|
||||
* If present, one may call 'getCombinedCodeFix' with this fixId.
|
||||
|
||||
@@ -295,10 +295,7 @@ namespace ts {
|
||||
|
||||
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
|
||||
|
||||
// TODO: GH#20538 return `ReadonlyArray<CodeFixAction>`
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeAction>;
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeFixAction>;
|
||||
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings): CombinedCodeActions;
|
||||
applyCodeActionCommand(action: CodeActionCommand): Promise<ApplyCodeActionCommandResult>;
|
||||
applyCodeActionCommand(action: CodeActionCommand[]): Promise<ApplyCodeActionCommandResult[]>;
|
||||
@@ -327,8 +324,6 @@ namespace ts {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface CombinedCodeFixScope { type: "file"; fileName: string; }
|
||||
|
||||
export interface GetCompletionsAtPositionOptions {
|
||||
@@ -419,8 +414,6 @@ namespace ts {
|
||||
commands?: CodeActionCommand[];
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface CodeFixAction extends CodeAction {
|
||||
/**
|
||||
* If present, one may call 'getCombinedCodeFix' with this fixId.
|
||||
@@ -429,8 +422,6 @@ namespace ts {
|
||||
fixId?: {};
|
||||
}
|
||||
|
||||
// TODO: GH#20538
|
||||
/* @internal */
|
||||
export interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileTextChanges>;
|
||||
commands: ReadonlyArray<CodeActionCommand> | undefined;
|
||||
|
||||
@@ -4091,7 +4091,8 @@ declare namespace ts {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeAction>;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeFixAction>;
|
||||
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings): CombinedCodeActions;
|
||||
applyCodeActionCommand(action: CodeActionCommand): Promise<ApplyCodeActionCommandResult>;
|
||||
applyCodeActionCommand(action: CodeActionCommand[]): Promise<ApplyCodeActionCommandResult[]>;
|
||||
applyCodeActionCommand(action: CodeActionCommand | CodeActionCommand[]): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
|
||||
@@ -4107,6 +4108,10 @@ declare namespace ts {
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
}
|
||||
interface CombinedCodeFixScope {
|
||||
type: "file";
|
||||
fileName: string;
|
||||
}
|
||||
interface GetCompletionsAtPositionOptions {
|
||||
includeExternalModuleExports: boolean;
|
||||
includeInsertTextCompletions: boolean;
|
||||
@@ -4184,6 +4189,17 @@ declare namespace ts {
|
||||
*/
|
||||
commands?: CodeActionCommand[];
|
||||
}
|
||||
interface CodeFixAction extends CodeAction {
|
||||
/**
|
||||
* If present, one may call 'getCombinedCodeFix' with this fixId.
|
||||
* This may be omitted to indicate that the code fix can't be applied in a group.
|
||||
*/
|
||||
fixId?: {};
|
||||
}
|
||||
interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileTextChanges>;
|
||||
commands: ReadonlyArray<CodeActionCommand> | undefined;
|
||||
}
|
||||
type CodeActionCommand = InstallPackageAction;
|
||||
interface InstallPackageAction {
|
||||
}
|
||||
@@ -5027,6 +5043,7 @@ declare namespace ts.server.protocol {
|
||||
DocCommentTemplate = "docCommentTemplate",
|
||||
CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects",
|
||||
GetCodeFixes = "getCodeFixes",
|
||||
GetCombinedCodeFix = "getCombinedCodeFix",
|
||||
ApplyCodeActionCommand = "applyCodeActionCommand",
|
||||
GetSupportedCodeFixes = "getSupportedCodeFixes",
|
||||
GetApplicableRefactors = "getApplicableRefactors",
|
||||
@@ -5389,6 +5406,13 @@ declare namespace ts.server.protocol {
|
||||
command: CommandTypes.GetCodeFixes;
|
||||
arguments: CodeFixRequestArgs;
|
||||
}
|
||||
interface GetCombinedCodeFixRequest extends Request {
|
||||
command: CommandTypes.GetCombinedCodeFix;
|
||||
arguments: GetCombinedCodeFixRequestArgs;
|
||||
}
|
||||
interface GetCombinedCodeFixResponse extends Response {
|
||||
body: CombinedCodeActions;
|
||||
}
|
||||
interface ApplyCodeActionCommandRequest extends Request {
|
||||
command: CommandTypes.ApplyCodeActionCommand;
|
||||
arguments: ApplyCodeActionCommandRequestArgs;
|
||||
@@ -5422,6 +5446,14 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
errorCodes?: ReadonlyArray<number>;
|
||||
}
|
||||
interface GetCombinedCodeFixRequestArgs {
|
||||
scope: GetCombinedCodeFixScope;
|
||||
fixId: {};
|
||||
}
|
||||
interface GetCombinedCodeFixScope {
|
||||
type: "file";
|
||||
args: FileRequestArgs;
|
||||
}
|
||||
interface ApplyCodeActionCommandRequestArgs {
|
||||
/** May also be an array of commands. */
|
||||
command: {};
|
||||
@@ -6164,7 +6196,7 @@ declare namespace ts.server.protocol {
|
||||
}
|
||||
interface CodeFixResponse extends Response {
|
||||
/** The code actions that are available */
|
||||
body?: CodeAction[];
|
||||
body?: CodeFixAction[];
|
||||
}
|
||||
interface CodeAction {
|
||||
/** Description of the code action to display in the UI of the editor */
|
||||
@@ -6174,6 +6206,17 @@ declare namespace ts.server.protocol {
|
||||
/** A command is an opaque object that should be passed to `ApplyCodeActionCommandRequestArgs` without modification. */
|
||||
commands?: {}[];
|
||||
}
|
||||
interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileCodeEdits>;
|
||||
commands?: ReadonlyArray<{}>;
|
||||
}
|
||||
interface CodeFixAction extends CodeAction {
|
||||
/**
|
||||
* If present, one may call 'getCombinedCodeFix' with this fixId.
|
||||
* This may be omitted to indicate that the code fix can't be applied in a group.
|
||||
*/
|
||||
fixId?: {};
|
||||
}
|
||||
/**
|
||||
* Format and format on key response message.
|
||||
*/
|
||||
|
||||
18
tests/baselines/reference/api/typescript.d.ts
vendored
18
tests/baselines/reference/api/typescript.d.ts
vendored
@@ -4091,7 +4091,8 @@ declare namespace ts {
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
|
||||
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeAction>;
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeFixAction>;
|
||||
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings): CombinedCodeActions;
|
||||
applyCodeActionCommand(action: CodeActionCommand): Promise<ApplyCodeActionCommandResult>;
|
||||
applyCodeActionCommand(action: CodeActionCommand[]): Promise<ApplyCodeActionCommandResult[]>;
|
||||
applyCodeActionCommand(action: CodeActionCommand | CodeActionCommand[]): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
|
||||
@@ -4107,6 +4108,10 @@ declare namespace ts {
|
||||
getProgram(): Program;
|
||||
dispose(): void;
|
||||
}
|
||||
interface CombinedCodeFixScope {
|
||||
type: "file";
|
||||
fileName: string;
|
||||
}
|
||||
interface GetCompletionsAtPositionOptions {
|
||||
includeExternalModuleExports: boolean;
|
||||
includeInsertTextCompletions: boolean;
|
||||
@@ -4184,6 +4189,17 @@ declare namespace ts {
|
||||
*/
|
||||
commands?: CodeActionCommand[];
|
||||
}
|
||||
interface CodeFixAction extends CodeAction {
|
||||
/**
|
||||
* If present, one may call 'getCombinedCodeFix' with this fixId.
|
||||
* This may be omitted to indicate that the code fix can't be applied in a group.
|
||||
*/
|
||||
fixId?: {};
|
||||
}
|
||||
interface CombinedCodeActions {
|
||||
changes: ReadonlyArray<FileTextChanges>;
|
||||
commands: ReadonlyArray<CodeActionCommand> | undefined;
|
||||
}
|
||||
type CodeActionCommand = InstallPackageAction;
|
||||
interface InstallPackageAction {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user