corsa-oxlint 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rule_tester.js +2 -1
- package/dist/rule_tester.js.map +1 -1
- package/dist/rules/native_bridge.js +75 -8
- package/dist/rules/native_bridge.js.map +1 -1
- package/dist/session.d.ts +23 -0
- package/dist/session.js +79 -8
- package/dist/session.js.map +1 -1
- package/dist/test_support.d.ts +16 -1
- package/dist/test_support.js +21 -1
- package/dist/test_support.js.map +1 -1
- package/package.json +5 -5
package/dist/rule_tester.js
CHANGED
|
@@ -53,7 +53,8 @@ var RuleTester = class {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
function createWorkspace() {
|
|
56
|
-
const
|
|
56
|
+
const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();
|
|
57
|
+
const workspace = mkdtempSync(join(root, "corsa-oxlint-"));
|
|
57
58
|
registerCleanup(workspace);
|
|
58
59
|
return workspace;
|
|
59
60
|
}
|
package/dist/rule_tester.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\ntype TestLifecycleGlobal = typeof globalThis & {\n after?: (callback: () => void) => unknown;\n afterAll?: (callback: () => void) => unknown;\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const workspace = createWorkspace();\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"invalid\", index),\n ),\n };\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n }\n}\n\nfunction createWorkspace(): string {\n const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();\n const workspace = mkdtempSync(join(root, \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): TestCase {\n const caseWorkspace = resolve(workspace, `${group}-${index}`);\n const normalized = typeof test === \"string\" ? ({ code: test } as TestCase) : test;\n const filename = resolveCaseFilename(caseWorkspace, normalized.filename, \"case.ts\");\n const projectRoot = isAbsolute(normalized.filename ?? \"\") ? dirname(filename) : caseWorkspace;\n writeFixture(filename, normalized.code, projectRoot);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n normalized.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: projectRoot,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n normalized.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(\n parserOptions,\n normalized,\n config,\n );\n return {\n ...normalized,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...normalized.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(normalized.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...normalized.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction resolveCaseFilename(\n caseWorkspace: string,\n filename: string | undefined,\n fallback: string,\n): string {\n if (!filename) {\n return resolve(caseWorkspace, fallback);\n }\n return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeFixture(filename: string, code: string, projectRoot: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n writeProjectConfig(resolve(projectRoot, \"tsconfig.json\"));\n}\n\nfunction writeProjectConfig(configPath: string): void {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n const afterAll = lifecycleCleanup();\n if (afterAll) {\n afterAll(() => cleanupWorkspace(workspace));\n }\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.once(\"beforeExit\", cleanupAllWorkspaces);\n process.once(\"exit\", cleanupAllWorkspaces);\n}\n\nfunction lifecycleCleanup(): ((callback: () => void) => unknown) | undefined {\n const testGlobal = globalThis as TestLifecycleGlobal;\n return typeof testGlobal.afterAll === \"function\"\n ? testGlobal.afterAll\n : typeof testGlobal.after === \"function\"\n ? testGlobal.after\n : undefined;\n}\n\nfunction cleanupWorkspace(workspace: string): void {\n if (!cleanupDirs.delete(workspace)) {\n return;\n }\n rmSync(workspace, { force: true, recursive: true });\n}\n\nfunction cleanupAllWorkspaces(): void {\n for (const dir of cleanupDirs) {\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2B;CAC/E,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,cAAc,UAAU,IAAI;CAC5B,mBAAmB,QAAQ,aAAa,eAAe,CAAC;AAC1D;AAEA,SAAS,mBAAmB,YAA0B;CACpD,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAClD,cACE,YACA,KAAK,UACH;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,QAAQ;EACV;EACA,SAAS,CAAC,MAAM;CAClB,GACA,MACA,CACF,CACF;AACF;AAEA,SAAS,gBAAgB,WAAyB;CAChD,YAAY,IAAI,SAAS;CACzB,MAAM,WAAW,iBAAiB;CAClC,IAAI,UACF,eAAe,iBAAiB,SAAS,CAAC;CAE5C,IAAI,kBACF;CAEF,mBAAmB;CACnB,QAAQ,KAAK,cAAc,oBAAoB;CAC/C,QAAQ,KAAK,QAAQ,oBAAoB;AAC3C;AAEA,SAAS,mBAAoE;CAC3E,MAAM,aAAa;CACnB,OAAO,OAAO,WAAW,aAAa,aAClC,WAAW,WACX,OAAO,WAAW,UAAU,aAC1B,WAAW,QACX,KAAA;AACR;AAEA,SAAS,iBAAiB,WAAyB;CACjD,IAAI,CAAC,YAAY,OAAO,SAAS,GAC/B;CAEF,OAAO,WAAW;EAAE,OAAO;EAAM,WAAW;CAAK,CAAC;AACpD;AAEA,SAAS,uBAA6B;CACpC,KAAK,MAAM,OAAO,aAChB,iBAAiB,GAAG;AAExB"}
|
|
1
|
+
{"version":3,"file":"rule_tester.js","names":["OxlintRuleTester","#inner","#config"],"sources":["../ts/rule_tester.ts"],"sourcesContent":["import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\nimport { RuleTester as OxlintRuleTester } from \"oxlint/plugins-dev\";\n\nimport { defaultCorsaExecutable, mergeTypeAwareParserOptions } from \"./context\";\nimport { decorateRule } from \"./plugin\";\nimport type { CorsaOxlintSettings, TypeAwareParserOptions } from \"./types\";\n\ntype TesterConfig = import(\"oxlint/plugins-dev\").RuleTester.Config;\ntype TestCase = import(\"oxlint/plugins-dev\").RuleTester.ValidTestCase &\n Partial<import(\"oxlint/plugins-dev\").RuleTester.InvalidTestCase>;\ntype TestCases = import(\"oxlint/plugins-dev\").RuleTester.TestCases;\nexport type RuleTesterConfig = TesterConfig & {\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n};\ntype TestLifecycleGlobal = typeof globalThis & {\n after?: (callback: () => void) => unknown;\n afterAll?: (callback: () => void) => unknown;\n};\n\nconst cleanupDirs = new Set<string>();\nlet cleanupInstalled = false;\n\nexport class RuleTester {\n /**\n * A thin Oxlint `RuleTester` wrapper that injects\n * `settings.corsaOxlint`\n * settings, temporary fixtures, and a default project service.\n *\n * @example\n * ```ts\n * const tester = new RuleTester();\n * tester.run(\"demo\", rule, {\n * valid: [{ code: \"const answer = 42;\" }],\n * invalid: [],\n * });\n * ```\n */\n static get describe() {\n return OxlintRuleTester.describe;\n }\n\n static set describe(value) {\n OxlintRuleTester.describe = value;\n }\n\n static get it() {\n return OxlintRuleTester.it;\n }\n\n static set it(value) {\n OxlintRuleTester.it = value;\n }\n\n static only(item: string | TestCase): TestCase {\n return OxlintRuleTester.only(item);\n }\n\n readonly #inner: OxlintRuleTester;\n readonly #config?: RuleTesterConfig;\n\n constructor(config?: RuleTesterConfig) {\n this.#config = config;\n this.#inner = new OxlintRuleTester(config);\n }\n\n run(ruleName: string, rule: Record<string, unknown>, tests: TestCases): void {\n const workspace = createWorkspace();\n const transformed = {\n valid: tests.valid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"valid\", index),\n ),\n invalid: tests.invalid.map((test, index) =>\n prepareTestCase(workspace, test, this.#config, \"invalid\", index),\n ),\n };\n this.#inner.run(ruleName, decorateRule(rule as never) as never, transformed as TestCases);\n }\n}\n\nfunction createWorkspace(): string {\n const root = process.env.CORSA_OXLINT_RULE_TESTER_TMPDIR ?? tmpdir();\n const workspace = mkdtempSync(join(root, \"corsa-oxlint-\"));\n registerCleanup(workspace);\n return workspace;\n}\n\nfunction prepareTestCase(\n workspace: string,\n test: string | TestCase,\n config: RuleTesterConfig | undefined,\n group: \"valid\" | \"invalid\",\n index: number,\n): TestCase {\n const caseWorkspace = resolve(workspace, `${group}-${index}`);\n const normalized = typeof test === \"string\" ? ({ code: test } as TestCase) : test;\n const filename = resolveCaseFilename(caseWorkspace, normalized.filename, \"case.ts\");\n const projectRoot = isAbsolute(normalized.filename ?? \"\") ? dirname(filename) : caseWorkspace;\n writeFixture(filename, normalized.code, projectRoot);\n const testerConfig = config;\n const baseSettings = testerConfig?.settings?.corsaOxlint;\n const caseSettings = (\n normalized.settings as {\n corsaOxlint?: CorsaOxlintSettings;\n }\n )?.corsaOxlint;\n const parserOptions = mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(\n mergeTypeAwareParserOptions(baseSettings, baseSettings?.parserOptions),\n mergeTypeAwareParserOptions(caseSettings, caseSettings?.parserOptions),\n ),\n {\n tsconfigRootDir: projectRoot,\n projectService: {\n allowDefaultProject: [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"],\n },\n },\n ),\n mergeTypeAwareParserOptions(\n config?.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n normalized.languageOptions?.parserOptions as TypeAwareParserOptions | undefined,\n ),\n );\n const parserOptionsWithRuntime = applyRuleTesterRuntimeDefaults(\n parserOptions,\n normalized,\n config,\n );\n return {\n ...normalized,\n filename,\n settings: {\n ...testerConfig?.settings,\n ...normalized.settings,\n corsaOxlint: {\n ...testerConfig?.settings?.corsaOxlint,\n ...(normalized.settings as { corsaOxlint?: CorsaOxlintSettings })?.corsaOxlint,\n parserOptions: parserOptionsWithRuntime,\n },\n } as never,\n languageOptions: {\n ...config?.languageOptions,\n ...normalized.languageOptions,\n parserOptions: {\n ...parserOptionsWithRuntime,\n } as never,\n },\n };\n}\n\nfunction resolveCaseFilename(\n caseWorkspace: string,\n filename: string | undefined,\n fallback: string,\n): string {\n if (!filename) {\n return resolve(caseWorkspace, fallback);\n }\n return isAbsolute(filename) ? filename : resolve(caseWorkspace, filename);\n}\n\nfunction applyRuleTesterRuntimeDefaults(\n parserOptions: TypeAwareParserOptions,\n test: TestCase,\n config: RuleTesterConfig | undefined,\n): TypeAwareParserOptions {\n if (parserOptions.corsa?.executable !== undefined) {\n return parserOptions;\n }\n const rootDir = resolve(test.cwd ?? config?.cwd ?? process.cwd());\n const executable = process.env.CORSA_EXECUTABLE ?? optionalDefaultCorsaExecutable(rootDir);\n if (!executable) {\n return parserOptions;\n }\n return mergeTypeAwareParserOptions(parserOptions, {\n corsa: {\n executable,\n },\n });\n}\n\nfunction optionalDefaultCorsaExecutable(rootDir: string): string | undefined {\n try {\n return defaultCorsaExecutable(rootDir);\n } catch {\n return undefined;\n }\n}\n\nfunction writeFixture(filename: string, code: string, projectRoot: string): void {\n mkdirSync(dirname(filename), { recursive: true });\n writeFileSync(filename, code);\n writeProjectConfig(resolve(projectRoot, \"tsconfig.json\"));\n}\n\nfunction writeProjectConfig(configPath: string): void {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n include: [\"**/*\"],\n },\n null,\n 2,\n ),\n );\n}\n\nfunction registerCleanup(workspace: string): void {\n cleanupDirs.add(workspace);\n const afterAll = lifecycleCleanup();\n if (afterAll) {\n afterAll(() => cleanupWorkspace(workspace));\n }\n if (cleanupInstalled) {\n return;\n }\n cleanupInstalled = true;\n process.once(\"beforeExit\", cleanupAllWorkspaces);\n process.once(\"exit\", cleanupAllWorkspaces);\n}\n\nfunction lifecycleCleanup(): ((callback: () => void) => unknown) | undefined {\n const testGlobal = globalThis as TestLifecycleGlobal;\n return typeof testGlobal.afterAll === \"function\"\n ? testGlobal.afterAll\n : typeof testGlobal.after === \"function\"\n ? testGlobal.after\n : undefined;\n}\n\nfunction cleanupWorkspace(workspace: string): void {\n if (!cleanupDirs.delete(workspace)) {\n return;\n }\n rmSync(workspace, { force: true, recursive: true });\n}\n\nfunction cleanupAllWorkspaces(): void {\n for (const dir of cleanupDirs) {\n cleanupWorkspace(dir);\n }\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,8BAAc,IAAI,IAAY;AACpC,IAAI,mBAAmB;AAEvB,IAAa,aAAb,MAAwB;;;;;;;;;;;;;;;CAetB,WAAW,WAAW;EACpB,OAAOA,aAAiB;CAC1B;CAEA,WAAW,SAAS,OAAO;EACzB,aAAiB,WAAW;CAC9B;CAEA,WAAW,KAAK;EACd,OAAOA,aAAiB;CAC1B;CAEA,WAAW,GAAG,OAAO;EACnB,aAAiB,KAAK;CACxB;CAEA,OAAO,KAAK,MAAmC;EAC7C,OAAOA,aAAiB,KAAK,IAAI;CACnC;CAEA;CACA;CAEA,YAAY,QAA2B;EACrC,KAAKE,UAAU;EACf,KAAKD,SAAS,IAAID,aAAiB,MAAM;CAC3C;CAEA,IAAI,UAAkB,MAA+B,OAAwB;EAC3E,MAAM,YAAY,gBAAgB;EAClC,MAAM,cAAc;GAClB,OAAO,MAAM,MAAM,KAAK,MAAM,UAC5B,gBAAgB,WAAW,MAAM,KAAKE,SAAS,SAAS,KAAK,CAC/D;GACA,SAAS,MAAM,QAAQ,KAAK,MAAM,UAChC,gBAAgB,WAAW,MAAM,KAAKA,SAAS,WAAW,KAAK,CACjE;EACF;EACA,KAAKD,OAAO,IAAI,UAAU,aAAa,IAAa,GAAY,WAAwB;CAC1F;AACF;AAEA,SAAS,kBAA0B;CACjC,MAAM,OAAO,QAAQ,IAAI,mCAAmC,OAAO;CACnE,MAAM,YAAY,YAAY,KAAK,MAAM,eAAe,CAAC;CACzD,gBAAgB,SAAS;CACzB,OAAO;AACT;AAEA,SAAS,gBACP,WACA,MACA,QACA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OfNode(context, node);
|
|
152
152
|
if (signatureFacts.expectedArgumentTypeTexts?.length) facts.expectedArgumentTypeTexts = signatureFacts.expectedArgumentTypeTexts;
|
|
153
153
|
if (signatureFacts.explicitTypeArgumentsRequired !== void 0) facts.explicitTypeArgumentsRequired = signatureFacts.explicitTypeArgumentsRequired;
|
|
154
|
-
const typeArgumentFacts = typeArgumentFactsOfCall(node, signatureFacts);
|
|
154
|
+
const typeArgumentFacts = typeArgumentFactsOfCall(context, node, signatureFacts);
|
|
155
155
|
for (const [key, value] of Object.entries(typeArgumentFacts)) facts[key] = value;
|
|
156
156
|
return facts;
|
|
157
157
|
}
|
|
@@ -222,26 +222,93 @@ function typeArgumentNodes(node) {
|
|
|
222
222
|
node.typeParameterInstantiation?.params
|
|
223
223
|
].find(Array.isArray) ?? [];
|
|
224
224
|
}
|
|
225
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Returns the defaults declared on the type parameters of the callee, when the
|
|
227
|
+
* callee is declared in the file being linted.
|
|
228
|
+
*
|
|
229
|
+
* Each entry is the rendered default text, or an empty string for a type
|
|
230
|
+
* parameter without one, so the result aligns with the type parameter list.
|
|
231
|
+
* Returns `undefined` when the declaration is not visible here, which keeps a
|
|
232
|
+
* caller from mistaking "no defaults" for "not found".
|
|
233
|
+
*/
|
|
234
|
+
function declaredTypeParameterDefaults(context, node) {
|
|
235
|
+
const name = identifierName(stripChainExpression(node.callee));
|
|
236
|
+
if (!name) return;
|
|
237
|
+
const params = findTypeParameterOwner(context.sourceCode?.ast, name)?.typeParameters?.params;
|
|
238
|
+
if (!Array.isArray(params)) return;
|
|
239
|
+
return params.map((param) => param?.default ? context.sourceCode.getText(param.default).trim() : "");
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Finds the declaration of `name` that carries a type parameter list.
|
|
243
|
+
*
|
|
244
|
+
* Walks the whole tree rather than a scope chain because the oxlint context
|
|
245
|
+
* does not expose scope analysis.
|
|
246
|
+
*/
|
|
247
|
+
function findTypeParameterOwner(root, name) {
|
|
248
|
+
if (!root || typeof root !== "object") return;
|
|
249
|
+
const stack = [root];
|
|
250
|
+
while (stack.length > 0) {
|
|
251
|
+
const current = stack.pop();
|
|
252
|
+
if (!current || typeof current !== "object") continue;
|
|
253
|
+
if (Array.isArray(current)) {
|
|
254
|
+
stack.push(...current);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (current.id?.name === name && current.typeParameters?.params) return current;
|
|
258
|
+
for (const key of Object.keys(current)) {
|
|
259
|
+
if (key === "parent") continue;
|
|
260
|
+
const value = current[key];
|
|
261
|
+
if (value && typeof value === "object") stack.push(value);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function typeArgumentFactsOfCall(context, node, signatureFacts) {
|
|
226
266
|
const typeArguments = typeArgumentNodes(node);
|
|
227
267
|
if (typeArguments.length === 0) return {};
|
|
228
268
|
const facts = { typeArgumentRanges: typeArguments.map((typeArgument) => rangeObject(typeArgument.range)).filter((range) => range !== void 0) };
|
|
229
269
|
const listRange = typeArgumentListRange(node, typeArguments);
|
|
230
270
|
if (listRange) facts.typeArgumentListRange = listRange;
|
|
231
|
-
const
|
|
271
|
+
const declaredDefaults = declaredTypeParameterDefaults(context, node);
|
|
272
|
+
const parameterCount = signatureFacts.signature?.typeParameters?.length ?? declaredDefaults?.length ?? signatureFacts.signature?.typeParameterDefaultTexts?.length ?? 0;
|
|
232
273
|
if (parameterCount > 0) facts.typeParameterCount = parameterCount;
|
|
233
|
-
const
|
|
274
|
+
const defaultTexts = declaredDefaults ?? signatureFacts.signature?.typeParameterDefaultTexts ?? [];
|
|
275
|
+
const lastIndex = typeArguments.length - 1;
|
|
276
|
+
const lastDefaultText = defaultTexts[lastIndex];
|
|
234
277
|
if (lastDefaultText !== void 0) {
|
|
235
278
|
const hasDefault = lastDefaultText.trim().length > 0;
|
|
236
279
|
facts.lastTypeParameterHasDefault = hasDefault;
|
|
237
|
-
if (hasDefault
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
280
|
+
if (hasDefault) {
|
|
281
|
+
if (declaredDefaults !== void 0 ? typeNodesResolveToSameType(context, typeArguments[lastIndex], declaredDefaultNode(context, node, lastIndex)) : signatureFacts.explicitTypeArgumentsRequired === false) {
|
|
282
|
+
facts.lastTypeArgumentEqualsDefault = true;
|
|
283
|
+
facts.lastTypeArgumentSameTypeFlagsAsDefault = true;
|
|
284
|
+
facts.lastTypeArgumentIdenticalToDefault = true;
|
|
285
|
+
}
|
|
241
286
|
}
|
|
242
287
|
}
|
|
243
288
|
return facts;
|
|
244
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns the AST node of the default declared on the callee's type parameter
|
|
292
|
+
* at `index`, when the callee is declared in the file being linted.
|
|
293
|
+
*/
|
|
294
|
+
function declaredDefaultNode(context, node, index) {
|
|
295
|
+
const name = identifierName(stripChainExpression(node.callee));
|
|
296
|
+
if (!name) return;
|
|
297
|
+
return findTypeParameterOwner(context.sourceCode?.ast, name)?.typeParameters?.params?.[index]?.default;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Reports whether two type nodes denote the same checker type.
|
|
301
|
+
*
|
|
302
|
+
* Comparing the checker's own type identity keeps this from depending on how
|
|
303
|
+
* either type happens to be spelled.
|
|
304
|
+
*/
|
|
305
|
+
function typeNodesResolveToSameType(context, left, right) {
|
|
306
|
+
if (!left || !right) return false;
|
|
307
|
+
const checker = checkerFor(context);
|
|
308
|
+
const leftType = checker.getTypeAtLocation(left);
|
|
309
|
+
const rightType = checker.getTypeAtLocation(right);
|
|
310
|
+
return leftType !== void 0 && rightType !== void 0 && leftType.id === rightType.id;
|
|
311
|
+
}
|
|
245
312
|
function typeArgumentListRange(node, typeArguments) {
|
|
246
313
|
const fromList = rangeObject([
|
|
247
314
|
node.typeArguments,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native_bridge.js","names":[],"sources":["../../ts/rules/native_bridge.ts"],"sourcesContent":["import { nativeLintRuleMetas, runNativeLintRule } from \"@corsa-bind/napi\";\nimport type {\n NativeLintDiagnostic,\n NativeLintNode,\n NativeLintRange,\n NativeLintRuleMeta,\n NativeNodeMetadataDepth,\n} from \"@corsa-bind/napi\";\n\nimport { createNativeRule } from \"./rule_creator\";\nimport { checkerFor, propertyNamesOfNode, typeAtNode, typeTextsAtNode } from \"./type_utils\";\nimport type { ContextWithParserOptions, CorsaCallSignatureFacts } from \"../types\";\n\ntype RangedNode = {\n readonly type: string;\n readonly range: readonly [number, number];\n};\n\ntype NativeRuleBridgeOptions = {\n readonly shouldRun?: (node: RangedNode, context: ContextWithParserOptions) => boolean;\n readonly includeTypeTexts?: NodeMetadataOption;\n readonly includePropertyNames?: NodeMetadataOption;\n readonly includeText?: NodeMetadataOption;\n readonly maxDepth?: number;\n};\n\ntype NodeMetadataOption = boolean | ((node: RangedNode, depth: number) => boolean);\n\nconst MAX_NATIVE_NODE_DEPTH = 4;\nconst nativeRuleMetasByName = new Map(nativeLintRuleMetas().map((meta) => [meta.name, meta]));\n\nexport function createRustNativeRule(\n ruleName: string,\n metaOverrides: Record<string, unknown> = {},\n bridgeOptions: NativeRuleBridgeOptions = {},\n) {\n const meta = nativeRuleMeta(ruleName);\n return createNativeRule(\n ruleName,\n {\n docs: {\n description: meta.docsDescription,\n },\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n ...metaOverrides,\n },\n (context) =>\n Object.fromEntries(\n meta.listeners.map((listener) => [\n listener,\n (node: RangedNode) => {\n if (bridgeOptions.shouldRun?.(node, context) === false) {\n return;\n }\n const includeTypeTexts = includeTypeTextsOption(bridgeOptions, meta);\n const includeText = includeTextOption(bridgeOptions, meta);\n reportNativeDiagnostics(\n context,\n node,\n runNativeLintRule(\n ruleName,\n toNativeNode(\n context,\n node,\n includeTypeTexts,\n maxDepthOption(bridgeOptions, meta),\n true,\n includePropertyNamesOption(bridgeOptions, meta),\n includeText,\n ),\n ),\n );\n },\n ]),\n ),\n );\n}\n\nexport function toNativeNode(\n context: ContextWithParserOptions,\n node: RangedNode,\n includeTypeTexts: NodeMetadataOption = true,\n maxDepth = MAX_NATIVE_NODE_DEPTH,\n includeRuleOptions = true,\n includePropertyNames: NodeMetadataOption = includeTypeTexts,\n includeText: NodeMetadataOption = false,\n depth = 0,\n): NativeLintNode {\n const fields: Record<string, unknown> = {};\n const children: Record<string, NativeLintNode> = {};\n const childLists: Record<string, NativeLintNode[]> = {};\n\n for (const [key, value] of Object.entries(node)) {\n if (isSkippedField(key)) {\n continue;\n }\n if (isNativeChildNode(value)) {\n if (maxDepth > 0) {\n children[key] = toNativeNode(\n context,\n value,\n includeTypeTexts,\n maxDepth - 1,\n false,\n includePropertyNames,\n includeText,\n depth + 1,\n );\n }\n continue;\n }\n if (Array.isArray(value)) {\n if (maxDepth > 0 && value.every(isNativeChildNode)) {\n childLists[key] = value.map((child) =>\n toNativeNode(\n context,\n child,\n includeTypeTexts,\n maxDepth - 1,\n false,\n includePropertyNames,\n includeText,\n depth + 1,\n ),\n );\n } else if (value.every(isJsonPrimitive)) {\n fields[key] = value;\n }\n continue;\n }\n if (isPrimitiveRecord(value)) {\n fields[key] = value;\n continue;\n }\n if (isJsonPrimitive(value)) {\n fields[key] = value;\n }\n }\n\n const typeAnnotationText = sourceTypeAnnotationText(context, node);\n if (typeAnnotationText) {\n fields.__typeAnnotationText = typeAnnotationText;\n }\n\n const options = (context as { options?: unknown }).options;\n if (includeRuleOptions && Array.isArray(options) && options.length > 0 && isJsonValue(options)) {\n fields.__ruleOptions = options;\n }\n if (includeRuleOptions) {\n addHostInputs(context, node, fields);\n }\n\n const nativeNode: NativeLintNode = {\n kind: node.type,\n range: nativeRange(node.range),\n };\n if (includeMetadataForNode(includeText, node, depth)) {\n nativeNode.text = context.sourceCode.getText(node as never);\n }\n if (includeMetadataForNode(includeTypeTexts, node, depth)) {\n nativeNode.typeTexts = typeTextsAtNode(context, node);\n }\n if (includeMetadataForNode(includePropertyNames, node, depth)) {\n nativeNode.propertyNames = propertyNamesOfNode(context, node);\n }\n if (Object.keys(fields).length > 0) {\n nativeNode.fields = fields;\n }\n if (Object.keys(children).length > 0) {\n nativeNode.children = children;\n }\n if (Object.keys(childLists).length > 0) {\n nativeNode.childLists = childLists;\n }\n return nativeNode;\n}\n\nexport function reportNativeDiagnostics(\n context: ContextWithParserOptions,\n node: RangedNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: reportNodeForRange(node, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction reportNodeForRange(root: RangedNode, range: NativeLintRange): RangedNode {\n return findNodeByRange(root, range) ?? root;\n}\n\nfunction findNodeByRange(\n value: unknown,\n range: NativeLintRange,\n seen = new Set<object>(),\n): RangedNode | undefined {\n if (typeof value !== \"object\" || value === null || seen.has(value)) {\n return undefined;\n }\n seen.add(value);\n\n if (isNativeChildNode(value) && sameRange(value.range, range)) {\n return value;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const match = findNodeByRange(item, range, seen);\n if (match) {\n return match;\n }\n }\n return undefined;\n }\n\n for (const [key, child] of Object.entries(value)) {\n if (isSkippedField(key)) {\n continue;\n }\n const match = findNodeByRange(child, range, seen);\n if (match) {\n return match;\n }\n }\n return undefined;\n}\n\nfunction nativeRuleMeta(ruleName: string): NativeLintRuleMeta {\n const meta = nativeRuleMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa oxlint native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n\nfunction includeTypeTextsOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includeTypeTexts ?? nodeMetadataDepthOption(meta.bridge.typeTexts, false);\n}\n\nfunction includePropertyNamesOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includePropertyNames ?? nodeMetadataDepthOption(meta.bridge.propertyNames, false);\n}\n\nfunction includeTextOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includeText ?? nodeMetadataDepthOption(meta.bridge.text, false);\n}\n\nfunction maxDepthOption(options: NativeRuleBridgeOptions, meta: NativeLintRuleMeta): number {\n return options.maxDepth ?? meta.bridge.maxDepth ?? MAX_NATIVE_NODE_DEPTH;\n}\n\nfunction nodeMetadataDepthOption(\n metadata: NativeNodeMetadataDepth | undefined,\n fallback: NodeMetadataOption,\n): NodeMetadataOption {\n if (!metadata) {\n return fallback;\n }\n return (_node, depth) => depth >= metadata.minDepth && depth <= metadata.maxDepth;\n}\n\nfunction includeMetadataForNode(\n option: NodeMetadataOption,\n node: RangedNode,\n depth: number,\n): boolean {\n return typeof option === \"function\" ? option(node, depth) : option;\n}\n\nfunction sourceTypeAnnotationText(\n context: ContextWithParserOptions,\n node: RangedNode,\n): string | undefined {\n const annotation = (node as any).typeAnnotation?.typeAnnotation ?? (node as any).typeAnnotation;\n if (!annotation) {\n return undefined;\n }\n const text = (context as any).sourceCode?.getText(annotation);\n return typeof text === \"string\" && text.length > 0 ? text : undefined;\n}\n\nfunction nativeRange(range: readonly [number, number]): NativeLintRange {\n return { start: range[0], end: range[1] };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction sameRange(range: readonly [number, number], expected: NativeLintRange): boolean {\n return range[0] === expected.start && range[1] === expected.end;\n}\n\nfunction addHostInputs(\n context: ContextWithParserOptions,\n node: RangedNode,\n fields: Record<string, unknown>,\n): void {\n const current = node as any;\n const ancestors = ancestorFacts(context, current);\n if (ancestors.length > 0) {\n fields.__ancestorFacts = ancestors;\n }\n if (current.type === \"CallExpression\" || current.type === \"NewExpression\") {\n const callFacts = callFactsOfNode(context, current);\n if (Object.keys(callFacts).length > 0) {\n fields.__callFacts = callFacts;\n }\n }\n if (current.parent?.type) {\n fields.__parentKind = current.parent.type;\n }\n const symbolFacts = symbolFactsOfNode(context, current);\n if (Object.keys(symbolFacts).length > 0) {\n fields.__symbolFacts = symbolFacts;\n }\n const typeParameterFacts = typeParameterFactsOfNode(context, current);\n if (Object.keys(typeParameterFacts).length > 0) {\n fields.__typeParameterFacts = typeParameterFacts;\n }\n const returnTypeFacts = returnTypeFactsOfNode(context, current);\n if (Object.keys(returnTypeFacts).length > 0) {\n fields.__returnTypeFacts = returnTypeFacts;\n }\n}\n\nfunction callFactsOfNode(context: ContextWithParserOptions, node: any): Record<string, unknown> {\n const facts: Record<string, unknown> = {};\n const calleeName = identifierName(stripChainExpression(node.callee));\n if (calleeName) {\n facts.calleeName = calleeName;\n }\n const signatureFacts = callSignatureFactsOfNode(context, node);\n if (signatureFacts.expectedArgumentTypeTexts?.length) {\n facts.expectedArgumentTypeTexts = signatureFacts.expectedArgumentTypeTexts;\n }\n if (signatureFacts.explicitTypeArgumentsRequired !== undefined) {\n facts.explicitTypeArgumentsRequired = signatureFacts.explicitTypeArgumentsRequired;\n }\n const typeArgumentFacts = typeArgumentFactsOfCall(node, signatureFacts);\n for (const [key, value] of Object.entries(typeArgumentFacts)) {\n facts[key] = value;\n }\n return facts;\n}\n\nfunction symbolFactsOfNode(context: ContextWithParserOptions, node: any): Record<string, unknown> {\n if (node.type !== \"Identifier\" && node.type !== \"MemberExpression\") {\n return {};\n }\n const target = node.type === \"MemberExpression\" ? node.property : node;\n if (target?.type !== \"Identifier\") {\n return {};\n }\n const symbol = checkerFor(context).getSymbolAtLocation(target);\n const declarations = symbol?.declarations?.filter(\n (declaration): declaration is string => typeof declaration === \"string\",\n );\n if (!declarations || declarations.length === 0) {\n return {};\n }\n return {\n declarations,\n filename: context.filename,\n cwd: context.cwd,\n sourceText: context.sourceCode.text,\n };\n}\n\nfunction typeParameterFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): Record<string, unknown> {\n if (node.type !== \"TSTypeParameterDeclaration\") {\n return {};\n }\n const params = Array.isArray(node.params) ? node.params : [];\n if (params.length !== 1) {\n return {};\n }\n const name = typeParameterName(params[0]);\n if (!name) {\n return {};\n }\n return {\n name,\n ownerText: node.parent\n ? context.sourceCode.getText(node.parent)\n : context.sourceCode.getText(node),\n };\n}\n\nfunction returnTypeFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): Record<string, unknown> {\n const returnTypeTexts =\n node.type === \"ReturnStatement\"\n ? returnTypeTextsOfNearestFunction(context, node)\n : isFunctionLike(node) || node.type === \"ArrowFunctionExpression\"\n ? returnTypeTextsOfFunction(context, node)\n : [];\n return returnTypeTexts.length > 0 ? { texts: returnTypeTexts } : {};\n}\n\nfunction ancestorFacts(\n context: ContextWithParserOptions,\n node: any,\n): readonly Record<string, unknown>[] {\n const ancestors = (context.sourceCode as any)?.getAncestors?.(node) ?? [];\n return ancestors\n .filter((ancestor: any) => typeof ancestor?.type === \"string\")\n .map((ancestor: any) => {\n const fact: Record<string, unknown> = { kind: ancestor.type };\n if (isRange(ancestor.range)) {\n fact.start = ancestor.range[0];\n fact.end = ancestor.range[1];\n }\n if (typeof ancestor.async === \"boolean\") {\n fact.async = ancestor.async;\n }\n const className = ancestor.id?.name;\n if (\n (ancestor.type === \"ClassDeclaration\" || ancestor.type === \"ClassExpression\") &&\n typeof className === \"string\" &&\n className.length > 0\n ) {\n fact.className = className;\n }\n if (isFunctionLike(ancestor)) {\n const paramNames = Array.isArray(ancestor.params)\n ? ancestor.params\n .map(identifierName)\n .filter((name: string | undefined): name is string => name !== undefined)\n : [];\n if (paramNames.length > 0) {\n fact.paramNames = paramNames;\n }\n if (ancestor.parent?.type) {\n fact.parentKind = ancestor.parent.type;\n }\n const parentCalleeName = identifierName(stripChainExpression(ancestor.parent?.callee));\n if (parentCalleeName) {\n fact.parentCalleeName = parentCalleeName;\n }\n if (ancestor.parent?.parent?.type) {\n fact.parentParentKind = ancestor.parent.parent.type;\n }\n const parentParentCalleeName = identifierName(\n stripChainExpression(ancestor.parent?.parent?.callee),\n );\n if (parentParentCalleeName) {\n fact.parentParentCalleeName = parentParentCalleeName;\n }\n }\n return fact;\n });\n}\n\nfunction callSignatureFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): CorsaCallSignatureFacts {\n const callee = stripChainExpression(node.callee);\n if (!callee) {\n return {};\n }\n const calleeType = typeAtNode(context, callee);\n if (!calleeType) {\n return {};\n }\n const args = Array.isArray(node.arguments) ? node.arguments : [];\n const explicitTypeArguments = typeArgumentNodes(node)\n .map((typeArgument) => context.sourceCode.getText(typeArgument))\n .filter((text: string): text is string => text.length > 0);\n return checkerFor(context).getCallSignatureFacts(\n calleeType,\n node.type === \"NewExpression\" ? 1 : 0,\n args.map((arg: unknown) => typeTextsAtNode(context, arg as never)),\n explicitTypeArguments,\n );\n}\n\nfunction typeArgumentNodes(node: any): readonly any[] {\n const candidates = [\n node.typeArguments?.params,\n node.typeParameters?.params,\n node.typeParameterInstantiation?.params,\n ];\n return candidates.find(Array.isArray) ?? [];\n}\n\nfunction typeArgumentFactsOfCall(\n node: any,\n signatureFacts: CorsaCallSignatureFacts,\n): Record<string, unknown> {\n const typeArguments = typeArgumentNodes(node);\n if (typeArguments.length === 0) {\n return {};\n }\n const facts: Record<string, unknown> = {\n typeArgumentRanges: typeArguments\n .map((typeArgument) => rangeObject(typeArgument.range))\n .filter((range): range is { start: number; end: number } => range !== undefined),\n };\n const listRange = typeArgumentListRange(node, typeArguments);\n if (listRange) {\n facts.typeArgumentListRange = listRange;\n }\n const parameterCount =\n signatureFacts.signature?.typeParameters?.length ??\n signatureFacts.signature?.typeParameterDefaultTexts?.length ??\n 0;\n if (parameterCount > 0) {\n facts.typeParameterCount = parameterCount;\n }\n const defaultTexts = signatureFacts.signature?.typeParameterDefaultTexts ?? [];\n const lastIndex = typeArguments.length - 1;\n const lastDefaultText = defaultTexts[lastIndex];\n if (lastDefaultText !== undefined) {\n const hasDefault = lastDefaultText.trim().length > 0;\n facts.lastTypeParameterHasDefault = hasDefault;\n if (hasDefault && signatureFacts.explicitTypeArgumentsRequired === false) {\n facts.lastTypeArgumentEqualsDefault = true;\n facts.lastTypeArgumentSameTypeFlagsAsDefault = true;\n facts.lastTypeArgumentIdenticalToDefault = true;\n }\n }\n return facts;\n}\n\nfunction typeArgumentListRange(\n node: any,\n typeArguments: readonly any[],\n): { start: number; end: number } | undefined {\n const candidates = [node.typeArguments, node.typeParameters, node.typeParameterInstantiation];\n const list = candidates.find((candidate) => Array.isArray(candidate?.params));\n const fromList = rangeObject(list?.range);\n if (fromList) {\n return fromList;\n }\n const first = rangeObject(typeArguments[0]?.range);\n const last = rangeObject(typeArguments[typeArguments.length - 1]?.range);\n if (!first || !last || first.start <= 0) {\n return undefined;\n }\n return { start: first.start - 1, end: last.end + 1 };\n}\n\nfunction rangeObject(range: unknown): { start: number; end: number } | undefined {\n return isRange(range) ? { start: range[0], end: range[1] } : undefined;\n}\n\nfunction typeParameterName(node: any): string | undefined {\n if (typeof node?.name === \"string\") {\n return node.name;\n }\n if (typeof node?.name?.name === \"string\") {\n return node.name.name;\n }\n return undefined;\n}\n\nfunction nearestFunctionAncestor(context: ContextWithParserOptions, node: any): any {\n const ancestors = (context.sourceCode as any)?.getAncestors?.(node) ?? [];\n return [...ancestors].reverse().find((ancestor: any) => ancestor.type?.includes(\"Function\"));\n}\n\nfunction isFunctionLike(node: any): boolean {\n return typeof node?.type === \"string\" && node.type.includes(\"Function\");\n}\n\nfunction returnTypeTextsOfNearestFunction(\n context: ContextWithParserOptions,\n node: any,\n): readonly string[] {\n const owner = nearestFunctionAncestor(context, node);\n return owner ? returnTypeTextsOfFunction(context, owner) : [];\n}\n\nfunction returnTypeTextsOfFunction(\n context: ContextWithParserOptions,\n node: any,\n): readonly string[] {\n const explicitAnnotation = node.returnType?.typeAnnotation ?? node.returnType;\n if (explicitAnnotation) {\n const text = context.sourceCode.getText(explicitAnnotation);\n if (text) {\n return [text];\n }\n }\n\n const checker = checkerFor(context);\n const type = typeAtNode(context, node);\n if (!type) {\n return [];\n }\n\n const texts = new Set<string>();\n for (const signature of checker.getSignaturesOfType(type, 0)) {\n const returnType = checker.getReturnTypeOfSignature(signature);\n if (!returnType) {\n continue;\n }\n for (const text of [...(returnType.texts ?? []), checker.typeToString(returnType)]) {\n if (text) {\n texts.add(text);\n }\n }\n }\n\n const resolved = [...texts];\n return resolved.every(isPermissiveTypeText) ? [] : resolved;\n}\n\nfunction isPermissiveTypeText(text: string): boolean {\n return text === \"any\" || text === \"unknown\" || text === \"never\";\n}\n\nfunction stripChainExpression(node: any): any {\n let current = node;\n while (current?.type === \"ChainExpression\") {\n current = current.expression;\n }\n return current;\n}\n\nfunction identifierName(node: any): string | undefined {\n const current = stripChainExpression(node);\n return current?.type === \"Identifier\" && typeof current.name === \"string\"\n ? current.name\n : undefined;\n}\n\nfunction isNativeChildNode(value: unknown): value is RangedNode {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { type?: unknown }).type === \"string\" &&\n isRange((value as { range?: unknown }).range)\n );\n}\n\nfunction isRange(value: unknown): value is readonly [number, number] {\n return (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === \"number\" &&\n typeof value[1] === \"number\"\n );\n}\n\nfunction isJsonPrimitive(value: unknown): value is string | number | boolean | null {\n return value === null || [\"boolean\", \"number\", \"string\"].includes(typeof value);\n}\n\nfunction isJsonValue(value: unknown): boolean {\n if (isJsonPrimitive(value)) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.every(isJsonValue);\n }\n return typeof value === \"object\" && value !== null && Object.values(value).every(isJsonValue);\n}\n\nfunction isPrimitiveRecord(\n value: unknown,\n): value is Record<string, string | number | boolean | null> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.values(value).every(isJsonPrimitive)\n );\n}\n\nfunction isSkippedField(key: string): boolean {\n return key === \"type\" || key === \"range\" || key === \"loc\" || key === \"parent\";\n}\n"],"mappings":";;;;AA4BA,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB,IAAI,IAAI,oBAAoB,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAE5F,SAAgB,qBACd,UACA,gBAAyC,CAAC,GAC1C,gBAAyC,CAAC,GAC1C;CACA,MAAM,OAAO,eAAe,QAAQ;CACpC,OAAO,iBACL,UACA;EACE,MAAM,EACJ,aAAa,KAAK,gBACpB;EACA,gBAAgB,KAAK;EACrB,UAAU,KAAK;EACf,GAAG;CACL,IACC,YACC,OAAO,YACL,KAAK,UAAU,KAAK,aAAa,CAC/B,WACC,SAAqB;EACpB,IAAI,cAAc,YAAY,MAAM,OAAO,MAAM,OAC/C;EAEF,MAAM,mBAAmB,uBAAuB,eAAe,IAAI;EACnE,MAAM,cAAc,kBAAkB,eAAe,IAAI;EACzD,wBACE,SACA,MACA,kBACE,UACA,aACE,SACA,MACA,kBACA,eAAe,eAAe,IAAI,GAClC,MACA,2BAA2B,eAAe,IAAI,GAC9C,WACF,CACF,CACF;CACF,CACF,CAAC,CACH,CACJ;AACF;AAEA,SAAgB,aACd,SACA,MACA,mBAAuC,MACvC,WAAW,uBACX,qBAAqB,MACrB,uBAA2C,kBAC3C,cAAkC,OAClC,QAAQ,GACQ;CAChB,MAAM,SAAkC,CAAC;CACzC,MAAM,WAA2C,CAAC;CAClD,MAAM,aAA+C,CAAC;CAEtD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,IAAI,eAAe,GAAG,GACpB;EAEF,IAAI,kBAAkB,KAAK,GAAG;GAC5B,IAAI,WAAW,GACb,SAAS,OAAO,aACd,SACA,OACA,kBACA,WAAW,GACX,OACA,sBACA,aACA,QAAQ,CACV;GAEF;EACF;EACA,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxB,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EpB,OAAO;AACT;AAEA,SAAS,eAAe,MAA+B;CACrD,MAAM,UAAU,qBAAqB,IAAI;CACzC,OAAO,SAAS,SAAS,gBAAgB,OAAO,QAAQ,SAAS,WAC7D,QAAQ,OACR,KAAA;AACN;AAEA,SAAS,kBAAkB,OAAqC;CAC9D,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS,YAC9C,QAAS,MAA8B,KAAK;AAEhD;AAEA,SAAS,QAAQ,OAAoD;CACnE,OACE,MAAM,QAAQ,KAAK,KACnB,MAAM,WAAW,KACjB,OAAO,MAAM,OAAO,YACpB,OAAO,MAAM,OAAO;AAExB;AAEA,SAAS,gBAAgB,OAA2D;CAClF,OAAO,UAAU,QAAQ;EAAC;EAAW;EAAU;CAAQ,CAAC,CAAC,SAAS,OAAO,KAAK;AAChF;AAEA,SAAS,YAAY,OAAyB;CAC5C,IAAI,gBAAgB,KAAK,GACvB,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,MAAM,WAAW;CAEhC,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,WAAW;AAC9F;AAEA,SAAS,kBACP,OAC2D;CAC3D,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,KACpB,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,eAAe;AAE9C;AAEA,SAAS,eAAe,KAAsB;CAC5C,OAAO,QAAQ,UAAU,QAAQ,WAAW,QAAQ,SAAS,QAAQ;AACvE"}
|
|
1
|
+
{"version":3,"file":"native_bridge.js","names":[],"sources":["../../ts/rules/native_bridge.ts"],"sourcesContent":["import { nativeLintRuleMetas, runNativeLintRule } from \"@corsa-bind/napi\";\nimport type {\n NativeLintDiagnostic,\n NativeLintNode,\n NativeLintRange,\n NativeLintRuleMeta,\n NativeNodeMetadataDepth,\n} from \"@corsa-bind/napi\";\n\nimport { createNativeRule } from \"./rule_creator\";\nimport { checkerFor, propertyNamesOfNode, typeAtNode, typeTextsAtNode } from \"./type_utils\";\nimport type { ContextWithParserOptions, CorsaCallSignatureFacts } from \"../types\";\n\ntype RangedNode = {\n readonly type: string;\n readonly range: readonly [number, number];\n};\n\ntype NativeRuleBridgeOptions = {\n readonly shouldRun?: (node: RangedNode, context: ContextWithParserOptions) => boolean;\n readonly includeTypeTexts?: NodeMetadataOption;\n readonly includePropertyNames?: NodeMetadataOption;\n readonly includeText?: NodeMetadataOption;\n readonly maxDepth?: number;\n};\n\ntype NodeMetadataOption = boolean | ((node: RangedNode, depth: number) => boolean);\n\nconst MAX_NATIVE_NODE_DEPTH = 4;\nconst nativeRuleMetasByName = new Map(nativeLintRuleMetas().map((meta) => [meta.name, meta]));\n\nexport function createRustNativeRule(\n ruleName: string,\n metaOverrides: Record<string, unknown> = {},\n bridgeOptions: NativeRuleBridgeOptions = {},\n) {\n const meta = nativeRuleMeta(ruleName);\n return createNativeRule(\n ruleName,\n {\n docs: {\n description: meta.docsDescription,\n },\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n ...metaOverrides,\n },\n (context) =>\n Object.fromEntries(\n meta.listeners.map((listener) => [\n listener,\n (node: RangedNode) => {\n if (bridgeOptions.shouldRun?.(node, context) === false) {\n return;\n }\n const includeTypeTexts = includeTypeTextsOption(bridgeOptions, meta);\n const includeText = includeTextOption(bridgeOptions, meta);\n reportNativeDiagnostics(\n context,\n node,\n runNativeLintRule(\n ruleName,\n toNativeNode(\n context,\n node,\n includeTypeTexts,\n maxDepthOption(bridgeOptions, meta),\n true,\n includePropertyNamesOption(bridgeOptions, meta),\n includeText,\n ),\n ),\n );\n },\n ]),\n ),\n );\n}\n\nexport function toNativeNode(\n context: ContextWithParserOptions,\n node: RangedNode,\n includeTypeTexts: NodeMetadataOption = true,\n maxDepth = MAX_NATIVE_NODE_DEPTH,\n includeRuleOptions = true,\n includePropertyNames: NodeMetadataOption = includeTypeTexts,\n includeText: NodeMetadataOption = false,\n depth = 0,\n): NativeLintNode {\n const fields: Record<string, unknown> = {};\n const children: Record<string, NativeLintNode> = {};\n const childLists: Record<string, NativeLintNode[]> = {};\n\n for (const [key, value] of Object.entries(node)) {\n if (isSkippedField(key)) {\n continue;\n }\n if (isNativeChildNode(value)) {\n if (maxDepth > 0) {\n children[key] = toNativeNode(\n context,\n value,\n includeTypeTexts,\n maxDepth - 1,\n false,\n includePropertyNames,\n includeText,\n depth + 1,\n );\n }\n continue;\n }\n if (Array.isArray(value)) {\n if (maxDepth > 0 && value.every(isNativeChildNode)) {\n childLists[key] = value.map((child) =>\n toNativeNode(\n context,\n child,\n includeTypeTexts,\n maxDepth - 1,\n false,\n includePropertyNames,\n includeText,\n depth + 1,\n ),\n );\n } else if (value.every(isJsonPrimitive)) {\n fields[key] = value;\n }\n continue;\n }\n if (isPrimitiveRecord(value)) {\n fields[key] = value;\n continue;\n }\n if (isJsonPrimitive(value)) {\n fields[key] = value;\n }\n }\n\n const typeAnnotationText = sourceTypeAnnotationText(context, node);\n if (typeAnnotationText) {\n fields.__typeAnnotationText = typeAnnotationText;\n }\n\n const options = (context as { options?: unknown }).options;\n if (includeRuleOptions && Array.isArray(options) && options.length > 0 && isJsonValue(options)) {\n fields.__ruleOptions = options;\n }\n if (includeRuleOptions) {\n addHostInputs(context, node, fields);\n }\n\n const nativeNode: NativeLintNode = {\n kind: node.type,\n range: nativeRange(node.range),\n };\n if (includeMetadataForNode(includeText, node, depth)) {\n nativeNode.text = context.sourceCode.getText(node as never);\n }\n if (includeMetadataForNode(includeTypeTexts, node, depth)) {\n nativeNode.typeTexts = typeTextsAtNode(context, node);\n }\n if (includeMetadataForNode(includePropertyNames, node, depth)) {\n nativeNode.propertyNames = propertyNamesOfNode(context, node);\n }\n if (Object.keys(fields).length > 0) {\n nativeNode.fields = fields;\n }\n if (Object.keys(children).length > 0) {\n nativeNode.children = children;\n }\n if (Object.keys(childLists).length > 0) {\n nativeNode.childLists = childLists;\n }\n return nativeNode;\n}\n\nexport function reportNativeDiagnostics(\n context: ContextWithParserOptions,\n node: RangedNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: reportNodeForRange(node, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction reportNodeForRange(root: RangedNode, range: NativeLintRange): RangedNode {\n return findNodeByRange(root, range) ?? root;\n}\n\nfunction findNodeByRange(\n value: unknown,\n range: NativeLintRange,\n seen = new Set<object>(),\n): RangedNode | undefined {\n if (typeof value !== \"object\" || value === null || seen.has(value)) {\n return undefined;\n }\n seen.add(value);\n\n if (isNativeChildNode(value) && sameRange(value.range, range)) {\n return value;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n const match = findNodeByRange(item, range, seen);\n if (match) {\n return match;\n }\n }\n return undefined;\n }\n\n for (const [key, child] of Object.entries(value)) {\n if (isSkippedField(key)) {\n continue;\n }\n const match = findNodeByRange(child, range, seen);\n if (match) {\n return match;\n }\n }\n return undefined;\n}\n\nfunction nativeRuleMeta(ruleName: string): NativeLintRuleMeta {\n const meta = nativeRuleMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa oxlint native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n\nfunction includeTypeTextsOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includeTypeTexts ?? nodeMetadataDepthOption(meta.bridge.typeTexts, false);\n}\n\nfunction includePropertyNamesOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includePropertyNames ?? nodeMetadataDepthOption(meta.bridge.propertyNames, false);\n}\n\nfunction includeTextOption(\n options: NativeRuleBridgeOptions,\n meta: NativeLintRuleMeta,\n): NodeMetadataOption {\n return options.includeText ?? nodeMetadataDepthOption(meta.bridge.text, false);\n}\n\nfunction maxDepthOption(options: NativeRuleBridgeOptions, meta: NativeLintRuleMeta): number {\n return options.maxDepth ?? meta.bridge.maxDepth ?? MAX_NATIVE_NODE_DEPTH;\n}\n\nfunction nodeMetadataDepthOption(\n metadata: NativeNodeMetadataDepth | undefined,\n fallback: NodeMetadataOption,\n): NodeMetadataOption {\n if (!metadata) {\n return fallback;\n }\n return (_node, depth) => depth >= metadata.minDepth && depth <= metadata.maxDepth;\n}\n\nfunction includeMetadataForNode(\n option: NodeMetadataOption,\n node: RangedNode,\n depth: number,\n): boolean {\n return typeof option === \"function\" ? option(node, depth) : option;\n}\n\nfunction sourceTypeAnnotationText(\n context: ContextWithParserOptions,\n node: RangedNode,\n): string | undefined {\n const annotation = (node as any).typeAnnotation?.typeAnnotation ?? (node as any).typeAnnotation;\n if (!annotation) {\n return undefined;\n }\n const text = (context as any).sourceCode?.getText(annotation);\n return typeof text === \"string\" && text.length > 0 ? text : undefined;\n}\n\nfunction nativeRange(range: readonly [number, number]): NativeLintRange {\n return { start: range[0], end: range[1] };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction sameRange(range: readonly [number, number], expected: NativeLintRange): boolean {\n return range[0] === expected.start && range[1] === expected.end;\n}\n\nfunction addHostInputs(\n context: ContextWithParserOptions,\n node: RangedNode,\n fields: Record<string, unknown>,\n): void {\n const current = node as any;\n const ancestors = ancestorFacts(context, current);\n if (ancestors.length > 0) {\n fields.__ancestorFacts = ancestors;\n }\n if (current.type === \"CallExpression\" || current.type === \"NewExpression\") {\n const callFacts = callFactsOfNode(context, current);\n if (Object.keys(callFacts).length > 0) {\n fields.__callFacts = callFacts;\n }\n }\n if (current.parent?.type) {\n fields.__parentKind = current.parent.type;\n }\n const symbolFacts = symbolFactsOfNode(context, current);\n if (Object.keys(symbolFacts).length > 0) {\n fields.__symbolFacts = symbolFacts;\n }\n const typeParameterFacts = typeParameterFactsOfNode(context, current);\n if (Object.keys(typeParameterFacts).length > 0) {\n fields.__typeParameterFacts = typeParameterFacts;\n }\n const returnTypeFacts = returnTypeFactsOfNode(context, current);\n if (Object.keys(returnTypeFacts).length > 0) {\n fields.__returnTypeFacts = returnTypeFacts;\n }\n}\n\nfunction callFactsOfNode(context: ContextWithParserOptions, node: any): Record<string, unknown> {\n const facts: Record<string, unknown> = {};\n const calleeName = identifierName(stripChainExpression(node.callee));\n if (calleeName) {\n facts.calleeName = calleeName;\n }\n const signatureFacts = callSignatureFactsOfNode(context, node);\n if (signatureFacts.expectedArgumentTypeTexts?.length) {\n facts.expectedArgumentTypeTexts = signatureFacts.expectedArgumentTypeTexts;\n }\n if (signatureFacts.explicitTypeArgumentsRequired !== undefined) {\n facts.explicitTypeArgumentsRequired = signatureFacts.explicitTypeArgumentsRequired;\n }\n const typeArgumentFacts = typeArgumentFactsOfCall(context, node, signatureFacts);\n for (const [key, value] of Object.entries(typeArgumentFacts)) {\n facts[key] = value;\n }\n return facts;\n}\n\nfunction symbolFactsOfNode(context: ContextWithParserOptions, node: any): Record<string, unknown> {\n if (node.type !== \"Identifier\" && node.type !== \"MemberExpression\") {\n return {};\n }\n const target = node.type === \"MemberExpression\" ? node.property : node;\n if (target?.type !== \"Identifier\") {\n return {};\n }\n const symbol = checkerFor(context).getSymbolAtLocation(target);\n const declarations = symbol?.declarations?.filter(\n (declaration): declaration is string => typeof declaration === \"string\",\n );\n if (!declarations || declarations.length === 0) {\n return {};\n }\n return {\n declarations,\n filename: context.filename,\n cwd: context.cwd,\n sourceText: context.sourceCode.text,\n };\n}\n\nfunction typeParameterFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): Record<string, unknown> {\n if (node.type !== \"TSTypeParameterDeclaration\") {\n return {};\n }\n const params = Array.isArray(node.params) ? node.params : [];\n if (params.length !== 1) {\n return {};\n }\n const name = typeParameterName(params[0]);\n if (!name) {\n return {};\n }\n return {\n name,\n ownerText: node.parent\n ? context.sourceCode.getText(node.parent)\n : context.sourceCode.getText(node),\n };\n}\n\nfunction returnTypeFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): Record<string, unknown> {\n const returnTypeTexts =\n node.type === \"ReturnStatement\"\n ? returnTypeTextsOfNearestFunction(context, node)\n : isFunctionLike(node) || node.type === \"ArrowFunctionExpression\"\n ? returnTypeTextsOfFunction(context, node)\n : [];\n return returnTypeTexts.length > 0 ? { texts: returnTypeTexts } : {};\n}\n\nfunction ancestorFacts(\n context: ContextWithParserOptions,\n node: any,\n): readonly Record<string, unknown>[] {\n const ancestors = (context.sourceCode as any)?.getAncestors?.(node) ?? [];\n return ancestors\n .filter((ancestor: any) => typeof ancestor?.type === \"string\")\n .map((ancestor: any) => {\n const fact: Record<string, unknown> = { kind: ancestor.type };\n if (isRange(ancestor.range)) {\n fact.start = ancestor.range[0];\n fact.end = ancestor.range[1];\n }\n if (typeof ancestor.async === \"boolean\") {\n fact.async = ancestor.async;\n }\n const className = ancestor.id?.name;\n if (\n (ancestor.type === \"ClassDeclaration\" || ancestor.type === \"ClassExpression\") &&\n typeof className === \"string\" &&\n className.length > 0\n ) {\n fact.className = className;\n }\n if (isFunctionLike(ancestor)) {\n const paramNames = Array.isArray(ancestor.params)\n ? ancestor.params\n .map(identifierName)\n .filter((name: string | undefined): name is string => name !== undefined)\n : [];\n if (paramNames.length > 0) {\n fact.paramNames = paramNames;\n }\n if (ancestor.parent?.type) {\n fact.parentKind = ancestor.parent.type;\n }\n const parentCalleeName = identifierName(stripChainExpression(ancestor.parent?.callee));\n if (parentCalleeName) {\n fact.parentCalleeName = parentCalleeName;\n }\n if (ancestor.parent?.parent?.type) {\n fact.parentParentKind = ancestor.parent.parent.type;\n }\n const parentParentCalleeName = identifierName(\n stripChainExpression(ancestor.parent?.parent?.callee),\n );\n if (parentParentCalleeName) {\n fact.parentParentCalleeName = parentParentCalleeName;\n }\n }\n return fact;\n });\n}\n\nfunction callSignatureFactsOfNode(\n context: ContextWithParserOptions,\n node: any,\n): CorsaCallSignatureFacts {\n const callee = stripChainExpression(node.callee);\n if (!callee) {\n return {};\n }\n const calleeType = typeAtNode(context, callee);\n if (!calleeType) {\n return {};\n }\n const args = Array.isArray(node.arguments) ? node.arguments : [];\n const explicitTypeArguments = typeArgumentNodes(node)\n .map((typeArgument) => context.sourceCode.getText(typeArgument))\n .filter((text: string): text is string => text.length > 0);\n return checkerFor(context).getCallSignatureFacts(\n calleeType,\n node.type === \"NewExpression\" ? 1 : 0,\n args.map((arg: unknown) => typeTextsAtNode(context, arg as never)),\n explicitTypeArguments,\n );\n}\n\nfunction typeArgumentNodes(node: any): readonly any[] {\n const candidates = [\n node.typeArguments?.params,\n node.typeParameters?.params,\n node.typeParameterInstantiation?.params,\n ];\n return candidates.find(Array.isArray) ?? [];\n}\n\n/**\n * Returns the defaults declared on the type parameters of the callee, when the\n * callee is declared in the file being linted.\n *\n * Each entry is the rendered default text, or an empty string for a type\n * parameter without one, so the result aligns with the type parameter list.\n * Returns `undefined` when the declaration is not visible here, which keeps a\n * caller from mistaking \"no defaults\" for \"not found\".\n */\nfunction declaredTypeParameterDefaults(\n context: ContextWithParserOptions,\n node: any,\n): readonly string[] | undefined {\n const name = identifierName(stripChainExpression(node.callee));\n if (!name) {\n return undefined;\n }\n const declaration = findTypeParameterOwner((context.sourceCode as any)?.ast, name);\n const params = declaration?.typeParameters?.params;\n if (!Array.isArray(params)) {\n return undefined;\n }\n return params.map((param: any) =>\n param?.default ? context.sourceCode.getText(param.default).trim() : \"\",\n );\n}\n\n/**\n * Finds the declaration of `name` that carries a type parameter list.\n *\n * Walks the whole tree rather than a scope chain because the oxlint context\n * does not expose scope analysis.\n */\nfunction findTypeParameterOwner(root: any, name: string): any {\n if (!root || typeof root !== \"object\") {\n return undefined;\n }\n const stack: any[] = [root];\n while (stack.length > 0) {\n const current = stack.pop();\n if (!current || typeof current !== \"object\") {\n continue;\n }\n if (Array.isArray(current)) {\n stack.push(...current);\n continue;\n }\n if (current.id?.name === name && current.typeParameters?.params) {\n return current;\n }\n for (const key of Object.keys(current)) {\n if (key === \"parent\") {\n continue;\n }\n const value = current[key];\n if (value && typeof value === \"object\") {\n stack.push(value);\n }\n }\n }\n return undefined;\n}\n\nfunction typeArgumentFactsOfCall(\n context: ContextWithParserOptions,\n node: any,\n signatureFacts: CorsaCallSignatureFacts,\n): Record<string, unknown> {\n const typeArguments = typeArgumentNodes(node);\n if (typeArguments.length === 0) {\n return {};\n }\n const facts: Record<string, unknown> = {\n typeArgumentRanges: typeArguments\n .map((typeArgument) => rangeObject(typeArgument.range))\n .filter((range): range is { start: number; end: number } => range !== undefined),\n };\n const listRange = typeArgumentListRange(node, typeArguments);\n if (listRange) {\n facts.typeArgumentListRange = listRange;\n }\n const declaredDefaults = declaredTypeParameterDefaults(context, node);\n const parameterCount =\n signatureFacts.signature?.typeParameters?.length ??\n declaredDefaults?.length ??\n signatureFacts.signature?.typeParameterDefaultTexts?.length ??\n 0;\n if (parameterCount > 0) {\n facts.typeParameterCount = parameterCount;\n }\n // Upstream exposes no endpoint for a type parameter's default, and a stable\n // TypeScript 7 declaration handle carries no source range to read it from.\n // The declaration is in the AST being linted whenever it is in this file, so\n // read it from there and only fall back to the signature's rendered texts.\n const defaultTexts =\n declaredDefaults ?? signatureFacts.signature?.typeParameterDefaultTexts ?? [];\n const lastIndex = typeArguments.length - 1;\n const lastDefaultText = defaultTexts[lastIndex];\n if (lastDefaultText !== undefined) {\n const hasDefault = lastDefaultText.trim().length > 0;\n facts.lastTypeParameterHasDefault = hasDefault;\n if (hasDefault) {\n const identical =\n declaredDefaults !== undefined\n ? typeNodesResolveToSameType(\n context,\n typeArguments[lastIndex],\n declaredDefaultNode(context, node, lastIndex),\n )\n : signatureFacts.explicitTypeArgumentsRequired === false;\n if (identical) {\n facts.lastTypeArgumentEqualsDefault = true;\n facts.lastTypeArgumentSameTypeFlagsAsDefault = true;\n facts.lastTypeArgumentIdenticalToDefault = true;\n }\n }\n }\n return facts;\n}\n\n/**\n * Returns the AST node of the default declared on the callee's type parameter\n * at `index`, when the callee is declared in the file being linted.\n */\nfunction declaredDefaultNode(context: ContextWithParserOptions, node: any, index: number): any {\n const name = identifierName(stripChainExpression(node.callee));\n if (!name) {\n return undefined;\n }\n const declaration = findTypeParameterOwner((context.sourceCode as any)?.ast, name);\n return declaration?.typeParameters?.params?.[index]?.default;\n}\n\n/**\n * Reports whether two type nodes denote the same checker type.\n *\n * Comparing the checker's own type identity keeps this from depending on how\n * either type happens to be spelled.\n */\nfunction typeNodesResolveToSameType(\n context: ContextWithParserOptions,\n left: any,\n right: any,\n): boolean {\n if (!left || !right) {\n return false;\n }\n const checker = checkerFor(context);\n const leftType = checker.getTypeAtLocation(left);\n const rightType = checker.getTypeAtLocation(right);\n return leftType !== undefined && rightType !== undefined && leftType.id === rightType.id;\n}\n\nfunction typeArgumentListRange(\n node: any,\n typeArguments: readonly any[],\n): { start: number; end: number } | undefined {\n const candidates = [node.typeArguments, node.typeParameters, node.typeParameterInstantiation];\n const list = candidates.find((candidate) => Array.isArray(candidate?.params));\n const fromList = rangeObject(list?.range);\n if (fromList) {\n return fromList;\n }\n const first = rangeObject(typeArguments[0]?.range);\n const last = rangeObject(typeArguments[typeArguments.length - 1]?.range);\n if (!first || !last || first.start <= 0) {\n return undefined;\n }\n return { start: first.start - 1, end: last.end + 1 };\n}\n\nfunction rangeObject(range: unknown): { start: number; end: number } | undefined {\n return isRange(range) ? { start: range[0], end: range[1] } : undefined;\n}\n\nfunction typeParameterName(node: any): string | undefined {\n if (typeof node?.name === \"string\") {\n return node.name;\n }\n if (typeof node?.name?.name === \"string\") {\n return node.name.name;\n }\n return undefined;\n}\n\nfunction nearestFunctionAncestor(context: ContextWithParserOptions, node: any): any {\n const ancestors = (context.sourceCode as any)?.getAncestors?.(node) ?? [];\n return [...ancestors].reverse().find((ancestor: any) => ancestor.type?.includes(\"Function\"));\n}\n\nfunction isFunctionLike(node: any): boolean {\n return typeof node?.type === \"string\" && node.type.includes(\"Function\");\n}\n\nfunction returnTypeTextsOfNearestFunction(\n context: ContextWithParserOptions,\n node: any,\n): readonly string[] {\n const owner = nearestFunctionAncestor(context, node);\n return owner ? returnTypeTextsOfFunction(context, owner) : [];\n}\n\nfunction returnTypeTextsOfFunction(\n context: ContextWithParserOptions,\n node: any,\n): readonly string[] {\n const explicitAnnotation = node.returnType?.typeAnnotation ?? node.returnType;\n if (explicitAnnotation) {\n const text = context.sourceCode.getText(explicitAnnotation);\n if (text) {\n return [text];\n }\n }\n\n const checker = checkerFor(context);\n const type = typeAtNode(context, node);\n if (!type) {\n return [];\n }\n\n const texts = new Set<string>();\n for (const signature of checker.getSignaturesOfType(type, 0)) {\n const returnType = checker.getReturnTypeOfSignature(signature);\n if (!returnType) {\n continue;\n }\n for (const text of [...(returnType.texts ?? []), checker.typeToString(returnType)]) {\n if (text) {\n texts.add(text);\n }\n }\n }\n\n const resolved = [...texts];\n return resolved.every(isPermissiveTypeText) ? [] : resolved;\n}\n\nfunction isPermissiveTypeText(text: string): boolean {\n return text === \"any\" || text === \"unknown\" || text === \"never\";\n}\n\nfunction stripChainExpression(node: any): any {\n let current = node;\n while (current?.type === \"ChainExpression\") {\n current = current.expression;\n }\n return current;\n}\n\nfunction identifierName(node: any): string | undefined {\n const current = stripChainExpression(node);\n return current?.type === \"Identifier\" && typeof current.name === \"string\"\n ? current.name\n : undefined;\n}\n\nfunction isNativeChildNode(value: unknown): value is RangedNode {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { type?: unknown }).type === \"string\" &&\n isRange((value as { range?: unknown }).range)\n );\n}\n\nfunction isRange(value: unknown): value is readonly [number, number] {\n return (\n Array.isArray(value) &&\n value.length === 2 &&\n typeof value[0] === \"number\" &&\n typeof value[1] === \"number\"\n );\n}\n\nfunction isJsonPrimitive(value: unknown): value is string | number | boolean | null {\n return value === null || [\"boolean\", \"number\", \"string\"].includes(typeof value);\n}\n\nfunction isJsonValue(value: unknown): boolean {\n if (isJsonPrimitive(value)) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.every(isJsonValue);\n }\n return typeof value === \"object\" && value !== null && Object.values(value).every(isJsonValue);\n}\n\nfunction isPrimitiveRecord(\n value: unknown,\n): value is Record<string, string | number | boolean | null> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.values(value).every(isJsonPrimitive)\n );\n}\n\nfunction isSkippedField(key: string): boolean {\n return key === \"type\" || key === \"range\" || key === \"loc\" || key === \"parent\";\n}\n"],"mappings":";;;;AA4BA,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB,IAAI,IAAI,oBAAoB,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAE5F,SAAgB,qBACd,UACA,gBAAyC,CAAC,GAC1C,gBAAyC,CAAC,GAC1C;CACA,MAAM,OAAO,eAAe,QAAQ;CACpC,OAAO,iBACL,UACA;EACE,MAAM,EACJ,aAAa,KAAK,gBACpB;EACA,gBAAgB,KAAK;EACrB,UAAU,KAAK;EACf,GAAG;CACL,IACC,YACC,OAAO,YACL,KAAK,UAAU,KAAK,aAAa,CAC/B,WACC,SAAqB;EACpB,IAAI,cAAc,YAAY,MAAM,OAAO,MAAM,OAC/C;EAEF,MAAM,mBAAmB,uBAAuB,eAAe,IAAI;EACnE,MAAM,cAAc,kBAAkB,eAAe,IAAI;EACzD,wBACE,SACA,MACA,kBACE,UACA,aACE,SACA,MACA,kBACA,eAAe,eAAe,IAAI,GAClC,MACA,2BAA2B,eAAe,IAAI,GAC9C,WACF,CACF,CACF;CACF,CACF,CAAC,CACH,CACJ;AACF;AAEA,SAAgB,aACd,SACA,MACA,mBAAuC,MACvC,WAAW,uBACX,qBAAqB,MACrB,uBAA2C,kBAC3C,cAAkC,OAClC,QAAQ,GACQ;CAChB,MAAM,SAAkC,CAAC;CACzC,MAAM,WA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,QAAQ,KAAK,GACrB,OAAO,MAAM,MAAM,WAAW;CAEhC,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,WAAW;AAC9F;AAEA,SAAS,kBACP,OAC2D;CAC3D,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,KACpB,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,eAAe;AAE9C;AAEA,SAAS,eAAe,KAAsB;CAC5C,OAAO,QAAQ,UAAU,QAAQ,WAAW,QAAQ,SAAS,QAAQ;AACvE"}
|
package/dist/session.d.ts
CHANGED
|
@@ -70,6 +70,19 @@ declare class CorsaProjectSession {
|
|
|
70
70
|
getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined;
|
|
71
71
|
cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[];
|
|
72
72
|
getTypeArguments(type: CorsaType): readonly CorsaType[];
|
|
73
|
+
/**
|
|
74
|
+
* Returns the type arguments a type was written with through a type alias.
|
|
75
|
+
*
|
|
76
|
+
* Empty when the type is not aliased, which is the common case.
|
|
77
|
+
*/
|
|
78
|
+
private aliasTypeArguments;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the alias symbol a type was written through, if any.
|
|
81
|
+
*
|
|
82
|
+
* The checker names an anonymous mapped type `__type`; the alias is what the
|
|
83
|
+
* source actually said, so it is the symbol a rule wants to see.
|
|
84
|
+
*/
|
|
85
|
+
private aliasSymbol;
|
|
73
86
|
getTypesOfType(type: CorsaType): readonly CorsaType[];
|
|
74
87
|
getTargetOfType(type: CorsaType): CorsaType | undefined;
|
|
75
88
|
getTypeParametersOfType(type: CorsaType): readonly CorsaType[];
|
|
@@ -112,6 +125,16 @@ declare class CorsaProjectSession {
|
|
|
112
125
|
private fileState;
|
|
113
126
|
private refreshIfNeeded;
|
|
114
127
|
private projectId;
|
|
128
|
+
/**
|
|
129
|
+
* Resolves the project a type handle must be looked up in.
|
|
130
|
+
*
|
|
131
|
+
* Stable TypeScript 7 runtimes resolve object handles per project and reject
|
|
132
|
+
* project-less lookups with `empty project ID for type handle <n>`, so every
|
|
133
|
+
* request that carries a type handle has to name a project. Prefer the
|
|
134
|
+
* project that issued the handle over the first project in the snapshot: a
|
|
135
|
+
* handle minted by one project is not resolvable in another.
|
|
136
|
+
*/
|
|
137
|
+
private projectIdForType;
|
|
115
138
|
private supportedOverlayText;
|
|
116
139
|
private overlayChanges;
|
|
117
140
|
private supportsOverlayChanges;
|
package/dist/session.js
CHANGED
|
@@ -17,6 +17,9 @@ const objectFlags = {
|
|
|
17
17
|
reference: 4,
|
|
18
18
|
mapped: 32
|
|
19
19
|
};
|
|
20
|
+
const symbolFlags = {
|
|
21
|
+
/** `SymbolFlags.TypeLiteral` — the checker's anonymous `__type` symbol. */
|
|
22
|
+
typeLiteral: 2048 };
|
|
20
23
|
var CorsaProjectSession = class {
|
|
21
24
|
project;
|
|
22
25
|
runtime;
|
|
@@ -128,6 +131,16 @@ var CorsaProjectSession = class {
|
|
|
128
131
|
if (cached !== void 0) return cached ?? void 0;
|
|
129
132
|
if (type.symbol) {
|
|
130
133
|
const symbol = this.getSymbol(type.symbol);
|
|
134
|
+
if (isUsableSymbol(symbol) && !isAnonymousTypeLiteralSymbol(symbol)) {
|
|
135
|
+
this.recoverDeclarationPositionsForSymbol(type, symbol);
|
|
136
|
+
this.#symbolsByTypeId.set(type.id, symbol);
|
|
137
|
+
return symbol;
|
|
138
|
+
}
|
|
139
|
+
const alias = this.aliasSymbol(type);
|
|
140
|
+
if (alias) {
|
|
141
|
+
this.#symbolsByTypeId.set(type.id, alias);
|
|
142
|
+
return alias;
|
|
143
|
+
}
|
|
131
144
|
if (isUsableSymbol(symbol)) {
|
|
132
145
|
this.recoverDeclarationPositionsForSymbol(type, symbol);
|
|
133
146
|
this.#symbolsByTypeId.set(type.id, symbol);
|
|
@@ -333,7 +346,7 @@ var CorsaProjectSession = class {
|
|
|
333
346
|
}
|
|
334
347
|
typeToString(type, flags) {
|
|
335
348
|
try {
|
|
336
|
-
const text = this.client().typeToString(this.#snapshot, this.
|
|
349
|
+
const text = this.client().typeToString(this.#snapshot, this.projectIdForType(type), type.id, void 0, flags);
|
|
337
350
|
if (flags === void 0) this.#typeTextById.set(type.id, text);
|
|
338
351
|
return text;
|
|
339
352
|
} catch (error) {
|
|
@@ -345,14 +358,14 @@ var CorsaProjectSession = class {
|
|
|
345
358
|
getBaseTypeOfLiteralType(type) {
|
|
346
359
|
return this.withMissingTypeHandleFallback(type, void 0, () => this.rememberType(this.client().callJson("getBaseTypeOfLiteralType", {
|
|
347
360
|
snapshot: this.#snapshot,
|
|
348
|
-
project: this.
|
|
361
|
+
project: this.projectIdForType(type),
|
|
349
362
|
type: type.id
|
|
350
363
|
})));
|
|
351
364
|
}
|
|
352
365
|
getPropertiesOfType(type) {
|
|
353
366
|
return this.withMissingTypeHandleFallback(type, [], () => this.rememberSymbols(this.client().callJson("getPropertiesOfType", {
|
|
354
367
|
snapshot: this.#snapshot,
|
|
355
|
-
project: this.
|
|
368
|
+
project: this.projectIdForType(type),
|
|
356
369
|
type: type.id
|
|
357
370
|
}) ?? []));
|
|
358
371
|
}
|
|
@@ -361,7 +374,7 @@ var CorsaProjectSession = class {
|
|
|
361
374
|
const source = this.sourceContextForType(type);
|
|
362
375
|
return this.rememberSignatures(this.client().callJson("getSignaturesOfType", {
|
|
363
376
|
snapshot: this.#snapshot,
|
|
364
|
-
project: this.
|
|
377
|
+
project: this.projectIdForType(type),
|
|
365
378
|
type: type.id,
|
|
366
379
|
kind,
|
|
367
380
|
...source
|
|
@@ -382,7 +395,7 @@ var CorsaProjectSession = class {
|
|
|
382
395
|
const source = this.sourceContextForType(type);
|
|
383
396
|
const facts = this.client().callJson("getCallSignatureFacts", {
|
|
384
397
|
snapshot: this.#snapshot,
|
|
385
|
-
project: this.
|
|
398
|
+
project: this.projectIdForType(type),
|
|
386
399
|
type: type.id,
|
|
387
400
|
kind,
|
|
388
401
|
...source,
|
|
@@ -418,7 +431,7 @@ var CorsaProjectSession = class {
|
|
|
418
431
|
const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : void 0;
|
|
419
432
|
const baseTypes = this.rememberTypes(this.client().callJson("getBaseTypes", {
|
|
420
433
|
snapshot: this.#snapshot,
|
|
421
|
-
project: this.
|
|
434
|
+
project: this.projectIdForType(type),
|
|
422
435
|
type: type.id,
|
|
423
436
|
texts: this.typeTexts(type)
|
|
424
437
|
}) ?? []);
|
|
@@ -477,10 +490,46 @@ var CorsaProjectSession = class {
|
|
|
477
490
|
}
|
|
478
491
|
getTypeArguments(type) {
|
|
479
492
|
return this.withMissingTypeHandleFallback(type, [], () => {
|
|
493
|
+
const aliasArguments = this.aliasTypeArguments(type);
|
|
494
|
+
if (aliasArguments.length > 0) return aliasArguments;
|
|
480
495
|
const source = this.sourceSliceForType(type);
|
|
481
|
-
return this.rememberTypes(source ? this.client().getTypeArgumentsAtSourceRange(this.#snapshot, this.
|
|
496
|
+
return this.rememberTypes(source ? this.client().getTypeArgumentsAtSourceRange(this.#snapshot, this.projectIdForType(type), type.id, type.objectFlags, source.node.fileName, source.node.pos, source.node.end, this.sourceTextForPath(source.node.fileName) ?? "") : this.client().getTypeArguments(this.#snapshot, this.projectIdForType(type), type.id, type.objectFlags));
|
|
482
497
|
});
|
|
483
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Returns the type arguments a type was written with through a type alias.
|
|
501
|
+
*
|
|
502
|
+
* Empty when the type is not aliased, which is the common case.
|
|
503
|
+
*/
|
|
504
|
+
aliasTypeArguments(type) {
|
|
505
|
+
if (((type.objectFlags ?? 0) & objectFlags.mapped) === 0) return [];
|
|
506
|
+
try {
|
|
507
|
+
return this.rememberTypes(this.client().callJson("getAliasTypeArgumentsOfType", {
|
|
508
|
+
snapshot: this.#snapshot,
|
|
509
|
+
project: this.projectIdForType(type),
|
|
510
|
+
type: type.id
|
|
511
|
+
}) ?? []);
|
|
512
|
+
} catch {
|
|
513
|
+
return [];
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Returns the alias symbol a type was written through, if any.
|
|
518
|
+
*
|
|
519
|
+
* The checker names an anonymous mapped type `__type`; the alias is what the
|
|
520
|
+
* source actually said, so it is the symbol a rule wants to see.
|
|
521
|
+
*/
|
|
522
|
+
aliasSymbol(type) {
|
|
523
|
+
try {
|
|
524
|
+
return this.rememberUsableSymbol(this.client().callJson("getAliasSymbolOfType", {
|
|
525
|
+
snapshot: this.#snapshot,
|
|
526
|
+
project: this.projectIdForType(type),
|
|
527
|
+
type: type.id
|
|
528
|
+
}));
|
|
529
|
+
} catch {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
484
533
|
getTypesOfType(type) {
|
|
485
534
|
if ((type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) === 0) return [];
|
|
486
535
|
return this.callTypeArray("getTypesOfType", type);
|
|
@@ -522,17 +571,19 @@ var CorsaProjectSession = class {
|
|
|
522
571
|
return (type.flags & typeFlags.substitution) !== 0 ? this.callType("getBaseTypeOfType", type) : void 0;
|
|
523
572
|
}
|
|
524
573
|
getConstraintOfType(type) {
|
|
525
|
-
return this.withMissingTypeHandleFallback(type, void 0, () => this.rememberType(this.client().getConstraintOfType(this.#snapshot, this.
|
|
574
|
+
return this.withMissingTypeHandleFallback(type, void 0, () => this.rememberType(this.client().getConstraintOfType(this.#snapshot, this.projectIdForType(type), type.id)));
|
|
526
575
|
}
|
|
527
576
|
callType(method, type) {
|
|
528
577
|
return this.withMissingTypeHandleFallback(type, void 0, () => this.rememberType(this.client().callJson(method, {
|
|
529
578
|
snapshot: this.#snapshot,
|
|
579
|
+
project: this.projectIdForType(type),
|
|
530
580
|
type: type.id
|
|
531
581
|
}) ?? void 0));
|
|
532
582
|
}
|
|
533
583
|
callTypeArray(method, type) {
|
|
534
584
|
return this.withMissingTypeHandleFallback(type, [], () => this.rememberTypes(this.client().callJson(method, {
|
|
535
585
|
snapshot: this.#snapshot,
|
|
586
|
+
project: this.projectIdForType(type),
|
|
536
587
|
type: type.id
|
|
537
588
|
}) ?? []));
|
|
538
589
|
}
|
|
@@ -815,6 +866,18 @@ var CorsaProjectSession = class {
|
|
|
815
866
|
if (!id) throw new Error(`corsa oxlint could not resolve a Corsa project for ${this.project.filename}`);
|
|
816
867
|
return id;
|
|
817
868
|
}
|
|
869
|
+
/**
|
|
870
|
+
* Resolves the project a type handle must be looked up in.
|
|
871
|
+
*
|
|
872
|
+
* Stable TypeScript 7 runtimes resolve object handles per project and reject
|
|
873
|
+
* project-less lookups with `empty project ID for type handle <n>`, so every
|
|
874
|
+
* request that carries a type handle has to name a project. Prefer the
|
|
875
|
+
* project that issued the handle over the first project in the snapshot: a
|
|
876
|
+
* handle minted by one project is not resolvable in another.
|
|
877
|
+
*/
|
|
878
|
+
projectIdForType(type) {
|
|
879
|
+
return this.#typeLookupById.get(type.id)?.projectId ?? this.projectId();
|
|
880
|
+
}
|
|
818
881
|
supportedOverlayText(fileName, sourceText, mtimeMs, cached) {
|
|
819
882
|
if (sourceText === void 0 || !this.supportsOverlayChanges()) return;
|
|
820
883
|
if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) return cached.sourceText;
|
|
@@ -849,6 +912,14 @@ function isArrayOrTupleLikeType(session, type) {
|
|
|
849
912
|
function isUsableSymbol(symbol) {
|
|
850
913
|
return symbol != null && !symbol.name.includes("�");
|
|
851
914
|
}
|
|
915
|
+
/**
|
|
916
|
+
* Reports whether a symbol is the checker's anonymous type-literal symbol.
|
|
917
|
+
*
|
|
918
|
+
* These are reported as `__type` and carry no information a rule can act on.
|
|
919
|
+
*/
|
|
920
|
+
function isAnonymousTypeLiteralSymbol(symbol) {
|
|
921
|
+
return symbol !== void 0 && (symbol.flags & symbolFlags.typeLiteral) !== 0;
|
|
922
|
+
}
|
|
852
923
|
function isSyntheticTypeHandle(handle) {
|
|
853
924
|
return handle.startsWith("synthetic-");
|
|
854
925
|
}
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#projects","#nodesById","#typeSourceById","#typeDeclarationFileById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype SourceRange = {\n start: number;\n end: number;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n /** Project that owns the file the type handle came from. */\n projectId?: string;\n sourceText?: string;\n symbolSearchRange?: SourceRange;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolsByTypeId = new Map<string, CorsaSymbol | null>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #baseTypesById = new Map<string, readonly CorsaType[]>();\n #implementedTypesById = new Map<string, readonly CorsaType[]>();\n #ownImplementedTypesById = new Map<string, readonly CorsaType[]>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #typeDeclarationFileById = new Map<string, string>();\n #classDeclarationByTypeId = new Map<string, CorsaNode>();\n #symbolSearchRangeByTypeId = new Map<string, SourceRange>();\n #sourceLengthByPath = new Map<string, number>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position,\n projectId: state.projectId,\n sourceText,\n });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position: start,\n projectId: state.projectId,\n sourceText,\n });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), \"looking up a symbol\");\n }\n\n private getSymbolUnchecked(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.getSymbolOfTypeById(typeId);\n return resolved?.id === symbol ? resolved : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolOfTypeUnchecked(type),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolOfTypeUnchecked(type: CorsaType): CorsaSymbol | undefined {\n const cached = this.#symbolsByTypeId.get(type.id);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (symbol) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n const lookupSymbol = this.getSymbolOfTypeAtLookup(type);\n if (lookupSymbol) {\n this.#symbolsByTypeId.set(type.id, lookupSymbol);\n return lookupSymbol;\n }\n this.#symbolsByTypeId.set(type.id, null);\n return undefined;\n }\n\n /**\n * Runs the source-position lookup for a natively resolved symbol whose\n * declaration handles are compact TypeScript 7 handles without offsets.\n *\n * When the native `getSymbolOfType` lookup succeeds, the position-recovery\n * path in `getSymbolOfTypeAtLookup` no longer runs, yet it is what records\n * the class-declaration range and namespace search scope that disambiguate\n * same-named declarations. The native symbol stays the source of truth;\n * this only restores those positional caches.\n */\n private recoverDeclarationPositionsForSymbol(type: CorsaType, symbol: CorsaSymbol): void {\n if (this.#classDeclarationByTypeId.has(type.id)) {\n return;\n }\n const declarations = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n if (declarations.length === 0 || !declarations.every(isPositionlessNodeHandle)) {\n return;\n }\n if (!this.#typeLookupById.has(type.id)) {\n return;\n }\n this.getSymbolOfTypeAtLookup(type);\n }\n\n private getSymbolOfTypeAtLookup(type: CorsaType): CorsaSymbol | undefined {\n const lookup = this.#typeLookupById.get(type.id);\n if (!lookup) {\n return undefined;\n }\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n const texts = [...this.typeTexts(type)];\n if (isUsableSymbol(symbol)) {\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n }\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n let typeSymbolName = typeSymbolNameFromTexts(texts);\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n const typeSymbol = this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n if (typeSymbol) {\n return typeSymbol;\n }\n }\n if (isUsableSymbol(symbol)) {\n try {\n const rendered = this.typeToString(type);\n if (!texts.includes(rendered)) {\n texts.unshift(rendered);\n }\n } catch {\n // A stale handle may still have cached texts or a usable lookup symbol.\n }\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n typeSymbolName = typeSymbolNameFromTexts(texts);\n }\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n return this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n }\n return undefined;\n }\n\n private getNearbyTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n texts: readonly string[],\n ): CorsaSymbol | undefined {\n if (lookup.symbolSearchRange) {\n return this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.symbolSearchRange.start,\n lookup.symbolSearchRange.end,\n );\n }\n const nearbySymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.position,\n lookup.position + 512,\n );\n if (nearbySymbol) {\n return nearbySymbol;\n }\n for (const qualifiedName of qualifiedTypeNamesFromTexts(texts, typeSymbolName)) {\n const qualifiedSymbol = this.findQualifiedTypeSymbol(\n type,\n lookup,\n sourceText,\n qualifiedName,\n typeSymbolName,\n );\n if (qualifiedSymbol) {\n return qualifiedSymbol;\n }\n }\n return this.findUniqueTypeSymbol(type, lookup, sourceText, typeSymbolName);\n }\n\n /**\n * Anchors a qualified type text such as `Second.Base` on its qualifier, so a\n * same-named declaration under a different container cannot win the lookup.\n */\n private findQualifiedTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n qualifiedName: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n const qualifiers = qualifiedName.slice(0, -(typeSymbolName.length + 1)).split(\".\");\n const qualifier = qualifiers[qualifiers.length - 1];\n const containerRange = qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n if (containerRange) {\n const declarationSymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n containerRange.start,\n containerRange.end,\n );\n if (declarationSymbol) {\n return declarationSymbol;\n }\n }\n let offset = 0;\n while (offset < sourceText.length) {\n const start = sourceText.indexOf(qualifiedName, offset);\n if (start < 0) {\n return undefined;\n }\n const before = start > 0 ? sourceText[start - 1] : undefined;\n const after = sourceText[start + qualifiedName.length];\n // A leading `.` means the qualifier itself is nested under another\n // container, so this occurrence names a different type.\n if (before !== \".\" && !isIdentifierPart(before) && !isIdentifierPart(after)) {\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n start + qualifiedName.length - typeSymbolName.length,\n );\n if (symbol) {\n return symbol;\n }\n }\n offset = start + qualifiedName.length;\n }\n return undefined;\n }\n\n /**\n * Scans the whole file, but only accepts a match when every occurrence of the\n * name resolves to the same declaration. Returning the first same-named\n * symbol would otherwise cache the wrong nominal symbol, and the wrong\n * implemented interfaces, for any file that declares two types with the same\n * simple name in different scopes.\n */\n private findUniqueTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n let uniqueSymbol: CorsaSymbol | undefined;\n let uniqueKey: string | undefined;\n let offset = 0;\n while (offset < sourceText.length) {\n const position = findIdentifierPosition(\n sourceText,\n typeSymbolName,\n offset,\n sourceText.length,\n );\n if (position === undefined) {\n break;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n const key = symbolDeclarationKey(symbol);\n if (uniqueKey !== undefined && uniqueKey !== key) {\n return undefined;\n }\n uniqueSymbol ??= symbol;\n uniqueKey = key;\n }\n offset = position + typeSymbolName.length;\n }\n return uniqueSymbol;\n }\n\n private findMatchingTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n start: number,\n end: number,\n ): CorsaSymbol | undefined {\n let offset = Math.max(0, start);\n const boundary = Math.min(sourceText.length, end);\n while (offset < boundary) {\n const position = findIdentifierPosition(sourceText, typeSymbolName, offset, boundary);\n if (position === undefined) {\n return undefined;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n return symbol;\n }\n offset = position + typeSymbolName.length;\n }\n return undefined;\n }\n\n private getMatchingSymbolAtPosition(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n position: number | undefined,\n ): CorsaSymbol | undefined {\n if (position === undefined || position === lookup.position) {\n return undefined;\n }\n const typeSymbol = this.getSymbolAtPosition(lookup.fileName, position, lookup.sourceText);\n if (!isUsableSymbol(typeSymbol) || typeSymbol.name !== typeSymbolName) {\n return undefined;\n }\n const uniqueDeclaration = uniqueClassDeclarationPosition(sourceText, typeSymbolName);\n const classStart = classDeclarationStartAtIdentifier(sourceText, position) ?? uniqueDeclaration;\n if (classStart !== undefined) {\n this.#classDeclarationByTypeId.set(type.id, {\n fileName: lookup.fileName,\n pos: classStart,\n end: sourceText.length,\n range: [classStart, sourceText.length],\n });\n }\n const symbolSearchRange =\n uniqueDeclaration === undefined\n ? (qualifiedNamespaceRangeAtIdentifier(sourceText, position) ??\n containingNamespaceRange(sourceText, position))\n : containingNamespaceRange(sourceText, uniqueDeclaration);\n if (symbolSearchRange) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n if (uniqueDeclaration !== undefined) {\n this.#typeLookupById.set(type.id, { ...lookup, symbolSearchRange });\n }\n } else if (uniqueDeclaration !== undefined) {\n // A reference can live inside a namespace while resolving to a\n // top-level declaration. Do not let the reference scope leak into the\n // next base-type lookup.\n this.#symbolSearchRangeByTypeId.delete(type.id);\n const { symbolSearchRange: _symbolSearchRange, ...unscopedLookup } = lookup;\n this.#typeLookupById.set(type.id, unscopedLookup);\n }\n return typeSymbol;\n }\n\n private getSymbolOfTypeById(typeId: string): CorsaSymbol | undefined {\n if (!this.#snapshot || typeId.trim().length === 0) {\n return undefined;\n }\n try {\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(\n this.#snapshot,\n typeId,\n // Stable runtimes resolve object handles per project, so the lookup\n // must name the project that produced the type rather than the first\n // project in the snapshot.\n this.#typeLookupById.get(typeId)?.projectId ?? this.#projects[0]?.id,\n ) as CorsaSymbol | null,\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }\n\n getNode(node: string | CorsaNode): CorsaNode | undefined {\n if (typeof node !== \"string\") {\n return node;\n }\n return this.#nodesById.get(node) ?? this.rememberNode(node);\n }\n\n getSourceTextForPath(path: string): string | undefined {\n return this.sourceTextForPath(path);\n }\n\n getClassDeclarationForType(type: CorsaType): CorsaNode | undefined {\n return this.#classDeclarationByTypeId.get(type.id);\n }\n\n rememberTypeLookupFromType(\n type: CorsaType | undefined,\n relatedType: CorsaType | undefined,\n ): void {\n if (!type || !relatedType || type.id === relatedType.id) {\n return;\n }\n const lookup = this.#typeLookupById.get(relatedType.id);\n if (lookup && !this.#typeLookupById.has(type.id)) {\n this.#typeLookupById.set(type.id, lookup);\n }\n const source = this.#typeSourceById.get(relatedType.id);\n if (source && !this.#typeSourceById.has(type.id)) {\n this.#typeSourceById.set(type.id, source);\n }\n const declarationFile = this.#typeDeclarationFileById.get(relatedType.id);\n if (declarationFile && !this.#typeDeclarationFileById.has(type.id)) {\n this.#typeDeclarationFileById.set(type.id, declarationFile);\n }\n const symbolSearchRange = this.#symbolSearchRangeByTypeId.get(relatedType.id);\n if (symbolSearchRange && !this.#symbolSearchRangeByTypeId.has(type.id)) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n }\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n return;\n }\n // A compact TypeScript 7 declaration handle carries no source range, but\n // its path still identifies the declaring file for file-scoped requests.\n const node = this.getNode(handle);\n if (node?.positionless) {\n this.#typeDeclarationFileById.set(type.id, node.fileName);\n }\n }\n\n private rememberTypeSourceRange(\n type: CorsaType,\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n ): void {\n if (\n this.#typeSourceById.has(type.id) ||\n !sourceText ||\n start < 0 ||\n end > sourceText.length ||\n start >= end\n ) {\n return;\n }\n const node = {\n fileName,\n pos: start,\n end,\n range: [start, end] as const,\n };\n this.#typeSourceById.set(type.id, {\n node,\n });\n }\n\n private cacheTypeText(type: CorsaType | undefined): void {\n if (!type || this.#typeTextById.has(type.id)) {\n return;\n }\n try {\n this.#typeTextById.set(\n type.id,\n this.client().typeToString(this.#snapshot!, this.projectId(), type.id),\n );\n } catch {\n // Some upstream handles are only renderable before a later relation query.\n }\n }\n\n private typeTexts(type: CorsaType): readonly string[] {\n if (Array.isArray(type.texts) && type.texts.length > 0) {\n return type.texts;\n }\n const cached = this.#typeTextById.get(type.id);\n return cached === undefined ? [] : [cached];\n }\n\n private sourceContextForType(type: CorsaType): { file?: string; sourceText?: string } {\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n return sourceText ? { file: lookup.fileName, sourceText } : {};\n }\n const source = this.#typeSourceById.get(type.id);\n if (source) {\n const sourceText = this.sourceTextForPath(source.node.fileName);\n return sourceText ? { file: source.node.fileName, sourceText } : {};\n }\n const declarationFile = this.#typeDeclarationFileById.get(type.id);\n if (declarationFile) {\n const sourceText = this.sourceTextForPath(declarationFile);\n return sourceText ? { file: declarationFile, sourceText } : {};\n }\n return {};\n }\n\n private rememberSymbol<T extends CorsaSymbol | undefined>(symbol: T): T {\n if (!symbol) {\n return symbol;\n }\n normalizeSymbol(symbol);\n this.#snapshotHasIssuedHandles = true;\n this.#symbolsById.set(symbol.id, symbol);\n return symbol;\n }\n\n private rememberUsableSymbol(symbol: CorsaSymbol | null | undefined): CorsaSymbol | undefined {\n return isUsableSymbol(symbol) ? this.rememberSymbol(symbol) : undefined;\n }\n\n private rememberSymbols<T extends readonly CorsaSymbol[]>(symbols: T): T {\n for (const symbol of symbols) {\n this.rememberSymbol(symbol);\n }\n return symbols;\n }\n\n private rememberSignatures<T extends readonly CorsaSignature[]>(signatures: T): T {\n for (const signature of signatures) {\n this.rememberSignature(signature);\n }\n return signatures;\n }\n\n private rememberSignature(signature: CorsaSignature): CorsaSignature {\n normalizeSignature(signature);\n if (signature.declaration) {\n this.rememberNode(signature.declaration);\n }\n for (const symbol of signature.parameterSymbols ?? []) {\n this.rememberSymbol(symbol);\n }\n if (signature.thisParameterSymbol) {\n this.rememberSymbol(signature.thisParameterSymbol);\n }\n return signature;\n }\n\n private rememberNode(handle: string): CorsaNode | undefined {\n const parsed = parseNodeHandle(handle, (fileName) => this.sourceLengthForPath(fileName));\n if (!parsed) {\n return undefined;\n }\n this.#nodesById.set(handle, parsed);\n return parsed;\n }\n\n private clearHandleCaches(): void {\n this.#symbolsById.clear();\n this.#symbolsByTypeId.clear();\n this.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#baseTypesById.clear();\n this.#implementedTypesById.clear();\n this.#ownImplementedTypesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#typeDeclarationFileById.clear();\n this.#classDeclarationByTypeId.clear();\n this.#symbolSearchRangeByTypeId.clear();\n this.#sourceLengthByPath.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceLengthForPath(path: string): number | undefined {\n const cached = this.#sourceLengthByPath.get(path);\n if (cached !== undefined) {\n return cached;\n }\n const length = this.sourceTextForPath(path)?.length;\n if (length !== undefined) {\n this.#sourceLengthByPath.set(path, length);\n }\n return length;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n // A compact TypeScript 7 handle carries a node id and a syntax kind instead\n // of source offsets, so its parsed range must never become a source range.\n if (!node || node.positionless) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n const direct = this.#files.get(path);\n if (direct) {\n return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);\n }\n for (const [fileName, cached] of this.#files) {\n if (pathsReferToSameFile(fileName, path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction isSyntheticTypeHandle(handle: string): boolean {\n return handle.startsWith(\"synthetic-\");\n}\n\nfunction typeSymbolNameFromTexts(texts: readonly string[]): string | undefined {\n for (const text of texts) {\n const match =\n /^(?:typeof\\s+)?(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)(?:\\s*<|$)/u.exec(\n text.trim(),\n );\n if (match?.[1]) {\n return match[1];\n }\n }\n return undefined;\n}\n\n/**\n * Collects the qualified spellings of `typeSymbolName` (such as `Second.Base`)\n * carried by a type's rendered texts. These keep the container context that\n * `typeSymbolNameFromTexts` drops.\n */\nfunction qualifiedTypeNamesFromTexts(\n texts: readonly string[],\n typeSymbolName: string,\n): readonly string[] {\n const qualifiedNames: string[] = [];\n for (const text of texts) {\n const rendered = text.trim().replace(/^typeof\\s+/u, \"\");\n const typeArgumentStart = rendered.indexOf(\"<\");\n const withoutTypeArguments =\n typeArgumentStart < 0 ? rendered : rendered.slice(0, typeArgumentStart);\n const name = withoutTypeArguments.trimEnd();\n if (name.endsWith(`.${typeSymbolName}`) && !qualifiedNames.includes(name)) {\n qualifiedNames.push(name);\n }\n }\n return qualifiedNames;\n}\n\n/**\n * Identifies a symbol by its declaration handle, which encodes a source range\n * and therefore stays comparable across separate lookups, unlike the opaque\n * symbol handle.\n */\nfunction symbolDeclarationKey(symbol: CorsaSymbol): string {\n return symbol.valueDeclaration ?? symbol.declarations[0] ?? symbol.id;\n}\n\nfunction classDeclarationStartAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): number | undefined {\n const prefixStart = Math.max(0, identifierPosition - 128);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /\\bclass\\s*$/u.exec(prefix);\n return match ? prefixStart + match.index : undefined;\n}\n\n/**\n * Returns the offset of the only `class <className>` declaration in the source,\n * or `undefined` when the file has none or more than one.\n *\n * Matches inside comments and string literals are ignored, so text such as\n * `// class Descendant` neither shadows nor duplicates a real declaration.\n */\nexport function uniqueClassDeclarationPosition(\n sourceText: string,\n className: string,\n): number | undefined {\n const escapedName = className.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\bclass\\\\s+${escapedName}\\\\b`, \"gu\");\n const codePositions = codePositionMask(sourceText);\n let unique: number | undefined;\n for (\n let declaration = declarationPattern.exec(sourceText);\n declaration;\n declaration = declarationPattern.exec(sourceText)\n ) {\n if (codePositions[declaration.index] !== 1) {\n continue;\n }\n if (unique !== undefined) {\n return undefined;\n }\n unique = declaration.index;\n }\n return unique;\n}\n\n/**\n * Marks each offset that is executable code rather than comment or string\n * literal content, using the same scanner as the namespace range helpers.\n */\nfunction codePositionMask(sourceText: string): Uint8Array {\n const mask = new Uint8Array(sourceText.length);\n const scanner = createSourceScanner();\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n mask[index] = 1;\n }\n return mask;\n}\n\nfunction qualifiedNamespaceRangeAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): SourceRange | undefined {\n const prefixStart = Math.max(0, identifierPosition - 256);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)\\s*\\.\\s*$/u.exec(prefix);\n return match?.[1] ? namespaceRangeByName(sourceText, match[1]) : undefined;\n}\n\nfunction qualifiedBaseNamespaceRangeAtDeclaration(\n sourceText: string,\n declarationPosition: number,\n): SourceRange | undefined {\n const headerEnd = sourceText.indexOf(\"{\", declarationPosition);\n const header = sourceText.slice(\n declarationPosition,\n headerEnd < 0 ? declarationPosition + 512 : headerEnd,\n );\n const match =\n /\\bextends\\s+(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)+([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)/u.exec(\n header,\n );\n if (!match) {\n return undefined;\n }\n const qualifiedBase = match[0].slice(\"extends\".length).trim();\n const qualifiers = qualifiedBase.split(\".\");\n const qualifier = qualifiers[qualifiers.length - 2];\n return qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n}\n\nfunction namespaceRangeByName(sourceText: string, name: string): SourceRange | undefined {\n const escapedName = name.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\b(?:namespace|module)\\\\s+${escapedName}\\\\s*\\\\{`, \"gu\");\n const declaration = declarationPattern.exec(sourceText);\n if (!declaration) {\n return undefined;\n }\n const open = declaration.index + declaration[0].lastIndexOf(\"{\");\n const scanner = createSourceScanner();\n let depth = 1;\n for (let index = open + 1; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (sourceText[index] === \"{\") {\n depth += 1;\n } else if (sourceText[index] === \"}\") {\n depth -= 1;\n if (depth === 0) {\n return { start: open + 1, end: index };\n }\n }\n }\n return undefined;\n}\n\nfunction containingNamespaceRange(sourceText: string, position: number): SourceRange | undefined {\n const scanner = createSourceScanner();\n const blocks: { start: number; namespace: boolean }[] = [];\n let pendingNamespace = false;\n let innermost: SourceRange | undefined;\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = sourceText[index];\n if (isIdentifierStart(char)) {\n let end = index + 1;\n while (isIdentifierPart(sourceText[end])) {\n end += 1;\n }\n const identifier = sourceText.slice(index, end);\n if (identifier === \"namespace\" || identifier === \"module\") {\n pendingNamespace = true;\n }\n index = end - 1;\n continue;\n }\n if (char === \"{\") {\n blocks.push({ start: index + 1, namespace: pendingNamespace });\n pendingNamespace = false;\n continue;\n }\n if (char === \"}\") {\n const block = blocks.pop();\n if (\n block?.namespace &&\n block.start <= position &&\n position < index &&\n (!innermost || block.start >= innermost.start)\n ) {\n innermost = { start: block.start, end: index };\n }\n continue;\n }\n if (pendingNamespace && (char === \";\" || char === \"=\")) {\n pendingNamespace = false;\n }\n }\n return innermost;\n}\n\nfunction createSourceScanner(): {\n skip(text: string, index: number): number;\n} {\n let quote: string | undefined;\n let escaped = false;\n let inLineComment = false;\n let inBlockComment = false;\n return {\n skip(text, index) {\n const char = text[index];\n const next = text[index + 1];\n if (inLineComment) {\n if (char === \"\\n\" || char === \"\\r\") {\n inLineComment = false;\n }\n return index + 1;\n }\n if (inBlockComment) {\n if (char === \"*\" && next === \"/\") {\n inBlockComment = false;\n return index + 2;\n }\n return index + 1;\n }\n if (quote) {\n if (escaped) {\n escaped = false;\n } else if (char === \"\\\\\") {\n escaped = true;\n } else if (char === quote) {\n quote = undefined;\n }\n return index + 1;\n }\n if (char === \"/\" && next === \"/\") {\n inLineComment = true;\n return index + 2;\n }\n if (char === \"/\" && next === \"*\") {\n inBlockComment = true;\n return index + 2;\n }\n if (char === '\"' || char === \"'\" || char === \"`\") {\n quote = char;\n return index + 1;\n }\n return index;\n },\n };\n}\n\nfunction isIdentifierStart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\p{ID_Start}]/u.test(char);\n}\n\nfunction findIdentifierPosition(\n sourceText: string,\n identifier: string,\n start: number,\n end: number,\n): number | undefined {\n const boundedEnd = Math.min(sourceText.length, end);\n let position = sourceText.indexOf(identifier, Math.max(0, start));\n while (position >= 0 && position < boundedEnd) {\n const before = position > 0 ? sourceText[position - 1] : undefined;\n const after = sourceText[position + identifier.length];\n if (!isIdentifierPart(before) && !isIdentifierPart(after)) {\n return position;\n }\n position = sourceText.indexOf(identifier, position + identifier.length);\n }\n return undefined;\n}\n\nfunction isIdentifierPart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\u200c\\u200d\\p{ID_Continue}]/u.test(char);\n}\n\nfunction pathsReferToSameFile(left: string, right: string): boolean {\n const normalizedLeft = left.replaceAll(\"\\\\\", \"/\").toLowerCase();\n const normalizedRight = right.replaceAll(\"\\\\\", \"/\").toLowerCase();\n return (\n normalizedLeft === normalizedRight ||\n normalizedLeft.endsWith(`/${normalizedRight}`) ||\n normalizedRight.endsWith(`/${normalizedLeft}`)\n );\n}\n\nfunction normalizeType(type: CorsaType): void {\n const mutable = type as {\n id: string;\n symbol?: string;\n };\n mutable.id = handleString((type as { id: unknown }).id);\n const symbol = (type as { symbol?: unknown }).symbol;\n if (symbol != null) {\n mutable.symbol = handleString(symbol);\n }\n}\n\nfunction normalizeSymbol(symbol: CorsaSymbol): void {\n const mutable = symbol as unknown as {\n id: string;\n declarations?: string[];\n valueDeclaration?: string;\n };\n mutable.id = handleString((symbol as { id: unknown }).id);\n const declarations = (symbol as { declarations?: readonly unknown[] }).declarations;\n if (Array.isArray(declarations)) {\n mutable.declarations = declarations.map(handleString);\n }\n const valueDeclaration = (symbol as { valueDeclaration?: unknown }).valueDeclaration;\n if (valueDeclaration != null) {\n mutable.valueDeclaration = handleString(valueDeclaration);\n }\n}\n\nfunction normalizeSignature(signature: CorsaSignature): void {\n const mutable = signature as unknown as {\n id: string;\n declaration?: string;\n typeParameters?: string[];\n parameters?: string[];\n thisParameter?: string;\n target?: string;\n };\n mutable.id = handleString((signature as { id: unknown }).id);\n const declaration = (signature as { declaration?: unknown }).declaration;\n if (declaration != null) {\n mutable.declaration = handleString(declaration);\n }\n const typeParameters = (signature as { typeParameters?: readonly unknown[] }).typeParameters;\n if (Array.isArray(typeParameters)) {\n mutable.typeParameters = typeParameters.map(handleString);\n }\n const parameters = (signature as { parameters?: readonly unknown[] }).parameters;\n if (Array.isArray(parameters)) {\n mutable.parameters = parameters.map(handleString);\n }\n const thisParameter = (signature as { thisParameter?: unknown }).thisParameter;\n if (thisParameter != null) {\n mutable.thisParameter = handleString(thisParameter);\n }\n const target = (signature as { target?: unknown }).target;\n if (target != null) {\n mutable.target = handleString(target);\n }\n}\n\nfunction handleString(value: unknown): string {\n return typeof value === \"string\" ? value : String(value);\n}\n\nfunction overlayTextFor(fileName: string, sourceText?: string): string | undefined {\n if (sourceText === undefined) {\n return undefined;\n }\n try {\n return readFileSync(fileName, \"utf8\") === sourceText ? undefined : sourceText;\n } catch {\n return sourceText;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n\nfunction languageIdFor(fileName: string): string {\n if (fileName.endsWith(\".tsx\")) {\n return \"typescriptreact\";\n }\n if (fileName.endsWith(\".jsx\")) {\n return \"javascriptreact\";\n }\n if (fileName.endsWith(\".js\")) {\n return \"javascript\";\n }\n return \"typescript\";\n}\n\nfunction parseNodeHandle(\n value: string,\n sourceLengthForPath: (fileName: string) => number | undefined,\n): CorsaNode | undefined {\n const [posText, secondText, thirdText, ...remainingParts] = value.split(\".\");\n const pos = Number(posText);\n const second = Number(secondText);\n if (!Number.isFinite(pos) || !Number.isFinite(second)) {\n return undefined;\n }\n const hasEndPosition = isFiniteNumberText(thirdText);\n const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(\".\");\n if (!fileName) {\n return undefined;\n }\n const end = hasEndPosition ? second : (sourceLengthForPath(fileName) ?? pos + 1);\n if (end < pos) {\n return undefined;\n }\n if (!hasEndPosition) {\n // Compact TypeScript 7 handle: `<node id>.<syntax kind>.<path>`. The\n // parsed numbers identify the node but are not source offsets.\n return { id: value, fileName, pos, end, range: [pos, end], positionless: true };\n }\n return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\n/**\n * Reports whether a node handle uses the compact TypeScript 7 wire format\n * `<node id>.<syntax kind>.<path>`, which carries no source offsets.\n */\nfunction isPositionlessNodeHandle(value: string): boolean {\n const [posText, secondText, thirdText] = value.split(\".\");\n return (\n isFiniteNumberText(posText) && isFiniteNumberText(secondText) && !isFiniteNumberText(thirdText)\n );\n}\n\nfunction isFiniteNumberText(text: string | undefined): boolean {\n return text !== undefined && text !== \"\" && Number.isFinite(Number(text));\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction isMissingTypeHandleError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"not found in snapshot registry\") || message.includes(\"empty type handle\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAgDA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,IAAa,sBAAb,MAAiC;CA0BpB;CACA;CA1BX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;CACxC,iCAAiB,IAAI,IAAkC;CACvD,wCAAwB,IAAI,IAAkC;CAC9D,2CAA2B,IAAI,IAAkC;CACjE,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,2CAA2B,IAAI,IAAoB;CACnD,4CAA4B,IAAI,IAAuB;CACvD,6CAA6B,IAAI,IAAyB;CAC1D,sCAAsB,IAAI,IAAoB;CAC9C,gCAAgB,IAAI,IAAoB;CACxC,iBAAiB;CACjB,4BAA4B;CAC5B;CACA;CAEA,YACE,SACA,SACA;EAFS,KAAA,UAAA;EACA,KAAA,UAAA;CACR;CAEH,QAAc;EACZ,IAAI,KAAKA,WAAW;GAClB,KAAK,iBAAiB,KAAKA,SAAS;GACpC,KAAKA,YAAY,KAAA;EACnB;EACA,KAAK,eAAe;EACpB,KAAKC,UAAU,KAAA;EACf,K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OAAO,CAAC,KAAK,GAAG;CAAE;AAC5D;;;;;AAMA,SAAS,yBAAyB,OAAwB;CACxD,MAAM,CAAC,SAAS,YAAY,aAAa,MAAM,MAAM,GAAG;CACxD,OACE,mBAAmB,OAAO,KAAK,mBAAmB,UAAU,KAAK,CAAC,mBAAmB,SAAS;AAElG;AAEA,SAAS,mBAAmB,MAAmC;CAC7D,OAAO,SAAS,KAAA,KAAa,SAAS,MAAM,OAAO,SAAS,OAAO,IAAI,CAAC;AAC1E;AAEA,SAAS,4BAA4B,OAAyB;CAC5D,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,aAAa,KAC9B,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,yBAAyB,OAAyB;CACzD,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,gCAAgC,KAAK,QAAQ,SAAS,mBAAmB;AAE9F;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#projects","#nodesById","#typeSourceById","#typeDeclarationFileById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype SourceRange = {\n start: number;\n end: number;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n /** Project that owns the file the type handle came from. */\n projectId?: string;\n sourceText?: string;\n symbolSearchRange?: SourceRange;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nconst symbolFlags = {\n /** `SymbolFlags.TypeLiteral` — the checker's anonymous `__type` symbol. */\n typeLiteral: 1 << 11,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolsByTypeId = new Map<string, CorsaSymbol | null>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #baseTypesById = new Map<string, readonly CorsaType[]>();\n #implementedTypesById = new Map<string, readonly CorsaType[]>();\n #ownImplementedTypesById = new Map<string, readonly CorsaType[]>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #typeDeclarationFileById = new Map<string, string>();\n #classDeclarationByTypeId = new Map<string, CorsaNode>();\n #symbolSearchRangeByTypeId = new Map<string, SourceRange>();\n #sourceLengthByPath = new Map<string, number>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position,\n projectId: state.projectId,\n sourceText,\n });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position: start,\n projectId: state.projectId,\n sourceText,\n });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), \"looking up a symbol\");\n }\n\n private getSymbolUnchecked(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.getSymbolOfTypeById(typeId);\n return resolved?.id === symbol ? resolved : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolOfTypeUnchecked(type),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolOfTypeUnchecked(type: CorsaType): CorsaSymbol | undefined {\n const cached = this.#symbolsByTypeId.get(type.id);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol) && !isAnonymousTypeLiteralSymbol(symbol)) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n // The checker names an anonymous type `__type`, which tells a rule\n // nothing. A mapped utility type like `Readonly<Dog>` still carries the\n // alias the source actually wrote, so prefer that.\n const alias = this.aliasSymbol(type);\n if (alias) {\n this.#symbolsByTypeId.set(type.id, alias);\n return alias;\n }\n if (isUsableSymbol(symbol)) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (symbol) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n const lookupSymbol = this.getSymbolOfTypeAtLookup(type);\n if (lookupSymbol) {\n this.#symbolsByTypeId.set(type.id, lookupSymbol);\n return lookupSymbol;\n }\n this.#symbolsByTypeId.set(type.id, null);\n return undefined;\n }\n\n /**\n * Runs the source-position lookup for a natively resolved symbol whose\n * declaration handles are compact TypeScript 7 handles without offsets.\n *\n * When the native `getSymbolOfType` lookup succeeds, the position-recovery\n * path in `getSymbolOfTypeAtLookup` no longer runs, yet it is what records\n * the class-declaration range and namespace search scope that disambiguate\n * same-named declarations. The native symbol stays the source of truth;\n * this only restores those positional caches.\n */\n private recoverDeclarationPositionsForSymbol(type: CorsaType, symbol: CorsaSymbol): void {\n if (this.#classDeclarationByTypeId.has(type.id)) {\n return;\n }\n const declarations = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n if (declarations.length === 0 || !declarations.every(isPositionlessNodeHandle)) {\n return;\n }\n if (!this.#typeLookupById.has(type.id)) {\n return;\n }\n this.getSymbolOfTypeAtLookup(type);\n }\n\n private getSymbolOfTypeAtLookup(type: CorsaType): CorsaSymbol | undefined {\n const lookup = this.#typeLookupById.get(type.id);\n if (!lookup) {\n return undefined;\n }\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n const texts = [...this.typeTexts(type)];\n if (isUsableSymbol(symbol)) {\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n }\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n let typeSymbolName = typeSymbolNameFromTexts(texts);\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n const typeSymbol = this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n if (typeSymbol) {\n return typeSymbol;\n }\n }\n if (isUsableSymbol(symbol)) {\n try {\n const rendered = this.typeToString(type);\n if (!texts.includes(rendered)) {\n texts.unshift(rendered);\n }\n } catch {\n // A stale handle may still have cached texts or a usable lookup symbol.\n }\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n typeSymbolName = typeSymbolNameFromTexts(texts);\n }\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n return this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n }\n return undefined;\n }\n\n private getNearbyTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n texts: readonly string[],\n ): CorsaSymbol | undefined {\n if (lookup.symbolSearchRange) {\n return this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.symbolSearchRange.start,\n lookup.symbolSearchRange.end,\n );\n }\n const nearbySymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.position,\n lookup.position + 512,\n );\n if (nearbySymbol) {\n return nearbySymbol;\n }\n for (const qualifiedName of qualifiedTypeNamesFromTexts(texts, typeSymbolName)) {\n const qualifiedSymbol = this.findQualifiedTypeSymbol(\n type,\n lookup,\n sourceText,\n qualifiedName,\n typeSymbolName,\n );\n if (qualifiedSymbol) {\n return qualifiedSymbol;\n }\n }\n return this.findUniqueTypeSymbol(type, lookup, sourceText, typeSymbolName);\n }\n\n /**\n * Anchors a qualified type text such as `Second.Base` on its qualifier, so a\n * same-named declaration under a different container cannot win the lookup.\n */\n private findQualifiedTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n qualifiedName: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n const qualifiers = qualifiedName.slice(0, -(typeSymbolName.length + 1)).split(\".\");\n const qualifier = qualifiers[qualifiers.length - 1];\n const containerRange = qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n if (containerRange) {\n const declarationSymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n containerRange.start,\n containerRange.end,\n );\n if (declarationSymbol) {\n return declarationSymbol;\n }\n }\n let offset = 0;\n while (offset < sourceText.length) {\n const start = sourceText.indexOf(qualifiedName, offset);\n if (start < 0) {\n return undefined;\n }\n const before = start > 0 ? sourceText[start - 1] : undefined;\n const after = sourceText[start + qualifiedName.length];\n // A leading `.` means the qualifier itself is nested under another\n // container, so this occurrence names a different type.\n if (before !== \".\" && !isIdentifierPart(before) && !isIdentifierPart(after)) {\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n start + qualifiedName.length - typeSymbolName.length,\n );\n if (symbol) {\n return symbol;\n }\n }\n offset = start + qualifiedName.length;\n }\n return undefined;\n }\n\n /**\n * Scans the whole file, but only accepts a match when every occurrence of the\n * name resolves to the same declaration. Returning the first same-named\n * symbol would otherwise cache the wrong nominal symbol, and the wrong\n * implemented interfaces, for any file that declares two types with the same\n * simple name in different scopes.\n */\n private findUniqueTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n let uniqueSymbol: CorsaSymbol | undefined;\n let uniqueKey: string | undefined;\n let offset = 0;\n while (offset < sourceText.length) {\n const position = findIdentifierPosition(\n sourceText,\n typeSymbolName,\n offset,\n sourceText.length,\n );\n if (position === undefined) {\n break;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n const key = symbolDeclarationKey(symbol);\n if (uniqueKey !== undefined && uniqueKey !== key) {\n return undefined;\n }\n uniqueSymbol ??= symbol;\n uniqueKey = key;\n }\n offset = position + typeSymbolName.length;\n }\n return uniqueSymbol;\n }\n\n private findMatchingTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n start: number,\n end: number,\n ): CorsaSymbol | undefined {\n let offset = Math.max(0, start);\n const boundary = Math.min(sourceText.length, end);\n while (offset < boundary) {\n const position = findIdentifierPosition(sourceText, typeSymbolName, offset, boundary);\n if (position === undefined) {\n return undefined;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n return symbol;\n }\n offset = position + typeSymbolName.length;\n }\n return undefined;\n }\n\n private getMatchingSymbolAtPosition(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n position: number | undefined,\n ): CorsaSymbol | undefined {\n if (position === undefined || position === lookup.position) {\n return undefined;\n }\n const typeSymbol = this.getSymbolAtPosition(lookup.fileName, position, lookup.sourceText);\n if (!isUsableSymbol(typeSymbol) || typeSymbol.name !== typeSymbolName) {\n return undefined;\n }\n const uniqueDeclaration = uniqueClassDeclarationPosition(sourceText, typeSymbolName);\n const classStart = classDeclarationStartAtIdentifier(sourceText, position) ?? uniqueDeclaration;\n if (classStart !== undefined) {\n this.#classDeclarationByTypeId.set(type.id, {\n fileName: lookup.fileName,\n pos: classStart,\n end: sourceText.length,\n range: [classStart, sourceText.length],\n });\n }\n const symbolSearchRange =\n uniqueDeclaration === undefined\n ? (qualifiedNamespaceRangeAtIdentifier(sourceText, position) ??\n containingNamespaceRange(sourceText, position))\n : containingNamespaceRange(sourceText, uniqueDeclaration);\n if (symbolSearchRange) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n if (uniqueDeclaration !== undefined) {\n this.#typeLookupById.set(type.id, { ...lookup, symbolSearchRange });\n }\n } else if (uniqueDeclaration !== undefined) {\n // A reference can live inside a namespace while resolving to a\n // top-level declaration. Do not let the reference scope leak into the\n // next base-type lookup.\n this.#symbolSearchRangeByTypeId.delete(type.id);\n const { symbolSearchRange: _symbolSearchRange, ...unscopedLookup } = lookup;\n this.#typeLookupById.set(type.id, unscopedLookup);\n }\n return typeSymbol;\n }\n\n private getSymbolOfTypeById(typeId: string): CorsaSymbol | undefined {\n if (!this.#snapshot || typeId.trim().length === 0) {\n return undefined;\n }\n try {\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(\n this.#snapshot,\n typeId,\n // Stable runtimes resolve object handles per project, so the lookup\n // must name the project that produced the type rather than the first\n // project in the snapshot.\n this.#typeLookupById.get(typeId)?.projectId ?? this.#projects[0]?.id,\n ) as CorsaSymbol | null,\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }\n\n getNode(node: string | CorsaNode): CorsaNode | undefined {\n if (typeof node !== \"string\") {\n return node;\n }\n return this.#nodesById.get(node) ?? this.rememberNode(node);\n }\n\n getSourceTextForPath(path: string): string | undefined {\n return this.sourceTextForPath(path);\n }\n\n getClassDeclarationForType(type: CorsaType): CorsaNode | undefined {\n return this.#classDeclarationByTypeId.get(type.id);\n }\n\n rememberTypeLookupFromType(\n type: CorsaType | undefined,\n relatedType: CorsaType | undefined,\n ): void {\n if (!type || !relatedType || type.id === relatedType.id) {\n return;\n }\n const lookup = this.#typeLookupById.get(relatedType.id);\n if (lookup && !this.#typeLookupById.has(type.id)) {\n this.#typeLookupById.set(type.id, lookup);\n }\n const source = this.#typeSourceById.get(relatedType.id);\n if (source && !this.#typeSourceById.has(type.id)) {\n this.#typeSourceById.set(type.id, source);\n }\n const declarationFile = this.#typeDeclarationFileById.get(relatedType.id);\n if (declarationFile && !this.#typeDeclarationFileById.has(type.id)) {\n this.#typeDeclarationFileById.set(type.id, declarationFile);\n }\n const symbolSearchRange = this.#symbolSearchRangeByTypeId.get(relatedType.id);\n if (symbolSearchRange && !this.#symbolSearchRangeByTypeId.has(type.id)) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n }\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectIdForType(type),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n // A mapped utility type such as `Readonly<Dog>` writes its argument\n // through an alias, and upstream `getTypeArguments` panics on it. The\n // checker still knows the alias arguments, and unlike the source-range\n // fallback below it answers with real type handles, so the result stays\n // usable for follow-up lookups like `getBaseTypes`.\n const aliasArguments = this.aliasTypeArguments(type);\n if (aliasArguments.length > 0) {\n return aliasArguments;\n }\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectIdForType(type),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectIdForType(type),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n /**\n * Returns the type arguments a type was written with through a type alias.\n *\n * Empty when the type is not aliased, which is the common case.\n */\n private aliasTypeArguments(type: CorsaType): readonly CorsaType[] {\n if (((type.objectFlags ?? 0) & objectFlags.mapped) === 0) {\n return [];\n }\n try {\n return this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(\"getAliasTypeArgumentsOfType\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }) ?? [],\n );\n } catch {\n return [];\n }\n }\n\n /**\n * Returns the alias symbol a type was written through, if any.\n *\n * The checker names an anonymous mapped type `__type`; the alias is what the\n * source actually said, so it is the symbol a rule wants to see.\n */\n private aliasSymbol(type: CorsaType): CorsaSymbol | undefined {\n try {\n return this.rememberUsableSymbol(\n this.client().callJson<CorsaSymbol | null>(\"getAliasSymbolOfType\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }),\n );\n } catch {\n return undefined;\n }\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectIdForType(type), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n project: this.projectIdForType(type),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n return;\n }\n // A compact TypeScript 7 declaration handle carries no source range, but\n // its path still identifies the declaring file for file-scoped requests.\n const node = this.getNode(handle);\n if (node?.positionless) {\n this.#typeDeclarationFileById.set(type.id, node.fileName);\n }\n }\n\n private rememberTypeSourceRange(\n type: CorsaType,\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n ): void {\n if (\n this.#typeSourceById.has(type.id) ||\n !sourceText ||\n start < 0 ||\n end > sourceText.length ||\n start >= end\n ) {\n return;\n }\n const node = {\n fileName,\n pos: start,\n end,\n range: [start, end] as const,\n };\n this.#typeSourceById.set(type.id, {\n node,\n });\n }\n\n private cacheTypeText(type: CorsaType | undefined): void {\n if (!type || this.#typeTextById.has(type.id)) {\n return;\n }\n try {\n this.#typeTextById.set(\n type.id,\n this.client().typeToString(this.#snapshot!, this.projectId(), type.id),\n );\n } catch {\n // Some upstream handles are only renderable before a later relation query.\n }\n }\n\n private typeTexts(type: CorsaType): readonly string[] {\n if (Array.isArray(type.texts) && type.texts.length > 0) {\n return type.texts;\n }\n const cached = this.#typeTextById.get(type.id);\n return cached === undefined ? [] : [cached];\n }\n\n private sourceContextForType(type: CorsaType): { file?: string; sourceText?: string } {\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n return sourceText ? { file: lookup.fileName, sourceText } : {};\n }\n const source = this.#typeSourceById.get(type.id);\n if (source) {\n const sourceText = this.sourceTextForPath(source.node.fileName);\n return sourceText ? { file: source.node.fileName, sourceText } : {};\n }\n const declarationFile = this.#typeDeclarationFileById.get(type.id);\n if (declarationFile) {\n const sourceText = this.sourceTextForPath(declarationFile);\n return sourceText ? { file: declarationFile, sourceText } : {};\n }\n return {};\n }\n\n private rememberSymbol<T extends CorsaSymbol | undefined>(symbol: T): T {\n if (!symbol) {\n return symbol;\n }\n normalizeSymbol(symbol);\n this.#snapshotHasIssuedHandles = true;\n this.#symbolsById.set(symbol.id, symbol);\n return symbol;\n }\n\n private rememberUsableSymbol(symbol: CorsaSymbol | null | undefined): CorsaSymbol | undefined {\n return isUsableSymbol(symbol) ? this.rememberSymbol(symbol) : undefined;\n }\n\n private rememberSymbols<T extends readonly CorsaSymbol[]>(symbols: T): T {\n for (const symbol of symbols) {\n this.rememberSymbol(symbol);\n }\n return symbols;\n }\n\n private rememberSignatures<T extends readonly CorsaSignature[]>(signatures: T): T {\n for (const signature of signatures) {\n this.rememberSignature(signature);\n }\n return signatures;\n }\n\n private rememberSignature(signature: CorsaSignature): CorsaSignature {\n normalizeSignature(signature);\n if (signature.declaration) {\n this.rememberNode(signature.declaration);\n }\n for (const symbol of signature.parameterSymbols ?? []) {\n this.rememberSymbol(symbol);\n }\n if (signature.thisParameterSymbol) {\n this.rememberSymbol(signature.thisParameterSymbol);\n }\n return signature;\n }\n\n private rememberNode(handle: string): CorsaNode | undefined {\n const parsed = parseNodeHandle(handle, (fileName) => this.sourceLengthForPath(fileName));\n if (!parsed) {\n return undefined;\n }\n this.#nodesById.set(handle, parsed);\n return parsed;\n }\n\n private clearHandleCaches(): void {\n this.#symbolsById.clear();\n this.#symbolsByTypeId.clear();\n this.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#baseTypesById.clear();\n this.#implementedTypesById.clear();\n this.#ownImplementedTypesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#typeDeclarationFileById.clear();\n this.#classDeclarationByTypeId.clear();\n this.#symbolSearchRangeByTypeId.clear();\n this.#sourceLengthByPath.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceLengthForPath(path: string): number | undefined {\n const cached = this.#sourceLengthByPath.get(path);\n if (cached !== undefined) {\n return cached;\n }\n const length = this.sourceTextForPath(path)?.length;\n if (length !== undefined) {\n this.#sourceLengthByPath.set(path, length);\n }\n return length;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n // A compact TypeScript 7 handle carries a node id and a syntax kind instead\n // of source offsets, so its parsed range must never become a source range.\n if (!node || node.positionless) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n const direct = this.#files.get(path);\n if (direct) {\n return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);\n }\n for (const [fileName, cached] of this.#files) {\n if (pathsReferToSameFile(fileName, path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n /**\n * Resolves the project a type handle must be looked up in.\n *\n * Stable TypeScript 7 runtimes resolve object handles per project and reject\n * project-less lookups with `empty project ID for type handle <n>`, so every\n * request that carries a type handle has to name a project. Prefer the\n * project that issued the handle over the first project in the snapshot: a\n * handle minted by one project is not resolvable in another.\n */\n private projectIdForType(type: CorsaType): string {\n return this.#typeLookupById.get(type.id)?.projectId ?? this.projectId();\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\n/**\n * Reports whether a symbol is the checker's anonymous type-literal symbol.\n *\n * These are reported as `__type` and carry no information a rule can act on.\n */\nfunction isAnonymousTypeLiteralSymbol(symbol: CorsaSymbol | undefined): boolean {\n return symbol !== undefined && (symbol.flags & symbolFlags.typeLiteral) !== 0;\n}\n\nfunction isSyntheticTypeHandle(handle: string): boolean {\n return handle.startsWith(\"synthetic-\");\n}\n\nfunction typeSymbolNameFromTexts(texts: readonly string[]): string | undefined {\n for (const text of texts) {\n const match =\n /^(?:typeof\\s+)?(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)(?:\\s*<|$)/u.exec(\n text.trim(),\n );\n if (match?.[1]) {\n return match[1];\n }\n }\n return undefined;\n}\n\n/**\n * Collects the qualified spellings of `typeSymbolName` (such as `Second.Base`)\n * carried by a type's rendered texts. These keep the container context that\n * `typeSymbolNameFromTexts` drops.\n */\nfunction qualifiedTypeNamesFromTexts(\n texts: readonly string[],\n typeSymbolName: string,\n): readonly string[] {\n const qualifiedNames: string[] = [];\n for (const text of texts) {\n const rendered = text.trim().replace(/^typeof\\s+/u, \"\");\n const typeArgumentStart = rendered.indexOf(\"<\");\n const withoutTypeArguments =\n typeArgumentStart < 0 ? rendered : rendered.slice(0, typeArgumentStart);\n const name = withoutTypeArguments.trimEnd();\n if (name.endsWith(`.${typeSymbolName}`) && !qualifiedNames.includes(name)) {\n qualifiedNames.push(name);\n }\n }\n return qualifiedNames;\n}\n\n/**\n * Identifies a symbol by its declaration handle, which encodes a source range\n * and therefore stays comparable across separate lookups, unlike the opaque\n * symbol handle.\n */\nfunction symbolDeclarationKey(symbol: CorsaSymbol): string {\n return symbol.valueDeclaration ?? symbol.declarations[0] ?? symbol.id;\n}\n\nfunction classDeclarationStartAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): number | undefined {\n const prefixStart = Math.max(0, identifierPosition - 128);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /\\bclass\\s*$/u.exec(prefix);\n return match ? prefixStart + match.index : undefined;\n}\n\n/**\n * Returns the offset of the only `class <className>` declaration in the source,\n * or `undefined` when the file has none or more than one.\n *\n * Matches inside comments and string literals are ignored, so text such as\n * `// class Descendant` neither shadows nor duplicates a real declaration.\n */\nexport function uniqueClassDeclarationPosition(\n sourceText: string,\n className: string,\n): number | undefined {\n const escapedName = className.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\bclass\\\\s+${escapedName}\\\\b`, \"gu\");\n const codePositions = codePositionMask(sourceText);\n let unique: number | undefined;\n for (\n let declaration = declarationPattern.exec(sourceText);\n declaration;\n declaration = declarationPattern.exec(sourceText)\n ) {\n if (codePositions[declaration.index] !== 1) {\n continue;\n }\n if (unique !== undefined) {\n return undefined;\n }\n unique = declaration.index;\n }\n return unique;\n}\n\n/**\n * Marks each offset that is executable code rather than comment or string\n * literal content, using the same scanner as the namespace range helpers.\n */\nfunction codePositionMask(sourceText: string): Uint8Array {\n const mask = new Uint8Array(sourceText.length);\n const scanner = createSourceScanner();\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n mask[index] = 1;\n }\n return mask;\n}\n\nfunction qualifiedNamespaceRangeAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): SourceRange | undefined {\n const prefixStart = Math.max(0, identifierPosition - 256);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)\\s*\\.\\s*$/u.exec(prefix);\n return match?.[1] ? namespaceRangeByName(sourceText, match[1]) : undefined;\n}\n\nfunction qualifiedBaseNamespaceRangeAtDeclaration(\n sourceText: string,\n declarationPosition: number,\n): SourceRange | undefined {\n const headerEnd = sourceText.indexOf(\"{\", declarationPosition);\n const header = sourceText.slice(\n declarationPosition,\n headerEnd < 0 ? declarationPosition + 512 : headerEnd,\n );\n const match =\n /\\bextends\\s+(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)+([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)/u.exec(\n header,\n );\n if (!match) {\n return undefined;\n }\n const qualifiedBase = match[0].slice(\"extends\".length).trim();\n const qualifiers = qualifiedBase.split(\".\");\n const qualifier = qualifiers[qualifiers.length - 2];\n return qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n}\n\nfunction namespaceRangeByName(sourceText: string, name: string): SourceRange | undefined {\n const escapedName = name.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\b(?:namespace|module)\\\\s+${escapedName}\\\\s*\\\\{`, \"gu\");\n const declaration = declarationPattern.exec(sourceText);\n if (!declaration) {\n return undefined;\n }\n const open = declaration.index + declaration[0].lastIndexOf(\"{\");\n const scanner = createSourceScanner();\n let depth = 1;\n for (let index = open + 1; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (sourceText[index] === \"{\") {\n depth += 1;\n } else if (sourceText[index] === \"}\") {\n depth -= 1;\n if (depth === 0) {\n return { start: open + 1, end: index };\n }\n }\n }\n return undefined;\n}\n\nfunction containingNamespaceRange(sourceText: string, position: number): SourceRange | undefined {\n const scanner = createSourceScanner();\n const blocks: { start: number; namespace: boolean }[] = [];\n let pendingNamespace = false;\n let innermost: SourceRange | undefined;\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = sourceText[index];\n if (isIdentifierStart(char)) {\n let end = index + 1;\n while (isIdentifierPart(sourceText[end])) {\n end += 1;\n }\n const identifier = sourceText.slice(index, end);\n if (identifier === \"namespace\" || identifier === \"module\") {\n pendingNamespace = true;\n }\n index = end - 1;\n continue;\n }\n if (char === \"{\") {\n blocks.push({ start: index + 1, namespace: pendingNamespace });\n pendingNamespace = false;\n continue;\n }\n if (char === \"}\") {\n const block = blocks.pop();\n if (\n block?.namespace &&\n block.start <= position &&\n position < index &&\n (!innermost || block.start >= innermost.start)\n ) {\n innermost = { start: block.start, end: index };\n }\n continue;\n }\n if (pendingNamespace && (char === \";\" || char === \"=\")) {\n pendingNamespace = false;\n }\n }\n return innermost;\n}\n\nfunction createSourceScanner(): {\n skip(text: string, index: number): number;\n} {\n let quote: string | undefined;\n let escaped = false;\n let inLineComment = false;\n let inBlockComment = false;\n return {\n skip(text, index) {\n const char = text[index];\n const next = text[index + 1];\n if (inLineComment) {\n if (char === \"\\n\" || char === \"\\r\") {\n inLineComment = false;\n }\n return index + 1;\n }\n if (inBlockComment) {\n if (char === \"*\" && next === \"/\") {\n inBlockComment = false;\n return index + 2;\n }\n return index + 1;\n }\n if (quote) {\n if (escaped) {\n escaped = false;\n } else if (char === \"\\\\\") {\n escaped = true;\n } else if (char === quote) {\n quote = undefined;\n }\n return index + 1;\n }\n if (char === \"/\" && next === \"/\") {\n inLineComment = true;\n return index + 2;\n }\n if (char === \"/\" && next === \"*\") {\n inBlockComment = true;\n return index + 2;\n }\n if (char === '\"' || char === \"'\" || char === \"`\") {\n quote = char;\n return index + 1;\n }\n return index;\n },\n };\n}\n\nfunction isIdentifierStart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\p{ID_Start}]/u.test(char);\n}\n\nfunction findIdentifierPosition(\n sourceText: string,\n identifier: string,\n start: number,\n end: number,\n): number | undefined {\n const boundedEnd = Math.min(sourceText.length, end);\n let position = sourceText.indexOf(identifier, Math.max(0, start));\n while (position >= 0 && position < boundedEnd) {\n const before = position > 0 ? sourceText[position - 1] : undefined;\n const after = sourceText[position + identifier.length];\n if (!isIdentifierPart(before) && !isIdentifierPart(after)) {\n return position;\n }\n position = sourceText.indexOf(identifier, position + identifier.length);\n }\n return undefined;\n}\n\nfunction isIdentifierPart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\u200c\\u200d\\p{ID_Continue}]/u.test(char);\n}\n\nfunction pathsReferToSameFile(left: string, right: string): boolean {\n const normalizedLeft = left.replaceAll(\"\\\\\", \"/\").toLowerCase();\n const normalizedRight = right.replaceAll(\"\\\\\", \"/\").toLowerCase();\n return (\n normalizedLeft === normalizedRight ||\n normalizedLeft.endsWith(`/${normalizedRight}`) ||\n normalizedRight.endsWith(`/${normalizedLeft}`)\n );\n}\n\nfunction normalizeType(type: CorsaType): void {\n const mutable = type as {\n id: string;\n symbol?: string;\n };\n mutable.id = handleString((type as { id: unknown }).id);\n const symbol = (type as { symbol?: unknown }).symbol;\n if (symbol != null) {\n mutable.symbol = handleString(symbol);\n }\n}\n\nfunction normalizeSymbol(symbol: CorsaSymbol): void {\n const mutable = symbol as unknown as {\n id: string;\n declarations?: string[];\n valueDeclaration?: string;\n };\n mutable.id = handleString((symbol as { id: unknown }).id);\n const declarations = (symbol as { declarations?: readonly unknown[] }).declarations;\n if (Array.isArray(declarations)) {\n mutable.declarations = declarations.map(handleString);\n }\n const valueDeclaration = (symbol as { valueDeclaration?: unknown }).valueDeclaration;\n if (valueDeclaration != null) {\n mutable.valueDeclaration = handleString(valueDeclaration);\n }\n}\n\nfunction normalizeSignature(signature: CorsaSignature): void {\n const mutable = signature as unknown as {\n id: string;\n declaration?: string;\n typeParameters?: string[];\n parameters?: string[];\n thisParameter?: string;\n target?: string;\n };\n mutable.id = handleString((signature as { id: unknown }).id);\n const declaration = (signature as { declaration?: unknown }).declaration;\n if (declaration != null) {\n mutable.declaration = handleString(declaration);\n }\n const typeParameters = (signature as { typeParameters?: readonly unknown[] }).typeParameters;\n if (Array.isArray(typeParameters)) {\n mutable.typeParameters = typeParameters.map(handleString);\n }\n const parameters = (signature as { parameters?: readonly unknown[] }).parameters;\n if (Array.isArray(parameters)) {\n mutable.parameters = parameters.map(handleString);\n }\n const thisParameter = (signature as { thisParameter?: unknown }).thisParameter;\n if (thisParameter != null) {\n mutable.thisParameter = handleString(thisParameter);\n }\n const target = (signature as { target?: unknown }).target;\n if (target != null) {\n mutable.target = handleString(target);\n }\n}\n\nfunction handleString(value: unknown): string {\n return typeof value === \"string\" ? value : String(value);\n}\n\nfunction overlayTextFor(fileName: string, sourceText?: string): string | undefined {\n if (sourceText === undefined) {\n return undefined;\n }\n try {\n return readFileSync(fileName, \"utf8\") === sourceText ? undefined : sourceText;\n } catch {\n return sourceText;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n\nfunction languageIdFor(fileName: string): string {\n if (fileName.endsWith(\".tsx\")) {\n return \"typescriptreact\";\n }\n if (fileName.endsWith(\".jsx\")) {\n return \"javascriptreact\";\n }\n if (fileName.endsWith(\".js\")) {\n return \"javascript\";\n }\n return \"typescript\";\n}\n\nfunction parseNodeHandle(\n value: string,\n sourceLengthForPath: (fileName: string) => number | undefined,\n): CorsaNode | undefined {\n const [posText, secondText, thirdText, ...remainingParts] = value.split(\".\");\n const pos = Number(posText);\n const second = Number(secondText);\n if (!Number.isFinite(pos) || !Number.isFinite(second)) {\n return undefined;\n }\n const hasEndPosition = isFiniteNumberText(thirdText);\n const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(\".\");\n if (!fileName) {\n return undefined;\n }\n const end = hasEndPosition ? second : (sourceLengthForPath(fileName) ?? pos + 1);\n if (end < pos) {\n return undefined;\n }\n if (!hasEndPosition) {\n // Compact TypeScript 7 handle: `<node id>.<syntax kind>.<path>`. The\n // parsed numbers identify the node but are not source offsets.\n return { id: value, fileName, pos, end, range: [pos, end], positionless: true };\n }\n return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\n/**\n * Reports whether a node handle uses the compact TypeScript 7 wire format\n * `<node id>.<syntax kind>.<path>`, which carries no source offsets.\n */\nfunction isPositionlessNodeHandle(value: string): boolean {\n const [posText, secondText, thirdText] = value.split(\".\");\n return (\n isFiniteNumberText(posText) && isFiniteNumberText(secondText) && !isFiniteNumberText(thirdText)\n );\n}\n\nfunction isFiniteNumberText(text: string | undefined): boolean {\n return text !== undefined && text !== \"\" && Number.isFinite(Number(text));\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction isMissingTypeHandleError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"not found in snapshot registry\") || message.includes(\"empty type handle\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAgDA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,MAAM,cAAc;;AAElB,aAAa,KACf;AAEA,IAAa,sBAAb,MAAiC;CA0BpB;CACA;CA1BX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;CACxC,iCAAiB,IAAI,IAAkC;CACvD,wCAAwB,IAAI,IAAkC;CAC9D,2CAA2B,IAAI,IAAkC;CACjE,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,2CAA2B,IAAI,IAAoB;CACnD,4CAA4B,IAAI,IAAuB;CACvD,6CAA6B,IAAI,IAAyB;CAC1D,sCAAsB,IAAI,IAAoB;CAC9C,gCAAgB,IAAI,IAAoB;CACxC,iBAAiB;CACjB,4BAA4B;CAC5B;CACA;CAEA,YACE,SACA,SACA;EAFS,KAAA,UAAA;EACA,KAAA,UAAA;CAC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olvedRealCorsaBinary(): string | undefined;
|
|
16
|
+
/** Registers a test case, mirroring the shape of vitest's `it`. */
|
|
17
|
+
type IntegrationCase = (name: string, fn: () => void | Promise<void>) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the `it` variant integration cases should register with.
|
|
20
|
+
*
|
|
21
|
+
* Integration cases need a real Corsa runtime, so they fall back to `it.skip`
|
|
22
|
+
* when the workspace has not built one. That silence is how this repository
|
|
23
|
+
* shipped a long run of protocol regressions — issues #384, #389, #390, #392,
|
|
24
|
+
* #393, #395, #410, #413, #416, #418, #427, #440, and #441 — while the suites
|
|
25
|
+
* covering those endpoints reported success without executing a single case.
|
|
26
|
+
*
|
|
27
|
+
* Set `CORSA_REQUIRE_INTEGRATION=1`, as the real-runtime CI job does, to turn a
|
|
28
|
+
* missing runtime into a failure instead of a skip.
|
|
29
|
+
*/
|
|
30
|
+
declare function integrationCase(): IntegrationCase;
|
|
16
31
|
//#endregion
|
|
17
|
-
export { resolvedRealCorsaBinary };
|
|
32
|
+
export { IntegrationCase, integrationCase, resolvedRealCorsaBinary };
|
|
18
33
|
//# sourceMappingURL=test_support.d.ts.map
|
package/dist/test_support.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
import { it } from "vitest";
|
|
3
4
|
//#region src/bindings/nodejs/corsa_oxlint/ts/test_support.ts
|
|
4
5
|
const workspaceRoot = resolve(import.meta.dirname, "../../../../..");
|
|
5
6
|
const CANDIDATES = [
|
|
@@ -28,7 +29,26 @@ function resolvedRealCorsaBinary() {
|
|
|
28
29
|
if (fromEnvironment && existsSync(fromEnvironment)) return resolve(fromEnvironment);
|
|
29
30
|
return CANDIDATES.map((candidate) => resolve(workspaceRoot, candidate)).find((candidate) => existsSync(candidate));
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the `it` variant integration cases should register with.
|
|
34
|
+
*
|
|
35
|
+
* Integration cases need a real Corsa runtime, so they fall back to `it.skip`
|
|
36
|
+
* when the workspace has not built one. That silence is how this repository
|
|
37
|
+
* shipped a long run of protocol regressions — issues #384, #389, #390, #392,
|
|
38
|
+
* #393, #395, #410, #413, #416, #418, #427, #440, and #441 — while the suites
|
|
39
|
+
* covering those endpoints reported success without executing a single case.
|
|
40
|
+
*
|
|
41
|
+
* Set `CORSA_REQUIRE_INTEGRATION=1`, as the real-runtime CI job does, to turn a
|
|
42
|
+
* missing runtime into a failure instead of a skip.
|
|
43
|
+
*/
|
|
44
|
+
function integrationCase() {
|
|
45
|
+
if (resolvedRealCorsaBinary()) return it;
|
|
46
|
+
if (!process.env.CORSA_REQUIRE_INTEGRATION) return it.skip;
|
|
47
|
+
return (name, _fn) => it(name, () => {
|
|
48
|
+
throw new Error(["CORSA_REQUIRE_INTEGRATION is set but no Corsa runtime was found.", "Build one with `vp run -w build_corsa`, or point CORSA_EXECUTABLE at an existing binary."].join(" "));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
31
51
|
//#endregion
|
|
32
|
-
export { resolvedRealCorsaBinary };
|
|
52
|
+
export { integrationCase, resolvedRealCorsaBinary };
|
|
33
53
|
|
|
34
54
|
//# sourceMappingURL=test_support.js.map
|
package/dist/test_support.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_support.js","names":[],"sources":["../ts/test_support.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst workspaceRoot = resolve(import.meta.dirname, \"../../../../..\");\n\nconst CANDIDATES = [\n \".cache/corsa\",\n \".cache/corsa.exe\",\n \"ref/corsa-upstream/.cache/corsa\",\n \"ref/corsa-upstream/.cache/corsa.exe\",\n \"ref/corsa-upstream/built/local/corsa\",\n \"ref/corsa-upstream/built/local/corsa.exe\",\n] as const;\n\n/**\n * Resolves the Corsa runtime the integration tests should exercise, or\n * `undefined` when the workspace has not built one yet.\n *\n * These tests deliberately do not call `defaultCorsaExecutable`. That helper is\n * the consumer-facing resolution order, and it prefers the runtime shipped\n * inside the installed `typescript` package. Using it here would silently bind\n * the suite to whatever TypeScript release happens to be in `node_modules`\n * rather than the Corsa build this repository pins in `corsa_ref.lock.toml`,\n * which is the version truth the rest of the workspace tests against.\n *\n * Mirrors `resolved_real_corsa_binary` in the Rust test support module.\n */\nexport function resolvedRealCorsaBinary(): string | undefined {\n const fromEnvironment = process.env.CORSA_EXECUTABLE;\n if (fromEnvironment && existsSync(fromEnvironment)) {\n return resolve(fromEnvironment);\n }\n return CANDIDATES.map((candidate) => resolve(workspaceRoot, candidate)).find((candidate) =>\n existsSync(candidate),\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"test_support.js","names":[],"sources":["../ts/test_support.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { it } from \"vitest\";\n\nconst workspaceRoot = resolve(import.meta.dirname, \"../../../../..\");\n\nconst CANDIDATES = [\n \".cache/corsa\",\n \".cache/corsa.exe\",\n \"ref/corsa-upstream/.cache/corsa\",\n \"ref/corsa-upstream/.cache/corsa.exe\",\n \"ref/corsa-upstream/built/local/corsa\",\n \"ref/corsa-upstream/built/local/corsa.exe\",\n] as const;\n\n/**\n * Resolves the Corsa runtime the integration tests should exercise, or\n * `undefined` when the workspace has not built one yet.\n *\n * These tests deliberately do not call `defaultCorsaExecutable`. That helper is\n * the consumer-facing resolution order, and it prefers the runtime shipped\n * inside the installed `typescript` package. Using it here would silently bind\n * the suite to whatever TypeScript release happens to be in `node_modules`\n * rather than the Corsa build this repository pins in `corsa_ref.lock.toml`,\n * which is the version truth the rest of the workspace tests against.\n *\n * Mirrors `resolved_real_corsa_binary` in the Rust test support module.\n */\nexport function resolvedRealCorsaBinary(): string | undefined {\n const fromEnvironment = process.env.CORSA_EXECUTABLE;\n if (fromEnvironment && existsSync(fromEnvironment)) {\n return resolve(fromEnvironment);\n }\n return CANDIDATES.map((candidate) => resolve(workspaceRoot, candidate)).find((candidate) =>\n existsSync(candidate),\n );\n}\n\n/** Registers a test case, mirroring the shape of vitest's `it`. */\nexport type IntegrationCase = (name: string, fn: () => void | Promise<void>) => void;\n\n/**\n * Returns the `it` variant integration cases should register with.\n *\n * Integration cases need a real Corsa runtime, so they fall back to `it.skip`\n * when the workspace has not built one. That silence is how this repository\n * shipped a long run of protocol regressions — issues #384, #389, #390, #392,\n * #393, #395, #410, #413, #416, #418, #427, #440, and #441 — while the suites\n * covering those endpoints reported success without executing a single case.\n *\n * Set `CORSA_REQUIRE_INTEGRATION=1`, as the real-runtime CI job does, to turn a\n * missing runtime into a failure instead of a skip.\n */\nexport function integrationCase(): IntegrationCase {\n if (resolvedRealCorsaBinary()) {\n return it;\n }\n if (!process.env.CORSA_REQUIRE_INTEGRATION) {\n return it.skip;\n }\n return (name, _fn) =>\n it(name, () => {\n throw new Error(\n [\n \"CORSA_REQUIRE_INTEGRATION is set but no Corsa runtime was found.\",\n \"Build one with `vp run -w build_corsa`, or point CORSA_EXECUTABLE at an existing binary.\",\n ].join(\" \"),\n );\n });\n}\n"],"mappings":";;;;AAKA,MAAM,gBAAgB,QAAQ,YAAY,SAAS,gBAAgB;AAEnE,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,SAAgB,0BAA8C;CAC5D,MAAM,kBAAkB,QAAQ,IAAI;CACpC,IAAI,mBAAmB,WAAW,eAAe,GAC/C,OAAO,QAAQ,eAAe;CAEhC,OAAO,WAAW,KAAK,cAAc,QAAQ,eAAe,SAAS,CAAC,CAAC,CAAC,MAAM,cAC5E,WAAW,SAAS,CACtB;AACF;;;;;;;;;;;;;AAiBA,SAAgB,kBAAmC;CACjD,IAAI,wBAAwB,GAC1B,OAAO;CAET,IAAI,CAAC,QAAQ,IAAI,2BACf,OAAO,GAAG;CAEZ,QAAQ,MAAM,QACZ,GAAG,YAAY;EACb,MAAM,IAAI,MACR,CACE,oEACA,0FACF,CAAC,CAAC,KAAK,GAAG,CACZ;CACF,CAAC;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Type-aware Oxlint helpers powered by Corsa",
|
|
5
5
|
"homepage": "https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint",
|
|
6
6
|
"bugs": {
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
"./package.json": "./package.json"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@corsa-bind/napi": "1.
|
|
98
|
+
"@corsa-bind/napi": "1.9.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@oxlint/plugins": "1.
|
|
102
|
-
"@typescript-eslint/utils": "8.
|
|
103
|
-
"oxlint": "1.
|
|
101
|
+
"@oxlint/plugins": "1.77.0",
|
|
102
|
+
"@typescript-eslint/utils": "8.66.0",
|
|
103
|
+
"oxlint": "1.77.0",
|
|
104
104
|
"oxlint-tsgolint": "7.0.2001"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|