Skip to content

Commit 4df09b0

Browse files
author
Andy Hanson
committed
Code review
1 parent 41c5710 commit 4df09b0

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/harness/fourslash.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,7 @@ Actual: ${stringify(fullActual)}`);
24352435
ts.Debug.assert(ts.contains(fixIds, fixId), "No available code fix has that group id.", () => `Expected '${fixId}'. Available action ids: ${fixIds}`);
24362436
const { changes, commands } = this.languageService.getCombinedCodeFix({ type: "file", fileName: this.activeFile.fileName }, fixId, this.formatCodeSettings);
24372437
assert.deepEqual(commands, options.commands);
2438+
assert(changes.every(c => c.fileName === this.activeFile.fileName), "TODO: support testing codefixes that touch multiple files");
24382439
this.applyChanges(changes);
24392440
this.verifyCurrentFileContent(newFileContent);
24402441
}

src/server/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,14 @@ namespace ts.server {
553553
return notImplemented();
554554
}
555555

556-
getCodeFixesAtPosition(file: string, start: number, end: number, errorCodes: number[]): CodeFixAction[] {
556+
getCodeFixesAtPosition(file: string, start: number, end: number, errorCodes: ReadonlyArray<number>): ReadonlyArray<CodeFixAction> {
557557
const args: protocol.CodeFixRequestArgs = { ...this.createFileRangeRequestArgs(file, start, end), errorCodes };
558558

559559
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
560560
const response = this.processResponse<protocol.CodeFixResponse>(request);
561561

562562
// TODO: GH#20538 shouldn't need cast
563-
return (response.body as protocol.CodeFixAction[]).map(({ description, changes, fixId }) => ({ description, changes: this.convertChanges(changes, file), fixId }));
563+
return (response.body as ReadonlyArray<protocol.CodeFixAction>).map(({ description, changes, fixId }) => ({ description, changes: this.convertChanges(changes, file), fixId }));
564564
}
565565

566566
getCombinedCodeFix = notImplemented;

src/server/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ namespace ts.server.protocol {
619619
/**
620620
* Errorcodes we want to get the fixes for.
621621
*/
622-
errorCodes?: number[];
622+
errorCodes?: ReadonlyArray<number>;
623623
}
624624

625625
// TODO: GH#20538

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ namespace ts {
18831883
return [];
18841884
}
18851885

1886-
function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeFixAction[] {
1886+
function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeFixAction> {
18871887
synchronizeHostData();
18881888
const sourceFile = getValidSourceFile(fileName);
18891889
const span = createTextSpanFromBounds(start, end);

src/services/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ namespace ts {
295295

296296
getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan;
297297

298-
// TODO: GH#20538 return `CodeFixAction[]`
299-
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[];
298+
// TODO: GH#20538 return `ReadonlyArray<CodeFixAction>`
299+
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings): ReadonlyArray<CodeAction>;
300300
// TODO: GH#20538
301301
/* @internal */
302302
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings): CombinedCodeActions;
@@ -428,8 +428,8 @@ namespace ts {
428428
// TODO: GH#20538
429429
/* @internal */
430430
export interface CombinedCodeActions {
431-
changes: FileTextChanges[];
432-
commands: CodeActionCommand[] | undefined;
431+
changes: ReadonlyArray<FileTextChanges>;
432+
commands: ReadonlyArray<CodeActionCommand> | undefined;
433433
}
434434

435435
// Publicly, this type is just `{}`. Internally it is a union of all the actions we use.

0 commit comments

Comments
 (0)