corsa-oxlint 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,6 @@ plugins with real type information powered by Corsa.
18
18
  - lets custom Oxlint rules query types and symbols from JS or TS
19
19
  - ships a `RuleTester` wrapper that injects temp projects and type-aware config
20
20
  - ships a growing TS-native ruleset under `corsa-oxlint/rules`
21
- - ships a source-wide native stylistic ruleset under `corsa-oxlint/stylistic`
22
21
 
23
22
  The design goal is simple: performance-critical pieces live in Rust, `napi-rs`
24
23
  bridges them into Node, and end users still get to author custom plugins and
@@ -149,52 +148,6 @@ families. `pendingNativeRuleNames` is intentionally empty, and
149
148
  `native_rules.test.ts` fails if implemented + pending drift away from the
150
149
  tracked upstream rule list.
151
150
 
152
- ## Stylistic Rules
153
-
154
- `corsa-oxlint/stylistic` is a separate path for Rust-backed style rules that do
155
- not need type information. The rules scan the full source text in native code
156
- and the JS plugin caches diagnostics per source/config so enabled rules can
157
- share one N-API call.
158
-
159
- ```ts
160
- import { corsaStylisticPlugin } from "corsa-oxlint/stylistic";
161
-
162
- export default [
163
- {
164
- settings: {
165
- corsaStylistic: {
166
- rules: {
167
- "eol-last": ["always"],
168
- "linebreak-style": ["unix"],
169
- "no-multiple-empty-lines": [{ max: 1, maxBOF: 0, maxEOF: 1 }],
170
- "no-tabs": [{ allowIndentationTabs: false }],
171
- "no-trailing-spaces": [{ skipBlankLines: false }],
172
- quotes: ["single", { avoidEscape: true }],
173
- "unicode-bom": ["never"],
174
- },
175
- },
176
- },
177
- plugins: {
178
- stylistic: corsaStylisticPlugin,
179
- },
180
- rules: {
181
- "stylistic/eol-last": "error",
182
- "stylistic/linebreak-style": "error",
183
- "stylistic/no-multiple-empty-lines": "error",
184
- "stylistic/no-tabs": "error",
185
- "stylistic/no-trailing-spaces": "error",
186
- "stylistic/quotes": "error",
187
- "stylistic/unicode-bom": "error",
188
- },
189
- },
190
- ];
191
- ```
192
-
193
- Rule options can also be supplied directly in `rules`, for example
194
- `"stylistic/quotes": ["error", "single"]`. For the fastest multi-rule path,
195
- put the same option payloads in `settings.corsaStylistic.rules`; that lets the
196
- bridge batch all configured stylistic rules into a single Rust source scan.
197
-
198
151
  ## Rust-Authored Rule Lane
199
152
 
200
153
  General-purpose built-in rules can be implemented as Rust rules and still ship
package/dist/checker.js CHANGED
@@ -191,6 +191,11 @@ function typeOfNewExpression(node, checker) {
191
191
  function nodeForTypeLookup(node) {
192
192
  if ("pos" in node) return node;
193
193
  switch (node.type) {
194
+ case "ClassBody": {
195
+ const parent = childNode(node, "parent");
196
+ if (parent && (parent.type === "ClassDeclaration" || parent.type === "ClassExpression")) return childNode(parent, "id") ?? parent;
197
+ return node;
198
+ }
194
199
  case "ClassDeclaration":
195
200
  case "ClassExpression": return childNode(node, "id") ?? node;
196
201
  case "TSPropertySignature": return childNode(node, "key") ?? node;
@@ -1 +1 @@
1
- {"version":3,"file":"checker.js","names":[],"sources":["../ts/checker.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport { createNodeMaps, toPosition } from \"./node_map\";\nimport { sessionForContext } from \"./registry\";\nimport type { CorsaProjectSession } from \"./session\";\nimport { SignatureKind } from \"./types\";\nimport type {\n ContextWithParserOptions,\n CorsaNode,\n CorsaProgramShape,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypeCheckerShape,\n} from \"./types\";\n\ntype ImplementingClassDeclarations = {\n /** Ranges of the classes that carry an `implements` clause, keyed by name. */\n readonly byName: ReadonlyMap<string, readonly (readonly [start: number, end: number])[]>;\n /**\n * Names declared by more than one class in the file. A lookup by simple name\n * cannot tell those declarations apart, so it needs a declaration position to\n * pick the right one.\n */\n readonly ambiguousNames: ReadonlySet<string>;\n};\n\ntype ImplementingClassCache = {\n readonly sourceText: string;\n readonly declarations: ImplementingClassDeclarations;\n};\n\nconst implementingClassNamesBySession = new WeakMap<\n CorsaProjectSession,\n Map<string, ImplementingClassCache>\n>();\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): CorsaProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n const type = sessionForContext(context).session.getTypeAtSourceRange(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n endPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n nodeKind(lookupNode),\n );\n primeImplementedTypesCacheFromNode(context, node, type, this);\n return type;\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getSymbol(symbol) {\n return sessionForContext(context).session.getSymbol(symbol);\n },\n getSymbolById(id) {\n return sessionForContext(context).session.getSymbol(id);\n },\n getSymbolOfType(type) {\n return sessionForContext(context).session.getSymbolOfType(type);\n },\n getNode(node) {\n return sessionForContext(context).session.getNode(node);\n },\n getNodeById(id) {\n return sessionForContext(context).session.getNode(id);\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getTypeOfSymbolById(id) {\n return sessionForContext(context).session.getTypeOfSymbolById(id);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbolById(id) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbolById(id);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol) ??\n this.getTypeAtLocation(node)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getCallSignatureFacts(type, kind, argumentTypeTexts, explicitTypeArgumentTexts) {\n return sessionForContext(context).session.getCallSignatureFacts(\n type,\n kind,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n );\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getImplementedTypes(node) {\n if (\"pos\" in node) {\n return implementedTypesFromCorsaNode(context, node, this);\n }\n const sourceText = sourceTextFor(context, node);\n const sourceNode = sourceText ? corsaNodeFromEstree(context, node) : undefined;\n if (sourceText && sourceNode) {\n const implemented = implementedTypesFromSourceText(context, sourceNode, sourceText, this);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n return implementedClauseNodes(node)\n .map((clause) => {\n const expression = implementedClauseChildNode(clause, \"expression\") ?? clause;\n const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);\n return symbol\n ? (this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeOfSymbol(symbol))\n : (this.getTypeAtLocation(expression) ?? this.getTypeAtLocation(clause));\n })\n .filter((type): type is CorsaType => type !== undefined);\n },\n getImplementedTypesOfType(type) {\n return implementedTypesFromTypeAndBases(context, type, this);\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n getTypesOfType(type) {\n return sessionForContext(context).session.getTypesOfType(type);\n },\n getTargetOfType(type) {\n return sessionForContext(context).session.getTargetOfType(type);\n },\n getTypeParametersOfType(type) {\n return sessionForContext(context).session.getTypeParametersOfType(type);\n },\n getOuterTypeParametersOfType(type) {\n return sessionForContext(context).session.getOuterTypeParametersOfType(type);\n },\n getLocalTypeParametersOfType(type) {\n return sessionForContext(context).session.getLocalTypeParametersOfType(type);\n },\n getObjectTypeOfType(type) {\n return sessionForContext(context).session.getObjectTypeOfType(type);\n },\n getIndexTypeOfType(type) {\n return sessionForContext(context).session.getIndexTypeOfType(type);\n },\n getCheckTypeOfType(type) {\n return sessionForContext(context).session.getCheckTypeOfType(type);\n },\n getExtendsTypeOfType(type) {\n return sessionForContext(context).session.getExtendsTypeOfType(type);\n },\n getBaseTypeOfType(type) {\n return sessionForContext(context).session.getBaseTypeOfType(type);\n },\n getConstraintOfType(type) {\n return sessionForContext(context).session.getConstraintOfType(type);\n },\n isUnionType(type) {\n return (type.flags & typeFlags.union) !== 0;\n },\n isIntersectionType(type) {\n return (type.flags & typeFlags.intersection) !== 0;\n },\n };\n}\n\nfunction primeImplementedTypesCacheFromNode(\n context: ContextWithParserOptions,\n node: Node | CorsaNode,\n type: CorsaType | undefined,\n checker: CorsaTypeCheckerShape,\n): void {\n if (!type || \"pos\" in node) {\n return;\n }\n const kind = (node as { readonly type?: string }).type;\n if (kind !== \"ClassDeclaration\" && kind !== \"ClassExpression\") {\n return;\n }\n const session = sessionForContext(context).session;\n if (session.getCachedOwnImplementedTypes(type.id)) {\n return;\n }\n session.cacheOwnImplementedTypes(type.id, checker.getImplementedTypes(node));\n}\n\nconst typeFlags = {\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nfunction sourceTextFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string | undefined {\n return sourceTextForPath(context, filenameFor(context, node));\n}\n\nfunction sourceTextForPath(\n context: ContextWithParserOptions,\n fileName: string,\n): string | undefined {\n return pathsReferToSameFile(fileName, context.filename)\n ? context.sourceCode.text\n : sessionForContext(context).session.getSourceTextForPath(fileName);\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 typeOfNewExpression(node: Node, checker: CorsaTypeCheckerShape): CorsaType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, SignatureKind.Construct)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | CorsaNode): Node | CorsaNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction endPosition(node: Node | CorsaNode): number {\n if (\"end\" in node) {\n return node.end;\n }\n const range = (node as Node & { readonly range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range[1];\n}\n\nfunction nodeKind(node: Node | CorsaNode): string | undefined {\n return \"pos\" in node ? undefined : (node as { readonly type?: string }).type;\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | CorsaNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromCorsaNode(\n context: ContextWithParserOptions,\n node: CorsaNode,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n return implementedTypesFromSourceText(context, node, sourceText, checker);\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction corsaNodeFromEstree(context: ContextWithParserOptions, node: Node): CorsaNode | undefined {\n const range = (node as { readonly range?: unknown }).range;\n if (\n !Array.isArray(range) ||\n range.length < 2 ||\n typeof range[0] !== \"number\" ||\n typeof range[1] !== \"number\"\n ) {\n return undefined;\n }\n return {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range: [range[0], range[1]] as const,\n };\n}\n\nfunction implementedTypesFromTypeAndBases(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n // Iterative DFS over the base chain so we don't pay for one closure call\n // and one `push(...subResult)` spread per base (each spread used to copy\n // the entire growing accumulator). Visit order doesn't matter because we\n // dedupe by `type.id`.\n const seenTypes = new Set<string>();\n const seenImplementedTypes = new Set<string>();\n const implemented: CorsaType[] = [];\n const stack: CorsaType[] = [type];\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (seenTypes.has(current.id)) {\n continue;\n }\n seenTypes.add(current.id);\n\n const ownImplemented = implementedTypesFromTypeDeclaration(context, current, checker);\n for (let index = 0; index < ownImplemented.length; index += 1) {\n const ownType = ownImplemented[index]!;\n if (seenImplementedTypes.has(ownType.id)) {\n continue;\n }\n seenImplementedTypes.add(ownType.id);\n implemented.push(ownType);\n }\n\n const bases = checker.getBaseTypes(current);\n // Push in reverse so the natural visit order matches the recursive form.\n for (let index = bases.length - 1; index >= 0; index -= 1) {\n const baseType = bases[index]!;\n if (seenTypes.has(baseType.id)) {\n continue;\n }\n stack.push(baseType);\n }\n }\n return session.cacheImplementedTypes(type.id, implemented);\n}\n\nfunction implementedTypesFromTypeDeclaration(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedOwnImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n const symbol =\n (type.symbol ? session.getSymbol(type.symbol) : undefined) ?? checker.getSymbolOfType(type);\n const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n const declarationNode = declaration ? session.getNode(declaration) : undefined;\n const matchedDeclarationNode = session.getClassDeclarationForType(type);\n const localImplementingDeclaration =\n declarationNode && pathsReferToSameFile(declarationNode.fileName, context.filename)\n ? implementingClassDeclaration(context, type, symbol, declarationNode)\n : undefined;\n const resolvedDeclarationNode =\n matchedDeclarationNode ??\n localImplementingDeclaration ??\n declarationNode ??\n implementingClassDeclaration(context, type, symbol);\n const sourceText = resolvedDeclarationNode\n ? sourceTextForPath(context, resolvedDeclarationNode.fileName)\n : undefined;\n const implemented =\n resolvedDeclarationNode && sourceText\n ? implementedTypesFromSourceText(context, resolvedDeclarationNode, sourceText, checker)\n : [];\n return session.cacheOwnImplementedTypes(type.id, implemented);\n}\n\nfunction implementingClassDeclaration(\n context: ContextWithParserOptions,\n type: CorsaType,\n symbol?: CorsaSymbol,\n declarationNode?: CorsaNode,\n): CorsaNode | undefined {\n const name = implementingClassName(type, symbol);\n if (!name) {\n return undefined;\n }\n const { byName, ambiguousNames } = implementingClassDeclarations(context);\n const ranges = byName.get(name);\n if (!ranges || ranges.length === 0) {\n return undefined;\n }\n const range = ambiguousNames.has(name)\n ? declaredRange(ranges, declarationNode, context.filename)\n : ranges[0];\n return range\n ? {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range,\n }\n : undefined;\n}\n\n/**\n * Picks the candidate whose `class` keyword sits inside `declarationNode`, which\n * is the declaration the symbol actually points at. Without a usable declaration\n * range there is nothing to disambiguate with, so the lookup gives up rather\n * than returning a same-named class from another scope.\n */\nfunction declaredRange(\n ranges: readonly (readonly [start: number, end: number])[],\n declarationNode: CorsaNode | undefined,\n filename: string,\n): readonly [start: number, end: number] | undefined {\n if (!declarationNode || !pathsReferToSameFile(declarationNode.fileName, filename)) {\n return undefined;\n }\n return ranges.find(([start]) => start >= declarationNode.pos && start < declarationNode.end);\n}\n\nfunction implementingClassName(type: CorsaType, symbol?: CorsaSymbol): string | undefined {\n return symbol?.name || typeSymbolName(type.texts ?? []);\n}\n\nfunction typeSymbolName(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\nfunction implementingClassDeclarations(\n context: ContextWithParserOptions,\n): ImplementingClassDeclarations {\n const session = sessionForContext(context).session;\n let byFile = implementingClassNamesBySession.get(session);\n if (!byFile) {\n byFile = new Map();\n implementingClassNamesBySession.set(session, byFile);\n }\n const sourceText = context.sourceCode.text;\n const cached = byFile.get(context.filename);\n if (cached?.sourceText === sourceText) {\n return cached.declarations;\n }\n const declarations = collectImplementingClassDeclarations(sourceText);\n byFile.set(context.filename, { sourceText, declarations });\n return declarations;\n}\n\nfunction collectImplementingClassDeclarations(sourceText: string): ImplementingClassDeclarations {\n const byName = new Map<string, (readonly [start: number, end: number])[]>();\n const declaredNames = new Set<string>();\n const ambiguousNames = new Set<string>();\n let offset = 0;\n while (offset < sourceText.length) {\n const classOffset = findKeywordOutsideTrivia(sourceText.slice(offset), \"class\");\n if (classOffset < 0) {\n break;\n }\n const declarationStart = offset + classOffset + \"class\".length;\n const rest = sourceText.slice(declarationStart);\n const match = /^\\s*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)/u.exec(rest);\n if (match?.[1]) {\n const name = match[1];\n if (declaredNames.has(name)) {\n ambiguousNames.add(name);\n }\n declaredNames.add(name);\n const bodyOpen = findClassBodyOpen(rest, 0);\n const header = rest.slice(0, bodyOpen >= 0 ? bodyOpen : rest.length);\n if (findKeywordOutsideTrivia(header, \"implements\") >= 0) {\n const range = [offset + classOffset, sourceText.length] as const;\n const ranges = byName.get(name);\n if (ranges) {\n ranges.push(range);\n } else {\n byName.set(name, [range]);\n }\n }\n }\n offset = declarationStart;\n }\n return { byName, ambiguousNames };\n}\n\nfunction implementedTypesFromSourceText(\n context: ContextWithParserOptions,\n node: CorsaNode,\n sourceText: string,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n if (node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return [];\n }\n const classText = sourceText.slice(node.pos, node.end);\n const classStart = findKeywordOutsideTrivia(classText, \"class\");\n const headerStart = classStart >= 0 ? classStart : 0;\n const bodyOpen = findClassBodyOpen(classText, headerStart);\n const headerText = classText.slice(headerStart, bodyOpen >= 0 ? bodyOpen : classText.length);\n const implementsIndex = findKeywordOutsideTrivia(headerText, \"implements\");\n if (implementsIndex < 0) {\n return [];\n }\n const clauseText = headerText.slice(implementsIndex + \"implements\".length);\n const clauseStart = node.pos + headerStart + implementsIndex + \"implements\".length;\n return splitTopLevelRanges(clauseText, \",\")\n .map((range) => {\n const raw = clauseText.slice(range.start, range.end);\n const leading = raw.search(/\\S/);\n if (leading < 0) {\n return undefined;\n }\n const trailing = raw.match(/\\s*$/)?.[0].length ?? 0;\n const pos = clauseStart + range.start + leading;\n const end = clauseStart + range.end - trailing;\n const lookupNode: CorsaNode = {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n const nameNode = implementedClauseNameNode(lookupNode, raw);\n const symbol =\n checker.getSymbolAtLocation(nameNode) ?? checker.getSymbolAtLocation(lookupNode);\n const type = symbol\n ? (checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol))\n : (checker.getTypeAtLocation(nameNode) ?? checker.getTypeAtLocation(lookupNode));\n if (type) {\n try {\n checker.typeToString(type);\n } catch {\n // Corsa-side relation fallbacks handle stale type handles; avoid\n // deriving replacement text from source names in the JS bridge.\n }\n }\n return type;\n })\n .filter((type): type is CorsaType => type !== undefined);\n}\n\nfunction implementedClauseNameNode(node: CorsaNode, raw: string): CorsaNode {\n const range = lastTypeNameIdentifierRange(raw);\n if (!range) {\n return node;\n }\n const pos = node.pos + range.start;\n const end = node.pos + range.end;\n return {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n}\n\nfunction lastTypeNameIdentifierRange(\n text: string,\n): { readonly start: number; readonly end: number } | undefined {\n let last: { start: number; end: number } | undefined;\n const scanner = createScanner();\n for (let index = 0; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = text[index];\n if (char === \"<\") {\n break;\n }\n if (!isIdentifierStart(char)) {\n continue;\n }\n let end = index + 1;\n while (isIdentifierPart(text[end])) {\n end += 1;\n }\n last = { start: index, end };\n index = end - 1;\n }\n return last;\n}\n\nfunction findClassBodyOpen(text: string, start: number): number {\n const scanner = createScanner();\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = start; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = text[index];\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (\n char === \"{\" &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n return index;\n } else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n }\n return -1;\n}\n\nfunction findKeywordOutsideTrivia(text: string, keyword: string): number {\n const scanner = createScanner();\n for (let index = 0; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (matchesKeyword(text, keyword, index)) {\n return index;\n }\n }\n return -1;\n}\n\nfunction matchesKeyword(text: string, keyword: string, index: number): boolean {\n return (\n text.startsWith(keyword, index) &&\n !isIdentifierPart(text[index - 1]) &&\n !isIdentifierPart(text[index + keyword.length])\n );\n}\n\nfunction isIdentifierPart(char: string | undefined): boolean {\n return char !== undefined && (isIdentifierStart(char) || /[0-9]/.test(char));\n}\n\nfunction isIdentifierStart(char: string | undefined): boolean {\n return char !== undefined && /[A-Za-z_$]/.test(char);\n}\n\nfunction splitTopLevelRanges(\n text: string,\n delimiter: string,\n): readonly { readonly start: number; readonly end: number }[] {\n const ranges: { start: number; end: number }[] = [];\n const scanner = createScanner();\n let start = 0;\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index];\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n else if (\n char === delimiter &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n ranges.push({ start, end: index });\n start = index + 1;\n }\n }\n ranges.push({ start, end: text.length });\n return ranges;\n}\n\nfunction createScanner(): {\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 isNode(value: unknown): value is Node {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"range\" in value;\n}\n\nfunction filenameFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string {\n if (\"fileName\" in node) {\n return node.fileName;\n }\n return context.filename;\n}\n"],"mappings":";;;;AAgCA,MAAM,kDAAkC,IAAI,QAG1C;AAEF,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,OAEvB;EACP,qBAAqB;GACnB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,mBAAmB;EAC/D;EACA,sBAAsB;GACpB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ;EAC5C;EACA,mBAAmB;GACjB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,iBAAiB;EAC7D;EACA,cAAc,WAAW,QAAQ,UAAU;GACzC,OAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;GAAK;EACnD;EACA,iBAAiB;GACf,OAAO,kBAAkB,OAAO;EAClC;CACF;AACF;AAEA,SAAgB,kBAAkB,SAA0D;CAC1F,OAAO;EACL,kBAAkB,MAAM;GACtB,IAAK,KAAoC,SAAS,iBAChD,OAAO,oBAAoB,MAAc,IAAI;GAE/C,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,qBAC9C,YAAY,SAAS,UAAU,GAC/B,WAAW,UAAU,GACrB,YAAY,UAAU,GACtB,cAAc,SAAS,UAAU,GACjC,SAAS,UAAU,CACrB;GACA,mCAAmC,SAAS,MAAM,MAAM,IAAI;GAC5D,OAAO;EACT;EACA,kBAAkB,MAAM;GACtB,OAAO,KAAK,kBAAkB,IAAI;EACpC;EACA,oBAAoB,MAAM;GACxB,MAAM,aAAa,kBAAkB,IAAI;GACzC,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,oBACxC,YAAY,SAAS,UAAU,GAC/B,WAAW,UAAU,GACrB,cAAc,SAAS,UAAU,CACnC;EACF;EACA,UAAU,QAAQ;GAChB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,UAAU,MAAM;E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AClB,UAAU;QACL,IAAI,SAAS,OAClB,QAAQ,KAAA;GAEV,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,OAAO,SAAS,KAAK;GAChC,gBAAgB;GAChB,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,OAAO,SAAS,KAAK;GAChC,iBAAiB;GACjB,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,QAAO,SAAS,OAAO,SAAS,KAAK;GAChD,QAAQ;GACR,OAAO,QAAQ;EACjB;EACA,OAAO;CACT,EACF;AACF;AAEA,SAAS,OAAO,OAA+B;CAC7C,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;AACtF;AAEA,SAAS,YACP,SACA,MACQ;CACR,IAAI,cAAc,MAChB,OAAO,KAAK;CAEd,OAAO,QAAQ;AACjB"}
1
+ {"version":3,"file":"checker.js","names":[],"sources":["../ts/checker.ts"],"sourcesContent":["import type { Node } from \"@oxlint/plugins\";\n\nimport { createNodeMaps, toPosition } from \"./node_map\";\nimport { sessionForContext } from \"./registry\";\nimport type { CorsaProjectSession } from \"./session\";\nimport { SignatureKind } from \"./types\";\nimport type {\n ContextWithParserOptions,\n CorsaNode,\n CorsaProgramShape,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypeCheckerShape,\n} from \"./types\";\n\ntype ImplementingClassDeclarations = {\n /** Ranges of the classes that carry an `implements` clause, keyed by name. */\n readonly byName: ReadonlyMap<string, readonly (readonly [start: number, end: number])[]>;\n /**\n * Names declared by more than one class in the file. A lookup by simple name\n * cannot tell those declarations apart, so it needs a declaration position to\n * pick the right one.\n */\n readonly ambiguousNames: ReadonlySet<string>;\n};\n\ntype ImplementingClassCache = {\n readonly sourceText: string;\n readonly declarations: ImplementingClassDeclarations;\n};\n\nconst implementingClassNamesBySession = new WeakMap<\n CorsaProjectSession,\n Map<string, ImplementingClassCache>\n>();\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): CorsaProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n const type = sessionForContext(context).session.getTypeAtSourceRange(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n endPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n nodeKind(lookupNode),\n );\n primeImplementedTypesCacheFromNode(context, node, type, this);\n return type;\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getSymbol(symbol) {\n return sessionForContext(context).session.getSymbol(symbol);\n },\n getSymbolById(id) {\n return sessionForContext(context).session.getSymbol(id);\n },\n getSymbolOfType(type) {\n return sessionForContext(context).session.getSymbolOfType(type);\n },\n getNode(node) {\n return sessionForContext(context).session.getNode(node);\n },\n getNodeById(id) {\n return sessionForContext(context).session.getNode(id);\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getTypeOfSymbolById(id) {\n return sessionForContext(context).session.getTypeOfSymbolById(id);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbolById(id) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbolById(id);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol) ??\n this.getTypeAtLocation(node)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getCallSignatureFacts(type, kind, argumentTypeTexts, explicitTypeArgumentTexts) {\n return sessionForContext(context).session.getCallSignatureFacts(\n type,\n kind,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n );\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getImplementedTypes(node) {\n if (\"pos\" in node) {\n return implementedTypesFromCorsaNode(context, node, this);\n }\n const sourceText = sourceTextFor(context, node);\n const sourceNode = sourceText ? corsaNodeFromEstree(context, node) : undefined;\n if (sourceText && sourceNode) {\n const implemented = implementedTypesFromSourceText(context, sourceNode, sourceText, this);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n return implementedClauseNodes(node)\n .map((clause) => {\n const expression = implementedClauseChildNode(clause, \"expression\") ?? clause;\n const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);\n return symbol\n ? (this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeOfSymbol(symbol))\n : (this.getTypeAtLocation(expression) ?? this.getTypeAtLocation(clause));\n })\n .filter((type): type is CorsaType => type !== undefined);\n },\n getImplementedTypesOfType(type) {\n return implementedTypesFromTypeAndBases(context, type, this);\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n getTypesOfType(type) {\n return sessionForContext(context).session.getTypesOfType(type);\n },\n getTargetOfType(type) {\n return sessionForContext(context).session.getTargetOfType(type);\n },\n getTypeParametersOfType(type) {\n return sessionForContext(context).session.getTypeParametersOfType(type);\n },\n getOuterTypeParametersOfType(type) {\n return sessionForContext(context).session.getOuterTypeParametersOfType(type);\n },\n getLocalTypeParametersOfType(type) {\n return sessionForContext(context).session.getLocalTypeParametersOfType(type);\n },\n getObjectTypeOfType(type) {\n return sessionForContext(context).session.getObjectTypeOfType(type);\n },\n getIndexTypeOfType(type) {\n return sessionForContext(context).session.getIndexTypeOfType(type);\n },\n getCheckTypeOfType(type) {\n return sessionForContext(context).session.getCheckTypeOfType(type);\n },\n getExtendsTypeOfType(type) {\n return sessionForContext(context).session.getExtendsTypeOfType(type);\n },\n getBaseTypeOfType(type) {\n return sessionForContext(context).session.getBaseTypeOfType(type);\n },\n getConstraintOfType(type) {\n return sessionForContext(context).session.getConstraintOfType(type);\n },\n isUnionType(type) {\n return (type.flags & typeFlags.union) !== 0;\n },\n isIntersectionType(type) {\n return (type.flags & typeFlags.intersection) !== 0;\n },\n };\n}\n\nfunction primeImplementedTypesCacheFromNode(\n context: ContextWithParserOptions,\n node: Node | CorsaNode,\n type: CorsaType | undefined,\n checker: CorsaTypeCheckerShape,\n): void {\n if (!type || \"pos\" in node) {\n return;\n }\n const kind = (node as { readonly type?: string }).type;\n if (kind !== \"ClassDeclaration\" && kind !== \"ClassExpression\") {\n return;\n }\n const session = sessionForContext(context).session;\n if (session.getCachedOwnImplementedTypes(type.id)) {\n return;\n }\n session.cacheOwnImplementedTypes(type.id, checker.getImplementedTypes(node));\n}\n\nconst typeFlags = {\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nfunction sourceTextFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string | undefined {\n return sourceTextForPath(context, filenameFor(context, node));\n}\n\nfunction sourceTextForPath(\n context: ContextWithParserOptions,\n fileName: string,\n): string | undefined {\n return pathsReferToSameFile(fileName, context.filename)\n ? context.sourceCode.text\n : sessionForContext(context).session.getSourceTextForPath(fileName);\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 typeOfNewExpression(node: Node, checker: CorsaTypeCheckerShape): CorsaType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, SignatureKind.Construct)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | CorsaNode): Node | CorsaNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassBody\": {\n const parent = childNode(node, \"parent\");\n if (\n parent &&\n ((parent as { readonly type?: string }).type === \"ClassDeclaration\" ||\n (parent as { readonly type?: string }).type === \"ClassExpression\")\n ) {\n return childNode(parent, \"id\") ?? parent;\n }\n return node;\n }\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction endPosition(node: Node | CorsaNode): number {\n if (\"end\" in node) {\n return node.end;\n }\n const range = (node as Node & { readonly range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range[1];\n}\n\nfunction nodeKind(node: Node | CorsaNode): string | undefined {\n return \"pos\" in node ? undefined : (node as { readonly type?: string }).type;\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | CorsaNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromCorsaNode(\n context: ContextWithParserOptions,\n node: CorsaNode,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n return implementedTypesFromSourceText(context, node, sourceText, checker);\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction corsaNodeFromEstree(context: ContextWithParserOptions, node: Node): CorsaNode | undefined {\n const range = (node as { readonly range?: unknown }).range;\n if (\n !Array.isArray(range) ||\n range.length < 2 ||\n typeof range[0] !== \"number\" ||\n typeof range[1] !== \"number\"\n ) {\n return undefined;\n }\n return {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range: [range[0], range[1]] as const,\n };\n}\n\nfunction implementedTypesFromTypeAndBases(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n // Iterative DFS over the base chain so we don't pay for one closure call\n // and one `push(...subResult)` spread per base (each spread used to copy\n // the entire growing accumulator). Visit order doesn't matter because we\n // dedupe by `type.id`.\n const seenTypes = new Set<string>();\n const seenImplementedTypes = new Set<string>();\n const implemented: CorsaType[] = [];\n const stack: CorsaType[] = [type];\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (seenTypes.has(current.id)) {\n continue;\n }\n seenTypes.add(current.id);\n\n const ownImplemented = implementedTypesFromTypeDeclaration(context, current, checker);\n for (let index = 0; index < ownImplemented.length; index += 1) {\n const ownType = ownImplemented[index]!;\n if (seenImplementedTypes.has(ownType.id)) {\n continue;\n }\n seenImplementedTypes.add(ownType.id);\n implemented.push(ownType);\n }\n\n const bases = checker.getBaseTypes(current);\n // Push in reverse so the natural visit order matches the recursive form.\n for (let index = bases.length - 1; index >= 0; index -= 1) {\n const baseType = bases[index]!;\n if (seenTypes.has(baseType.id)) {\n continue;\n }\n stack.push(baseType);\n }\n }\n return session.cacheImplementedTypes(type.id, implemented);\n}\n\nfunction implementedTypesFromTypeDeclaration(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedOwnImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n const symbol =\n (type.symbol ? session.getSymbol(type.symbol) : undefined) ?? checker.getSymbolOfType(type);\n const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n const declarationNode = declaration ? session.getNode(declaration) : undefined;\n const matchedDeclarationNode = session.getClassDeclarationForType(type);\n const localImplementingDeclaration =\n declarationNode && pathsReferToSameFile(declarationNode.fileName, context.filename)\n ? implementingClassDeclaration(context, type, symbol, declarationNode)\n : undefined;\n const resolvedDeclarationNode =\n matchedDeclarationNode ??\n localImplementingDeclaration ??\n declarationNode ??\n implementingClassDeclaration(context, type, symbol);\n const sourceText = resolvedDeclarationNode\n ? sourceTextForPath(context, resolvedDeclarationNode.fileName)\n : undefined;\n const implemented =\n resolvedDeclarationNode && sourceText\n ? implementedTypesFromSourceText(context, resolvedDeclarationNode, sourceText, checker)\n : [];\n return session.cacheOwnImplementedTypes(type.id, implemented);\n}\n\nfunction implementingClassDeclaration(\n context: ContextWithParserOptions,\n type: CorsaType,\n symbol?: CorsaSymbol,\n declarationNode?: CorsaNode,\n): CorsaNode | undefined {\n const name = implementingClassName(type, symbol);\n if (!name) {\n return undefined;\n }\n const { byName, ambiguousNames } = implementingClassDeclarations(context);\n const ranges = byName.get(name);\n if (!ranges || ranges.length === 0) {\n return undefined;\n }\n const range = ambiguousNames.has(name)\n ? declaredRange(ranges, declarationNode, context.filename)\n : ranges[0];\n return range\n ? {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range,\n }\n : undefined;\n}\n\n/**\n * Picks the candidate whose `class` keyword sits inside `declarationNode`, which\n * is the declaration the symbol actually points at. Without a usable declaration\n * range there is nothing to disambiguate with, so the lookup gives up rather\n * than returning a same-named class from another scope.\n */\nfunction declaredRange(\n ranges: readonly (readonly [start: number, end: number])[],\n declarationNode: CorsaNode | undefined,\n filename: string,\n): readonly [start: number, end: number] | undefined {\n if (!declarationNode || !pathsReferToSameFile(declarationNode.fileName, filename)) {\n return undefined;\n }\n return ranges.find(([start]) => start >= declarationNode.pos && start < declarationNode.end);\n}\n\nfunction implementingClassName(type: CorsaType, symbol?: CorsaSymbol): string | undefined {\n return symbol?.name || typeSymbolName(type.texts ?? []);\n}\n\nfunction typeSymbolName(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\nfunction implementingClassDeclarations(\n context: ContextWithParserOptions,\n): ImplementingClassDeclarations {\n const session = sessionForContext(context).session;\n let byFile = implementingClassNamesBySession.get(session);\n if (!byFile) {\n byFile = new Map();\n implementingClassNamesBySession.set(session, byFile);\n }\n const sourceText = context.sourceCode.text;\n const cached = byFile.get(context.filename);\n if (cached?.sourceText === sourceText) {\n return cached.declarations;\n }\n const declarations = collectImplementingClassDeclarations(sourceText);\n byFile.set(context.filename, { sourceText, declarations });\n return declarations;\n}\n\nfunction collectImplementingClassDeclarations(sourceText: string): ImplementingClassDeclarations {\n const byName = new Map<string, (readonly [start: number, end: number])[]>();\n const declaredNames = new Set<string>();\n const ambiguousNames = new Set<string>();\n let offset = 0;\n while (offset < sourceText.length) {\n const classOffset = findKeywordOutsideTrivia(sourceText.slice(offset), \"class\");\n if (classOffset < 0) {\n break;\n }\n const declarationStart = offset + classOffset + \"class\".length;\n const rest = sourceText.slice(declarationStart);\n const match = /^\\s*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)/u.exec(rest);\n if (match?.[1]) {\n const name = match[1];\n if (declaredNames.has(name)) {\n ambiguousNames.add(name);\n }\n declaredNames.add(name);\n const bodyOpen = findClassBodyOpen(rest, 0);\n const header = rest.slice(0, bodyOpen >= 0 ? bodyOpen : rest.length);\n if (findKeywordOutsideTrivia(header, \"implements\") >= 0) {\n const range = [offset + classOffset, sourceText.length] as const;\n const ranges = byName.get(name);\n if (ranges) {\n ranges.push(range);\n } else {\n byName.set(name, [range]);\n }\n }\n }\n offset = declarationStart;\n }\n return { byName, ambiguousNames };\n}\n\nfunction implementedTypesFromSourceText(\n context: ContextWithParserOptions,\n node: CorsaNode,\n sourceText: string,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n if (node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return [];\n }\n const classText = sourceText.slice(node.pos, node.end);\n const classStart = findKeywordOutsideTrivia(classText, \"class\");\n const headerStart = classStart >= 0 ? classStart : 0;\n const bodyOpen = findClassBodyOpen(classText, headerStart);\n const headerText = classText.slice(headerStart, bodyOpen >= 0 ? bodyOpen : classText.length);\n const implementsIndex = findKeywordOutsideTrivia(headerText, \"implements\");\n if (implementsIndex < 0) {\n return [];\n }\n const clauseText = headerText.slice(implementsIndex + \"implements\".length);\n const clauseStart = node.pos + headerStart + implementsIndex + \"implements\".length;\n return splitTopLevelRanges(clauseText, \",\")\n .map((range) => {\n const raw = clauseText.slice(range.start, range.end);\n const leading = raw.search(/\\S/);\n if (leading < 0) {\n return undefined;\n }\n const trailing = raw.match(/\\s*$/)?.[0].length ?? 0;\n const pos = clauseStart + range.start + leading;\n const end = clauseStart + range.end - trailing;\n const lookupNode: CorsaNode = {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n const nameNode = implementedClauseNameNode(lookupNode, raw);\n const symbol =\n checker.getSymbolAtLocation(nameNode) ?? checker.getSymbolAtLocation(lookupNode);\n const type = symbol\n ? (checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol))\n : (checker.getTypeAtLocation(nameNode) ?? checker.getTypeAtLocation(lookupNode));\n if (type) {\n try {\n checker.typeToString(type);\n } catch {\n // Corsa-side relation fallbacks handle stale type handles; avoid\n // deriving replacement text from source names in the JS bridge.\n }\n }\n return type;\n })\n .filter((type): type is CorsaType => type !== undefined);\n}\n\nfunction implementedClauseNameNode(node: CorsaNode, raw: string): CorsaNode {\n const range = lastTypeNameIdentifierRange(raw);\n if (!range) {\n return node;\n }\n const pos = node.pos + range.start;\n const end = node.pos + range.end;\n return {\n fileName: node.fileName,\n pos,\n end,\n range: [pos, end] as const,\n };\n}\n\nfunction lastTypeNameIdentifierRange(\n text: string,\n): { readonly start: number; readonly end: number } | undefined {\n let last: { start: number; end: number } | undefined;\n const scanner = createScanner();\n for (let index = 0; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = text[index];\n if (char === \"<\") {\n break;\n }\n if (!isIdentifierStart(char)) {\n continue;\n }\n let end = index + 1;\n while (isIdentifierPart(text[end])) {\n end += 1;\n }\n last = { start: index, end };\n index = end - 1;\n }\n return last;\n}\n\nfunction findClassBodyOpen(text: string, start: number): number {\n const scanner = createScanner();\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = start; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = text[index];\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (\n char === \"{\" &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n return index;\n } else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n }\n return -1;\n}\n\nfunction findKeywordOutsideTrivia(text: string, keyword: string): number {\n const scanner = createScanner();\n for (let index = 0; index < text.length; index += 1) {\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (matchesKeyword(text, keyword, index)) {\n return index;\n }\n }\n return -1;\n}\n\nfunction matchesKeyword(text: string, keyword: string, index: number): boolean {\n return (\n text.startsWith(keyword, index) &&\n !isIdentifierPart(text[index - 1]) &&\n !isIdentifierPart(text[index + keyword.length])\n );\n}\n\nfunction isIdentifierPart(char: string | undefined): boolean {\n return char !== undefined && (isIdentifierStart(char) || /[0-9]/.test(char));\n}\n\nfunction isIdentifierStart(char: string | undefined): boolean {\n return char !== undefined && /[A-Za-z_$]/.test(char);\n}\n\nfunction splitTopLevelRanges(\n text: string,\n delimiter: string,\n): readonly { readonly start: number; readonly end: number }[] {\n const ranges: { start: number; end: number }[] = [];\n const scanner = createScanner();\n let start = 0;\n let angleDepth = 0;\n let parenDepth = 0;\n let bracketDepth = 0;\n let braceDepth = 0;\n for (let index = 0; index < text.length; index += 1) {\n const char = text[index];\n const nextIndex = scanner.skip(text, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (char === \"<\") angleDepth += 1;\n else if (char === \">\") angleDepth = Math.max(0, angleDepth - 1);\n else if (char === \"(\") parenDepth += 1;\n else if (char === \")\") parenDepth = Math.max(0, parenDepth - 1);\n else if (char === \"[\") bracketDepth += 1;\n else if (char === \"]\") bracketDepth = Math.max(0, bracketDepth - 1);\n else if (char === \"{\") braceDepth += 1;\n else if (char === \"}\") braceDepth = Math.max(0, braceDepth - 1);\n else if (\n char === delimiter &&\n angleDepth === 0 &&\n parenDepth === 0 &&\n bracketDepth === 0 &&\n braceDepth === 0\n ) {\n ranges.push({ start, end: index });\n start = index + 1;\n }\n }\n ranges.push({ start, end: text.length });\n return ranges;\n}\n\nfunction createScanner(): {\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 isNode(value: unknown): value is Node {\n return typeof value === \"object\" && value !== null && \"type\" in value && \"range\" in value;\n}\n\nfunction filenameFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string {\n if (\"fileName\" in node) {\n return node.fileName;\n }\n return context.filename;\n}\n"],"mappings":";;;;AAgCA,MAAM,kDAAkC,IAAI,QAG1C;AAEF,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,OAEvB;EACP,qBAAqB;GACnB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,mBAAmB;EAC/D;EACA,sBAAsB;GACpB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ;EAC5C;EACA,mBAAmB;GACjB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,iBAAiB;EAC7D;EACA,cAAc,WAAW,QAAQ,UAAU;GACzC,OAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;GAAK;EACnD;EACA,iBAAiB;GACf,OAAO,kBAAkB,OAAO;EAClC;CACF;AACF;AAEA,SAAgB,kBAAkB,SAA0D;CAC1F,OAAO;EACL,kBAAkB,MAAM;GACtB,IAAK,KAAoC,SAAS,iBAChD,OAAO,oBAAoB,MAAc,IAAI;GAE/C,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,qBAC9C,YAAY,SAAS,UAAU,GAC/B,WAAW,UAAU,GACrB,YAAY,UAAU,GACtB,cAAc,SAAS,UAAU,GACjC,SAAS,UAAU,CACrB;GACA,mCAAmC,SAAS,MAAM,MAAM,IAAI;GAC5D,OAAO;EACT;EACA,kBAAkB,MAAM;GACtB,OAAO,KAAK,kBAAkB,IAAI;EACpC;EACA,oBAAoB,MAAM;GACxB,MAAM,aAAa,kBAAkB,IAAI;GACzC,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,oBACxC,YAAY,SAAS,UAAU,GAC/B,WAAW,UAAU,GACrB,cAAc,SAAS,UAAU,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;GACjB,IAAI,SAAS,QAAQ,SAAS,MAC5B,gBAAgB;GAElB,OAAO,QAAQ;EACjB;EACA,IAAI,gBAAgB;GAClB,IAAI,SAAS,OAAO,SAAS,KAAK;IAChC,iBAAiB;IACjB,OAAO,QAAQ;GACjB;GACA,OAAO,QAAQ;EACjB;EACA,IAAI,OAAO;GACT,IAAI,SACF,UAAU;QACL,IAAI,SAAS,MAClB,UAAU;QACL,IAAI,SAAS,OAClB,QAAQ,KAAA;GAEV,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,OAAO,SAAS,KAAK;GAChC,gBAAgB;GAChB,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,OAAO,SAAS,KAAK;GAChC,iBAAiB;GACjB,OAAO,QAAQ;EACjB;EACA,IAAI,SAAS,QAAO,SAAS,OAAO,SAAS,KAAK;GAChD,QAAQ;GACR,OAAO,QAAQ;EACjB;EACA,OAAO;CACT,EACF;AACF;AAEA,SAAS,OAAO,OAA+B;CAC7C,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,WAAW;AACtF;AAEA,SAAS,YACP,SACA,MACQ;CACR,IAAI,cAAc,MAChB,OAAO,KAAK;CAEd,OAAO,QAAQ;AACjB"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ast_utils_d_exports } from "./ast_utils.js";
2
- import { ContextWithParserOptions, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaStylisticSettings, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, ParserServices, ParserServicesWithTypeInformation, ProjectServiceOptions, SignatureKind, TypeAwareParserOptions } from "./types.js";
2
+ import { ContextWithParserOptions, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, ParserServices, ParserServicesWithTypeInformation, ProjectServiceOptions, SignatureKind, TypeAwareParserOptions } from "./types.js";
3
3
  import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from "./compat.js";
4
4
  import { json_schema_d_exports } from "./json_schema.js";
5
5
  import { oxlintCompat, oxlint_compat_d_exports } from "./oxlint_compat.js";
@@ -11,7 +11,6 @@ import { ESLintUtils, OxlintUtils, RuleCreator } from "./oxlint_utils.js";
11
11
  import { RuleTester, RuleTesterConfig } from "./rule_tester.js";
12
12
  import { TSESLint } from "./ts_eslint.js";
13
13
  import { index_d_exports } from "./rules/index.js";
14
- import { stylistic_d_exports } from "./stylistic.js";
15
14
  import { ESTree as ESTree$1 } from "@oxlint/plugins";
16
15
  //#region src/bindings/nodejs/corsa_oxlint/ts/index.d.ts
17
16
  type CorsaAstNodeType = keyof typeof AST_NODE_TYPES;
@@ -230,5 +229,5 @@ declare namespace ESTree {
230
229
  export {};
231
230
  }
232
231
  //#endregion
233
- export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaOxlintSettings, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaStylisticSettings, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, ESTree, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type Plugin, type ProjectServiceOptions, type Rule, type RuleContext, RuleCreator, type RuleDefinition, type RuleDiagnostic, type RuleDocs, type RuleMetaWithMessages, RuleTester, type RuleTesterConfig, SignatureKind, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules, stylistic_d_exports as stylistic };
232
+ export { ast_utils_d_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, type ContextWithParserOptions, type CorsaNode, type CorsaOxlintSettings, type CorsaProgramShape, type CorsaRuntimeOptions, type CorsaSignature, type CorsaSymbol, type CorsaType, type CorsaTypeCheckerShape, ESLintUtils, ESTree, json_schema_d_exports as JSONSchema, oxlint_compat_d_exports as OxlintCompat, OxlintUtils, type ParserServices, type ParserServicesWithTypeInformation, type Plugin, type ProjectServiceOptions, type Rule, type RuleContext, RuleCreator, type RuleDefinition, type RuleDiagnostic, type RuleDocs, type RuleMetaWithMessages, RuleTester, type RuleTesterConfig, SignatureKind, TSESLint, TSESTree, ts_utils_d_exports as TSUtils, type TypeAwareParserOptions, utils_d_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, index_d_exports as rules };
234
233
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -11,5 +11,4 @@ import { ESLintUtils, OxlintUtils, RuleCreator } from "./oxlint_utils.js";
11
11
  import { RuleTester } from "./rule_tester.js";
12
12
  import { TSESLint } from "./ts_eslint.js";
13
13
  import { rules_exports } from "./rules/index.js";
14
- import { stylistic_exports } from "./stylistic.js";
15
- export { ast_utils_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, ESLintUtils, json_schema_exports as JSONSchema, oxlint_compat_exports as OxlintCompat, OxlintUtils, RuleCreator, RuleTester, SignatureKind, TSESLint, TSESTree, ts_utils_exports as TSUtils, utils_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, rules_exports as rules, stylistic_exports as stylistic };
14
+ export { ast_utils_exports as ASTUtils, AST_NODE_TYPES, AST_TOKEN_TYPES, ESLintUtils, json_schema_exports as JSONSchema, oxlint_compat_exports as OxlintCompat, OxlintUtils, RuleCreator, RuleTester, SignatureKind, TSESLint, TSESTree, ts_utils_exports as TSUtils, utils_exports as Utils, compatPlugin, definePlugin, defineRule, getParserServices, oxlintCompat, rules_exports as rules };
package/dist/session.js CHANGED
@@ -241,15 +241,26 @@ var CorsaProjectSession = class {
241
241
  if (position === void 0 || position === lookup.position) return;
242
242
  const typeSymbol = this.getSymbolAtPosition(lookup.fileName, position, lookup.sourceText);
243
243
  if (!isUsableSymbol(typeSymbol) || typeSymbol.name !== typeSymbolName) return;
244
- const classStart = classDeclarationStartAtIdentifier(sourceText, position);
244
+ const uniqueDeclaration = uniqueClassDeclarationPosition(sourceText, typeSymbolName);
245
+ const classStart = classDeclarationStartAtIdentifier(sourceText, position) ?? uniqueDeclaration;
245
246
  if (classStart !== void 0) this.#classDeclarationByTypeId.set(type.id, {
246
247
  fileName: lookup.fileName,
247
248
  pos: classStart,
248
249
  end: sourceText.length,
249
250
  range: [classStart, sourceText.length]
250
251
  });
251
- const symbolSearchRange = containingNamespaceRange(sourceText, position) ?? qualifiedNamespaceRangeAtIdentifier(sourceText, position);
252
- if (symbolSearchRange) this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);
252
+ const symbolSearchRange = uniqueDeclaration === void 0 ? qualifiedNamespaceRangeAtIdentifier(sourceText, position) ?? containingNamespaceRange(sourceText, position) : containingNamespaceRange(sourceText, uniqueDeclaration);
253
+ if (symbolSearchRange) {
254
+ this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);
255
+ if (uniqueDeclaration !== void 0) this.#typeLookupById.set(type.id, {
256
+ ...lookup,
257
+ symbolSearchRange
258
+ });
259
+ } else if (uniqueDeclaration !== void 0) {
260
+ this.#symbolSearchRangeByTypeId.delete(type.id);
261
+ const { symbolSearchRange: _symbolSearchRange, ...unscopedLookup } = lookup;
262
+ this.#typeLookupById.set(type.id, unscopedLookup);
263
+ }
253
264
  return typeSymbol;
254
265
  }
255
266
  getSymbolOfTypeById(typeId) {
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#nodesById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#typeSourceById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#projects","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype SourceRange = {\n start: number;\n end: number;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\n symbolSearchRange?: SourceRange;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolsByTypeId = new Map<string, CorsaSymbol | null>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #baseTypesById = new Map<string, readonly CorsaType[]>();\n #implementedTypesById = new Map<string, readonly CorsaType[]>();\n #ownImplementedTypesById = new Map<string, readonly CorsaType[]>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #classDeclarationByTypeId = new Map<string, CorsaNode>();\n #symbolSearchRangeByTypeId = new Map<string, SourceRange>();\n #sourceLengthByPath = new Map<string, number>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position, sourceText });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position: start, sourceText });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), \"looking up a symbol\");\n }\n\n private getSymbolUnchecked(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.getSymbolOfTypeById(typeId);\n return resolved?.id === symbol ? resolved : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolOfTypeUnchecked(type),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolOfTypeUnchecked(type: CorsaType): CorsaSymbol | undefined {\n const cached = this.#symbolsByTypeId.get(type.id);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (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 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 classStart = classDeclarationStartAtIdentifier(sourceText, position);\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 containingNamespaceRange(sourceText, position) ??\n qualifiedNamespaceRangeAtIdentifier(sourceText, position);\n if (symbolSearchRange) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\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(this.#snapshot, typeId) 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 getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n }\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 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.#classDeclarationByTypeId.clear();\n this.#symbolSearchRangeByTypeId.clear();\n this.#sourceLengthByPath.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceLengthForPath(path: string): number | undefined {\n const cached = this.#sourceLengthByPath.get(path);\n if (cached !== undefined) {\n return cached;\n }\n const length = this.sourceTextForPath(path)?.length;\n if (length !== undefined) {\n this.#sourceLengthByPath.set(path, length);\n }\n return length;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n if (!node) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n const direct = this.#files.get(path);\n if (direct) {\n return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);\n }\n for (const [fileName, cached] of this.#files) {\n if (pathsReferToSameFile(fileName, path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction isSyntheticTypeHandle(handle: string): boolean {\n return handle.startsWith(\"synthetic-\");\n}\n\nfunction typeSymbolNameFromTexts(texts: readonly string[]): string | undefined {\n for (const text of texts) {\n const match =\n /^(?:typeof\\s+)?(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)(?:\\s*<|$)/u.exec(\n text.trim(),\n );\n if (match?.[1]) {\n return match[1];\n }\n }\n return undefined;\n}\n\n/**\n * Collects the qualified spellings of `typeSymbolName` (such as `Second.Base`)\n * carried by a type's rendered texts. These keep the container context that\n * `typeSymbolNameFromTexts` drops.\n */\nfunction qualifiedTypeNamesFromTexts(\n texts: readonly string[],\n typeSymbolName: string,\n): readonly string[] {\n const qualifiedNames: string[] = [];\n for (const text of texts) {\n const rendered = text.trim().replace(/^typeof\\s+/u, \"\");\n const typeArgumentStart = rendered.indexOf(\"<\");\n const withoutTypeArguments =\n typeArgumentStart < 0 ? rendered : rendered.slice(0, typeArgumentStart);\n const name = withoutTypeArguments.trimEnd();\n if (name.endsWith(`.${typeSymbolName}`) && !qualifiedNames.includes(name)) {\n qualifiedNames.push(name);\n }\n }\n return qualifiedNames;\n}\n\n/**\n * Identifies a symbol by its declaration handle, which encodes a source range\n * and therefore stays comparable across separate lookups, unlike the opaque\n * symbol handle.\n */\nfunction symbolDeclarationKey(symbol: CorsaSymbol): string {\n return symbol.valueDeclaration ?? symbol.declarations[0] ?? symbol.id;\n}\n\nfunction classDeclarationStartAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): number | undefined {\n const prefixStart = Math.max(0, identifierPosition - 128);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /\\bclass\\s*$/u.exec(prefix);\n return match ? prefixStart + match.index : undefined;\n}\n\nfunction uniqueClassDeclarationPosition(sourceText: string, className: string): number | undefined {\n const escapedName = className.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\bclass\\\\s+${escapedName}\\\\b`, \"gu\");\n const declaration = declarationPattern.exec(sourceText);\n if (!declaration || declarationPattern.exec(sourceText)) {\n return undefined;\n }\n return declaration.index;\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 const third = Number(thirdText);\n if (!Number.isFinite(pos) || !Number.isFinite(second)) {\n return undefined;\n }\n const hasEndPosition = Number.isFinite(third);\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 return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction isMissingTypeHandleError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"not found in snapshot registry\") || message.includes(\"empty type handle\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AA8CA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,IAAa,sBAAb,MAAiC;CAyBpB;CACA;CAzBX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;CACxC,iCAAiB,IAAI,IAAkC;CACvD,wCAAwB,IAAI,IAAkC;CAC9D,2CAA2B,IAAI,IAAkC;CACjE,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,4CAA4B,IAAI,IAAuB;CACvD,6CAA6B,IAAI,IAAyB;CAC1D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AM,iBAAiB,OAAO,SAAS,KAAK;CAC5C,MAAM,YAAY,iBAAiB,iBAAiB,CAAC,WAAW,GAAG,cAAc,EAAA,CAAG,KAAK,GAAG;CAC5F,IAAI,CAAC,UACH;CAEF,MAAM,MAAM,iBAAiB,SAAU,oBAAoB,QAAQ,KAAK,MAAM;CAC9E,IAAI,MAAM,KACR;CAEF,OAAO;EAAE,IAAI;EAAO;EAAU;EAAK;EAAK,OAAO,CAAC,KAAK,GAAG;CAAE;AAC5D;AAEA,SAAS,4BAA4B,OAAyB;CAC5D,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,aAAa,KAC9B,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,yBAAyB,OAAyB;CACzD,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,gCAAgC,KAAK,QAAQ,SAAS,mBAAmB;AAE9F;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
1
+ {"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#nodesById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#typeSourceById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#projects","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype SourceRange = {\n start: number;\n end: number;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\n symbolSearchRange?: SourceRange;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolsByTypeId = new Map<string, CorsaSymbol | null>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #baseTypesById = new Map<string, readonly CorsaType[]>();\n #implementedTypesById = new Map<string, readonly CorsaType[]>();\n #ownImplementedTypesById = new Map<string, readonly CorsaType[]>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #classDeclarationByTypeId = new Map<string, CorsaNode>();\n #symbolSearchRangeByTypeId = new Map<string, SourceRange>();\n #sourceLengthByPath = new Map<string, number>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position, sourceText });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, { fileName, position: start, sourceText });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), \"looking up a symbol\");\n }\n\n private getSymbolUnchecked(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.getSymbolOfTypeById(typeId);\n return resolved?.id === symbol ? resolved : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolOfTypeUnchecked(type),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolOfTypeUnchecked(type: CorsaType): CorsaSymbol | undefined {\n const cached = this.#symbolsByTypeId.get(type.id);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (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 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(this.#snapshot, typeId) 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 getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n }\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 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.#classDeclarationByTypeId.clear();\n this.#symbolSearchRangeByTypeId.clear();\n this.#sourceLengthByPath.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceLengthForPath(path: string): number | undefined {\n const cached = this.#sourceLengthByPath.get(path);\n if (cached !== undefined) {\n return cached;\n }\n const length = this.sourceTextForPath(path)?.length;\n if (length !== undefined) {\n this.#sourceLengthByPath.set(path, length);\n }\n return length;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n if (!node) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n const direct = this.#files.get(path);\n if (direct) {\n return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);\n }\n for (const [fileName, cached] of this.#files) {\n if (pathsReferToSameFile(fileName, path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction isSyntheticTypeHandle(handle: string): boolean {\n return handle.startsWith(\"synthetic-\");\n}\n\nfunction typeSymbolNameFromTexts(texts: readonly string[]): string | undefined {\n for (const text of texts) {\n const match =\n /^(?:typeof\\s+)?(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)(?:\\s*<|$)/u.exec(\n text.trim(),\n );\n if (match?.[1]) {\n return match[1];\n }\n }\n return undefined;\n}\n\n/**\n * Collects the qualified spellings of `typeSymbolName` (such as `Second.Base`)\n * carried by a type's rendered texts. These keep the container context that\n * `typeSymbolNameFromTexts` drops.\n */\nfunction qualifiedTypeNamesFromTexts(\n texts: readonly string[],\n typeSymbolName: string,\n): readonly string[] {\n const qualifiedNames: string[] = [];\n for (const text of texts) {\n const rendered = text.trim().replace(/^typeof\\s+/u, \"\");\n const typeArgumentStart = rendered.indexOf(\"<\");\n const withoutTypeArguments =\n typeArgumentStart < 0 ? rendered : rendered.slice(0, typeArgumentStart);\n const name = withoutTypeArguments.trimEnd();\n if (name.endsWith(`.${typeSymbolName}`) && !qualifiedNames.includes(name)) {\n qualifiedNames.push(name);\n }\n }\n return qualifiedNames;\n}\n\n/**\n * Identifies a symbol by its declaration handle, which encodes a source range\n * and therefore stays comparable across separate lookups, unlike the opaque\n * symbol handle.\n */\nfunction symbolDeclarationKey(symbol: CorsaSymbol): string {\n return symbol.valueDeclaration ?? symbol.declarations[0] ?? symbol.id;\n}\n\nfunction classDeclarationStartAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): number | undefined {\n const prefixStart = Math.max(0, identifierPosition - 128);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /\\bclass\\s*$/u.exec(prefix);\n return match ? prefixStart + match.index : undefined;\n}\n\nfunction uniqueClassDeclarationPosition(sourceText: string, className: string): number | undefined {\n const escapedName = className.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\bclass\\\\s+${escapedName}\\\\b`, \"gu\");\n const declaration = declarationPattern.exec(sourceText);\n if (!declaration || declarationPattern.exec(sourceText)) {\n return undefined;\n }\n return declaration.index;\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 const third = Number(thirdText);\n if (!Number.isFinite(pos) || !Number.isFinite(second)) {\n return undefined;\n }\n const hasEndPosition = Number.isFinite(third);\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 return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction isMissingTypeHandleError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"not found in snapshot registry\") || message.includes(\"empty type handle\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AA8CA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,IAAa,sBAAb,MAAiC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,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,yBAAyB,OAAyB;CACzD,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,gCAAgC,KAAK,QAAQ,SAAS,mBAAmB;AAE9F;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
package/dist/types.d.ts CHANGED
@@ -24,9 +24,6 @@ interface TypeAwareParserOptions {
24
24
  interface CorsaOxlintSettings extends TypeAwareParserOptions {
25
25
  parserOptions?: TypeAwareParserOptions;
26
26
  }
27
- interface CorsaStylisticSettings {
28
- rules?: Record<string, readonly unknown[]>;
29
- }
30
27
  interface ResolvedRuntimeOptions {
31
28
  executable: string;
32
29
  cwd: string;
@@ -162,7 +159,6 @@ type ContextWithParserOptions = Context & {
162
159
  };
163
160
  readonly settings?: {
164
161
  readonly corsaOxlint?: CorsaOxlintSettings;
165
- readonly corsaStylistic?: CorsaStylisticSettings;
166
162
  readonly [key: string]: unknown;
167
163
  };
168
164
  readonly parserServices?: ParserServices;
@@ -173,5 +169,5 @@ interface SessionProjectState {
173
169
  readonly snapshot: string;
174
170
  }
175
171
  //#endregion
176
- export { ContextWithParserOptions, CorsaCallSignatureFacts, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaStylisticSettings, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, CorsaTypePredicate, ParserServices, ParserServicesWithTypeInformation, type ProjectResponse, ProjectServiceOptions, ResolvedProjectConfig, ResolvedRuntimeOptions, SessionProjectState, SignatureKind, TypeAwareParserOptions };
172
+ export { ContextWithParserOptions, CorsaCallSignatureFacts, CorsaNode, CorsaOxlintSettings, CorsaProgramShape, CorsaRuntimeOptions, CorsaSignature, CorsaSymbol, CorsaType, CorsaTypeCheckerShape, CorsaTypePredicate, ParserServices, ParserServicesWithTypeInformation, type ProjectResponse, ProjectServiceOptions, ResolvedProjectConfig, ResolvedRuntimeOptions, SessionProjectState, SignatureKind, TypeAwareParserOptions };
177
173
  //# 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 { ApiMode, ConfigResponse, ProjectResponse, TypeResponse } from \"@corsa-bind/napi\";\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 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 CorsaStylisticSettings {\n rules?: Record<string, readonly unknown[]>;\n}\n\nexport interface ResolvedRuntimeOptions {\n executable: string;\n cwd: string;\n mode: ApiMode;\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\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\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 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 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 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 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 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 corsaStylistic?: CorsaStylisticSettings;\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":";AAsFA,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 { ApiMode, ConfigResponse, ProjectResponse, TypeResponse } from \"@corsa-bind/napi\";\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 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 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\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\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 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 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 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 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 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":";AAkFA,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": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Type-aware Oxlint helpers powered by Corsa",
5
5
  "homepage": "https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint",
6
6
  "bugs": {
@@ -68,12 +68,6 @@
68
68
  "bun": "./dist/rules/index.js",
69
69
  "import": "./dist/rules/index.js"
70
70
  },
71
- "./stylistic": {
72
- "types": "./dist/stylistic.d.ts",
73
- "deno": "./dist/stylistic.js",
74
- "bun": "./dist/stylistic.js",
75
- "import": "./dist/stylistic.js"
76
- },
77
71
  "./compat": {
78
72
  "types": "./dist/oxlint_compat.d.ts",
79
73
  "deno": "./dist/oxlint_compat.js",
@@ -101,7 +95,7 @@
101
95
  "./package.json": "./package.json"
102
96
  },
103
97
  "dependencies": {
104
- "@corsa-bind/napi": "1.2.0"
98
+ "@corsa-bind/napi": "1.4.0"
105
99
  },
106
100
  "devDependencies": {
107
101
  "@oxlint/plugins": "1.76.0",
@@ -1,35 +0,0 @@
1
- import { Plugin, Rule } from "./plugin.js";
2
- declare namespace stylistic_d_exports {
3
- export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticRules, corsaStylisticPlugin as default, implementedStylisticRuleNames };
4
- }
5
- type CorsaStylisticRuleName = "eol-last" | "linebreak-style" | "no-multiple-empty-lines" | "no-tabs" | "no-trailing-spaces" | "quotes" | "unicode-bom" | "arrow-spacing" | "comma-spacing" | "semi-spacing" | "space-in-parens" | "template-curly-spacing" | "rest-spread-spacing" | "no-multi-spaces" | "no-whitespace-before-property" | "dot-location" | "spaced-comment" | "object-curly-spacing" | "array-bracket-spacing" | "computed-property-spacing" | "block-spacing" | "space-before-blocks" | "function-call-spacing" | "space-before-function-paren" | "no-floating-decimal" | "template-tag-spacing" | "yield-star-spacing" | "generator-star-spacing" | "comma-dangle" | "space-infix-ops" | "max-len" | "semi-style" | "comma-style" | "arrow-parens" | "switch-colon-spacing" | "no-extra-semi" | "new-parens" | "space-unary-ops" | "wrap-regex" | "implicit-arrow-linebreak" | "operator-linebreak" | "keyword-spacing";
6
- type CorsaStylisticRuleOptions = readonly unknown[];
7
- interface CorsaStylisticSettings {
8
- /**
9
- * Rule options used by the native batch runner.
10
- *
11
- * Keep this in sync with enabled Oxlint rules when several stylistic rules
12
- * are active; the JS bridge can then perform one native scan and share the
13
- * diagnostics across individual rule reports.
14
- */
15
- readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;
16
- }
17
- /**
18
- * Native stylistic rule names exported by `corsa-oxlint/stylistic`.
19
- */
20
- declare const implementedStylisticRuleNames: readonly ["eol-last", "linebreak-style", "no-multiple-empty-lines", "no-tabs", "no-trailing-spaces", "quotes", "unicode-bom", "arrow-spacing", "comma-spacing", "semi-spacing", "space-in-parens", "template-curly-spacing", "rest-spread-spacing", "no-multi-spaces", "no-whitespace-before-property", "dot-location", "spaced-comment", "object-curly-spacing", "array-bracket-spacing", "computed-property-spacing", "block-spacing", "space-before-blocks", "function-call-spacing", "space-before-function-paren", "no-floating-decimal", "template-tag-spacing", "yield-star-spacing", "generator-star-spacing", "comma-dangle", "space-infix-ops", "max-len", "semi-style", "comma-style", "arrow-parens", "switch-colon-spacing", "no-extra-semi", "new-parens", "space-unary-ops", "wrap-regex", "implicit-arrow-linebreak", "operator-linebreak", "keyword-spacing"];
21
- /**
22
- * Oxlint-compatible stylistic rules backed by the Rust source scanner.
23
- */
24
- declare const corsaStylisticRules: Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;
25
- /**
26
- * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.
27
- *
28
- * Register it under any namespace, then enable rules such as
29
- * `stylistic/quotes` or `stylistic/no-trailing-spaces`.
30
- */
31
- declare const corsaStylisticPlugin: Plugin;
32
- declare function createStylisticRule(ruleName: CorsaStylisticRuleName): Rule;
33
- //#endregion
34
- export { CorsaStylisticRuleName, CorsaStylisticRuleOptions, CorsaStylisticSettings, corsaStylisticPlugin, corsaStylisticPlugin as default, corsaStylisticRules, implementedStylisticRuleNames, stylistic_d_exports };
35
- //# sourceMappingURL=stylistic.d.ts.map
package/dist/stylistic.js DELETED
@@ -1,248 +0,0 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { definePlugin, defineRule } from "./plugin.js";
3
- import { nativeStylisticRuleMetas, runNativeStylisticLint } from "@corsa-bind/napi";
4
- //#region src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts
5
- var stylistic_exports = /* @__PURE__ */ __exportAll({
6
- corsaStylisticPlugin: () => corsaStylisticPlugin,
7
- corsaStylisticRules: () => corsaStylisticRules,
8
- default: () => corsaStylisticPlugin,
9
- implementedStylisticRuleNames: () => implementedStylisticRuleNames
10
- });
11
- const stylisticMetas = nativeStylisticRuleMetas();
12
- const stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));
13
- const diagnosticsCache = /* @__PURE__ */ new WeakMap();
14
- /**
15
- * Native stylistic rule names exported by `corsa-oxlint/stylistic`.
16
- */
17
- const implementedStylisticRuleNames = [
18
- "eol-last",
19
- "linebreak-style",
20
- "no-multiple-empty-lines",
21
- "no-tabs",
22
- "no-trailing-spaces",
23
- "quotes",
24
- "unicode-bom",
25
- "arrow-spacing",
26
- "comma-spacing",
27
- "semi-spacing",
28
- "space-in-parens",
29
- "template-curly-spacing",
30
- "rest-spread-spacing",
31
- "no-multi-spaces",
32
- "no-whitespace-before-property",
33
- "dot-location",
34
- "spaced-comment",
35
- "object-curly-spacing",
36
- "array-bracket-spacing",
37
- "computed-property-spacing",
38
- "block-spacing",
39
- "space-before-blocks",
40
- "function-call-spacing",
41
- "space-before-function-paren",
42
- "no-floating-decimal",
43
- "template-tag-spacing",
44
- "yield-star-spacing",
45
- "generator-star-spacing",
46
- "comma-dangle",
47
- "space-infix-ops",
48
- "max-len",
49
- "semi-style",
50
- "comma-style",
51
- "arrow-parens",
52
- "switch-colon-spacing",
53
- "no-extra-semi",
54
- "new-parens",
55
- "space-unary-ops",
56
- "wrap-regex",
57
- "implicit-arrow-linebreak",
58
- "operator-linebreak",
59
- "keyword-spacing"
60
- ];
61
- /**
62
- * Oxlint-compatible stylistic rules backed by the Rust source scanner.
63
- */
64
- const corsaStylisticRules = Object.freeze(Object.fromEntries(implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)])));
65
- /**
66
- * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.
67
- *
68
- * Register it under any namespace, then enable rules such as
69
- * `stylistic/quotes` or `stylistic/no-trailing-spaces`.
70
- */
71
- const corsaStylisticPlugin = definePlugin({
72
- meta: { name: "oxlint-plugin-corsa-stylistic" },
73
- rules: corsaStylisticRules
74
- });
75
- function createStylisticRule(ruleName) {
76
- const meta = stylisticRuleMeta(ruleName);
77
- return defineRule({
78
- defaultOptions: [],
79
- meta: {
80
- type: "layout",
81
- docs: {
82
- description: meta.docsDescription,
83
- requiresTypeChecking: false,
84
- url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`
85
- },
86
- fixable: "whitespace",
87
- hasSuggestions: meta.hasSuggestions,
88
- messages: meta.messages,
89
- schema: { type: "array" }
90
- },
91
- create(context) {
92
- return { Program(node) {
93
- reportStylisticDiagnostics(context, node, diagnosticsForRule(context, ruleName).filter((diagnostic) => diagnostic.ruleName === ruleName));
94
- } };
95
- }
96
- });
97
- }
98
- function diagnosticsForRule(context, ruleName) {
99
- const sourceCode = context.sourceCode;
100
- const sourceText = sourceTextForContext(context);
101
- const config = stylisticRunConfig(context, ruleName);
102
- const key = JSON.stringify(config);
103
- let sourceCache = diagnosticsCache.get(sourceCode);
104
- if (!sourceCache) {
105
- sourceCache = /* @__PURE__ */ new Map();
106
- diagnosticsCache.set(sourceCode, sourceCache);
107
- }
108
- const cached = sourceCache.get(key);
109
- if (cached?.sourceText === sourceText) return cached.diagnostics;
110
- const diagnostics = mapNativeDiagnosticRanges(runNativeStylisticLint(sourceText, { rules: config }), sourceText);
111
- sourceCache.set(key, {
112
- sourceText,
113
- diagnostics
114
- });
115
- return diagnostics;
116
- }
117
- function stylisticRunConfig(context, currentRuleName) {
118
- const settingsRules = context.settings?.corsaStylistic?.rules;
119
- const rules = /* @__PURE__ */ new Map();
120
- if (settingsRules) for (const [name, options] of Object.entries(settingsRules)) {
121
- assertKnownStylisticRuleName(name);
122
- rules.set(name, normalizeOptions(options));
123
- }
124
- const currentOptions = currentRuleOptions(context);
125
- if (!rules.has(currentRuleName) || currentOptions.length > 0) rules.set(currentRuleName, currentOptions);
126
- return implementedStylisticRuleNames.filter((ruleName) => rules.has(ruleName)).map((ruleName) => ({
127
- name: ruleName,
128
- options: rules.get(ruleName) ?? []
129
- }));
130
- }
131
- function reportStylisticDiagnostics(context, program, diagnostics) {
132
- for (const diagnostic of diagnostics) context.report({
133
- node: rangeNode(program, diagnostic.range),
134
- messageId: diagnostic.messageId,
135
- ...diagnostic.suggestions?.length ? { suggest: diagnostic.suggestions.map((suggestion) => ({
136
- messageId: suggestion.messageId,
137
- fix: (fixer) => suggestion.fixes.map((fix) => fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText))
138
- })) } : {}
139
- });
140
- }
141
- function rangeNode(program, range) {
142
- return {
143
- ...program,
144
- range: oxlintRange(range)
145
- };
146
- }
147
- function oxlintRange(range) {
148
- return [range.start, range.end];
149
- }
150
- function mapNativeDiagnosticRanges(diagnostics, sourceText) {
151
- const byteToUtf16 = createByteToUtf16Mapper(sourceText);
152
- return diagnostics.map((diagnostic) => ({
153
- ...diagnostic,
154
- range: mapNativeRange(diagnostic.range, byteToUtf16),
155
- ...diagnostic.suggestions?.length ? { suggestions: diagnostic.suggestions.map((suggestion) => mapNativeSuggestion(suggestion, byteToUtf16)) } : {}
156
- }));
157
- }
158
- function mapNativeSuggestion(suggestion, byteToUtf16) {
159
- return {
160
- ...suggestion,
161
- fixes: suggestion.fixes.map((fix) => mapNativeFix(fix, byteToUtf16))
162
- };
163
- }
164
- function mapNativeFix(fix, byteToUtf16) {
165
- return {
166
- ...fix,
167
- range: mapNativeRange(fix.range, byteToUtf16)
168
- };
169
- }
170
- function mapNativeRange(range, byteToUtf16) {
171
- return {
172
- start: byteToUtf16(range.start),
173
- end: byteToUtf16(range.end)
174
- };
175
- }
176
- function createByteToUtf16Mapper(sourceText) {
177
- const nonAsciiSpans = [];
178
- let byteOffset = 0;
179
- let utf16Offset = 0;
180
- while (utf16Offset < sourceText.length) {
181
- const codePoint = sourceText.codePointAt(utf16Offset);
182
- if (codePoint === void 0) break;
183
- const utf16Length = codePoint > 65535 ? 2 : 1;
184
- const byteLength = utf8ByteLength(codePoint);
185
- const byteEnd = byteOffset + byteLength;
186
- const utf16End = utf16Offset + utf16Length;
187
- if (byteLength !== utf16Length) nonAsciiSpans.push({
188
- byteStart: byteOffset,
189
- byteEnd,
190
- utf16Start: utf16Offset,
191
- deltaAfter: byteEnd - utf16End
192
- });
193
- byteOffset = byteEnd;
194
- utf16Offset = utf16End;
195
- }
196
- if (nonAsciiSpans.length === 0) return (offset) => clampOffset(offset, sourceText.length);
197
- const totalBytes = byteOffset;
198
- return (offset) => {
199
- const byteOffset = clampOffset(offset, totalBytes);
200
- let low = 0;
201
- let high = nonAsciiSpans.length;
202
- while (low < high) {
203
- const mid = Math.floor((low + high) / 2);
204
- if (nonAsciiSpans[mid].byteEnd <= byteOffset) low = mid + 1;
205
- else high = mid;
206
- }
207
- const nextSpan = nonAsciiSpans[low];
208
- if (nextSpan && byteOffset >= nextSpan.byteStart && byteOffset < nextSpan.byteEnd) return nextSpan.utf16Start;
209
- return clampOffset(byteOffset - (nonAsciiSpans[low - 1]?.deltaAfter ?? 0), sourceText.length);
210
- };
211
- }
212
- function utf8ByteLength(codePoint) {
213
- if (codePoint <= 127) return 1;
214
- if (codePoint <= 2047) return 2;
215
- if (codePoint <= 65535) return 3;
216
- return 4;
217
- }
218
- function clampOffset(offset, max) {
219
- if (!Number.isFinite(offset)) return 0;
220
- if (offset <= 0) return 0;
221
- if (offset >= max) return max;
222
- return Math.trunc(offset);
223
- }
224
- function sourceTextForContext(context) {
225
- const text = context.sourceCode.text;
226
- if (typeof text === "string") return text;
227
- return context.sourceCode.getText({ type: "Program" });
228
- }
229
- function currentRuleOptions(context) {
230
- return normalizeOptions(context.options);
231
- }
232
- function normalizeOptions(options) {
233
- if (Array.isArray(options)) return options;
234
- if (options == null) return [];
235
- return [options];
236
- }
237
- function assertKnownStylisticRuleName(name) {
238
- if (!implementedStylisticRuleNames.includes(name)) throw new Error(`unknown corsa stylistic rule: ${name}`);
239
- }
240
- function stylisticRuleMeta(ruleName) {
241
- const meta = stylisticMetasByName.get(ruleName);
242
- if (!meta) throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);
243
- return meta;
244
- }
245
- //#endregion
246
- export { corsaStylisticPlugin, corsaStylisticPlugin as default, corsaStylisticRules, implementedStylisticRuleNames, stylistic_exports };
247
-
248
- //# sourceMappingURL=stylistic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stylistic.js","names":[],"sources":["../ts/stylistic.ts"],"sourcesContent":["import {\n nativeStylisticRuleMetas,\n runNativeStylisticLint,\n type NativeLintDiagnostic,\n type NativeLintFix,\n type NativeLintRange,\n type NativeLintRuleMeta,\n type NativeLintSuggestion,\n type NativeStylisticRuleConfig,\n} from \"@corsa-bind/napi\";\n\nimport { definePlugin, defineRule } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\ntype ProgramNode = {\n readonly type: string;\n readonly range?: readonly [number, number];\n};\n\nexport type CorsaStylisticRuleName =\n | \"eol-last\"\n | \"linebreak-style\"\n | \"no-multiple-empty-lines\"\n | \"no-tabs\"\n | \"no-trailing-spaces\"\n | \"quotes\"\n | \"unicode-bom\"\n | \"arrow-spacing\"\n | \"comma-spacing\"\n | \"semi-spacing\"\n | \"space-in-parens\"\n | \"template-curly-spacing\"\n | \"rest-spread-spacing\"\n | \"no-multi-spaces\"\n | \"no-whitespace-before-property\"\n | \"dot-location\"\n | \"spaced-comment\"\n | \"object-curly-spacing\"\n | \"array-bracket-spacing\"\n | \"computed-property-spacing\"\n | \"block-spacing\"\n | \"space-before-blocks\"\n | \"function-call-spacing\"\n | \"space-before-function-paren\"\n | \"no-floating-decimal\"\n | \"template-tag-spacing\"\n | \"yield-star-spacing\"\n | \"generator-star-spacing\"\n | \"comma-dangle\"\n | \"space-infix-ops\"\n | \"max-len\"\n | \"semi-style\"\n | \"comma-style\"\n | \"arrow-parens\"\n | \"switch-colon-spacing\"\n | \"no-extra-semi\"\n | \"new-parens\"\n | \"space-unary-ops\"\n | \"wrap-regex\"\n | \"implicit-arrow-linebreak\"\n | \"operator-linebreak\"\n | \"keyword-spacing\";\n\nexport type CorsaStylisticRuleOptions = readonly unknown[];\n\nexport interface CorsaStylisticSettings {\n /**\n * Rule options used by the native batch runner.\n *\n * Keep this in sync with enabled Oxlint rules when several stylistic rules\n * are active; the JS bridge can then perform one native scan and share the\n * diagnostics across individual rule reports.\n */\n readonly rules?: Partial<Record<CorsaStylisticRuleName, CorsaStylisticRuleOptions>>;\n}\n\nconst stylisticMetas = nativeStylisticRuleMetas();\nconst stylisticMetasByName = new Map(stylisticMetas.map((meta) => [meta.name, meta]));\ntype CachedStylisticDiagnostics = {\n readonly sourceText: string;\n readonly diagnostics: readonly NativeLintDiagnostic[];\n};\n\ntype ByteToUtf16Mapper = (offset: number) => number;\n\ntype NonAsciiSpan = {\n readonly byteStart: number;\n readonly byteEnd: number;\n readonly utf16Start: number;\n readonly deltaAfter: number;\n};\n\nconst diagnosticsCache = new WeakMap<object, Map<string, CachedStylisticDiagnostics>>();\n\n/**\n * Native stylistic rule names exported by `corsa-oxlint/stylistic`.\n */\nexport const implementedStylisticRuleNames = [\n \"eol-last\",\n \"linebreak-style\",\n \"no-multiple-empty-lines\",\n \"no-tabs\",\n \"no-trailing-spaces\",\n \"quotes\",\n \"unicode-bom\",\n \"arrow-spacing\",\n \"comma-spacing\",\n \"semi-spacing\",\n \"space-in-parens\",\n \"template-curly-spacing\",\n \"rest-spread-spacing\",\n \"no-multi-spaces\",\n \"no-whitespace-before-property\",\n \"dot-location\",\n \"spaced-comment\",\n \"object-curly-spacing\",\n \"array-bracket-spacing\",\n \"computed-property-spacing\",\n \"block-spacing\",\n \"space-before-blocks\",\n \"function-call-spacing\",\n \"space-before-function-paren\",\n \"no-floating-decimal\",\n \"template-tag-spacing\",\n \"yield-star-spacing\",\n \"generator-star-spacing\",\n \"comma-dangle\",\n \"space-infix-ops\",\n \"max-len\",\n \"semi-style\",\n \"comma-style\",\n \"arrow-parens\",\n \"switch-colon-spacing\",\n \"no-extra-semi\",\n \"new-parens\",\n \"space-unary-ops\",\n \"wrap-regex\",\n \"implicit-arrow-linebreak\",\n \"operator-linebreak\",\n \"keyword-spacing\",\n] as const satisfies readonly CorsaStylisticRuleName[];\n\n/**\n * Oxlint-compatible stylistic rules backed by the Rust source scanner.\n */\nexport const corsaStylisticRules = Object.freeze(\n Object.fromEntries(\n implementedStylisticRuleNames.map((ruleName) => [ruleName, createStylisticRule(ruleName)]),\n ),\n) as Readonly<Record<CorsaStylisticRuleName, ReturnType<typeof createStylisticRule>>>;\n\n/**\n * Oxlint plugin exposing Corsa's Rust-backed stylistic rules.\n *\n * Register it under any namespace, then enable rules such as\n * `stylistic/quotes` or `stylistic/no-trailing-spaces`.\n */\nexport const corsaStylisticPlugin = definePlugin({\n meta: { name: \"oxlint-plugin-corsa-stylistic\" },\n rules: corsaStylisticRules,\n});\n\nexport default corsaStylisticPlugin;\n\nfunction createStylisticRule(ruleName: CorsaStylisticRuleName) {\n const meta = stylisticRuleMeta(ruleName);\n return defineRule({\n defaultOptions: [],\n meta: {\n type: \"layout\",\n docs: {\n description: meta.docsDescription,\n requiresTypeChecking: false,\n url: `https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint/ts/stylistic.ts`,\n },\n fixable: \"whitespace\",\n hasSuggestions: meta.hasSuggestions,\n messages: meta.messages,\n schema: { type: \"array\" },\n },\n create(context: ContextWithParserOptions) {\n return {\n Program(node: ProgramNode) {\n reportStylisticDiagnostics(\n context,\n node,\n diagnosticsForRule(context, ruleName).filter(\n (diagnostic) => diagnostic.ruleName === ruleName,\n ),\n );\n },\n };\n },\n });\n}\n\nfunction diagnosticsForRule(\n context: ContextWithParserOptions,\n ruleName: CorsaStylisticRuleName,\n): readonly NativeLintDiagnostic[] {\n const sourceCode = context.sourceCode as unknown as object;\n const sourceText = sourceTextForContext(context);\n const config = stylisticRunConfig(context, ruleName);\n const key = JSON.stringify(config);\n let sourceCache = diagnosticsCache.get(sourceCode);\n if (!sourceCache) {\n sourceCache = new Map();\n diagnosticsCache.set(sourceCode, sourceCache);\n }\n\n const cached = sourceCache.get(key);\n if (cached?.sourceText === sourceText) {\n return cached.diagnostics;\n }\n\n const diagnostics = mapNativeDiagnosticRanges(\n runNativeStylisticLint(sourceText, { rules: config }),\n sourceText,\n );\n sourceCache.set(key, { sourceText, diagnostics });\n return diagnostics;\n}\n\nfunction stylisticRunConfig(\n context: ContextWithParserOptions,\n currentRuleName: CorsaStylisticRuleName,\n): readonly NativeStylisticRuleConfig[] {\n const settingsRules = context.settings?.corsaStylistic?.rules;\n const rules = new Map<CorsaStylisticRuleName, CorsaStylisticRuleOptions>();\n\n if (settingsRules) {\n for (const [name, options] of Object.entries(settingsRules)) {\n assertKnownStylisticRuleName(name);\n rules.set(name, normalizeOptions(options));\n }\n }\n\n const currentOptions = currentRuleOptions(context);\n if (!rules.has(currentRuleName) || currentOptions.length > 0) {\n rules.set(currentRuleName, currentOptions);\n }\n\n return implementedStylisticRuleNames\n .filter((ruleName) => rules.has(ruleName))\n .map((ruleName) => ({\n name: ruleName,\n options: rules.get(ruleName) ?? [],\n }));\n}\n\nfunction reportStylisticDiagnostics(\n context: ContextWithParserOptions,\n program: ProgramNode,\n diagnostics: readonly NativeLintDiagnostic[],\n): void {\n for (const diagnostic of diagnostics) {\n context.report({\n node: rangeNode(program, diagnostic.range),\n messageId: diagnostic.messageId,\n ...(diagnostic.suggestions?.length\n ? {\n suggest: diagnostic.suggestions.map((suggestion) => ({\n messageId: suggestion.messageId,\n fix: (fixer: any) =>\n suggestion.fixes.map((fix) =>\n fixer.replaceTextRange(oxlintRange(fix.range), fix.replacementText),\n ),\n })),\n }\n : {}),\n } as never);\n }\n}\n\nfunction rangeNode(program: ProgramNode, range: NativeLintRange): ProgramNode {\n return {\n ...program,\n range: oxlintRange(range),\n };\n}\n\nfunction oxlintRange(range: NativeLintRange): [number, number] {\n return [range.start, range.end];\n}\n\nfunction mapNativeDiagnosticRanges(\n diagnostics: readonly NativeLintDiagnostic[],\n sourceText: string,\n): readonly NativeLintDiagnostic[] {\n const byteToUtf16 = createByteToUtf16Mapper(sourceText);\n return diagnostics.map((diagnostic) => ({\n ...diagnostic,\n range: mapNativeRange(diagnostic.range, byteToUtf16),\n ...(diagnostic.suggestions?.length\n ? {\n suggestions: diagnostic.suggestions.map((suggestion) =>\n mapNativeSuggestion(suggestion, byteToUtf16),\n ),\n }\n : {}),\n }));\n}\n\nfunction mapNativeSuggestion(\n suggestion: NativeLintSuggestion,\n byteToUtf16: ByteToUtf16Mapper,\n): NativeLintSuggestion {\n return {\n ...suggestion,\n fixes: suggestion.fixes.map((fix) => mapNativeFix(fix, byteToUtf16)),\n };\n}\n\nfunction mapNativeFix(fix: NativeLintFix, byteToUtf16: ByteToUtf16Mapper): NativeLintFix {\n return {\n ...fix,\n range: mapNativeRange(fix.range, byteToUtf16),\n };\n}\n\nfunction mapNativeRange(range: NativeLintRange, byteToUtf16: ByteToUtf16Mapper): NativeLintRange {\n return {\n start: byteToUtf16(range.start),\n end: byteToUtf16(range.end),\n };\n}\n\nfunction createByteToUtf16Mapper(sourceText: string): ByteToUtf16Mapper {\n const nonAsciiSpans: NonAsciiSpan[] = [];\n let byteOffset = 0;\n let utf16Offset = 0;\n\n while (utf16Offset < sourceText.length) {\n const codePoint = sourceText.codePointAt(utf16Offset);\n if (codePoint === undefined) {\n break;\n }\n const utf16Length = codePoint > 0xffff ? 2 : 1;\n const byteLength = utf8ByteLength(codePoint);\n const byteEnd = byteOffset + byteLength;\n const utf16End = utf16Offset + utf16Length;\n if (byteLength !== utf16Length) {\n nonAsciiSpans.push({\n byteStart: byteOffset,\n byteEnd,\n utf16Start: utf16Offset,\n deltaAfter: byteEnd - utf16End,\n });\n }\n byteOffset = byteEnd;\n utf16Offset = utf16End;\n }\n\n if (nonAsciiSpans.length === 0) {\n return (offset) => clampOffset(offset, sourceText.length);\n }\n\n const totalBytes = byteOffset;\n return (offset) => {\n const byteOffset = clampOffset(offset, totalBytes);\n let low = 0;\n let high = nonAsciiSpans.length;\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n if (nonAsciiSpans[mid].byteEnd <= byteOffset) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n\n const nextSpan = nonAsciiSpans[low];\n if (nextSpan && byteOffset >= nextSpan.byteStart && byteOffset < nextSpan.byteEnd) {\n return nextSpan.utf16Start;\n }\n\n const previousSpan = nonAsciiSpans[low - 1];\n const delta = previousSpan?.deltaAfter ?? 0;\n return clampOffset(byteOffset - delta, sourceText.length);\n };\n}\n\nfunction utf8ByteLength(codePoint: number): number {\n if (codePoint <= 0x7f) {\n return 1;\n }\n if (codePoint <= 0x7ff) {\n return 2;\n }\n if (codePoint <= 0xffff) {\n return 3;\n }\n return 4;\n}\n\nfunction clampOffset(offset: number, max: number): number {\n if (!Number.isFinite(offset)) {\n return 0;\n }\n if (offset <= 0) {\n return 0;\n }\n if (offset >= max) {\n return max;\n }\n return Math.trunc(offset);\n}\n\nfunction sourceTextForContext(context: ContextWithParserOptions): string {\n const text = (context.sourceCode as { text?: unknown }).text;\n if (typeof text === \"string\") {\n return text;\n }\n return context.sourceCode.getText({ type: \"Program\" } as never);\n}\n\nfunction currentRuleOptions(context: ContextWithParserOptions): CorsaStylisticRuleOptions {\n return normalizeOptions((context as { options?: unknown }).options);\n}\n\nfunction normalizeOptions(options: unknown): CorsaStylisticRuleOptions {\n if (Array.isArray(options)) {\n return options;\n }\n if (options == null) {\n return [];\n }\n return [options];\n}\n\nfunction assertKnownStylisticRuleName(name: string): asserts name is CorsaStylisticRuleName {\n if (!(implementedStylisticRuleNames as readonly string[]).includes(name)) {\n throw new Error(`unknown corsa stylistic rule: ${name}`);\n }\n}\n\nfunction stylisticRuleMeta(ruleName: CorsaStylisticRuleName): NativeLintRuleMeta {\n const meta = stylisticMetasByName.get(ruleName);\n if (!meta) {\n throw new Error(`corsa stylistic native Rust rule is not registered: ${ruleName}`);\n }\n return meta;\n}\n"],"mappings":";;;;;;;;;;AA4EA,MAAM,iBAAiB,yBAAyB;AAChD,MAAM,uBAAuB,IAAI,IAAI,eAAe,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAepF,MAAM,mCAAmB,IAAI,QAAyD;;;;AAKtF,MAAa,gCAAgC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAKA,MAAa,sBAAsB,OAAO,OACxC,OAAO,YACL,8BAA8B,KAAK,aAAa,CAAC,UAAU,oBAAoB,QAAQ,CAAC,CAAC,CAC3F,CACF;;;;;;;AAQA,MAAa,uBAAuB,aAAa;CAC/C,MAAM,EAAE,MAAM,gCAAgC;CAC9C,OAAO;AACT,CAAC;AAID,SAAS,oBAAoB,UAAkC;CAC7D,MAAM,OAAO,kBAAkB,QAAQ;CACvC,OAAO,WAAW;EAChB,gBAAgB,CAAC;EACjB,MAAM;GACJ,MAAM;GACN,MAAM;IACJ,aAAa,KAAK;IAClB,sBAAsB;IACtB,KAAK;GACP;GACA,SAAS;GACT,gBAAgB,KAAK;GACrB,UAAU,KAAK;GACf,QAAQ,EAAE,MAAM,QAAQ;EAC1B;EACA,OAAO,SA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