mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Make getSupportedCodeFixes plugin test such that we dont need to update its baseline for every new error (#53070)
This commit is contained in:
parent
40cd0de05b
commit
b19cfc03f2
@ -49,6 +49,7 @@ function createCodeFixActionWorker(fixName: string, description: string, changes
|
||||
/** @internal */
|
||||
export function registerCodeFix(reg: CodeFixRegistration) {
|
||||
for (const error of reg.errorCodes) {
|
||||
errorCodeToFixesArray = undefined;
|
||||
errorCodeToFixes.add(String(error), reg);
|
||||
}
|
||||
if (reg.fixIds) {
|
||||
@ -59,9 +60,10 @@ export function registerCodeFix(reg: CodeFixRegistration) {
|
||||
}
|
||||
}
|
||||
|
||||
let errorCodeToFixesArray: readonly string[] | undefined;
|
||||
/** @internal */
|
||||
export function getSupportedErrorCodes(): readonly string[] {
|
||||
return arrayFrom(errorCodeToFixes.keys());
|
||||
return errorCodeToFixesArray ??= arrayFrom(errorCodeToFixes.keys());
|
||||
}
|
||||
|
||||
function removeFixIdIfFixAllUnavailable(registration: CodeFixRegistration, diagnostics: Diagnostic[]) {
|
||||
|
||||
@ -560,7 +560,7 @@ export class TestSession extends ts.server.Session {
|
||||
}
|
||||
const response = super.executeCommand(request);
|
||||
if (this.logger.hasLevel(ts.server.LogLevel.verbose)) {
|
||||
this.logger.info(`response:${ts.server.indent(JSON.stringify(response, undefined, 2))}`);
|
||||
this.logger.info(`response:${ts.server.indent(JSON.stringify(response.response === ts.getSupportedCodeFixes() ? { ...response, response: "ts.getSupportedCodeFixes()" } : response, undefined, 2))}`);
|
||||
this.testhost.baselineHost("After request");
|
||||
}
|
||||
return response;
|
||||
|
||||
@ -195,7 +195,7 @@ describe("unittests:: tsserver:: plugins overriding getSupportedCodeFixes", () =
|
||||
return ["b"];
|
||||
default:
|
||||
// Make this stable list of single item so we dont have to update the baseline for every additional error
|
||||
return [info.languageService.getSupportedCodeFixes(fileName)[0]];
|
||||
return info.languageService.getSupportedCodeFixes(fileName);
|
||||
}
|
||||
};
|
||||
return proxy;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user