corsa-oxlint 2.0.0-beta.5 → 2.0.0-beta.7

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/context.d.ts CHANGED
@@ -1,6 +1,14 @@
1
- import { ContextWithParserOptions, ResolvedProjectConfig, TypeAwareParserOptions } from "./types.js";
1
+ import { ContextWithParserOptions, CorsaRuntimeKind, ResolvedProjectConfig, TypeAwareParserOptions } from "./types.js";
2
2
  //#region src/bindings/nodejs/corsa_oxlint/ts/context.d.ts
3
- declare function defaultCorsaExecutable(rootDir: string, platform?: NodeJS.Platform, resolveFrom?: string): string;
3
+ /**
4
+ * Finds the Corsa runtime executable a workspace has installed.
5
+ *
6
+ * Without a preference this is `typescript` 7 or newer, then `tsrs`, then
7
+ * `.cache/corsa`, so a workspace that installs both packages keeps running
8
+ * TypeScript's own binary. `runtime: "tsrs"` prefers tsrs and fails when it is
9
+ * not installed; `runtime: "typescript"` never picks tsrs.
10
+ */
11
+ declare function defaultCorsaExecutable(rootDir: string, platform?: NodeJS.Platform, resolveFrom?: string, runtime?: CorsaRuntimeKind): string;
4
12
  declare function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig;
5
13
  /**
6
14
  * Resolves the type-aware parser options visible to a rule.
package/dist/context.js CHANGED
@@ -14,12 +14,32 @@ const DEFAULT_TS_CONFIG = { compilerOptions: {
14
14
  target: "es2022",
15
15
  strict: true
16
16
  } };
17
- function defaultCorsaExecutable(rootDir, platform = process.platform, resolveFrom) {
18
- const stableTypeScript = resolveStableTypeScriptExecutableFrom(resolve(rootDir, "package.json"), platform) ?? (resolveFrom ? resolveStableTypeScriptExecutableFrom(resolveFrom, platform) : void 0);
19
- if (stableTypeScript) return stableTypeScript;
17
+ /**
18
+ * Finds the Corsa runtime executable a workspace has installed.
19
+ *
20
+ * Without a preference this is `typescript` 7 or newer, then `tsrs`, then
21
+ * `.cache/corsa`, so a workspace that installs both packages keeps running
22
+ * TypeScript's own binary. `runtime: "tsrs"` prefers tsrs and fails when it is
23
+ * not installed; `runtime: "typescript"` never picks tsrs.
24
+ */
25
+ function defaultCorsaExecutable(rootDir, platform = process.platform, resolveFrom, runtime) {
26
+ const anchors = [resolve(rootDir, "package.json"), ...resolveFrom ? [resolveFrom] : []];
27
+ const fromAnchors = (resolveFrom) => {
28
+ for (const anchor of anchors) {
29
+ const executable = resolveFrom(anchor, platform);
30
+ if (executable) return executable;
31
+ }
32
+ };
33
+ if (runtime === "tsrs") {
34
+ const tsrs = fromAnchors(resolveTsrsExecutableFrom);
35
+ if (tsrs) return tsrs;
36
+ throw new Error(["corsa-oxlint could not locate the tsrs executable requested by `parserOptions.corsa.runtime`.", "Install `tsrs` with its platform package (`@tsrs/<platform>-<arch>`), or set `CORSA_EXECUTABLE`."].join(" "));
37
+ }
38
+ const installed = fromAnchors(resolveStableTypeScriptExecutableFrom) ?? (runtime === "typescript" ? void 0 : fromAnchors(resolveTsrsExecutableFrom));
39
+ if (installed) return installed;
20
40
  const fallback = resolve(rootDir, platform === "win32" ? ".cache/corsa.exe" : ".cache/corsa");
21
41
  if (existsSync(fallback)) return fallback;
22
- throw new Error(["corsa-oxlint could not locate a Corsa runtime executable.", "Install `typescript` 7, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`."].join(" "));
42
+ throw new Error(["corsa-oxlint could not locate a Corsa runtime executable.", "Install `typescript` 7 or `tsrs`, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`."].join(" "));
23
43
  }
24
44
  function resolveProjectConfig(context) {
25
45
  const filename = resolve(context.filename);
@@ -56,7 +76,7 @@ function resolveTypeAwareParserOptions(context, defaults = {}, resolveFrom) {
56
76
  function resolveRuntimeOptions(rootDir, parserOptions) {
57
77
  const runtime = parserOptions.corsa;
58
78
  return {
59
- executable: resolve(runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir)),
79
+ executable: resolve(runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, void 0, void 0, runtime?.runtime)),
60
80
  cwd: resolve(runtime?.cwd ?? rootDir),
61
81
  mode: runtime?.mode ?? "msgpack",
62
82
  runExternalCode: runtime?.runExternalCode ?? false,
@@ -114,6 +134,30 @@ function resolveStableTypeScriptExecutableFrom(anchor, platform) {
114
134
  const executable = resolve(dirname(platformPackageJsonPath), "lib", platform === "win32" ? "tsc.exe" : "tsc");
115
135
  return existsSync(executable) ? executable : void 0;
116
136
  }
137
+ /**
138
+ * Resolves the native tsrs binary the way the `tsrs` launcher does: from the
139
+ * `@tsrs/<platform>-<arch>` optional dependency (with a `-gnu` / `-musl`
140
+ * suffix on Linux), whose package root holds the binary next to the
141
+ * `lib.*.d.ts` files it loads. The launcher itself is a Node script, so it is
142
+ * not what gets spawned.
143
+ */
144
+ function resolveTsrsExecutableFrom(anchor, platform) {
145
+ const packageJsonPath = resolveOptional(createRequire(anchor), "tsrs/package.json");
146
+ if (!packageJsonPath) return;
147
+ const requireFromTsrs = createRequire(packageJsonPath);
148
+ const base = `@tsrs/${platform}-${process.arch}`;
149
+ const candidates = platform === "linux" ? isMuslRuntime() ? [`${base}-musl`, `${base}-gnu`] : [`${base}-gnu`, `${base}-musl`] : [base];
150
+ for (const candidate of candidates) {
151
+ const platformPackageJsonPath = resolveOptional(requireFromTsrs, `${candidate}/package.json`);
152
+ if (!platformPackageJsonPath) continue;
153
+ const executable = resolve(dirname(platformPackageJsonPath), platform === "win32" ? "tsrs.exe" : "tsrs");
154
+ if (existsSync(executable)) return executable;
155
+ }
156
+ }
157
+ function isMuslRuntime() {
158
+ if (process.platform !== "linux") return false;
159
+ return !(process.report?.getReport())?.header?.glibcVersionRuntime;
160
+ }
117
161
  function isTypeScriptVersionSevenOrNewer(packageJsonPath) {
118
162
  try {
119
163
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
@@ -141,7 +185,7 @@ function applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir, re
141
185
  ...resolved,
142
186
  projectService: true
143
187
  };
144
- if (defaults.corsa === true && resolved.corsa?.executable === void 0) resolved = mergeTypeAwareParserOptions(resolved, { corsa: { executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, void 0, resolveFrom) } });
188
+ if (defaults.corsa === true && resolved.corsa?.executable === void 0) resolved = mergeTypeAwareParserOptions(resolved, { corsa: { executable: process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, void 0, resolveFrom, resolved.corsa?.runtime) } });
145
189
  return resolved;
146
190
  }
147
191
  function mergeTypeAwareParserOptions(base, override) {
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(\n rootDir: string,\n platform = process.platform,\n resolveFrom?: string,\n): string {\n const stableTypeScript =\n resolveStableTypeScriptExecutableFrom(resolve(rootDir, \"package.json\"), platform) ??\n (resolveFrom ? resolveStableTypeScriptExecutableFrom(resolveFrom, platform) : undefined);\n if (stableTypeScript) {\n return stableTypeScript;\n }\n const fallback = resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n if (existsSync(fallback)) {\n return fallback;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate a Corsa runtime executable.\",\n \"Install `typescript` 7, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`.\",\n ].join(\" \"),\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n resolveFrom?: string,\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir, resolveFrom);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n runExternalCode: runtime?.runExternalCode ?? false,\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveStableTypeScriptExecutableFrom(\n anchor: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromAnchor = createRequire(anchor);\n const packageJsonPath = resolveOptional(requireFromAnchor, \"typescript/package.json\");\n if (!packageJsonPath || !isTypeScriptVersionSevenOrNewer(packageJsonPath)) {\n return undefined;\n }\n\n const platformPackage = `@typescript/typescript-${platform}-${process.arch}`;\n const requireFromTypeScript = createRequire(packageJsonPath);\n const platformPackageJsonPath = resolveOptional(\n requireFromTypeScript,\n `${platformPackage}/package.json`,\n );\n if (!platformPackageJsonPath) {\n return undefined;\n }\n\n const executable = resolve(\n dirname(platformPackageJsonPath),\n \"lib\",\n platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n return existsSync(executable) ? executable : undefined;\n}\n\nfunction isTypeScriptVersionSevenOrNewer(packageJsonPath: string): boolean {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly version?: string;\n };\n const major = Number.parseInt(packageJson.version?.split(\".\")[0] ?? \"\", 10);\n return Number.isFinite(major) && major >= 7;\n } catch {\n return false;\n }\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n resolveFrom?: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable:\n process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, undefined, resolveFrom),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;AAAO;AAClE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;A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ACE,SAAS,mBAAmB,QAC5B,cAAc,mBAAmB,KAAA,KACjC,cAAc,YAAY,KAAA,GAE1B,WAAW;EACT,GAAG;EACH,gBAAgB;CAClB;CAEF,IAAI,SAAS,UAAU,QAAQ,SAAS,OAAO,eAAe,KAAA,GAC5D,WAAW,4BAA4B,UAAU,EAC/C,OAAO,EACL,YACE,QAAQ,IAAI,oBAAoB,uBAAuB,SAAS,KAAA,GAAW,WAAW,EAC1F,EACF,CAAC;CAEH,OAAO;AACT;AAEA,SAAgB,4BACd,MACA,UACwB;CACxB,IAAI,CAAC,MACH,OAAO,gCAAgC,YAAY,CAAC,CAAC;CAEvD,IAAI,CAAC,UACH,OAAO,gCAAgC,IAAI;CAE7C,MAAM,UAAU;EACd,GAAG,KAAK;EACR,GAAG,SAAS;CACd;CACA,OAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,cAAc;EAChF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,QAAQ,IAAI,CAAC;CAC9D;AACF;AAEA,SAAS,gCAAgC,SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;CACT;AACF;AAEA,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;CAClD;AACF"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n CorsaRuntimeKind,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\n/**\n * Finds the Corsa runtime executable a workspace has installed.\n *\n * Without a preference this is `typescript` 7 or newer, then `tsrs`, then\n * `.cache/corsa`, so a workspace that installs both packages keeps running\n * TypeScript's own binary. `runtime: \"tsrs\"` prefers tsrs and fails when it is\n * not installed; `runtime: \"typescript\"` never picks tsrs.\n */\nexport function defaultCorsaExecutable(\n rootDir: string,\n platform = process.platform,\n resolveFrom?: string,\n runtime?: CorsaRuntimeKind,\n): string {\n const anchors = [resolve(rootDir, \"package.json\"), ...(resolveFrom ? [resolveFrom] : [])];\n const fromAnchors = (\n resolveFrom: (anchor: string, platform: NodeJS.Platform) => string | undefined,\n ): string | undefined => {\n for (const anchor of anchors) {\n const executable = resolveFrom(anchor, platform);\n if (executable) {\n return executable;\n }\n }\n return undefined;\n };\n if (runtime === \"tsrs\") {\n const tsrs = fromAnchors(resolveTsrsExecutableFrom);\n if (tsrs) {\n return tsrs;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate the tsrs executable requested by `parserOptions.corsa.runtime`.\",\n \"Install `tsrs` with its platform package (`@tsrs/<platform>-<arch>`), or set `CORSA_EXECUTABLE`.\",\n ].join(\" \"),\n );\n }\n const installed =\n fromAnchors(resolveStableTypeScriptExecutableFrom) ??\n (runtime === \"typescript\" ? undefined : fromAnchors(resolveTsrsExecutableFrom));\n if (installed) {\n return installed;\n }\n const fallback = resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n if (existsSync(fallback)) {\n return fallback;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate a Corsa runtime executable.\",\n \"Install `typescript` 7 or `tsrs`, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`.\",\n ].join(\" \"),\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n resolveFrom?: string,\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir, resolveFrom);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ??\n process.env.CORSA_EXECUTABLE ??\n defaultCorsaExecutable(rootDir, undefined, undefined, runtime?.runtime),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n runExternalCode: runtime?.runExternalCode ?? false,\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveStableTypeScriptExecutableFrom(\n anchor: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromAnchor = createRequire(anchor);\n const packageJsonPath = resolveOptional(requireFromAnchor, \"typescript/package.json\");\n if (!packageJsonPath || !isTypeScriptVersionSevenOrNewer(packageJsonPath)) {\n return undefined;\n }\n\n const platformPackage = `@typescript/typescript-${platform}-${process.arch}`;\n const requireFromTypeScript = createRequire(packageJsonPath);\n const platformPackageJsonPath = resolveOptional(\n requireFromTypeScript,\n `${platformPackage}/package.json`,\n );\n if (!platformPackageJsonPath) {\n return undefined;\n }\n\n const executable = resolve(\n dirname(platformPackageJsonPath),\n \"lib\",\n platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n return existsSync(executable) ? executable : undefined;\n}\n\n/**\n * Resolves the native tsrs binary the way the `tsrs` launcher does: from the\n * `@tsrs/<platform>-<arch>` optional dependency (with a `-gnu` / `-musl`\n * suffix on Linux), whose package root holds the binary next to the\n * `lib.*.d.ts` files it loads. The launcher itself is a Node script, so it is\n * not what gets spawned.\n */\nfunction resolveTsrsExecutableFrom(anchor: string, platform: NodeJS.Platform): string | undefined {\n const packageJsonPath = resolveOptional(createRequire(anchor), \"tsrs/package.json\");\n if (!packageJsonPath) {\n return undefined;\n }\n const requireFromTsrs = createRequire(packageJsonPath);\n const base = `@tsrs/${platform}-${process.arch}`;\n const candidates =\n platform === \"linux\"\n ? isMuslRuntime()\n ? [`${base}-musl`, `${base}-gnu`]\n : [`${base}-gnu`, `${base}-musl`]\n : [base];\n for (const candidate of candidates) {\n const platformPackageJsonPath = resolveOptional(requireFromTsrs, `${candidate}/package.json`);\n if (!platformPackageJsonPath) {\n continue;\n }\n const executable = resolve(\n dirname(platformPackageJsonPath),\n platform === \"win32\" ? \"tsrs.exe\" : \"tsrs\",\n );\n if (existsSync(executable)) {\n return executable;\n }\n }\n return undefined;\n}\n\nfunction isMuslRuntime(): boolean {\n if (process.platform !== \"linux\") {\n return false;\n }\n const report = process.report?.getReport() as\n | { header?: { glibcVersionRuntime?: string } }\n | undefined;\n return !report?.header?.glibcVersionRuntime;\n}\n\nfunction isTypeScriptVersionSevenOrNewer(packageJsonPath: string): boolean {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly version?: string;\n };\n const major = Number.parseInt(packageJson.version?.split(\".\")[0] ?? \"\", 10);\n return Number.isFinite(major) && major >= 7;\n } catch {\n return false;\n }\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n resolveFrom?: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable:\n process.env.CORSA_EXECUTABLE ??\n defaultCorsaExecutable(rootDir, undefined, resolveFrom, resolved.corsa?.runtime),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAcA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;AAAO;AAClE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;AACV,EACF;;;;;;;;;AAUA,SAAgB,uBACd,SACA,WAAW,QAAQ,UACnB,aACA,SACQ;CACR,MAAM,UAAU,CAAC,QAAQ,SAAS,cAAc,GAAG,GAAI,cAAc,CAAC,WAAW,IAAI,CAAC,CAAE;CACxF,MAAM,eACJ,gBACuB;EACvB,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,aAAa,YAAY,QAAQ,QAAQ;GA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,CAAC,CAAC;CAEvD,IAAI,CAAC,UACH,OAAO,gCAAgC,IAAI;CAE7C,MAAM,UAAU;EACd,GAAG,KAAK;EACR,GAAG,SAAS;CACd;CACA,OAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,cAAc;EAChF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,QAAQ,IAAI,CAAC;CAC9D;AACF;AAEA,SAAS,gCAAgC,SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;CACT;AACF;AAEA,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;CAClD;AACF"}
package/dist/session.js CHANGED
@@ -1370,7 +1370,8 @@ function parseNodeHandle(value, sourceLengthForPath) {
1370
1370
  const second = Number(secondText);
1371
1371
  if (!Number.isFinite(pos) || !Number.isFinite(second)) return;
1372
1372
  const hasEndPosition = isFiniteNumberText(thirdText);
1373
- const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(".");
1373
+ const hasFileKey = isFileKeyText(thirdText);
1374
+ const fileName = (hasEndPosition || hasFileKey ? remainingParts : [thirdText, ...remainingParts]).join(".");
1374
1375
  if (!fileName) return;
1375
1376
  const end = hasEndPosition ? second : sourceLengthForPath(fileName) ?? pos + 1;
1376
1377
  if (end < pos) return;
@@ -1391,13 +1392,18 @@ function parseNodeHandle(value, sourceLengthForPath) {
1391
1392
  };
1392
1393
  }
1393
1394
  /**
1394
- * Reports whether a node handle uses the compact TypeScript 7 wire format
1395
- * `<node id>.<syntax kind>.<path>`, which carries no source offsets.
1395
+ * Reports whether a node handle uses a compact TypeScript 7 wire format,
1396
+ * `<node index>.<syntax kind>.<path>` or, on TypeScript 7.1 development
1397
+ * builds, `<node index>.<syntax kind>.#<file id>.<path>`. Neither carries
1398
+ * source offsets.
1396
1399
  */
1397
1400
  function isPositionlessNodeHandle(value) {
1398
1401
  const [posText, secondText, thirdText] = value.split(".");
1399
1402
  return isFiniteNumberText(posText) && isFiniteNumberText(secondText) && !isFiniteNumberText(thirdText);
1400
1403
  }
1404
+ function isFileKeyText(text) {
1405
+ return text !== void 0 && /^#\d+$/.test(text);
1406
+ }
1401
1407
  function isFiniteNumberText(text) {
1402
1408
  return text !== void 0 && text !== "" && Number.isFinite(Number(text));
1403
1409
  }
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#jsDocTagsBySymbolId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#projects","#nodesById","#typeSourceById","#typeDeclarationFileById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#snapshotHasIssuedHandles","#sourceLengthByPath","#crossFileSourceTextByPath","#statByPath","#fatalTransportError","#config","#lastRefreshMs","#mapperExtensions"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport {\n type ContentMapperDefinition,\n type EncodedSourceFile,\n type ProjectResponse,\n CorsaApiClient,\n CorsaSpanMap,\n SpanMap,\n contentMappersFromConfig,\n} from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaIndexInfo,\n CorsaJsDocTagInfo,\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 /** `undefined` until resolved, `null` once known not to be content mapped. */\n contentMapping?: ContentMapping | null;\n};\n\n/** Content mapper state the session resolved for one file. */\nexport type ContentMapping = {\n /** `name@version` identity of the mapper that produced the virtual text. */\n readonly contentMapper: string;\n /** Filename whose extension decided how the virtual text was parsed. */\n readonly virtualFileName: string;\n /** Virtual TypeScript the checker sees for this file. */\n readonly virtualText: string;\n /** Mapping between authored and virtual positions. */\n readonly spanMap: CorsaSpanMap;\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 #jsDocTagsBySymbolId = new Map<string, readonly CorsaJsDocTagInfo[]>();\n #statByPath = new Map<string, { mtimeMs: number; at: number }>();\n #crossFileSourceTextByPath = new Map<string, string | undefined>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n #mapperExtensions?: readonly string[];\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 const checkerPosition = this.checkerPosition(fileName, state, position);\n state.typeByPosition.set(\n position,\n checkerPosition === undefined\n ? undefined\n : (this.client().getTypeAtPosition(\n this.#snapshot!,\n state.projectId,\n fileName,\n checkerPosition,\n ) as CorsaType | 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 if (this.contentMappingFor(fileName, state)) {\n // The range hints disambiguate against the file's text, which for a\n // mapped file is the mapper's virtual TypeScript rather than what the\n // linter is holding. Fall back to the position lookup, which is mapped.\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\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 const checkerPosition = this.checkerPosition(fileName, state, position);\n state.symbolByPosition.set(\n position,\n checkerPosition === undefined\n ? undefined\n : (this.client().getSymbolAtPosition(\n this.#snapshot!,\n state.projectId,\n fileName,\n checkerPosition,\n ) as CorsaSymbol | 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 * Asks the checker whether `source` is assignable to `target`, through the\n * upstream `isTypeAssignableTo` endpoint. Returns undefined when either\n * handle cannot be resolved.\n */\n isTypeAssignableTo(source: CorsaType, target: CorsaType): boolean | undefined {\n return this.withTransportRecovery(() => {\n if (!this.#snapshot || !source.id || !target.id) {\n return undefined;\n }\n try {\n const result = this.client().callJson<boolean | null>(\"isTypeAssignableTo\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(source),\n source: source.id,\n target: target.id,\n });\n return typeof result === \"boolean\" ? result : undefined;\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }, \"checking type assignability\");\n }\n\n /**\n * Returns the JSDoc tags attached to a symbol, straight from the checker's\n * `getJsDocTags` endpoint. Results are cached per symbol handle for the\n * lifetime of the current snapshot.\n */\n getJsDocTags(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[] {\n return (\n this.withTransportRecovery(() => this.getJsDocTagsUnchecked(symbol), \"reading JSDoc tags\") ??\n []\n );\n }\n\n private getJsDocTagsUnchecked(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[] {\n if (!this.#snapshot) {\n return [];\n }\n const cached = this.#jsDocTagsBySymbolId.get(symbol.id);\n if (cached) {\n return cached;\n }\n let tags: readonly CorsaJsDocTagInfo[];\n try {\n tags =\n this.client().callJson<readonly CorsaJsDocTagInfo[] | null>(\"getJsDocTags\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n symbol: symbol.id,\n }) ?? [];\n } catch (error) {\n // A stale or foreign-project symbol handle means \"no tag data\", not a\n // lint failure; anything else keeps propagating.\n if (!isMissingTypeHandleError(error)) {\n throw error;\n }\n tags = [];\n }\n this.#jsDocTagsBySymbolId.set(symbol.id, tags);\n return tags;\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 getTypeLookupSource(\n type: CorsaType,\n ): { fileName: string; position: number; sourceText?: string } | undefined {\n const lookup = this.#typeLookupById.get(type.id);\n return lookup\n ? { fileName: lookup.fileName, position: lookup.position, sourceText: lookup.sourceText }\n : undefined;\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 getIndexInfosOfType(type: CorsaType): readonly CorsaIndexInfo[] {\n return this.withMissingTypeHandleFallback<readonly CorsaIndexInfo[]>(type, [], () =>\n this.rememberIndexInfos(\n this.client().callJson<readonly CorsaIndexInfo[] | null>(\"getIndexInfosOfType\", {\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 if (signature.id.trim().length === 0) {\n return undefined;\n }\n try {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n if (signature.id.trim().length === 0) {\n return undefined;\n }\n let predicate: CorsaTypePredicate | undefined;\n try {\n predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getNonNullableType(type: CorsaType): CorsaType | undefined {\n return this.callType(\"getNonNullableType\", type);\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 rememberIndexInfos<T extends readonly CorsaIndexInfo[]>(infos: T): T {\n for (const info of infos) {\n this.rememberType(info.keyType);\n this.rememberType(info.valueType);\n }\n return infos;\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.#jsDocTagsBySymbolId.clear();\n this.#crossFileSourceTextByPath.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 /**\n * Rate-limits the per-query `statSync`: while the same lint source text is\n * being processed and the cache lifetime has not elapsed, the last observed\n * mtime is authoritative. Every type query used to stat the file.\n */\n private statMtimeMsThrottled(\n fileName: string,\n sourceText: string | undefined,\n cached: FileCache | undefined,\n now: number,\n ): number {\n const entry = this.#statByPath.get(fileName);\n if (\n entry &&\n now - entry.at <= this.runtime.cacheLifetimeMs &&\n cached !== undefined &&\n cached.lintSourceText === sourceText\n ) {\n return entry.mtimeMs;\n }\n const mtimeMs = statMtimeMs(fileName);\n this.#statByPath.set(fileName, { mtimeMs, at: now });\n return mtimeMs;\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 if (this.#crossFileSourceTextByPath.has(path)) {\n return this.#crossFileSourceTextByPath.get(path);\n }\n const text = readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n this.#crossFileSourceTextByPath.set(path, text);\n return text;\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 this.#mapperExtensions = 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 runExternalCode: this.runtime.runExternalCode,\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 /**\n * Content mapper state for `fileName`, or `undefined` when no mapper owns it.\n *\n * Resolving it costs one `getSourceFile` request per file, so the lookup is\n * skipped entirely unless the project declares a mapper that claims the\n * file's extension.\n */\n getContentMapping(fileName: string, sourceText?: string): ContentMapping | undefined {\n return this.withTransportRecovery(\n () => this.contentMappingFor(fileName, this.fileState(fileName, sourceText)),\n \"reading content mapper state\",\n );\n }\n\n /** Content mappers the project's `tsconfig` declares. */\n getContentMappers(): readonly ContentMapperDefinition[] {\n return this.withTransportRecovery(\n () => contentMappersFromConfig(this.config()),\n \"reading content mappers\",\n );\n }\n\n private contentMappingFor(fileName: string, state: FileCache): ContentMapping | undefined {\n if (state.contentMapping !== undefined) {\n return state.contentMapping ?? undefined;\n }\n state.contentMapping = null;\n if (!this.mapperOwnedExtensions().some((extension) => fileName.endsWith(extension))) {\n return undefined;\n }\n const sourceFile = this.decodeSourceFileForMapping(fileName, state);\n const mapping = sourceFile?.contentMapping;\n if (mapping) {\n state.contentMapping = {\n contentMapper: mapping.contentMapper,\n virtualFileName: mapping.virtualFileName,\n virtualText: sourceFile.text,\n spanMap: CorsaSpanMap.fromSegments(mapping.spanMap),\n };\n }\n return state.contentMapping ?? undefined;\n }\n\n /**\n * Decodes a file's source-file record, or `undefined` when it cannot be read.\n *\n * A runtime whose binary source-file protocol this build does not decode is\n * treated as \"not content mapped\", which is how the bridge behaved before it\n * understood mappers at all. Transport failures still propagate so the\n * session can restart the worker.\n */\n private decodeSourceFileForMapping(\n fileName: string,\n state: FileCache,\n ): EncodedSourceFile | undefined {\n try {\n return (\n this.client().getEncodedSourceFile(this.#snapshot!, state.projectId, fileName) ?? undefined\n );\n } catch (error) {\n if (isRecoverableTransportError(error)) {\n throw error;\n }\n return undefined;\n }\n }\n\n /**\n * Translates an authored position into the position the checker knows.\n *\n * Returns the position unchanged for files no mapper owns, and `undefined`\n * when the authored position has no counterpart in the virtual text — text\n * the checker never saw has no type or symbol to report.\n */\n private checkerPosition(\n fileName: string,\n state: FileCache,\n position: number,\n ): number | undefined {\n const mapping = this.contentMappingFor(fileName, state);\n if (!mapping) {\n return position;\n }\n const projections = mapping.spanMap.originalToVirtualPositions(position, SpanMap.Feature.Hover);\n return projections[0]?.position;\n }\n\n private mapperOwnedExtensions(): readonly string[] {\n if (!this.#mapperExtensions) {\n this.#mapperExtensions = contentMappersFromConfig(this.config()).flatMap(\n (mapper) => mapper.extensions,\n );\n }\n return this.#mapperExtensions;\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 = this.statMtimeMsThrottled(fileName, sourceText, cached, now);\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\") ||\n message.includes(\"empty type handle\") ||\n message.includes(\"empty signature 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":";;;AAwEA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KA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AK,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,KACjD,QAAQ,SAAS,mBAAmB,KACpC,QAAQ,SAAS,wBAAwB;AAE7C;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","#jsDocTagsBySymbolId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#projects","#nodesById","#typeSourceById","#typeDeclarationFileById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#snapshotHasIssuedHandles","#sourceLengthByPath","#crossFileSourceTextByPath","#statByPath","#fatalTransportError","#config","#lastRefreshMs","#mapperExtensions"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport {\n type ContentMapperDefinition,\n type EncodedSourceFile,\n type ProjectResponse,\n CorsaApiClient,\n CorsaSpanMap,\n SpanMap,\n contentMappersFromConfig,\n} from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaIndexInfo,\n CorsaJsDocTagInfo,\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 /** `undefined` until resolved, `null` once known not to be content mapped. */\n contentMapping?: ContentMapping | null;\n};\n\n/** Content mapper state the session resolved for one file. */\nexport type ContentMapping = {\n /** `name@version` identity of the mapper that produced the virtual text. */\n readonly contentMapper: string;\n /** Filename whose extension decided how the virtual text was parsed. */\n readonly virtualFileName: string;\n /** Virtual TypeScript the checker sees for this file. */\n readonly virtualText: string;\n /** Mapping between authored and virtual positions. */\n readonly spanMap: CorsaSpanMap;\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 #jsDocTagsBySymbolId = new Map<string, readonly CorsaJsDocTagInfo[]>();\n #statByPath = new Map<string, { mtimeMs: number; at: number }>();\n #crossFileSourceTextByPath = new Map<string, string | undefined>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n #mapperExtensions?: readonly string[];\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 const checkerPosition = this.checkerPosition(fileName, state, position);\n state.typeByPosition.set(\n position,\n checkerPosition === undefined\n ? undefined\n : (this.client().getTypeAtPosition(\n this.#snapshot!,\n state.projectId,\n fileName,\n checkerPosition,\n ) as CorsaType | 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 if (this.contentMappingFor(fileName, state)) {\n // The range hints disambiguate against the file's text, which for a\n // mapped file is the mapper's virtual TypeScript rather than what the\n // linter is holding. Fall back to the position lookup, which is mapped.\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\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 const checkerPosition = this.checkerPosition(fileName, state, position);\n state.symbolByPosition.set(\n position,\n checkerPosition === undefined\n ? undefined\n : (this.client().getSymbolAtPosition(\n this.#snapshot!,\n state.projectId,\n fileName,\n checkerPosition,\n ) as CorsaSymbol | 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 * Asks the checker whether `source` is assignable to `target`, through the\n * upstream `isTypeAssignableTo` endpoint. Returns undefined when either\n * handle cannot be resolved.\n */\n isTypeAssignableTo(source: CorsaType, target: CorsaType): boolean | undefined {\n return this.withTransportRecovery(() => {\n if (!this.#snapshot || !source.id || !target.id) {\n return undefined;\n }\n try {\n const result = this.client().callJson<boolean | null>(\"isTypeAssignableTo\", {\n snapshot: this.#snapshot,\n project: this.projectIdForType(source),\n source: source.id,\n target: target.id,\n });\n return typeof result === \"boolean\" ? result : undefined;\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }, \"checking type assignability\");\n }\n\n /**\n * Returns the JSDoc tags attached to a symbol, straight from the checker's\n * `getJsDocTags` endpoint. Results are cached per symbol handle for the\n * lifetime of the current snapshot.\n */\n getJsDocTags(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[] {\n return (\n this.withTransportRecovery(() => this.getJsDocTagsUnchecked(symbol), \"reading JSDoc tags\") ??\n []\n );\n }\n\n private getJsDocTagsUnchecked(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[] {\n if (!this.#snapshot) {\n return [];\n }\n const cached = this.#jsDocTagsBySymbolId.get(symbol.id);\n if (cached) {\n return cached;\n }\n let tags: readonly CorsaJsDocTagInfo[];\n try {\n tags =\n this.client().callJson<readonly CorsaJsDocTagInfo[] | null>(\"getJsDocTags\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n symbol: symbol.id,\n }) ?? [];\n } catch (error) {\n // A stale or foreign-project symbol handle means \"no tag data\", not a\n // lint failure; anything else keeps propagating.\n if (!isMissingTypeHandleError(error)) {\n throw error;\n }\n tags = [];\n }\n this.#jsDocTagsBySymbolId.set(symbol.id, tags);\n return tags;\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 getTypeLookupSource(\n type: CorsaType,\n ): { fileName: string; position: number; sourceText?: string } | undefined {\n const lookup = this.#typeLookupById.get(type.id);\n return lookup\n ? { fileName: lookup.fileName, position: lookup.position, sourceText: lookup.sourceText }\n : undefined;\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 getIndexInfosOfType(type: CorsaType): readonly CorsaIndexInfo[] {\n return this.withMissingTypeHandleFallback<readonly CorsaIndexInfo[]>(type, [], () =>\n this.rememberIndexInfos(\n this.client().callJson<readonly CorsaIndexInfo[] | null>(\"getIndexInfosOfType\", {\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 if (signature.id.trim().length === 0) {\n return undefined;\n }\n try {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n if (signature.id.trim().length === 0) {\n return undefined;\n }\n let predicate: CorsaTypePredicate | undefined;\n try {\n predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getNonNullableType(type: CorsaType): CorsaType | undefined {\n return this.callType(\"getNonNullableType\", type);\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 rememberIndexInfos<T extends readonly CorsaIndexInfo[]>(infos: T): T {\n for (const info of infos) {\n this.rememberType(info.keyType);\n this.rememberType(info.valueType);\n }\n return infos;\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.#jsDocTagsBySymbolId.clear();\n this.#crossFileSourceTextByPath.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 /**\n * Rate-limits the per-query `statSync`: while the same lint source text is\n * being processed and the cache lifetime has not elapsed, the last observed\n * mtime is authoritative. Every type query used to stat the file.\n */\n private statMtimeMsThrottled(\n fileName: string,\n sourceText: string | undefined,\n cached: FileCache | undefined,\n now: number,\n ): number {\n const entry = this.#statByPath.get(fileName);\n if (\n entry &&\n now - entry.at <= this.runtime.cacheLifetimeMs &&\n cached !== undefined &&\n cached.lintSourceText === sourceText\n ) {\n return entry.mtimeMs;\n }\n const mtimeMs = statMtimeMs(fileName);\n this.#statByPath.set(fileName, { mtimeMs, at: now });\n return mtimeMs;\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 if (this.#crossFileSourceTextByPath.has(path)) {\n return this.#crossFileSourceTextByPath.get(path);\n }\n const text = readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n this.#crossFileSourceTextByPath.set(path, text);\n return text;\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 this.#mapperExtensions = 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 runExternalCode: this.runtime.runExternalCode,\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 /**\n * Content mapper state for `fileName`, or `undefined` when no mapper owns it.\n *\n * Resolving it costs one `getSourceFile` request per file, so the lookup is\n * skipped entirely unless the project declares a mapper that claims the\n * file's extension.\n */\n getContentMapping(fileName: string, sourceText?: string): ContentMapping | undefined {\n return this.withTransportRecovery(\n () => this.contentMappingFor(fileName, this.fileState(fileName, sourceText)),\n \"reading content mapper state\",\n );\n }\n\n /** Content mappers the project's `tsconfig` declares. */\n getContentMappers(): readonly ContentMapperDefinition[] {\n return this.withTransportRecovery(\n () => contentMappersFromConfig(this.config()),\n \"reading content mappers\",\n );\n }\n\n private contentMappingFor(fileName: string, state: FileCache): ContentMapping | undefined {\n if (state.contentMapping !== undefined) {\n return state.contentMapping ?? undefined;\n }\n state.contentMapping = null;\n if (!this.mapperOwnedExtensions().some((extension) => fileName.endsWith(extension))) {\n return undefined;\n }\n const sourceFile = this.decodeSourceFileForMapping(fileName, state);\n const mapping = sourceFile?.contentMapping;\n if (mapping) {\n state.contentMapping = {\n contentMapper: mapping.contentMapper,\n virtualFileName: mapping.virtualFileName,\n virtualText: sourceFile.text,\n spanMap: CorsaSpanMap.fromSegments(mapping.spanMap),\n };\n }\n return state.contentMapping ?? undefined;\n }\n\n /**\n * Decodes a file's source-file record, or `undefined` when it cannot be read.\n *\n * A runtime whose binary source-file protocol this build does not decode is\n * treated as \"not content mapped\", which is how the bridge behaved before it\n * understood mappers at all. Transport failures still propagate so the\n * session can restart the worker.\n */\n private decodeSourceFileForMapping(\n fileName: string,\n state: FileCache,\n ): EncodedSourceFile | undefined {\n try {\n return (\n this.client().getEncodedSourceFile(this.#snapshot!, state.projectId, fileName) ?? undefined\n );\n } catch (error) {\n if (isRecoverableTransportError(error)) {\n throw error;\n }\n return undefined;\n }\n }\n\n /**\n * Translates an authored position into the position the checker knows.\n *\n * Returns the position unchanged for files no mapper owns, and `undefined`\n * when the authored position has no counterpart in the virtual text — text\n * the checker never saw has no type or symbol to report.\n */\n private checkerPosition(\n fileName: string,\n state: FileCache,\n position: number,\n ): number | undefined {\n const mapping = this.contentMappingFor(fileName, state);\n if (!mapping) {\n return position;\n }\n const projections = mapping.spanMap.originalToVirtualPositions(position, SpanMap.Feature.Hover);\n return projections[0]?.position;\n }\n\n private mapperOwnedExtensions(): readonly string[] {\n if (!this.#mapperExtensions) {\n this.#mapperExtensions = contentMappersFromConfig(this.config()).flatMap(\n (mapper) => mapper.extensions,\n );\n }\n return this.#mapperExtensions;\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 = this.statMtimeMsThrottled(fileName, sourceText, cached, now);\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 // TypeScript 7.1 development builds key the handle by the declaring source\n // file: `<node index>.<syntax kind>.#<file id>.<path>`.\n const hasFileKey = isFileKeyText(thirdText);\n const fileName = (\n hasEndPosition || hasFileKey ? remainingParts : [thirdText, ...remainingParts]\n ).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 index>.<syntax kind>[.#<file id>].<path>`.\n // The 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 a compact TypeScript 7 wire format,\n * `<node index>.<syntax kind>.<path>` or, on TypeScript 7.1 development\n * builds, `<node index>.<syntax kind>.#<file id>.<path>`. Neither carries\n * 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 isFileKeyText(text: string | undefined): boolean {\n return text !== undefined && /^#\\d+$/.test(text);\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\") ||\n message.includes(\"empty type handle\") ||\n message.includes(\"empty signature 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":";;;AAwEA,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;CA8BpB;CACA;CA9BX;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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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,KACjD,QAAQ,SAAS,mBAAmB,KACpC,QAAQ,SAAS,wBAAwB;AAE7C;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"}
package/dist/types.d.ts CHANGED
@@ -2,8 +2,15 @@ import { ContentMapping } from "./session.js";
2
2
  import { ApiMode, ConfigResponse, ContentMapperDefinition, ProjectResponse, TypeResponse } from "@corsa-bind/napi";
3
3
  import { Context, Node, SourceCode } from "@oxlint/plugins";
4
4
  //#region src/bindings/nodejs/corsa_oxlint/ts/types.d.ts
5
+ /** Which installed Corsa runtime package discovery prefers. */
6
+ type CorsaRuntimeKind = "typescript" | "tsrs";
5
7
  interface CorsaRuntimeOptions {
6
8
  executable?: string;
9
+ /**
10
+ * Runtime package to discover when `executable` and `CORSA_EXECUTABLE` are
11
+ * unset. Defaults to `typescript` 7, then `tsrs`.
12
+ */
13
+ runtime?: CorsaRuntimeKind;
7
14
  cwd?: string;
8
15
  mode?: ApiMode;
9
16
  requestTimeoutMs?: number;
@@ -203,5 +210,5 @@ interface SessionProjectState {
203
210
  readonly snapshot: string;
204
211
  }
205
212
  //#endregion
206
- export { ContextWithParserOptions, CorsaCallSignatureFacts, CorsaIndexInfo, CorsaJsDocTagInfo, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, CorsaTypePredicate, ParserServices, ParserServicesWithTypeInformation, type ProjectResponse, ProjectServiceOptions, ResolvedProjectConfig, ResolvedRuntimeOptions, SessionProjectState, SignatureKind, TypeAwareParserOptions };
213
+ export { ContextWithParserOptions, CorsaCallSignatureFacts, CorsaIndexInfo, CorsaJsDocTagInfo, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeKind, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, CorsaTypePredicate, ParserServices, ParserServicesWithTypeInformation, type ProjectResponse, ProjectServiceOptions, ResolvedProjectConfig, ResolvedRuntimeOptions, SessionProjectState, SignatureKind, TypeAwareParserOptions };
207
214
  //# sourceMappingURL=types.d.ts.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../ts/types.ts"],"sourcesContent":["import type { Context, Node, SourceCode } from \"@oxlint/plugins\";\nimport type {\n ApiMode,\n ConfigResponse,\n ContentMapperDefinition,\n ProjectResponse,\n TypeResponse,\n} from \"@corsa-bind/napi\";\n\nimport type { ContentMapping } from \"./session\";\n\nexport interface CorsaRuntimeOptions {\n executable?: string;\n cwd?: string;\n mode?: ApiMode;\n requestTimeoutMs?: number;\n shutdownTimeoutMs?: number;\n outboundCapacity?: number;\n allowUnstableUpstreamCalls?: boolean;\n /** Allows trusted projects to execute configured TypeScript content mapper processes. */\n runExternalCode?: boolean;\n cacheLifetimeMs?: number;\n}\n\nexport interface ProjectServiceOptions {\n allowDefaultProject?: string[];\n defaultProject?: string;\n}\n\nexport interface TypeAwareParserOptions {\n project?: string | string[];\n projectService?: boolean | ProjectServiceOptions;\n tsconfigRootDir?: string;\n corsa?: CorsaRuntimeOptions;\n}\n\nexport interface CorsaOxlintSettings extends TypeAwareParserOptions {\n parserOptions?: TypeAwareParserOptions;\n}\n\nexport interface ResolvedRuntimeOptions {\n executable: string;\n cwd: string;\n mode: ApiMode;\n runExternalCode: boolean;\n cacheLifetimeMs: number;\n}\n\nexport interface ResolvedProjectConfig {\n filename: string;\n rootDir: string;\n configPath: string;\n runtime: ResolvedRuntimeOptions;\n}\n\nexport interface CorsaNode {\n readonly id?: string;\n readonly fileName: string;\n readonly pos: number;\n readonly end: number;\n readonly range: readonly [number, number];\n /**\n * Set when the node was parsed from a compact TypeScript 7 declaration\n * handle, whose leading number is a node id rather than a source offset. The\n * range of such a node cannot anchor source-text scans.\n */\n readonly positionless?: boolean;\n}\n\nexport interface CorsaSymbol {\n readonly id: string;\n readonly name: string;\n readonly flags: number;\n readonly checkFlags: number;\n readonly declarations: readonly string[];\n readonly valueDeclaration?: string;\n}\n\n/** One JSDoc tag on a symbol, mirroring the upstream `JSDocTagInfo` shape. */\nexport interface CorsaJsDocTagInfo {\n readonly name: string;\n readonly text?: string;\n}\n\nexport interface CorsaSignature {\n readonly id: string;\n readonly flags: number;\n readonly declaration?: string;\n readonly typeParameters: readonly string[];\n readonly parameters: readonly string[];\n readonly parameterSymbols?: readonly CorsaSymbol[];\n readonly parameterTypeTexts?: readonly (readonly string[])[];\n readonly thisParameter?: string;\n readonly thisParameterSymbol?: CorsaSymbol;\n readonly thisParameterTypeTexts?: readonly string[];\n readonly target?: string;\n readonly typeParameterDefaultTexts?: readonly string[];\n}\n\nexport interface CorsaIndexInfo {\n readonly keyType: CorsaType;\n readonly valueType: CorsaType;\n readonly isReadonly: boolean;\n}\n\nexport interface CorsaCallSignatureFacts {\n readonly signature?: CorsaSignature;\n readonly expectedArgumentTypeTexts?: readonly (readonly string[])[];\n readonly explicitTypeArgumentsRequired?: boolean;\n}\n\nexport enum SignatureKind {\n Call = 0,\n Construct = 1,\n}\n\nexport interface CorsaTypePredicate {\n readonly kind: number;\n readonly parameterIndex: number;\n readonly parameterName?: string;\n readonly type?: CorsaType;\n}\n\nexport interface CorsaType extends TypeResponse {\n readonly __corsaOxlintKind: \"type\";\n}\n\nexport interface CorsaProgramShape {\n getCompilerOptions(): unknown;\n getCurrentDirectory(): string;\n getRootFileNames(): readonly string[];\n getSourceFile(fileName?: string): {\n readonly fileName: string;\n readonly text: string;\n };\n /**\n * Content mapper state for a file, or `undefined` when no mapper owns it.\n *\n * Rules that report positions the checker handed back have to project them\n * through `contentMapping.spanMap` before they name a place in the authored\n * file.\n */\n getContentMapping(fileName?: string): ContentMapping | undefined;\n /** Content mappers the project's `tsconfig` declares. */\n getContentMappers(): readonly ContentMapperDefinition[];\n getTypeChecker(): CorsaTypeCheckerShape;\n}\n\nexport interface CorsaTypeCheckerShape {\n getTypeAtLocation(node: Node | CorsaNode): CorsaType | undefined;\n getContextualType(node: Node | CorsaNode): CorsaType | undefined;\n getSymbolAtLocation(node: Node | CorsaNode): CorsaSymbol | undefined;\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined;\n getSymbolById(id: string): CorsaSymbol | undefined;\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;\n getJsDocTags(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[];\n isTypeAssignableTo(source: CorsaType, target: CorsaType): boolean | undefined;\n getNode(node: string | CorsaNode): CorsaNode | undefined;\n getNodeById(id: string): CorsaNode | undefined;\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined;\n getTypeOfSymbolById(id: string): CorsaType | undefined;\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined;\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined;\n getTypeOfSymbolAtLocation(symbol: CorsaSymbol, node: Node | CorsaNode): CorsaType | undefined;\n typeToString(type: CorsaType, enclosingDeclaration?: Node | CorsaNode, flags?: number): string;\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined;\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[];\n getIndexInfosOfType(type: CorsaType): readonly CorsaIndexInfo[];\n getSignaturesOfType(type: CorsaType, kind: SignatureKind): readonly CorsaSignature[];\n getCallSignatureFacts(\n type: CorsaType,\n kind: SignatureKind,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts;\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined;\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined;\n getNonNullableType(type: CorsaType): CorsaType | undefined;\n getBaseTypes(type: CorsaType): readonly CorsaType[];\n getImplementedTypes(node: Node | CorsaNode): readonly CorsaType[];\n getImplementedTypesOfType(type: CorsaType): readonly CorsaType[];\n getTypeArguments(type: CorsaType): readonly CorsaType[];\n getTypesOfType(type: CorsaType): readonly CorsaType[];\n getTargetOfType(type: CorsaType): CorsaType | undefined;\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined;\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined;\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined;\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined;\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined;\n getConstraintOfType(type: CorsaType): CorsaType | undefined;\n isUnionType(type: CorsaType): boolean;\n isIntersectionType(type: CorsaType): boolean;\n}\n\nexport interface ParserServices {\n readonly program: CorsaProgramShape;\n readonly esTreeNodeToTSNodeMap: {\n get(node: Node): CorsaNode;\n has(node: Node): boolean;\n };\n readonly tsNodeToESTreeNodeMap: {\n get(node: CorsaNode): Node;\n has(node: CorsaNode): boolean;\n };\n readonly hasFullTypeInformation: boolean;\n getTypeAtLocation(node: Node): CorsaType | undefined;\n getSymbolAtLocation(node: Node): CorsaSymbol | undefined;\n}\n\nexport type ParserServicesWithTypeInformation = ParserServices & {\n readonly hasFullTypeInformation: true;\n};\n\nexport type ContextWithParserOptions = Context & {\n readonly filename: string;\n readonly cwd: string;\n readonly sourceCode: SourceCode;\n readonly parserOptions?: TypeAwareParserOptions;\n readonly languageOptions?: {\n readonly parserOptions?: TypeAwareParserOptions;\n };\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n readonly parserServices?: ParserServices;\n};\n\nexport interface SessionProjectState {\n readonly config: ConfigResponse;\n readonly project: ProjectResponse;\n readonly snapshot: string;\n}\n\nexport type { ProjectResponse };\n"],"mappings":";AA+GA,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,cAAA,UAAA,KAAA;CACA,cAAA,cAAA,eAAA,KAAA;;AACF,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../ts/types.ts"],"sourcesContent":["import type { Context, Node, SourceCode } from \"@oxlint/plugins\";\nimport type {\n ApiMode,\n ConfigResponse,\n ContentMapperDefinition,\n ProjectResponse,\n TypeResponse,\n} from \"@corsa-bind/napi\";\n\nimport type { ContentMapping } from \"./session\";\n\n/** Which installed Corsa runtime package discovery prefers. */\nexport type CorsaRuntimeKind = \"typescript\" | \"tsrs\";\n\nexport interface CorsaRuntimeOptions {\n executable?: string;\n /**\n * Runtime package to discover when `executable` and `CORSA_EXECUTABLE` are\n * unset. Defaults to `typescript` 7, then `tsrs`.\n */\n runtime?: CorsaRuntimeKind;\n cwd?: string;\n mode?: ApiMode;\n requestTimeoutMs?: number;\n shutdownTimeoutMs?: number;\n outboundCapacity?: number;\n allowUnstableUpstreamCalls?: boolean;\n /** Allows trusted projects to execute configured TypeScript content mapper processes. */\n runExternalCode?: boolean;\n cacheLifetimeMs?: number;\n}\n\nexport interface ProjectServiceOptions {\n allowDefaultProject?: string[];\n defaultProject?: string;\n}\n\nexport interface TypeAwareParserOptions {\n project?: string | string[];\n projectService?: boolean | ProjectServiceOptions;\n tsconfigRootDir?: string;\n corsa?: CorsaRuntimeOptions;\n}\n\nexport interface CorsaOxlintSettings extends TypeAwareParserOptions {\n parserOptions?: TypeAwareParserOptions;\n}\n\nexport interface ResolvedRuntimeOptions {\n executable: string;\n cwd: string;\n mode: ApiMode;\n runExternalCode: boolean;\n cacheLifetimeMs: number;\n}\n\nexport interface ResolvedProjectConfig {\n filename: string;\n rootDir: string;\n configPath: string;\n runtime: ResolvedRuntimeOptions;\n}\n\nexport interface CorsaNode {\n readonly id?: string;\n readonly fileName: string;\n readonly pos: number;\n readonly end: number;\n readonly range: readonly [number, number];\n /**\n * Set when the node was parsed from a compact TypeScript 7 declaration\n * handle, whose leading number is a node id rather than a source offset. The\n * range of such a node cannot anchor source-text scans.\n */\n readonly positionless?: boolean;\n}\n\nexport interface CorsaSymbol {\n readonly id: string;\n readonly name: string;\n readonly flags: number;\n readonly checkFlags: number;\n readonly declarations: readonly string[];\n readonly valueDeclaration?: string;\n}\n\n/** One JSDoc tag on a symbol, mirroring the upstream `JSDocTagInfo` shape. */\nexport interface CorsaJsDocTagInfo {\n readonly name: string;\n readonly text?: string;\n}\n\nexport interface CorsaSignature {\n readonly id: string;\n readonly flags: number;\n readonly declaration?: string;\n readonly typeParameters: readonly string[];\n readonly parameters: readonly string[];\n readonly parameterSymbols?: readonly CorsaSymbol[];\n readonly parameterTypeTexts?: readonly (readonly string[])[];\n readonly thisParameter?: string;\n readonly thisParameterSymbol?: CorsaSymbol;\n readonly thisParameterTypeTexts?: readonly string[];\n readonly target?: string;\n readonly typeParameterDefaultTexts?: readonly string[];\n}\n\nexport interface CorsaIndexInfo {\n readonly keyType: CorsaType;\n readonly valueType: CorsaType;\n readonly isReadonly: boolean;\n}\n\nexport interface CorsaCallSignatureFacts {\n readonly signature?: CorsaSignature;\n readonly expectedArgumentTypeTexts?: readonly (readonly string[])[];\n readonly explicitTypeArgumentsRequired?: boolean;\n}\n\nexport enum SignatureKind {\n Call = 0,\n Construct = 1,\n}\n\nexport interface CorsaTypePredicate {\n readonly kind: number;\n readonly parameterIndex: number;\n readonly parameterName?: string;\n readonly type?: CorsaType;\n}\n\nexport interface CorsaType extends TypeResponse {\n readonly __corsaOxlintKind: \"type\";\n}\n\nexport interface CorsaProgramShape {\n getCompilerOptions(): unknown;\n getCurrentDirectory(): string;\n getRootFileNames(): readonly string[];\n getSourceFile(fileName?: string): {\n readonly fileName: string;\n readonly text: string;\n };\n /**\n * Content mapper state for a file, or `undefined` when no mapper owns it.\n *\n * Rules that report positions the checker handed back have to project them\n * through `contentMapping.spanMap` before they name a place in the authored\n * file.\n */\n getContentMapping(fileName?: string): ContentMapping | undefined;\n /** Content mappers the project's `tsconfig` declares. */\n getContentMappers(): readonly ContentMapperDefinition[];\n getTypeChecker(): CorsaTypeCheckerShape;\n}\n\nexport interface CorsaTypeCheckerShape {\n getTypeAtLocation(node: Node | CorsaNode): CorsaType | undefined;\n getContextualType(node: Node | CorsaNode): CorsaType | undefined;\n getSymbolAtLocation(node: Node | CorsaNode): CorsaSymbol | undefined;\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined;\n getSymbolById(id: string): CorsaSymbol | undefined;\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;\n getJsDocTags(symbol: CorsaSymbol): readonly CorsaJsDocTagInfo[];\n isTypeAssignableTo(source: CorsaType, target: CorsaType): boolean | undefined;\n getNode(node: string | CorsaNode): CorsaNode | undefined;\n getNodeById(id: string): CorsaNode | undefined;\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined;\n getTypeOfSymbolById(id: string): CorsaType | undefined;\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined;\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined;\n getTypeOfSymbolAtLocation(symbol: CorsaSymbol, node: Node | CorsaNode): CorsaType | undefined;\n typeToString(type: CorsaType, enclosingDeclaration?: Node | CorsaNode, flags?: number): string;\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined;\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[];\n getIndexInfosOfType(type: CorsaType): readonly CorsaIndexInfo[];\n getSignaturesOfType(type: CorsaType, kind: SignatureKind): readonly CorsaSignature[];\n getCallSignatureFacts(\n type: CorsaType,\n kind: SignatureKind,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts;\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined;\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined;\n getNonNullableType(type: CorsaType): CorsaType | undefined;\n getBaseTypes(type: CorsaType): readonly CorsaType[];\n getImplementedTypes(node: Node | CorsaNode): readonly CorsaType[];\n getImplementedTypesOfType(type: CorsaType): readonly CorsaType[];\n getTypeArguments(type: CorsaType): readonly CorsaType[];\n getTypesOfType(type: CorsaType): readonly CorsaType[];\n getTargetOfType(type: CorsaType): CorsaType | undefined;\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[];\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined;\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined;\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined;\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined;\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined;\n getConstraintOfType(type: CorsaType): CorsaType | undefined;\n isUnionType(type: CorsaType): boolean;\n isIntersectionType(type: CorsaType): boolean;\n}\n\nexport interface ParserServices {\n readonly program: CorsaProgramShape;\n readonly esTreeNodeToTSNodeMap: {\n get(node: Node): CorsaNode;\n has(node: Node): boolean;\n };\n readonly tsNodeToESTreeNodeMap: {\n get(node: CorsaNode): Node;\n has(node: CorsaNode): boolean;\n };\n readonly hasFullTypeInformation: boolean;\n getTypeAtLocation(node: Node): CorsaType | undefined;\n getSymbolAtLocation(node: Node): CorsaSymbol | undefined;\n}\n\nexport type ParserServicesWithTypeInformation = ParserServices & {\n readonly hasFullTypeInformation: true;\n};\n\nexport type ContextWithParserOptions = Context & {\n readonly filename: string;\n readonly cwd: string;\n readonly sourceCode: SourceCode;\n readonly parserOptions?: TypeAwareParserOptions;\n readonly languageOptions?: {\n readonly parserOptions?: TypeAwareParserOptions;\n };\n readonly settings?: {\n readonly corsaOxlint?: CorsaOxlintSettings;\n readonly [key: string]: unknown;\n };\n readonly parserServices?: ParserServices;\n};\n\nexport interface SessionProjectState {\n readonly config: ConfigResponse;\n readonly project: ProjectResponse;\n readonly snapshot: string;\n}\n\nexport type { ProjectResponse };\n"],"mappings":";AAuHA,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,cAAA,UAAA,KAAA;CACA,cAAA,cAAA,eAAA,KAAA;;AACF,EAAA,CAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsa-oxlint",
3
- "version": "2.0.0-beta.5",
3
+ "version": "2.0.0-beta.7",
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,7 +95,7 @@
95
95
  "./package.json": "./package.json"
96
96
  },
97
97
  "dependencies": {
98
- "@corsa-bind/napi": "2.0.0-beta.5"
98
+ "@corsa-bind/napi": "2.0.0-beta.7"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@oxlint/plugins": "1.80.0",