corsa-oxlint 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checker.js +30 -4
- package/dist/checker.js.map +1 -1
- package/dist/context.js +17 -2
- package/dist/context.js.map +1 -1
- package/dist/session.d.ts +20 -1
- package/dist/session.js +94 -9
- package/dist/session.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/checker.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createNodeMaps, toPosition } from "./node_map.js";
|
|
2
|
+
import { uniqueClassDeclarationPosition } from "./session.js";
|
|
2
3
|
import { sessionForContext } from "./registry.js";
|
|
3
4
|
import "./types.js";
|
|
4
5
|
//#region src/bindings/nodejs/corsa_oxlint/ts/checker.ts
|
|
@@ -285,16 +286,41 @@ function implementedTypesFromTypeDeclaration(context, type, checker) {
|
|
|
285
286
|
const session = sessionForContext(context).session;
|
|
286
287
|
const cached = session.getCachedOwnImplementedTypes(type.id);
|
|
287
288
|
if (cached) return cached;
|
|
288
|
-
const symbol = (type.symbol ? session.getSymbol(type.symbol) : void 0)
|
|
289
|
+
const symbol = checker.getSymbolOfType(type) ?? (type.symbol ? session.getSymbol(type.symbol) : void 0);
|
|
289
290
|
const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
|
|
290
|
-
const
|
|
291
|
+
const scanDeclarationNode = declarationNodeForImplementsScan(context, symbol, declaration ? session.getNode(declaration) : void 0);
|
|
291
292
|
const matchedDeclarationNode = session.getClassDeclarationForType(type);
|
|
292
|
-
const localImplementingDeclaration =
|
|
293
|
-
const resolvedDeclarationNode = matchedDeclarationNode ?? localImplementingDeclaration ??
|
|
293
|
+
const localImplementingDeclaration = scanDeclarationNode && pathsReferToSameFile(scanDeclarationNode.fileName, context.filename) ? implementingClassDeclaration(context, type, symbol, scanDeclarationNode) : void 0;
|
|
294
|
+
const resolvedDeclarationNode = matchedDeclarationNode ?? localImplementingDeclaration ?? scanDeclarationNode ?? implementingClassDeclaration(context, type, symbol);
|
|
294
295
|
const sourceText = resolvedDeclarationNode ? sourceTextForPath(context, resolvedDeclarationNode.fileName) : void 0;
|
|
295
296
|
const implemented = resolvedDeclarationNode && sourceText ? implementedTypesFromSourceText(context, resolvedDeclarationNode, sourceText, checker) : [];
|
|
296
297
|
return session.cacheOwnImplementedTypes(type.id, implemented);
|
|
297
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Returns a declaration node whose range can anchor an `implements` source
|
|
301
|
+
* scan.
|
|
302
|
+
*
|
|
303
|
+
* Positional handles are used as-is. A compact TypeScript 7 declaration handle
|
|
304
|
+
* carries a node id instead of source offsets, so its parsed range cannot
|
|
305
|
+
* anchor a scan; the declaring file is searched for the symbol's unique class
|
|
306
|
+
* declaration instead. An ambiguous name yields no node rather than a
|
|
307
|
+
* same-named declaration from another scope.
|
|
308
|
+
*/
|
|
309
|
+
function declarationNodeForImplementsScan(context, symbol, declarationNode) {
|
|
310
|
+
if (!declarationNode?.positionless) return declarationNode;
|
|
311
|
+
const name = symbol?.name;
|
|
312
|
+
if (!name) return;
|
|
313
|
+
const sourceText = sourceTextForPath(context, declarationNode.fileName);
|
|
314
|
+
if (!sourceText) return;
|
|
315
|
+
const pos = uniqueClassDeclarationPosition(sourceText, name);
|
|
316
|
+
if (pos === void 0) return;
|
|
317
|
+
return {
|
|
318
|
+
fileName: declarationNode.fileName,
|
|
319
|
+
pos,
|
|
320
|
+
end: sourceText.length,
|
|
321
|
+
range: [pos, sourceText.length]
|
|
322
|
+
};
|
|
323
|
+
}
|
|
298
324
|
function implementingClassDeclaration(context, type, symbol, declarationNode) {
|
|
299
325
|
const name = implementingClassName(type, symbol);
|
|
300
326
|
if (!name) return;
|
package/dist/checker.js.map
CHANGED
|
@@ -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(context, 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(\n context: ContextWithParserOptions,\n node: Node,\n checker: CorsaTypeCheckerShape,\n): 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 const type = constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n sessionForContext(context).session.rememberTypeLookupFromType(type, calleeType);\n return type;\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 case \"PropertyDefinition\":\n case \"TSAbstractPropertyDefinition\":\n return childNode(node, \"typeAnnotation\") ?? 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,QAA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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"}
|
|
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 { uniqueClassDeclarationPosition } from \"./session\";\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(context, 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(\n context: ContextWithParserOptions,\n node: Node,\n checker: CorsaTypeCheckerShape,\n): 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 const type = constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n sessionForContext(context).session.rememberTypeLookupFromType(type, calleeType);\n return type;\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 case \"PropertyDefinition\":\n case \"TSAbstractPropertyDefinition\":\n return childNode(node, \"typeAnnotation\") ?? 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 // Resolve through the session's type-symbol lookup first: it primes the\n // declaration-position caches for compact TypeScript 7 handles before the\n // source scans below run, while a direct `getSymbol(type.symbol)` cache hit\n // would skip that recovery.\n const symbol =\n checker.getSymbolOfType(type) ?? (type.symbol ? session.getSymbol(type.symbol) : undefined);\n const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];\n const declarationNode = declaration ? session.getNode(declaration) : undefined;\n const scanDeclarationNode = declarationNodeForImplementsScan(context, symbol, declarationNode);\n const matchedDeclarationNode = session.getClassDeclarationForType(type);\n const localImplementingDeclaration =\n scanDeclarationNode && pathsReferToSameFile(scanDeclarationNode.fileName, context.filename)\n ? implementingClassDeclaration(context, type, symbol, scanDeclarationNode)\n : undefined;\n const resolvedDeclarationNode =\n matchedDeclarationNode ??\n localImplementingDeclaration ??\n scanDeclarationNode ??\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\n/**\n * Returns a declaration node whose range can anchor an `implements` source\n * scan.\n *\n * Positional handles are used as-is. A compact TypeScript 7 declaration handle\n * carries a node id instead of source offsets, so its parsed range cannot\n * anchor a scan; the declaring file is searched for the symbol's unique class\n * declaration instead. An ambiguous name yields no node rather than a\n * same-named declaration from another scope.\n */\nfunction declarationNodeForImplementsScan(\n context: ContextWithParserOptions,\n symbol: CorsaSymbol | undefined,\n declarationNode: CorsaNode | undefined,\n): CorsaNode | undefined {\n if (!declarationNode?.positionless) {\n return declarationNode;\n }\n const name = symbol?.name;\n if (!name) {\n return undefined;\n }\n const sourceText = sourceTextForPath(context, declarationNode.fileName);\n if (!sourceText) {\n return undefined;\n }\n const pos = uniqueClassDeclarationPosition(sourceText, name);\n if (pos === undefined) {\n return undefined;\n }\n return {\n fileName: declarationNode.fileName,\n pos,\n end: sourceText.length,\n range: [pos, sourceText.length] as const,\n };\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":";;;;;AAiCA,MAAM,kDAAkC,IAAI,QAG1C;AAEF,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,OAEv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;GACjC,QAAQ,QAAQ;EAClB;CACF;CACA,OAAO,KAAK;EAAE;EAAO,KAAK,KAAK;CAAO,CAAC;CACvC,OAAO;AACT;AAEA,SAAS,gBAEP;CACA,IAAI;CACJ,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,IAAI,iBAAiB;CACrB,OAAO,EACL,KAAK,MAAM,OAAO;EAChB,MAAM,OAAO,KAAK;EAClB,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI,eAAe;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/context.js
CHANGED
|
@@ -17,7 +17,7 @@ const DEFAULT_TS_CONFIG = { compilerOptions: {
|
|
|
17
17
|
function defaultCorsaExecutable(rootDir, platform = process.platform, resolveFrom) {
|
|
18
18
|
const stableTypeScript = resolveStableTypeScriptExecutableFrom(resolve(rootDir, "package.json"), platform) ?? (resolveFrom ? resolveStableTypeScriptExecutableFrom(resolveFrom, platform) : void 0);
|
|
19
19
|
if (stableTypeScript) return stableTypeScript;
|
|
20
|
-
const nativePreview = resolveNativePreviewExecutableFrom(resolve(rootDir, "package.json")) ?? (resolveFrom ? resolveNativePreviewExecutableFrom(resolveFrom) : void 0);
|
|
20
|
+
const nativePreview = resolveNativePreviewExecutableFrom(resolve(rootDir, "package.json"), platform) ?? (resolveFrom ? resolveNativePreviewExecutableFrom(resolveFrom, platform) : void 0);
|
|
21
21
|
if (nativePreview) return nativePreview;
|
|
22
22
|
const fallback = resolve(rootDir, platform === "win32" ? ".cache/corsa.exe" : ".cache/corsa");
|
|
23
23
|
if (existsSync(fallback)) return fallback;
|
|
@@ -124,16 +124,31 @@ function isTypeScriptVersionSevenOrNewer(packageJsonPath) {
|
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
function resolveNativePreviewExecutableFrom(anchor) {
|
|
127
|
+
function resolveNativePreviewExecutableFrom(anchor, platform) {
|
|
128
128
|
const requireFromRoot = createRequire(anchor);
|
|
129
129
|
const packageJsonPath = resolveOptional(requireFromRoot, "@typescript/native-preview/package.json");
|
|
130
130
|
if (packageJsonPath) {
|
|
131
|
+
const platformExecutable = nativePreviewPlatformExecutable(packageJsonPath, platform);
|
|
132
|
+
if (platformExecutable) return platformExecutable;
|
|
133
|
+
if (platform === "win32") return;
|
|
131
134
|
const binPath = nativePreviewBinPath(packageJsonPath);
|
|
132
135
|
if (binPath && existsSync(binPath)) return binPath;
|
|
133
136
|
}
|
|
137
|
+
if (platform === "win32") return;
|
|
134
138
|
const packageEntry = resolveOptional(requireFromRoot, "@typescript/native-preview");
|
|
135
139
|
return packageEntry && existsSync(packageEntry) ? packageEntry : void 0;
|
|
136
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Resolves the platform-specific `tsgo` executable that the
|
|
143
|
+
* `@typescript/native-preview` meta package installs as an optional
|
|
144
|
+
* dependency, mirroring how the stable `typescript` runtime is resolved.
|
|
145
|
+
*/
|
|
146
|
+
function nativePreviewPlatformExecutable(packageJsonPath, platform) {
|
|
147
|
+
const platformPackageJsonPath = resolveOptional(createRequire(packageJsonPath), `@typescript/native-preview-${platform}-${process.arch}/package.json`);
|
|
148
|
+
if (!platformPackageJsonPath) return;
|
|
149
|
+
const executable = resolve(dirname(platformPackageJsonPath), "lib", platform === "win32" ? "tsgo.exe" : "tsgo");
|
|
150
|
+
return existsSync(executable) ? executable : void 0;
|
|
151
|
+
}
|
|
137
152
|
function resolveOptional(requireFromRoot, specifier) {
|
|
138
153
|
try {
|
|
139
154
|
return requireFromRoot.resolve(specifier);
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(\n rootDir: string,\n platform = process.platform,\n resolveFrom?: string,\n): string {\n const stableTypeScript =\n resolveStableTypeScriptExecutableFrom(resolve(rootDir, \"package.json\"), platform) ??\n (resolveFrom ? resolveStableTypeScriptExecutableFrom(resolveFrom, platform) : undefined);\n if (stableTypeScript) {\n return stableTypeScript;\n }\n const nativePreview =\n resolveNativePreviewExecutableFrom(resolve(rootDir, \"package.json\")) ??\n (resolveFrom ? resolveNativePreviewExecutableFrom(resolveFrom) : undefined);\n if (nativePreview) {\n return nativePreview;\n }\n const fallback = resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n if (existsSync(fallback)) {\n return fallback;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate a Corsa runtime executable.\",\n \"Install `typescript` 7 or `@typescript/native-preview`, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`.\",\n ].join(\" \"),\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n resolveFrom?: string,\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir, resolveFrom);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveStableTypeScriptExecutableFrom(\n anchor: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromAnchor = createRequire(anchor);\n const packageJsonPath = resolveOptional(requireFromAnchor, \"typescript/package.json\");\n if (!packageJsonPath || !isTypeScriptVersionSevenOrNewer(packageJsonPath)) {\n return undefined;\n }\n\n const platformPackage = `@typescript/typescript-${platform}-${process.arch}`;\n const requireFromTypeScript = createRequire(packageJsonPath);\n const platformPackageJsonPath = resolveOptional(\n requireFromTypeScript,\n `${platformPackage}/package.json`,\n );\n if (!platformPackageJsonPath) {\n return undefined;\n }\n\n const executable = resolve(\n dirname(platformPackageJsonPath),\n \"lib\",\n platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n return existsSync(executable) ? executable : undefined;\n}\n\nfunction isTypeScriptVersionSevenOrNewer(packageJsonPath: string): boolean {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly version?: string;\n };\n const major = Number.parseInt(packageJson.version?.split(\".\")[0] ?? \"\", 10);\n return Number.isFinite(major) && major >= 7;\n } catch {\n return false;\n }\n}\n\nfunction resolveNativePreviewExecutableFrom(anchor: string): string | undefined {\n const requireFromRoot = createRequire(anchor);\n const packageJsonPath = resolveOptional(\n requireFromRoot,\n \"@typescript/native-preview/package.json\",\n );\n if (packageJsonPath) {\n const binPath = nativePreviewBinPath(packageJsonPath);\n if (binPath && existsSync(binPath)) {\n return binPath;\n }\n }\n const packageEntry = resolveOptional(requireFromRoot, \"@typescript/native-preview\");\n return packageEntry && existsSync(packageEntry) ? packageEntry : undefined;\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction nativePreviewBinPath(packageJsonPath: string): string | undefined {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly bin?: string | Record<string, string>;\n };\n const bin =\n typeof packageJson.bin === \"string\"\n ? packageJson.bin\n : (packageJson.bin?.tsgo ?? Object.values(packageJson.bin ?? {})[0]);\n return bin ? resolve(dirname(packageJsonPath), bin) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n resolveFrom?: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable:\n process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, undefined, resolveFrom),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;AAAO;AAClE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;AACV,EACF;AAEA,SAAgB,uBACd,SACA,WAAW,QAAQ,UACnB,aACQ;CACR,MAAM,mBACJ,sCAAsC,QAAQ,SAAS,cAAc,GAAG,QAAQ,MAC/E,cAAc,sCAAsC,aAAa,QAAQ,IAAI,KAAA;CAChF,IAAI,kBACF,OAAO;CAET,MAAM,gBACJ,mCAAmC,QAAQ,SAAS,cAAc,CAAC,MAClE,cAAc,mCAAmC,WAAW,IAAI,KAAA;CACnE,IAAI,eACF,OAAO;CAET,MAAM,WAAW,QAAQ,SAAS,aAAa,UAAU,qBAAqB,cAAc;CAC5F,IAAI,WAAW,QAAQ,GACrB,OAAO;CAET,MAAM,IAAI,MACR,CACE,6DACA,sKACF,CAAC,CAAC,KAAK,GAAG,CACZ;AACF;AAEA,SAAgB,qBA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AO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;CAClD;AACF"}
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../ts/context.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\n\nimport type {\n ContextWithParserOptions,\n CorsaOxlintSettings,\n ProjectServiceOptions,\n ResolvedProjectConfig,\n ResolvedRuntimeOptions,\n TypeAwareParserOptions,\n} from \"./types\";\n\nconst DEFAULT_CACHE_LIFETIME_MS = 250;\nconst DEFAULT_PROJECT_PATTERNS = [\"*.ts\", \"*.tsx\", \"*.js\", \"*.jsx\"];\nconst DEFAULT_TS_CONFIG = {\n compilerOptions: {\n module: \"esnext\",\n target: \"es2022\",\n strict: true,\n },\n};\n\nexport function defaultCorsaExecutable(\n rootDir: string,\n platform = process.platform,\n resolveFrom?: string,\n): string {\n const stableTypeScript =\n resolveStableTypeScriptExecutableFrom(resolve(rootDir, \"package.json\"), platform) ??\n (resolveFrom ? resolveStableTypeScriptExecutableFrom(resolveFrom, platform) : undefined);\n if (stableTypeScript) {\n return stableTypeScript;\n }\n const nativePreview =\n resolveNativePreviewExecutableFrom(resolve(rootDir, \"package.json\"), platform) ??\n (resolveFrom ? resolveNativePreviewExecutableFrom(resolveFrom, platform) : undefined);\n if (nativePreview) {\n return nativePreview;\n }\n const fallback = resolve(rootDir, platform === \"win32\" ? \".cache/corsa.exe\" : \".cache/corsa\");\n if (existsSync(fallback)) {\n return fallback;\n }\n throw new Error(\n [\n \"corsa-oxlint could not locate a Corsa runtime executable.\",\n \"Install `typescript` 7 or `@typescript/native-preview`, set `CORSA_EXECUTABLE`, configure `parserOptions.corsa.executable`, or pass `resolveFrom` to `definePlugin`.\",\n ].join(\" \"),\n );\n}\n\nexport function resolveProjectConfig(context: ContextWithParserOptions): ResolvedProjectConfig {\n const filename = resolve(context.filename);\n const parserOptions = resolveTypeAwareParserOptions(context);\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n const runtime = resolveRuntimeOptions(rootDir, parserOptions);\n const configPath =\n resolveExplicitProject(rootDir, parserOptions) ??\n discoverTsconfig(filename, rootDir) ??\n resolveDefaultProject(rootDir, filename, parserOptions.projectService);\n if (!configPath) {\n throw new Error(`corsa oxlint could not resolve a tsconfig for ${filename}`);\n }\n return { filename, rootDir, configPath, runtime };\n}\n\n/**\n * Resolves the type-aware parser options visible to a rule.\n *\n * Oxlint exposes a fixed `context.languageOptions.parserOptions` object at\n * runtime, so `corsa oxlint` stores its richer configuration under\n * `settings.corsaOxlint` and rehydrates the rule-facing parser options\n * shape from there.\n *\n * @example\n * ```ts\n * const parserOptions = resolveTypeAwareParserOptions(context);\n * parserOptions.corsa?.mode;\n * ```\n */\nexport function resolveTypeAwareParserOptions(\n context: ContextWithParserOptions,\n defaults: TypeAwareParserOptionDefaults = {},\n resolveFrom?: string,\n): TypeAwareParserOptions {\n const parserOptions = mergeTypeAwareParserOptions(\n resolveSettingsParserOptions(context.settings?.corsaOxlint),\n mergeTypeAwareParserOptions(context.parserOptions, context.languageOptions?.parserOptions),\n );\n const rootDir = resolve(parserOptions.tsconfigRootDir ?? context.cwd);\n return applyTypeAwareParserOptionDefaults(parserOptions, defaults, rootDir, resolveFrom);\n}\n\ntype TypeAwareParserOptionDefaults = {\n readonly corsa?: boolean;\n readonly projectService?: boolean;\n};\n\nfunction resolveRuntimeOptions(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): ResolvedRuntimeOptions {\n const runtime = parserOptions.corsa;\n return {\n executable: resolve(\n runtime?.executable ?? process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir),\n ),\n cwd: resolve(runtime?.cwd ?? rootDir),\n mode: runtime?.mode ?? \"msgpack\",\n cacheLifetimeMs: runtime?.cacheLifetimeMs ?? DEFAULT_CACHE_LIFETIME_MS,\n };\n}\n\nfunction resolveExplicitProject(\n rootDir: string,\n parserOptions: TypeAwareParserOptions,\n): string | undefined {\n const projects = asArray(parserOptions.project).map((project) => {\n return resolve(rootDir, project);\n });\n return projects.find(existsSync);\n}\n\nfunction discoverTsconfig(filename: string, rootDir: string): string | undefined {\n let current = dirname(filename);\n const boundary = resolve(rootDir);\n while (current.startsWith(boundary)) {\n const candidate = resolve(current, \"tsconfig.json\");\n if (existsSync(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n return undefined;\n}\n\nfunction resolveDefaultProject(\n rootDir: string,\n filename: string,\n projectService: boolean | ProjectServiceOptions | undefined,\n): string | undefined {\n if (!projectService) {\n return undefined;\n }\n if (projectService !== true && projectService.defaultProject) {\n return resolve(rootDir, projectService.defaultProject);\n }\n if (!matchesDefaultProject(filename, projectService as true | ProjectServiceOptions)) {\n return undefined;\n }\n const id = Buffer.from(filename).toString(\"hex\").slice(0, 24);\n const cacheDir = resolve(rootDir, \".cache/corsa_oxlint/default\");\n const configPath = resolve(cacheDir, `${id}.tsconfig.json`);\n if (!existsSync(configPath)) {\n mkdirSync(cacheDir, { recursive: true });\n writeFileSync(\n configPath,\n JSON.stringify(\n {\n ...DEFAULT_TS_CONFIG,\n files: [filename],\n },\n null,\n 2,\n ),\n );\n }\n return configPath;\n}\n\nfunction matchesDefaultProject(\n filename: string,\n projectService: true | ProjectServiceOptions,\n): boolean {\n const patterns =\n (projectService === true ? undefined : projectService.allowDefaultProject) ??\n DEFAULT_PROJECT_PATTERNS;\n return patterns.some((pattern: string) => globMatch(filename, pattern));\n}\n\nfunction globMatch(value: string, pattern: string): boolean {\n const escaped = pattern.replaceAll(\".\", \"\\\\.\").replaceAll(\"*\", \".*\");\n return new RegExp(`${escaped}$`).test(value);\n}\n\nfunction asArray(value: string | string[] | undefined): string[] {\n return value ? (Array.isArray(value) ? value : [value]) : [];\n}\n\nfunction resolveStableTypeScriptExecutableFrom(\n anchor: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromAnchor = createRequire(anchor);\n const packageJsonPath = resolveOptional(requireFromAnchor, \"typescript/package.json\");\n if (!packageJsonPath || !isTypeScriptVersionSevenOrNewer(packageJsonPath)) {\n return undefined;\n }\n\n const platformPackage = `@typescript/typescript-${platform}-${process.arch}`;\n const requireFromTypeScript = createRequire(packageJsonPath);\n const platformPackageJsonPath = resolveOptional(\n requireFromTypeScript,\n `${platformPackage}/package.json`,\n );\n if (!platformPackageJsonPath) {\n return undefined;\n }\n\n const executable = resolve(\n dirname(platformPackageJsonPath),\n \"lib\",\n platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n return existsSync(executable) ? executable : undefined;\n}\n\nfunction isTypeScriptVersionSevenOrNewer(packageJsonPath: string): boolean {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly version?: string;\n };\n const major = Number.parseInt(packageJson.version?.split(\".\")[0] ?? \"\", 10);\n return Number.isFinite(major) && major >= 7;\n } catch {\n return false;\n }\n}\n\nfunction resolveNativePreviewExecutableFrom(\n anchor: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromRoot = createRequire(anchor);\n const packageJsonPath = resolveOptional(\n requireFromRoot,\n \"@typescript/native-preview/package.json\",\n );\n if (packageJsonPath) {\n const platformExecutable = nativePreviewPlatformExecutable(packageJsonPath, platform);\n if (platformExecutable) {\n return platformExecutable;\n }\n // The meta package's `bin` entry is a Node script behind a shebang.\n // Windows cannot spawn it (`os error 193`), so the script is only a\n // usable runtime on platforms that honor shebang lines.\n if (platform === \"win32\") {\n return undefined;\n }\n const binPath = nativePreviewBinPath(packageJsonPath);\n if (binPath && existsSync(binPath)) {\n return binPath;\n }\n }\n if (platform === \"win32\") {\n return undefined;\n }\n const packageEntry = resolveOptional(requireFromRoot, \"@typescript/native-preview\");\n return packageEntry && existsSync(packageEntry) ? packageEntry : undefined;\n}\n\n/**\n * Resolves the platform-specific `tsgo` executable that the\n * `@typescript/native-preview` meta package installs as an optional\n * dependency, mirroring how the stable `typescript` runtime is resolved.\n */\nfunction nativePreviewPlatformExecutable(\n packageJsonPath: string,\n platform: NodeJS.Platform,\n): string | undefined {\n const requireFromPreview = createRequire(packageJsonPath);\n const platformPackageJsonPath = resolveOptional(\n requireFromPreview,\n `@typescript/native-preview-${platform}-${process.arch}/package.json`,\n );\n if (!platformPackageJsonPath) {\n return undefined;\n }\n const executable = resolve(\n dirname(platformPackageJsonPath),\n \"lib\",\n platform === \"win32\" ? \"tsgo.exe\" : \"tsgo\",\n );\n return existsSync(executable) ? executable : undefined;\n}\n\nfunction resolveOptional(requireFromRoot: NodeJS.Require, specifier: string): string | undefined {\n try {\n return requireFromRoot.resolve(specifier);\n } catch {\n return undefined;\n }\n}\n\nfunction nativePreviewBinPath(packageJsonPath: string): string | undefined {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n readonly bin?: string | Record<string, string>;\n };\n const bin =\n typeof packageJson.bin === \"string\"\n ? packageJson.bin\n : (packageJson.bin?.tsgo ?? Object.values(packageJson.bin ?? {})[0]);\n return bin ? resolve(dirname(packageJsonPath), bin) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction resolveSettingsParserOptions(\n settings: CorsaOxlintSettings | undefined,\n): TypeAwareParserOptions {\n if (!settings) {\n return {};\n }\n const { parserOptions, ...inline } = settings;\n return mergeTypeAwareParserOptions(inline, parserOptions);\n}\n\nfunction applyTypeAwareParserOptionDefaults(\n parserOptions: TypeAwareParserOptions,\n defaults: TypeAwareParserOptionDefaults,\n rootDir: string,\n resolveFrom?: string,\n): TypeAwareParserOptions {\n let resolved = parserOptions;\n if (\n defaults.projectService === true &&\n parserOptions.projectService === undefined &&\n parserOptions.project === undefined\n ) {\n resolved = {\n ...resolved,\n projectService: true,\n };\n }\n if (defaults.corsa === true && resolved.corsa?.executable === undefined) {\n resolved = mergeTypeAwareParserOptions(resolved, {\n corsa: {\n executable:\n process.env.CORSA_EXECUTABLE ?? defaultCorsaExecutable(rootDir, undefined, resolveFrom),\n },\n });\n }\n return resolved;\n}\n\nexport function mergeTypeAwareParserOptions(\n base: TypeAwareParserOptions | undefined,\n override: TypeAwareParserOptions | undefined,\n): TypeAwareParserOptions {\n if (!base) {\n return normalizeTypeAwareParserOptions(override ?? {});\n }\n if (!override) {\n return normalizeTypeAwareParserOptions(base);\n }\n const runtime = {\n ...base.corsa,\n ...override.corsa,\n };\n return {\n ...base,\n ...override,\n project: override.project ?? base.project,\n projectService: mergeProjectService(base.projectService, override.projectService),\n tsconfigRootDir: override.tsconfigRootDir ?? base.tsconfigRootDir,\n ...(Object.keys(runtime).length > 0 ? { corsa: runtime } : {}),\n };\n}\n\nfunction normalizeTypeAwareParserOptions(options: TypeAwareParserOptions): TypeAwareParserOptions {\n const runtime = options.corsa;\n if (!runtime) {\n return options;\n }\n return {\n ...options,\n corsa: runtime,\n };\n}\n\nfunction mergeProjectService(\n base: boolean | ProjectServiceOptions | undefined,\n override: boolean | ProjectServiceOptions | undefined,\n): boolean | ProjectServiceOptions | undefined {\n if (override === undefined) {\n return base;\n }\n if (typeof override === \"boolean\") {\n return override;\n }\n if (base === undefined || typeof base === \"boolean\") {\n return override;\n }\n return {\n ...base,\n ...override,\n allowDefaultProject: override.allowDefaultProject ?? base.allowDefaultProject,\n defaultProject: override.defaultProject ?? base.defaultProject,\n };\n}\n"],"mappings":";;;;AAaA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;CAAC;CAAQ;CAAS;CAAQ;AAAO;AAClE,MAAM,oBAAoB,EACxB,iBAAiB;CACf,QAAQ;CACR,QAAQ;CACR,QAAQ;AACV,EACF;AAEA,SAAgB,uBACd,SACA,WAAW,QAAQ,UACnB,aACQ;CACR,MAAM,mBACJ,sCAAsC,QAAQ,SAAS,cAAc,GAAG,QAAQ,MAC/E,cAAc,sCAAsC,aAAa,QAAQ,IAAI,KAAA;CAChF,IAAI,kBACF,OAAO;CAET,MAA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ACwB;CACxB,IAAI,CAAC,MACH,OAAO,gCAAgC,YAAY,CAAC,CAAC;CAEvD,IAAI,CAAC,UACH,OAAO,gCAAgC,IAAI;CAE7C,MAAM,UAAU;EACd,GAAG,KAAK;EACR,GAAG,SAAS;CACd;CACA,OAAO;EACL,GAAG;EACH,GAAG;EACH,SAAS,SAAS,WAAW,KAAK;EAClC,gBAAgB,oBAAoB,KAAK,gBAAgB,SAAS,cAAc;EAChF,iBAAiB,SAAS,mBAAmB,KAAK;EAClD,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,QAAQ,IAAI,CAAC;CAC9D;AACF;AAEA,SAAS,gCAAgC,SAAyD;CAChG,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,SACH,OAAO;CAET,OAAO;EACL,GAAG;EACH,OAAO;CACT;AACF;AAEA,SAAS,oBACP,MACA,UAC6C;CAC7C,IAAI,aAAa,KAAA,GACf,OAAO;CAET,IAAI,OAAO,aAAa,WACtB,OAAO;CAET,IAAI,SAAS,KAAA,KAAa,OAAO,SAAS,WACxC,OAAO;CAET,OAAO;EACL,GAAG;EACH,GAAG;EACH,qBAAqB,SAAS,uBAAuB,KAAK;EAC1D,gBAAgB,SAAS,kBAAkB,KAAK;CAClD;AACF"}
|
package/dist/session.d.ts
CHANGED
|
@@ -18,6 +18,17 @@ declare class CorsaProjectSession {
|
|
|
18
18
|
private getSymbolUnchecked;
|
|
19
19
|
getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;
|
|
20
20
|
private getSymbolOfTypeUnchecked;
|
|
21
|
+
/**
|
|
22
|
+
* Runs the source-position lookup for a natively resolved symbol whose
|
|
23
|
+
* declaration handles are compact TypeScript 7 handles without offsets.
|
|
24
|
+
*
|
|
25
|
+
* When the native `getSymbolOfType` lookup succeeds, the position-recovery
|
|
26
|
+
* path in `getSymbolOfTypeAtLookup` no longer runs, yet it is what records
|
|
27
|
+
* the class-declaration range and namespace search scope that disambiguate
|
|
28
|
+
* same-named declarations. The native symbol stays the source of truth;
|
|
29
|
+
* this only restores those positional caches.
|
|
30
|
+
*/
|
|
31
|
+
private recoverDeclarationPositionsForSymbol;
|
|
21
32
|
private getSymbolOfTypeAtLookup;
|
|
22
33
|
private getNearbyTypeSymbol;
|
|
23
34
|
/**
|
|
@@ -105,6 +116,14 @@ declare class CorsaProjectSession {
|
|
|
105
116
|
private overlayChanges;
|
|
106
117
|
private supportsOverlayChanges;
|
|
107
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns the offset of the only `class <className>` declaration in the source,
|
|
121
|
+
* or `undefined` when the file has none or more than one.
|
|
122
|
+
*
|
|
123
|
+
* Matches inside comments and string literals are ignored, so text such as
|
|
124
|
+
* `// class Descendant` neither shadows nor duplicates a real declaration.
|
|
125
|
+
*/
|
|
126
|
+
declare function uniqueClassDeclarationPosition(sourceText: string, className: string): number | undefined;
|
|
108
127
|
//#endregion
|
|
109
|
-
export { CorsaProjectSession };
|
|
128
|
+
export { CorsaProjectSession, uniqueClassDeclarationPosition };
|
|
110
129
|
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.js
CHANGED
|
@@ -34,6 +34,7 @@ var CorsaProjectSession = class {
|
|
|
34
34
|
#ownImplementedTypesById = /* @__PURE__ */ new Map();
|
|
35
35
|
#typeLookupById = /* @__PURE__ */ new Map();
|
|
36
36
|
#typeSourceById = /* @__PURE__ */ new Map();
|
|
37
|
+
#typeDeclarationFileById = /* @__PURE__ */ new Map();
|
|
37
38
|
#classDeclarationByTypeId = /* @__PURE__ */ new Map();
|
|
38
39
|
#symbolSearchRangeByTypeId = /* @__PURE__ */ new Map();
|
|
39
40
|
#sourceLengthByPath = /* @__PURE__ */ new Map();
|
|
@@ -74,6 +75,7 @@ var CorsaProjectSession = class {
|
|
|
74
75
|
if (type) this.#typeLookupById.set(type.id, {
|
|
75
76
|
fileName,
|
|
76
77
|
position,
|
|
78
|
+
projectId: state.projectId,
|
|
77
79
|
sourceText
|
|
78
80
|
});
|
|
79
81
|
return type;
|
|
@@ -91,6 +93,7 @@ var CorsaProjectSession = class {
|
|
|
91
93
|
this.#typeLookupById.set(type.id, {
|
|
92
94
|
fileName,
|
|
93
95
|
position: start,
|
|
96
|
+
projectId: state.projectId,
|
|
94
97
|
sourceText
|
|
95
98
|
});
|
|
96
99
|
if (kind !== "Identifier") this.rememberTypeSourceRange(type, fileName, start, end, sourceText);
|
|
@@ -126,12 +129,14 @@ var CorsaProjectSession = class {
|
|
|
126
129
|
if (type.symbol) {
|
|
127
130
|
const symbol = this.getSymbol(type.symbol);
|
|
128
131
|
if (isUsableSymbol(symbol)) {
|
|
132
|
+
this.recoverDeclarationPositionsForSymbol(type, symbol);
|
|
129
133
|
this.#symbolsByTypeId.set(type.id, symbol);
|
|
130
134
|
return symbol;
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
const symbol = this.getSymbolOfTypeById(type.id);
|
|
134
138
|
if (symbol) {
|
|
139
|
+
this.recoverDeclarationPositionsForSymbol(type, symbol);
|
|
135
140
|
this.#symbolsByTypeId.set(type.id, symbol);
|
|
136
141
|
return symbol;
|
|
137
142
|
}
|
|
@@ -142,6 +147,23 @@ var CorsaProjectSession = class {
|
|
|
142
147
|
}
|
|
143
148
|
this.#symbolsByTypeId.set(type.id, null);
|
|
144
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Runs the source-position lookup for a natively resolved symbol whose
|
|
152
|
+
* declaration handles are compact TypeScript 7 handles without offsets.
|
|
153
|
+
*
|
|
154
|
+
* When the native `getSymbolOfType` lookup succeeds, the position-recovery
|
|
155
|
+
* path in `getSymbolOfTypeAtLookup` no longer runs, yet it is what records
|
|
156
|
+
* the class-declaration range and namespace search scope that disambiguate
|
|
157
|
+
* same-named declarations. The native symbol stays the source of truth;
|
|
158
|
+
* this only restores those positional caches.
|
|
159
|
+
*/
|
|
160
|
+
recoverDeclarationPositionsForSymbol(type, symbol) {
|
|
161
|
+
if (this.#classDeclarationByTypeId.has(type.id)) return;
|
|
162
|
+
const declarations = [symbol.valueDeclaration, ...symbol.declarations ?? []].filter((handle) => handle !== void 0);
|
|
163
|
+
if (declarations.length === 0 || !declarations.every(isPositionlessNodeHandle)) return;
|
|
164
|
+
if (!this.#typeLookupById.has(type.id)) return;
|
|
165
|
+
this.getSymbolOfTypeAtLookup(type);
|
|
166
|
+
}
|
|
145
167
|
getSymbolOfTypeAtLookup(type) {
|
|
146
168
|
const lookup = this.#typeLookupById.get(type.id);
|
|
147
169
|
if (!lookup) return;
|
|
@@ -266,7 +288,7 @@ var CorsaProjectSession = class {
|
|
|
266
288
|
getSymbolOfTypeById(typeId) {
|
|
267
289
|
if (!this.#snapshot || typeId.trim().length === 0) return;
|
|
268
290
|
try {
|
|
269
|
-
return this.rememberUsableSymbol(this.client().getSymbolOfType(this.#snapshot, typeId));
|
|
291
|
+
return this.rememberUsableSymbol(this.client().getSymbolOfType(this.#snapshot, typeId, this.#typeLookupById.get(typeId)?.projectId ?? this.#projects[0]?.id));
|
|
270
292
|
} catch (error) {
|
|
271
293
|
if (isMissingTypeHandleError(error)) return;
|
|
272
294
|
throw error;
|
|
@@ -288,6 +310,8 @@ var CorsaProjectSession = class {
|
|
|
288
310
|
if (lookup && !this.#typeLookupById.has(type.id)) this.#typeLookupById.set(type.id, lookup);
|
|
289
311
|
const source = this.#typeSourceById.get(relatedType.id);
|
|
290
312
|
if (source && !this.#typeSourceById.has(type.id)) this.#typeSourceById.set(type.id, source);
|
|
313
|
+
const declarationFile = this.#typeDeclarationFileById.get(relatedType.id);
|
|
314
|
+
if (declarationFile && !this.#typeDeclarationFileById.has(type.id)) this.#typeDeclarationFileById.set(type.id, declarationFile);
|
|
291
315
|
const symbolSearchRange = this.#symbolSearchRangeByTypeId.get(relatedType.id);
|
|
292
316
|
if (symbolSearchRange && !this.#symbolSearchRangeByTypeId.has(type.id)) this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);
|
|
293
317
|
}
|
|
@@ -554,7 +578,12 @@ var CorsaProjectSession = class {
|
|
|
554
578
|
rememberTypeSource(type, handle) {
|
|
555
579
|
if (!type || !handle || this.#typeSourceById.has(type.id)) return;
|
|
556
580
|
const source = this.sourceSliceForHandle(handle);
|
|
557
|
-
if (source)
|
|
581
|
+
if (source) {
|
|
582
|
+
this.#typeSourceById.set(type.id, source);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const node = this.getNode(handle);
|
|
586
|
+
if (node?.positionless) this.#typeDeclarationFileById.set(type.id, node.fileName);
|
|
558
587
|
}
|
|
559
588
|
rememberTypeSourceRange(type, fileName, start, end, sourceText) {
|
|
560
589
|
if (this.#typeSourceById.has(type.id) || !sourceText || start < 0 || end > sourceText.length || start >= end) return;
|
|
@@ -594,6 +623,14 @@ var CorsaProjectSession = class {
|
|
|
594
623
|
sourceText
|
|
595
624
|
} : {};
|
|
596
625
|
}
|
|
626
|
+
const declarationFile = this.#typeDeclarationFileById.get(type.id);
|
|
627
|
+
if (declarationFile) {
|
|
628
|
+
const sourceText = this.sourceTextForPath(declarationFile);
|
|
629
|
+
return sourceText ? {
|
|
630
|
+
file: declarationFile,
|
|
631
|
+
sourceText
|
|
632
|
+
} : {};
|
|
633
|
+
}
|
|
597
634
|
return {};
|
|
598
635
|
}
|
|
599
636
|
rememberSymbol(symbol) {
|
|
@@ -637,6 +674,7 @@ var CorsaProjectSession = class {
|
|
|
637
674
|
this.#ownImplementedTypesById.clear();
|
|
638
675
|
this.#typeLookupById.clear();
|
|
639
676
|
this.#typeSourceById.clear();
|
|
677
|
+
this.#typeDeclarationFileById.clear();
|
|
640
678
|
this.#classDeclarationByTypeId.clear();
|
|
641
679
|
this.#symbolSearchRangeByTypeId.clear();
|
|
642
680
|
this.#sourceLengthByPath.clear();
|
|
@@ -651,7 +689,7 @@ var CorsaProjectSession = class {
|
|
|
651
689
|
}
|
|
652
690
|
sourceSliceForHandle(handle) {
|
|
653
691
|
const node = this.getNode(handle);
|
|
654
|
-
if (!node) return;
|
|
692
|
+
if (!node || node.positionless) return;
|
|
655
693
|
const sourceText = this.sourceTextForPath(node.fileName);
|
|
656
694
|
if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) return;
|
|
657
695
|
return { node };
|
|
@@ -849,12 +887,41 @@ function classDeclarationStartAtIdentifier(sourceText, identifierPosition) {
|
|
|
849
887
|
const match = /\bclass\s*$/u.exec(prefix);
|
|
850
888
|
return match ? prefixStart + match.index : void 0;
|
|
851
889
|
}
|
|
890
|
+
/**
|
|
891
|
+
* Returns the offset of the only `class <className>` declaration in the source,
|
|
892
|
+
* or `undefined` when the file has none or more than one.
|
|
893
|
+
*
|
|
894
|
+
* Matches inside comments and string literals are ignored, so text such as
|
|
895
|
+
* `// class Descendant` neither shadows nor duplicates a real declaration.
|
|
896
|
+
*/
|
|
852
897
|
function uniqueClassDeclarationPosition(sourceText, className) {
|
|
853
898
|
const escapedName = className.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
854
899
|
const declarationPattern = new RegExp(`\\bclass\\s+${escapedName}\\b`, "gu");
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
900
|
+
const codePositions = codePositionMask(sourceText);
|
|
901
|
+
let unique;
|
|
902
|
+
for (let declaration = declarationPattern.exec(sourceText); declaration; declaration = declarationPattern.exec(sourceText)) {
|
|
903
|
+
if (codePositions[declaration.index] !== 1) continue;
|
|
904
|
+
if (unique !== void 0) return;
|
|
905
|
+
unique = declaration.index;
|
|
906
|
+
}
|
|
907
|
+
return unique;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Marks each offset that is executable code rather than comment or string
|
|
911
|
+
* literal content, using the same scanner as the namespace range helpers.
|
|
912
|
+
*/
|
|
913
|
+
function codePositionMask(sourceText) {
|
|
914
|
+
const mask = new Uint8Array(sourceText.length);
|
|
915
|
+
const scanner = createSourceScanner();
|
|
916
|
+
for (let index = 0; index < sourceText.length; index += 1) {
|
|
917
|
+
const nextIndex = scanner.skip(sourceText, index);
|
|
918
|
+
if (nextIndex > index) {
|
|
919
|
+
index = nextIndex - 1;
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
mask[index] = 1;
|
|
923
|
+
}
|
|
924
|
+
return mask;
|
|
858
925
|
}
|
|
859
926
|
function qualifiedNamespaceRangeAtIdentifier(sourceText, identifierPosition) {
|
|
860
927
|
const prefixStart = Math.max(0, identifierPosition - 256);
|
|
@@ -1051,13 +1118,20 @@ function parseNodeHandle(value, sourceLengthForPath) {
|
|
|
1051
1118
|
const [posText, secondText, thirdText, ...remainingParts] = value.split(".");
|
|
1052
1119
|
const pos = Number(posText);
|
|
1053
1120
|
const second = Number(secondText);
|
|
1054
|
-
const third = Number(thirdText);
|
|
1055
1121
|
if (!Number.isFinite(pos) || !Number.isFinite(second)) return;
|
|
1056
|
-
const hasEndPosition =
|
|
1122
|
+
const hasEndPosition = isFiniteNumberText(thirdText);
|
|
1057
1123
|
const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(".");
|
|
1058
1124
|
if (!fileName) return;
|
|
1059
1125
|
const end = hasEndPosition ? second : sourceLengthForPath(fileName) ?? pos + 1;
|
|
1060
1126
|
if (end < pos) return;
|
|
1127
|
+
if (!hasEndPosition) return {
|
|
1128
|
+
id: value,
|
|
1129
|
+
fileName,
|
|
1130
|
+
pos,
|
|
1131
|
+
end,
|
|
1132
|
+
range: [pos, end],
|
|
1133
|
+
positionless: true
|
|
1134
|
+
};
|
|
1061
1135
|
return {
|
|
1062
1136
|
id: value,
|
|
1063
1137
|
fileName,
|
|
@@ -1066,6 +1140,17 @@ function parseNodeHandle(value, sourceLengthForPath) {
|
|
|
1066
1140
|
range: [pos, end]
|
|
1067
1141
|
};
|
|
1068
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Reports whether a node handle uses the compact TypeScript 7 wire format
|
|
1145
|
+
* `<node id>.<syntax kind>.<path>`, which carries no source offsets.
|
|
1146
|
+
*/
|
|
1147
|
+
function isPositionlessNodeHandle(value) {
|
|
1148
|
+
const [posText, secondText, thirdText] = value.split(".");
|
|
1149
|
+
return isFiniteNumberText(posText) && isFiniteNumberText(secondText) && !isFiniteNumberText(thirdText);
|
|
1150
|
+
}
|
|
1151
|
+
function isFiniteNumberText(text) {
|
|
1152
|
+
return text !== void 0 && text !== "" && Number.isFinite(Number(text));
|
|
1153
|
+
}
|
|
1069
1154
|
function isRecoverableTransportError(error) {
|
|
1070
1155
|
const message = errorMessage(error);
|
|
1071
1156
|
return message.includes("process is closed:") || message.includes("Broken pipe") || message.includes("EPIPE") || message.includes("failed to fill whole buffer") || message.includes("msgpack worker") || message.includes("msgpack stdin") || message.includes("msgpack stdout") || message.includes("jsonrpc reader") || message.includes("jsonrpc writer") || message.includes("jsonrpc connection");
|
|
@@ -1085,6 +1170,6 @@ function readFileOrUndefined(path) {
|
|
|
1085
1170
|
}
|
|
1086
1171
|
}
|
|
1087
1172
|
//#endregion
|
|
1088
|
-
export { CorsaProjectSession };
|
|
1173
|
+
export { CorsaProjectSession, uniqueClassDeclarationPosition };
|
|
1089
1174
|
|
|
1090
1175
|
//# sourceMappingURL=session.js.map
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#nodesById","#typeSourceById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#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 rememberTypeLookupFromType(\n type: CorsaType | undefined,\n relatedType: CorsaType | undefined,\n ): void {\n if (!type || !relatedType || type.id === relatedType.id) {\n return;\n }\n const lookup = this.#typeLookupById.get(relatedType.id);\n if (lookup && !this.#typeLookupById.has(type.id)) {\n this.#typeLookupById.set(type.id, lookup);\n }\n const source = this.#typeSourceById.get(relatedType.id);\n if (source && !this.#typeSourceById.has(type.id)) {\n this.#typeSourceById.set(type.id, source);\n }\n const symbolSearchRange = this.#symbolSearchRangeByTypeId.get(relatedType.id);\n if (symbolSearchRange && !this.#symbolSearchRangeByTypeId.has(type.id)) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n }\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n }\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,KAA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D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#classDeclarationByTypeId","#symbolSearchRangeByTypeId","#projects","#nodesById","#typeSourceById","#typeDeclarationFileById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype SourceRange = {\n start: number;\n end: number;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n /** Project that owns the file the type handle came from. */\n projectId?: string;\n sourceText?: string;\n symbolSearchRange?: SourceRange;\n};\n\nconst typeFlags = {\n object: 1 << 20,\n index: 1 << 21,\n templateLiteral: 1 << 22,\n stringMapping: 1 << 23,\n substitution: 1 << 24,\n indexedAccess: 1 << 25,\n conditional: 1 << 26,\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nconst objectFlags = {\n classOrInterface: (1 << 0) | (1 << 1),\n reference: 1 << 2,\n mapped: 1 << 5,\n} as const;\n\nexport class CorsaProjectSession {\n #client?: CorsaApiClient;\n #config?: { options: unknown; fileNames: string[] };\n #snapshot?: string;\n #projects: ProjectResponse[] = [];\n #files = new Map<string, FileCache>();\n #symbolsById = new Map<string, CorsaSymbol>();\n #symbolsByTypeId = new Map<string, CorsaSymbol | null>();\n #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #baseTypesById = new Map<string, readonly CorsaType[]>();\n #implementedTypesById = new Map<string, readonly CorsaType[]>();\n #ownImplementedTypesById = new Map<string, readonly CorsaType[]>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\n #typeDeclarationFileById = new Map<string, string>();\n #classDeclarationByTypeId = new Map<string, CorsaNode>();\n #symbolSearchRangeByTypeId = new Map<string, SourceRange>();\n #sourceLengthByPath = new Map<string, number>();\n #typeTextById = new Map<string, string>();\n #lastRefreshMs = 0;\n #snapshotHasIssuedHandles = false;\n #supportsOverlayChanges?: boolean;\n #fatalTransportError?: Error;\n\n constructor(\n readonly project: ResolvedProjectConfig,\n readonly runtime: ResolvedRuntimeOptions,\n ) {}\n\n close(): void {\n if (this.#snapshot) {\n this.tryReleaseHandle(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.tryCloseClient();\n this.#client = undefined;\n this.#supportsOverlayChanges = undefined;\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n }\n\n getCompilerOptions(): unknown {\n return this.withTransportRecovery(() => this.config().options, \"reading compiler options\");\n }\n\n getRootFileNames(): readonly string[] {\n return this.withTransportRecovery(() => this.config().fileNames, \"reading root file names\");\n }\n\n getTypeAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a type\",\n );\n }\n\n private getTypeAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaType | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.typeByPosition.has(position)) {\n state.typeByPosition.set(\n position,\n this.client().getTypeAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaType\n | undefined,\n );\n }\n const type = this.rememberType(state.typeByPosition.get(position));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position,\n projectId: state.projectId,\n sourceText,\n });\n }\n return type;\n }\n\n getTypeAtSourceRange(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n return this.withTransportRecovery(\n () => this.getTypeAtSourceRangeUnchecked(fileName, start, end, sourceText, kind),\n \"looking up a type\",\n );\n }\n\n private getTypeAtSourceRangeUnchecked(\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n kind: string | undefined,\n ): CorsaType | undefined {\n if (!sourceText || end <= start) {\n return this.getTypeAtPositionUnchecked(fileName, start, sourceText);\n }\n const state = this.fileState(fileName, sourceText);\n const key = `${start}:${end}:${kind ?? \"\"}`;\n if (!state.typeBySourceRange.has(key)) {\n state.typeBySourceRange.set(\n key,\n this.client().getTypeAtSourceRange(\n this.#snapshot!,\n state.projectId,\n fileName,\n start,\n end,\n sourceText,\n kind,\n ) as CorsaType | undefined,\n );\n }\n const type = this.rememberType(state.typeBySourceRange.get(key));\n if (type) {\n this.#typeLookupById.set(type.id, {\n fileName,\n position: start,\n projectId: state.projectId,\n sourceText,\n });\n if (kind !== \"Identifier\") {\n this.rememberTypeSourceRange(type, fileName, start, end, sourceText);\n }\n }\n return type;\n }\n\n getSymbolAtPosition(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolAtPositionUnchecked(fileName, position, sourceText),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolAtPositionUnchecked(\n fileName: string,\n position: number,\n sourceText?: string,\n ): CorsaSymbol | undefined {\n const state = this.fileState(fileName, sourceText);\n if (!state.symbolByPosition.has(position)) {\n state.symbolByPosition.set(\n position,\n this.client().getSymbolAtPosition(this.#snapshot!, state.projectId, fileName, position) as\n | CorsaSymbol\n | undefined,\n );\n }\n return this.rememberSymbol(state.symbolByPosition.get(position));\n }\n\n getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), \"looking up a symbol\");\n }\n\n private getSymbolUnchecked(symbol: string | CorsaSymbol): CorsaSymbol | undefined {\n if (typeof symbol !== \"string\") {\n return this.rememberSymbol(symbol);\n }\n const cached = this.#symbolsById.get(symbol);\n if (cached) {\n return cached;\n }\n const typeId = this.#symbolTypeById.get(symbol);\n if (!typeId || !this.#snapshot) {\n return undefined;\n }\n const resolved = this.getSymbolOfTypeById(typeId);\n return resolved?.id === symbol ? resolved : undefined;\n }\n\n getSymbolOfType(type: CorsaType): CorsaSymbol | undefined {\n return this.withTransportRecovery(\n () => this.getSymbolOfTypeUnchecked(type),\n \"looking up a symbol\",\n );\n }\n\n private getSymbolOfTypeUnchecked(type: CorsaType): CorsaSymbol | undefined {\n const cached = this.#symbolsByTypeId.get(type.id);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (symbol) {\n this.recoverDeclarationPositionsForSymbol(type, symbol);\n this.#symbolsByTypeId.set(type.id, symbol);\n return symbol;\n }\n const lookupSymbol = this.getSymbolOfTypeAtLookup(type);\n if (lookupSymbol) {\n this.#symbolsByTypeId.set(type.id, lookupSymbol);\n return lookupSymbol;\n }\n this.#symbolsByTypeId.set(type.id, null);\n return undefined;\n }\n\n /**\n * Runs the source-position lookup for a natively resolved symbol whose\n * declaration handles are compact TypeScript 7 handles without offsets.\n *\n * When the native `getSymbolOfType` lookup succeeds, the position-recovery\n * path in `getSymbolOfTypeAtLookup` no longer runs, yet it is what records\n * the class-declaration range and namespace search scope that disambiguate\n * same-named declarations. The native symbol stays the source of truth;\n * this only restores those positional caches.\n */\n private recoverDeclarationPositionsForSymbol(type: CorsaType, symbol: CorsaSymbol): void {\n if (this.#classDeclarationByTypeId.has(type.id)) {\n return;\n }\n const declarations = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n if (declarations.length === 0 || !declarations.every(isPositionlessNodeHandle)) {\n return;\n }\n if (!this.#typeLookupById.has(type.id)) {\n return;\n }\n this.getSymbolOfTypeAtLookup(type);\n }\n\n private getSymbolOfTypeAtLookup(type: CorsaType): CorsaSymbol | undefined {\n const lookup = this.#typeLookupById.get(type.id);\n if (!lookup) {\n return undefined;\n }\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n const texts = [...this.typeTexts(type)];\n if (isUsableSymbol(symbol)) {\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n }\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n let typeSymbolName = typeSymbolNameFromTexts(texts);\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n const typeSymbol = this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n if (typeSymbol) {\n return typeSymbol;\n }\n }\n if (isUsableSymbol(symbol)) {\n try {\n const rendered = this.typeToString(type);\n if (!texts.includes(rendered)) {\n texts.unshift(rendered);\n }\n } catch {\n // A stale handle may still have cached texts or a usable lookup symbol.\n }\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n typeSymbolName = typeSymbolNameFromTexts(texts);\n }\n if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {\n return this.getNearbyTypeSymbol(type, lookup, sourceText, typeSymbolName, texts);\n }\n return undefined;\n }\n\n private getNearbyTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n texts: readonly string[],\n ): CorsaSymbol | undefined {\n if (lookup.symbolSearchRange) {\n return this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.symbolSearchRange.start,\n lookup.symbolSearchRange.end,\n );\n }\n const nearbySymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n lookup.position,\n lookup.position + 512,\n );\n if (nearbySymbol) {\n return nearbySymbol;\n }\n for (const qualifiedName of qualifiedTypeNamesFromTexts(texts, typeSymbolName)) {\n const qualifiedSymbol = this.findQualifiedTypeSymbol(\n type,\n lookup,\n sourceText,\n qualifiedName,\n typeSymbolName,\n );\n if (qualifiedSymbol) {\n return qualifiedSymbol;\n }\n }\n return this.findUniqueTypeSymbol(type, lookup, sourceText, typeSymbolName);\n }\n\n /**\n * Anchors a qualified type text such as `Second.Base` on its qualifier, so a\n * same-named declaration under a different container cannot win the lookup.\n */\n private findQualifiedTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n qualifiedName: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n const qualifiers = qualifiedName.slice(0, -(typeSymbolName.length + 1)).split(\".\");\n const qualifier = qualifiers[qualifiers.length - 1];\n const containerRange = qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n if (containerRange) {\n const declarationSymbol = this.findMatchingTypeSymbol(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n containerRange.start,\n containerRange.end,\n );\n if (declarationSymbol) {\n return declarationSymbol;\n }\n }\n let offset = 0;\n while (offset < sourceText.length) {\n const start = sourceText.indexOf(qualifiedName, offset);\n if (start < 0) {\n return undefined;\n }\n const before = start > 0 ? sourceText[start - 1] : undefined;\n const after = sourceText[start + qualifiedName.length];\n // A leading `.` means the qualifier itself is nested under another\n // container, so this occurrence names a different type.\n if (before !== \".\" && !isIdentifierPart(before) && !isIdentifierPart(after)) {\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n start + qualifiedName.length - typeSymbolName.length,\n );\n if (symbol) {\n return symbol;\n }\n }\n offset = start + qualifiedName.length;\n }\n return undefined;\n }\n\n /**\n * Scans the whole file, but only accepts a match when every occurrence of the\n * name resolves to the same declaration. Returning the first same-named\n * symbol would otherwise cache the wrong nominal symbol, and the wrong\n * implemented interfaces, for any file that declares two types with the same\n * simple name in different scopes.\n */\n private findUniqueTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n let uniqueSymbol: CorsaSymbol | undefined;\n let uniqueKey: string | undefined;\n let offset = 0;\n while (offset < sourceText.length) {\n const position = findIdentifierPosition(\n sourceText,\n typeSymbolName,\n offset,\n sourceText.length,\n );\n if (position === undefined) {\n break;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n const key = symbolDeclarationKey(symbol);\n if (uniqueKey !== undefined && uniqueKey !== key) {\n return undefined;\n }\n uniqueSymbol ??= symbol;\n uniqueKey = key;\n }\n offset = position + typeSymbolName.length;\n }\n return uniqueSymbol;\n }\n\n private findMatchingTypeSymbol(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n start: number,\n end: number,\n ): CorsaSymbol | undefined {\n let offset = Math.max(0, start);\n const boundary = Math.min(sourceText.length, end);\n while (offset < boundary) {\n const position = findIdentifierPosition(sourceText, typeSymbolName, offset, boundary);\n if (position === undefined) {\n return undefined;\n }\n const symbol = this.getMatchingSymbolAtPosition(\n type,\n lookup,\n sourceText,\n typeSymbolName,\n position,\n );\n if (symbol) {\n return symbol;\n }\n offset = position + typeSymbolName.length;\n }\n return undefined;\n }\n\n private getMatchingSymbolAtPosition(\n type: CorsaType,\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n position: number | undefined,\n ): CorsaSymbol | undefined {\n if (position === undefined || position === lookup.position) {\n return undefined;\n }\n const typeSymbol = this.getSymbolAtPosition(lookup.fileName, position, lookup.sourceText);\n if (!isUsableSymbol(typeSymbol) || typeSymbol.name !== typeSymbolName) {\n return undefined;\n }\n const uniqueDeclaration = uniqueClassDeclarationPosition(sourceText, typeSymbolName);\n const classStart = classDeclarationStartAtIdentifier(sourceText, position) ?? uniqueDeclaration;\n if (classStart !== undefined) {\n this.#classDeclarationByTypeId.set(type.id, {\n fileName: lookup.fileName,\n pos: classStart,\n end: sourceText.length,\n range: [classStart, sourceText.length],\n });\n }\n const symbolSearchRange =\n uniqueDeclaration === undefined\n ? (qualifiedNamespaceRangeAtIdentifier(sourceText, position) ??\n containingNamespaceRange(sourceText, position))\n : containingNamespaceRange(sourceText, uniqueDeclaration);\n if (symbolSearchRange) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n if (uniqueDeclaration !== undefined) {\n this.#typeLookupById.set(type.id, { ...lookup, symbolSearchRange });\n }\n } else if (uniqueDeclaration !== undefined) {\n // A reference can live inside a namespace while resolving to a\n // top-level declaration. Do not let the reference scope leak into the\n // next base-type lookup.\n this.#symbolSearchRangeByTypeId.delete(type.id);\n const { symbolSearchRange: _symbolSearchRange, ...unscopedLookup } = lookup;\n this.#typeLookupById.set(type.id, unscopedLookup);\n }\n return typeSymbol;\n }\n\n private getSymbolOfTypeById(typeId: string): CorsaSymbol | undefined {\n if (!this.#snapshot || typeId.trim().length === 0) {\n return undefined;\n }\n try {\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(\n this.#snapshot,\n typeId,\n // Stable runtimes resolve object handles per project, so the lookup\n // must name the project that produced the type rather than the first\n // project in the snapshot.\n this.#typeLookupById.get(typeId)?.projectId ?? this.#projects[0]?.id,\n ) as CorsaSymbol | null,\n );\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return undefined;\n }\n throw error;\n }\n }\n\n getNode(node: string | CorsaNode): CorsaNode | undefined {\n if (typeof node !== \"string\") {\n return node;\n }\n return this.#nodesById.get(node) ?? this.rememberNode(node);\n }\n\n getSourceTextForPath(path: string): string | undefined {\n return this.sourceTextForPath(path);\n }\n\n getClassDeclarationForType(type: CorsaType): CorsaNode | undefined {\n return this.#classDeclarationByTypeId.get(type.id);\n }\n\n rememberTypeLookupFromType(\n type: CorsaType | undefined,\n relatedType: CorsaType | undefined,\n ): void {\n if (!type || !relatedType || type.id === relatedType.id) {\n return;\n }\n const lookup = this.#typeLookupById.get(relatedType.id);\n if (lookup && !this.#typeLookupById.has(type.id)) {\n this.#typeLookupById.set(type.id, lookup);\n }\n const source = this.#typeSourceById.get(relatedType.id);\n if (source && !this.#typeSourceById.has(type.id)) {\n this.#typeSourceById.set(type.id, source);\n }\n const declarationFile = this.#typeDeclarationFileById.get(relatedType.id);\n if (declarationFile && !this.#typeDeclarationFileById.has(type.id)) {\n this.#typeDeclarationFileById.set(type.id, declarationFile);\n }\n const symbolSearchRange = this.#symbolSearchRangeByTypeId.get(relatedType.id);\n if (symbolSearchRange && !this.#symbolSearchRangeByTypeId.has(type.id)) {\n this.#symbolSearchRangeByTypeId.set(type.id, symbolSearchRange);\n }\n }\n\n getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getTypeOfSymbol\"));\n }\n\n getDeclaredTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined {\n const type = this.rememberType(this.tryGetSymbolType(symbol, \"getDeclaredTypeOfSymbol\"));\n this.rememberTypeSource(type, symbol.valueDeclaration);\n return type;\n }\n\n getDeclaredTypeOfSymbolById(id: string): CorsaType | undefined {\n return this.rememberType(this.tryGetSymbolTypeId(id, \"getDeclaredTypeOfSymbol\"));\n }\n\n typeToString(type: CorsaType, flags?: number): string {\n try {\n const text = this.client().typeToString(\n this.#snapshot!,\n this.projectId(),\n type.id,\n undefined,\n flags,\n );\n if (flags === undefined) {\n this.#typeTextById.set(type.id, text);\n }\n return text;\n } catch (error) {\n const cached = flags === undefined ? this.#typeTextById.get(type.id) : undefined;\n if (cached !== undefined) {\n return cached;\n }\n throw error;\n }\n }\n\n getBaseTypeOfLiteralType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n ),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSymbol[]>(type, [], () =>\n this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\n return this.withMissingTypeHandleFallback<readonly CorsaSignature[]>(type, [], () => {\n const source = this.sourceContextForType(type);\n return this.rememberSignatures(\n this.client().callJson(\"getSignaturesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n }) ?? [],\n );\n });\n }\n\n private withMissingTypeHandleFallback<T>(type: CorsaType, fallback: T, operation: () => T): T {\n if (type.id.trim().length === 0) {\n return fallback;\n }\n try {\n return operation();\n } catch (error) {\n if (isMissingTypeHandleError(error)) {\n return fallback;\n }\n throw error;\n }\n }\n\n getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\n return this.withMissingTypeHandleFallback<CorsaCallSignatureFacts>(type, {}, () => {\n const source = this.sourceContextForType(type);\n const facts = this.client().callJson<CorsaCallSignatureFacts>(\"getCallSignatureFacts\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n kind,\n ...source,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n });\n if (facts?.signature) {\n this.rememberSignature(facts.signature);\n }\n return facts ?? {};\n });\n }\n\n getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson(\"getReturnTypeOfSignature\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n }),\n );\n }\n\n getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined {\n const predicate = this.client().callJson<CorsaTypePredicate | undefined>(\n \"getTypePredicateOfSignature\",\n {\n snapshot: this.#snapshot,\n project: this.projectId(),\n signature: signature.id,\n },\n );\n if (predicate?.type) {\n this.rememberType(predicate.type);\n }\n return predicate;\n }\n\n getBaseTypes(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) {\n return [];\n }\n const cached = this.#baseTypesById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n const relatedTypeLookup = lookup ? this.relatedTypeLookup(type, lookup) : undefined;\n const baseTypes = this.rememberTypes(\n this.client().callJson<readonly CorsaType[]>(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n for (const baseType of baseTypes) {\n this.cacheTypeText(baseType);\n if (relatedTypeLookup && !this.#typeLookupById.has(baseType.id)) {\n this.#typeLookupById.set(baseType.id, relatedTypeLookup);\n }\n }\n this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\n }\n\n private relatedTypeLookup(type: CorsaType, lookup: TypeLookup): TypeLookup {\n if (lookup.symbolSearchRange) {\n return lookup;\n }\n const rememberedRange = this.#symbolSearchRangeByTypeId.get(type.id);\n if (rememberedRange) {\n return { ...lookup, symbolSearchRange: rememberedRange };\n }\n const cachedSymbol = this.#symbolsByTypeId.get(type.id);\n const symbol =\n cachedSymbol === null ? undefined : (cachedSymbol ?? this.getSymbolOfTypeUnchecked(type));\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n if (!symbol || !sourceText) {\n return lookup;\n }\n const recoveredDeclaration = uniqueClassDeclarationPosition(sourceText, symbol.name);\n if (recoveredDeclaration !== undefined) {\n const recoveredRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, recoveredDeclaration) ??\n containingNamespaceRange(sourceText, recoveredDeclaration);\n if (recoveredRange) {\n return { ...lookup, symbolSearchRange: recoveredRange };\n }\n }\n const declarationHandles = [symbol.valueDeclaration, ...(symbol.declarations ?? [])].filter(\n (handle): handle is string => handle !== undefined,\n );\n for (const handle of declarationHandles) {\n const declaration = this.getNode(handle);\n if (!declaration || !pathsReferToSameFile(declaration.fileName, lookup.fileName)) {\n continue;\n }\n const symbolSearchRange =\n qualifiedBaseNamespaceRangeAtDeclaration(sourceText, declaration.pos) ??\n containingNamespaceRange(sourceText, declaration.pos);\n if (symbolSearchRange) {\n return { ...lookup, symbolSearchRange };\n }\n }\n return lookup;\n }\n\n getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#implementedTypesById.get(typeId);\n }\n\n cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#implementedTypesById.set(typeId, types);\n return types;\n }\n\n getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined {\n return this.#ownImplementedTypesById.get(typeId);\n }\n\n cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[] {\n this.#ownImplementedTypesById.set(typeId, types);\n return types;\n }\n\n getTypeArguments(type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () => {\n const source = this.sourceSliceForType(type);\n return this.rememberTypes(\n source\n ? (this.client().getTypeArgumentsAtSourceRange(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n source.node.fileName,\n source.node.pos,\n source.node.end,\n this.sourceTextForPath(source.node.fileName) ?? \"\",\n ) as unknown as readonly CorsaType[])\n : (this.client().getTypeArguments(\n this.#snapshot!,\n this.projectId(),\n type.id,\n type.objectFlags,\n ) as unknown as readonly CorsaType[]),\n );\n });\n }\n\n getTypesOfType(type: CorsaType): readonly CorsaType[] {\n if (\n (type.flags & (typeFlags.union | typeFlags.intersection | typeFlags.templateLiteral)) ===\n 0\n ) {\n return [];\n }\n return this.callTypeArray(\"getTypesOfType\", type);\n }\n\n getTargetOfType(type: CorsaType): CorsaType | undefined {\n if (\n (type.flags & (typeFlags.index | typeFlags.stringMapping)) === 0 &&\n ((type.objectFlags ?? 0) & (objectFlags.reference | objectFlags.mapped)) === 0\n ) {\n return undefined;\n }\n const target = this.callType(\"getTargetOfType\", type);\n this.cacheTypeText(target);\n return target;\n }\n\n getTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getTypeParametersOfType\", type);\n }\n\n getOuterTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getOuterTypeParametersOfType\", type);\n }\n\n getLocalTypeParametersOfType(type: CorsaType): readonly CorsaType[] {\n const flags = type.objectFlags ?? 0;\n if ((type.flags & typeFlags.object) === 0 || (flags & objectFlags.classOrInterface) === 0) {\n return [];\n }\n return this.callTypeArray(\"getLocalTypeParametersOfType\", type);\n }\n\n getObjectTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getObjectTypeOfType\", type)\n : undefined;\n }\n\n getIndexTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.indexedAccess) !== 0\n ? this.callType(\"getIndexTypeOfType\", type)\n : undefined;\n }\n\n getCheckTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getCheckTypeOfType\", type)\n : undefined;\n }\n\n getExtendsTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.conditional) !== 0\n ? this.callType(\"getExtendsTypeOfType\", type)\n : undefined;\n }\n\n getBaseTypeOfType(type: CorsaType): CorsaType | undefined {\n return (type.flags & typeFlags.substitution) !== 0\n ? this.callType(\"getBaseTypeOfType\", type)\n : undefined;\n }\n\n getConstraintOfType(type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n ),\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.withMissingTypeHandleFallback<CorsaType | undefined>(type, undefined, () =>\n this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n ),\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.withMissingTypeHandleFallback<readonly CorsaType[]>(type, [], () =>\n this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? [],\n ),\n );\n }\n\n private tryGetSymbolType(\n symbol: CorsaSymbol,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n return this.tryGetSymbolTypeId(symbol.id, method);\n }\n\n private tryGetSymbolTypeId(\n id: string,\n method: \"getTypeOfSymbol\" | \"getDeclaredTypeOfSymbol\",\n ): CorsaType | undefined {\n try {\n return this.client()[method](this.#snapshot!, this.projectId(), id) as CorsaType | undefined;\n } catch {\n return undefined;\n }\n }\n\n private sourceSliceForType(type: CorsaType): SourceSlice | undefined {\n const cached = this.#typeSourceById.get(type.id);\n if (cached) {\n return cached;\n }\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n const fromLookup = this.#typeSourceById.get(type.id);\n if (fromLookup) {\n return fromLookup;\n }\n }\n if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n this.rememberTypeSource(type, symbol?.valueDeclaration);\n }\n return this.#typeSourceById.get(type.id);\n }\n\n private rememberType<T extends CorsaType | undefined>(type: T): T {\n if (type) {\n normalizeType(type);\n this.#snapshotHasIssuedHandles = true;\n }\n if (type?.symbol) {\n this.#symbolTypeById.set(type.symbol, type.id);\n }\n if (type?.texts?.[0]) {\n this.#typeTextById.set(type.id, type.texts[0]);\n }\n return type;\n }\n\n private rememberTypes<T extends readonly CorsaType[]>(types: T): T {\n for (const type of types) {\n this.rememberType(type);\n }\n return types;\n }\n\n private rememberTypeSource(type: CorsaType | undefined, handle: string | undefined): void {\n if (!type || !handle || this.#typeSourceById.has(type.id)) {\n return;\n }\n const source = this.sourceSliceForHandle(handle);\n if (source) {\n this.#typeSourceById.set(type.id, source);\n return;\n }\n // A compact TypeScript 7 declaration handle carries no source range, but\n // its path still identifies the declaring file for file-scoped requests.\n const node = this.getNode(handle);\n if (node?.positionless) {\n this.#typeDeclarationFileById.set(type.id, node.fileName);\n }\n }\n\n private rememberTypeSourceRange(\n type: CorsaType,\n fileName: string,\n start: number,\n end: number,\n sourceText: string | undefined,\n ): void {\n if (\n this.#typeSourceById.has(type.id) ||\n !sourceText ||\n start < 0 ||\n end > sourceText.length ||\n start >= end\n ) {\n return;\n }\n const node = {\n fileName,\n pos: start,\n end,\n range: [start, end] as const,\n };\n this.#typeSourceById.set(type.id, {\n node,\n });\n }\n\n private cacheTypeText(type: CorsaType | undefined): void {\n if (!type || this.#typeTextById.has(type.id)) {\n return;\n }\n try {\n this.#typeTextById.set(\n type.id,\n this.client().typeToString(this.#snapshot!, this.projectId(), type.id),\n );\n } catch {\n // Some upstream handles are only renderable before a later relation query.\n }\n }\n\n private typeTexts(type: CorsaType): readonly string[] {\n if (Array.isArray(type.texts) && type.texts.length > 0) {\n return type.texts;\n }\n const cached = this.#typeTextById.get(type.id);\n return cached === undefined ? [] : [cached];\n }\n\n private sourceContextForType(type: CorsaType): { file?: string; sourceText?: string } {\n const lookup = this.#typeLookupById.get(type.id);\n if (lookup) {\n const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);\n return sourceText ? { file: lookup.fileName, sourceText } : {};\n }\n const source = this.#typeSourceById.get(type.id);\n if (source) {\n const sourceText = this.sourceTextForPath(source.node.fileName);\n return sourceText ? { file: source.node.fileName, sourceText } : {};\n }\n const declarationFile = this.#typeDeclarationFileById.get(type.id);\n if (declarationFile) {\n const sourceText = this.sourceTextForPath(declarationFile);\n return sourceText ? { file: declarationFile, sourceText } : {};\n }\n return {};\n }\n\n private rememberSymbol<T extends CorsaSymbol | undefined>(symbol: T): T {\n if (!symbol) {\n return symbol;\n }\n normalizeSymbol(symbol);\n this.#snapshotHasIssuedHandles = true;\n this.#symbolsById.set(symbol.id, symbol);\n return symbol;\n }\n\n private rememberUsableSymbol(symbol: CorsaSymbol | null | undefined): CorsaSymbol | undefined {\n return isUsableSymbol(symbol) ? this.rememberSymbol(symbol) : undefined;\n }\n\n private rememberSymbols<T extends readonly CorsaSymbol[]>(symbols: T): T {\n for (const symbol of symbols) {\n this.rememberSymbol(symbol);\n }\n return symbols;\n }\n\n private rememberSignatures<T extends readonly CorsaSignature[]>(signatures: T): T {\n for (const signature of signatures) {\n this.rememberSignature(signature);\n }\n return signatures;\n }\n\n private rememberSignature(signature: CorsaSignature): CorsaSignature {\n normalizeSignature(signature);\n if (signature.declaration) {\n this.rememberNode(signature.declaration);\n }\n for (const symbol of signature.parameterSymbols ?? []) {\n this.rememberSymbol(symbol);\n }\n if (signature.thisParameterSymbol) {\n this.rememberSymbol(signature.thisParameterSymbol);\n }\n return signature;\n }\n\n private rememberNode(handle: string): CorsaNode | undefined {\n const parsed = parseNodeHandle(handle, (fileName) => this.sourceLengthForPath(fileName));\n if (!parsed) {\n return undefined;\n }\n this.#nodesById.set(handle, parsed);\n return parsed;\n }\n\n private clearHandleCaches(): void {\n this.#symbolsById.clear();\n this.#symbolsByTypeId.clear();\n this.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#baseTypesById.clear();\n this.#implementedTypesById.clear();\n this.#ownImplementedTypesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#typeDeclarationFileById.clear();\n this.#classDeclarationByTypeId.clear();\n this.#symbolSearchRangeByTypeId.clear();\n this.#sourceLengthByPath.clear();\n this.#snapshotHasIssuedHandles = false;\n }\n\n private sourceLengthForPath(path: string): number | undefined {\n const cached = this.#sourceLengthByPath.get(path);\n if (cached !== undefined) {\n return cached;\n }\n const length = this.sourceTextForPath(path)?.length;\n if (length !== undefined) {\n this.#sourceLengthByPath.set(path, length);\n }\n return length;\n }\n\n private sourceSliceForHandle(handle: string): SourceSlice | undefined {\n const node = this.getNode(handle);\n // A compact TypeScript 7 handle carries a node id and a syntax kind instead\n // of source offsets, so its parsed range must never become a source range.\n if (!node || node.positionless) {\n return undefined;\n }\n const sourceText = this.sourceTextForPath(node.fileName);\n if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) {\n return undefined;\n }\n return {\n node,\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n const direct = this.#files.get(path);\n if (direct) {\n return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);\n }\n for (const [fileName, cached] of this.#files) {\n if (pathsReferToSameFile(fileName, path)) {\n return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);\n }\n }\n return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);\n }\n\n private withTransportRecovery<T>(operation: () => T, action: string): T {\n if (this.#fatalTransportError) {\n throw this.#fatalTransportError;\n }\n try {\n return operation();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n this.resetClientAfterTransportFailure();\n try {\n return operation();\n } catch (retryError) {\n if (!isRecoverableTransportError(retryError)) {\n throw retryError;\n }\n const fatal = new Error(\n `corsa type-aware backend exited while ${action}; restarted the session, but the retry failed`,\n );\n (fatal as Error & { cause?: unknown }).cause = retryError;\n this.#fatalTransportError = fatal;\n throw fatal;\n }\n }\n }\n\n private resetClientAfterTransportFailure(): void {\n this.tryCloseClient();\n this.#client = undefined;\n this.#config = undefined;\n this.#snapshot = undefined;\n this.#projects = [];\n this.#files.clear();\n this.clearHandleCaches();\n this.#typeTextById.clear();\n this.#lastRefreshMs = 0;\n this.#supportsOverlayChanges = undefined;\n this.#fatalTransportError = undefined;\n }\n\n private tryReleaseHandle(handle: string): void {\n try {\n this.#client?.releaseHandle(handle);\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private tryCloseClient(): void {\n try {\n this.#client?.close();\n } catch (error) {\n if (!isRecoverableTransportError(error)) {\n throw error;\n }\n }\n }\n\n private client(): CorsaApiClient {\n if (!this.#client) {\n this.#client = CorsaApiClient.spawn({\n executable: this.runtime.executable,\n cwd: this.runtime.cwd,\n mode: this.runtime.mode,\n });\n this.#client.initialize();\n }\n return this.#client;\n }\n\n private config(): { options: unknown; fileNames: string[] } {\n if (!this.#config) {\n this.#config = this.client().parseConfigFile(this.project.configPath);\n }\n const config = this.#config;\n if (!config) {\n throw new Error(`corsa oxlint could not parse a Corsa config for ${this.project.configPath}`);\n }\n return config;\n }\n\n private fileState(fileName: string, sourceText?: string): FileCache {\n const prepared = this.refreshIfNeeded(fileName, sourceText);\n const current = this.#files.get(fileName);\n if (current) {\n return current;\n }\n const project = this.client().callJson<ProjectResponse | null>(\"getDefaultProjectForFile\", {\n snapshot: this.#snapshot,\n file: fileName,\n });\n const state: FileCache = {\n mtimeMs: prepared.mtimeMs,\n lintSourceText: prepared.lintSourceText,\n sourceText: prepared.sourceText,\n projectId: project?.id ?? this.projectId(),\n typeByPosition: new Map(),\n typeBySourceRange: new Map(),\n symbolByPosition: new Map(),\n };\n this.#files.set(fileName, state);\n return state;\n }\n\n private refreshIfNeeded(fileName: string, sourceText?: string): PreparedFileState {\n const now = Date.now();\n const expired = now - this.#lastRefreshMs > this.runtime.cacheLifetimeMs;\n const cached = this.#files.get(fileName);\n const mtimeMs = statMtimeMs(fileName);\n const overlayText = this.supportedOverlayText(fileName, sourceText, mtimeMs, cached);\n const mtimeChanged = cached !== undefined && mtimeMs !== cached.mtimeMs;\n const textChanged = overlayText !== cached?.sourceText;\n const prepared = {\n mtimeMs,\n lintSourceText: sourceText,\n sourceText: overlayText,\n };\n const stale =\n !this.#snapshot ||\n mtimeChanged ||\n textChanged ||\n (expired && !this.#snapshotHasIssuedHandles);\n if (!stale) {\n return prepared;\n }\n const previous = this.#snapshot;\n const overlayChanges = this.overlayChanges(fileName, overlayText, cached);\n const response = this.client().updateSnapshot({\n ...(previous\n ? { fileChanges: { changed: [fileName] } }\n : { openProject: this.project.configPath }),\n ...(overlayChanges === undefined ? {} : { overlayChanges }),\n });\n this.#snapshot = response.snapshot;\n this.#projects = response.projects;\n this.#lastRefreshMs = now;\n this.#files.clear();\n this.clearHandleCaches();\n if (previous && previous !== this.#snapshot) {\n this.tryReleaseHandle(previous);\n }\n return prepared;\n }\n\n private projectId(): string {\n const id = this.#projects[0]?.id;\n if (!id) {\n throw new Error(\n `corsa oxlint could not resolve a Corsa project for ${this.project.filename}`,\n );\n }\n return id;\n }\n\n private supportedOverlayText(\n fileName: string,\n sourceText: string | undefined,\n mtimeMs: number,\n cached?: FileCache,\n ): string | undefined {\n if (sourceText === undefined || !this.supportsOverlayChanges()) {\n return undefined;\n }\n if (cached?.lintSourceText === sourceText && cached.mtimeMs === mtimeMs) {\n return cached.sourceText;\n }\n return overlayTextFor(fileName, sourceText);\n }\n\n private overlayChanges(\n fileName: string,\n overlayText: string | undefined,\n cached?: FileCache,\n ):\n | {\n upsert?: { document: string; text: string; languageId: string }[];\n delete?: string[];\n }\n | undefined {\n if (!this.supportsOverlayChanges()) {\n return undefined;\n }\n if (overlayText !== undefined) {\n return {\n upsert: [\n {\n document: fileName,\n text: overlayText,\n languageId: languageIdFor(fileName),\n },\n ],\n };\n }\n if (cached?.sourceText !== undefined) {\n return { delete: [fileName] };\n }\n return undefined;\n }\n\n private supportsOverlayChanges(): boolean {\n if (this.#supportsOverlayChanges !== undefined) {\n return this.#supportsOverlayChanges;\n }\n try {\n const capabilities = this.client().callJson<{\n overlay?: { updateSnapshotOverlayChanges?: boolean };\n }>(\"describeCapabilities\");\n this.#supportsOverlayChanges = capabilities?.overlay?.updateSnapshotOverlayChanges === true;\n } catch {\n this.#supportsOverlayChanges = false;\n }\n return this.#supportsOverlayChanges;\n }\n}\n\nfunction isArrayOrTupleLikeType(session: CorsaProjectSession, type: CorsaType): boolean {\n const texts =\n Array.isArray(type.texts) && type.texts.length > 0 ? type.texts : [session.typeToString(type)];\n return texts.some((text) => {\n const normalized = text.trimStart();\n return (\n normalized.startsWith(\"readonly [\") || normalized.startsWith(\"[\") || normalized.endsWith(\"[]\")\n );\n });\n}\n\nfunction isUsableSymbol(symbol: CorsaSymbol | null | undefined): symbol is CorsaSymbol {\n return symbol != null && !symbol.name.includes(\"\\ufffd\");\n}\n\nfunction isSyntheticTypeHandle(handle: string): boolean {\n return handle.startsWith(\"synthetic-\");\n}\n\nfunction typeSymbolNameFromTexts(texts: readonly string[]): string | undefined {\n for (const text of texts) {\n const match =\n /^(?:typeof\\s+)?(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)*([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)(?:\\s*<|$)/u.exec(\n text.trim(),\n );\n if (match?.[1]) {\n return match[1];\n }\n }\n return undefined;\n}\n\n/**\n * Collects the qualified spellings of `typeSymbolName` (such as `Second.Base`)\n * carried by a type's rendered texts. These keep the container context that\n * `typeSymbolNameFromTexts` drops.\n */\nfunction qualifiedTypeNamesFromTexts(\n texts: readonly string[],\n typeSymbolName: string,\n): readonly string[] {\n const qualifiedNames: string[] = [];\n for (const text of texts) {\n const rendered = text.trim().replace(/^typeof\\s+/u, \"\");\n const typeArgumentStart = rendered.indexOf(\"<\");\n const withoutTypeArguments =\n typeArgumentStart < 0 ? rendered : rendered.slice(0, typeArgumentStart);\n const name = withoutTypeArguments.trimEnd();\n if (name.endsWith(`.${typeSymbolName}`) && !qualifiedNames.includes(name)) {\n qualifiedNames.push(name);\n }\n }\n return qualifiedNames;\n}\n\n/**\n * Identifies a symbol by its declaration handle, which encodes a source range\n * and therefore stays comparable across separate lookups, unlike the opaque\n * symbol handle.\n */\nfunction symbolDeclarationKey(symbol: CorsaSymbol): string {\n return symbol.valueDeclaration ?? symbol.declarations[0] ?? symbol.id;\n}\n\nfunction classDeclarationStartAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): number | undefined {\n const prefixStart = Math.max(0, identifierPosition - 128);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /\\bclass\\s*$/u.exec(prefix);\n return match ? prefixStart + match.index : undefined;\n}\n\n/**\n * Returns the offset of the only `class <className>` declaration in the source,\n * or `undefined` when the file has none or more than one.\n *\n * Matches inside comments and string literals are ignored, so text such as\n * `// class Descendant` neither shadows nor duplicates a real declaration.\n */\nexport function uniqueClassDeclarationPosition(\n sourceText: string,\n className: string,\n): number | undefined {\n const escapedName = className.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\bclass\\\\s+${escapedName}\\\\b`, \"gu\");\n const codePositions = codePositionMask(sourceText);\n let unique: number | undefined;\n for (\n let declaration = declarationPattern.exec(sourceText);\n declaration;\n declaration = declarationPattern.exec(sourceText)\n ) {\n if (codePositions[declaration.index] !== 1) {\n continue;\n }\n if (unique !== undefined) {\n return undefined;\n }\n unique = declaration.index;\n }\n return unique;\n}\n\n/**\n * Marks each offset that is executable code rather than comment or string\n * literal content, using the same scanner as the namespace range helpers.\n */\nfunction codePositionMask(sourceText: string): Uint8Array {\n const mask = new Uint8Array(sourceText.length);\n const scanner = createSourceScanner();\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n mask[index] = 1;\n }\n return mask;\n}\n\nfunction qualifiedNamespaceRangeAtIdentifier(\n sourceText: string,\n identifierPosition: number,\n): SourceRange | undefined {\n const prefixStart = Math.max(0, identifierPosition - 256);\n const prefix = sourceText.slice(prefixStart, identifierPosition);\n const match = /([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)\\s*\\.\\s*$/u.exec(prefix);\n return match?.[1] ? namespaceRangeByName(sourceText, match[1]) : undefined;\n}\n\nfunction qualifiedBaseNamespaceRangeAtDeclaration(\n sourceText: string,\n declarationPosition: number,\n): SourceRange | undefined {\n const headerEnd = sourceText.indexOf(\"{\", declarationPosition);\n const header = sourceText.slice(\n declarationPosition,\n headerEnd < 0 ? declarationPosition + 512 : headerEnd,\n );\n const match =\n /\\bextends\\s+(?:[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*\\.)+([$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}]*)/u.exec(\n header,\n );\n if (!match) {\n return undefined;\n }\n const qualifiedBase = match[0].slice(\"extends\".length).trim();\n const qualifiers = qualifiedBase.split(\".\");\n const qualifier = qualifiers[qualifiers.length - 2];\n return qualifier ? namespaceRangeByName(sourceText, qualifier) : undefined;\n}\n\nfunction namespaceRangeByName(sourceText: string, name: string): SourceRange | undefined {\n const escapedName = name.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const declarationPattern = new RegExp(`\\\\b(?:namespace|module)\\\\s+${escapedName}\\\\s*\\\\{`, \"gu\");\n const declaration = declarationPattern.exec(sourceText);\n if (!declaration) {\n return undefined;\n }\n const open = declaration.index + declaration[0].lastIndexOf(\"{\");\n const scanner = createSourceScanner();\n let depth = 1;\n for (let index = open + 1; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n if (sourceText[index] === \"{\") {\n depth += 1;\n } else if (sourceText[index] === \"}\") {\n depth -= 1;\n if (depth === 0) {\n return { start: open + 1, end: index };\n }\n }\n }\n return undefined;\n}\n\nfunction containingNamespaceRange(sourceText: string, position: number): SourceRange | undefined {\n const scanner = createSourceScanner();\n const blocks: { start: number; namespace: boolean }[] = [];\n let pendingNamespace = false;\n let innermost: SourceRange | undefined;\n for (let index = 0; index < sourceText.length; index += 1) {\n const nextIndex = scanner.skip(sourceText, index);\n if (nextIndex > index) {\n index = nextIndex - 1;\n continue;\n }\n const char = sourceText[index];\n if (isIdentifierStart(char)) {\n let end = index + 1;\n while (isIdentifierPart(sourceText[end])) {\n end += 1;\n }\n const identifier = sourceText.slice(index, end);\n if (identifier === \"namespace\" || identifier === \"module\") {\n pendingNamespace = true;\n }\n index = end - 1;\n continue;\n }\n if (char === \"{\") {\n blocks.push({ start: index + 1, namespace: pendingNamespace });\n pendingNamespace = false;\n continue;\n }\n if (char === \"}\") {\n const block = blocks.pop();\n if (\n block?.namespace &&\n block.start <= position &&\n position < index &&\n (!innermost || block.start >= innermost.start)\n ) {\n innermost = { start: block.start, end: index };\n }\n continue;\n }\n if (pendingNamespace && (char === \";\" || char === \"=\")) {\n pendingNamespace = false;\n }\n }\n return innermost;\n}\n\nfunction createSourceScanner(): {\n skip(text: string, index: number): number;\n} {\n let quote: string | undefined;\n let escaped = false;\n let inLineComment = false;\n let inBlockComment = false;\n return {\n skip(text, index) {\n const char = text[index];\n const next = text[index + 1];\n if (inLineComment) {\n if (char === \"\\n\" || char === \"\\r\") {\n inLineComment = false;\n }\n return index + 1;\n }\n if (inBlockComment) {\n if (char === \"*\" && next === \"/\") {\n inBlockComment = false;\n return index + 2;\n }\n return index + 1;\n }\n if (quote) {\n if (escaped) {\n escaped = false;\n } else if (char === \"\\\\\") {\n escaped = true;\n } else if (char === quote) {\n quote = undefined;\n }\n return index + 1;\n }\n if (char === \"/\" && next === \"/\") {\n inLineComment = true;\n return index + 2;\n }\n if (char === \"/\" && next === \"*\") {\n inBlockComment = true;\n return index + 2;\n }\n if (char === '\"' || char === \"'\" || char === \"`\") {\n quote = char;\n return index + 1;\n }\n return index;\n },\n };\n}\n\nfunction isIdentifierStart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\p{ID_Start}]/u.test(char);\n}\n\nfunction findIdentifierPosition(\n sourceText: string,\n identifier: string,\n start: number,\n end: number,\n): number | undefined {\n const boundedEnd = Math.min(sourceText.length, end);\n let position = sourceText.indexOf(identifier, Math.max(0, start));\n while (position >= 0 && position < boundedEnd) {\n const before = position > 0 ? sourceText[position - 1] : undefined;\n const after = sourceText[position + identifier.length];\n if (!isIdentifierPart(before) && !isIdentifierPart(after)) {\n return position;\n }\n position = sourceText.indexOf(identifier, position + identifier.length);\n }\n return undefined;\n}\n\nfunction isIdentifierPart(char: string | undefined): boolean {\n return char !== undefined && /[$_\\u200c\\u200d\\p{ID_Continue}]/u.test(char);\n}\n\nfunction pathsReferToSameFile(left: string, right: string): boolean {\n const normalizedLeft = left.replaceAll(\"\\\\\", \"/\").toLowerCase();\n const normalizedRight = right.replaceAll(\"\\\\\", \"/\").toLowerCase();\n return (\n normalizedLeft === normalizedRight ||\n normalizedLeft.endsWith(`/${normalizedRight}`) ||\n normalizedRight.endsWith(`/${normalizedLeft}`)\n );\n}\n\nfunction normalizeType(type: CorsaType): void {\n const mutable = type as {\n id: string;\n symbol?: string;\n };\n mutable.id = handleString((type as { id: unknown }).id);\n const symbol = (type as { symbol?: unknown }).symbol;\n if (symbol != null) {\n mutable.symbol = handleString(symbol);\n }\n}\n\nfunction normalizeSymbol(symbol: CorsaSymbol): void {\n const mutable = symbol as unknown as {\n id: string;\n declarations?: string[];\n valueDeclaration?: string;\n };\n mutable.id = handleString((symbol as { id: unknown }).id);\n const declarations = (symbol as { declarations?: readonly unknown[] }).declarations;\n if (Array.isArray(declarations)) {\n mutable.declarations = declarations.map(handleString);\n }\n const valueDeclaration = (symbol as { valueDeclaration?: unknown }).valueDeclaration;\n if (valueDeclaration != null) {\n mutable.valueDeclaration = handleString(valueDeclaration);\n }\n}\n\nfunction normalizeSignature(signature: CorsaSignature): void {\n const mutable = signature as unknown as {\n id: string;\n declaration?: string;\n typeParameters?: string[];\n parameters?: string[];\n thisParameter?: string;\n target?: string;\n };\n mutable.id = handleString((signature as { id: unknown }).id);\n const declaration = (signature as { declaration?: unknown }).declaration;\n if (declaration != null) {\n mutable.declaration = handleString(declaration);\n }\n const typeParameters = (signature as { typeParameters?: readonly unknown[] }).typeParameters;\n if (Array.isArray(typeParameters)) {\n mutable.typeParameters = typeParameters.map(handleString);\n }\n const parameters = (signature as { parameters?: readonly unknown[] }).parameters;\n if (Array.isArray(parameters)) {\n mutable.parameters = parameters.map(handleString);\n }\n const thisParameter = (signature as { thisParameter?: unknown }).thisParameter;\n if (thisParameter != null) {\n mutable.thisParameter = handleString(thisParameter);\n }\n const target = (signature as { target?: unknown }).target;\n if (target != null) {\n mutable.target = handleString(target);\n }\n}\n\nfunction handleString(value: unknown): string {\n return typeof value === \"string\" ? value : String(value);\n}\n\nfunction overlayTextFor(fileName: string, sourceText?: string): string | undefined {\n if (sourceText === undefined) {\n return undefined;\n }\n try {\n return readFileSync(fileName, \"utf8\") === sourceText ? undefined : sourceText;\n } catch {\n return sourceText;\n }\n}\n\nfunction statMtimeMs(fileName: string): number {\n try {\n return statSync(fileName).mtimeMs;\n } catch {\n return 0;\n }\n}\n\nfunction languageIdFor(fileName: string): string {\n if (fileName.endsWith(\".tsx\")) {\n return \"typescriptreact\";\n }\n if (fileName.endsWith(\".jsx\")) {\n return \"javascriptreact\";\n }\n if (fileName.endsWith(\".js\")) {\n return \"javascript\";\n }\n return \"typescript\";\n}\n\nfunction parseNodeHandle(\n value: string,\n sourceLengthForPath: (fileName: string) => number | undefined,\n): CorsaNode | undefined {\n const [posText, secondText, thirdText, ...remainingParts] = value.split(\".\");\n const pos = Number(posText);\n const second = Number(secondText);\n if (!Number.isFinite(pos) || !Number.isFinite(second)) {\n return undefined;\n }\n const hasEndPosition = isFiniteNumberText(thirdText);\n const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(\".\");\n if (!fileName) {\n return undefined;\n }\n const end = hasEndPosition ? second : (sourceLengthForPath(fileName) ?? pos + 1);\n if (end < pos) {\n return undefined;\n }\n if (!hasEndPosition) {\n // Compact TypeScript 7 handle: `<node id>.<syntax kind>.<path>`. The\n // parsed numbers identify the node but are not source offsets.\n return { id: value, fileName, pos, end, range: [pos, end], positionless: true };\n }\n return { id: value, fileName, pos, end, range: [pos, end] };\n}\n\n/**\n * Reports whether a node handle uses the compact TypeScript 7 wire format\n * `<node id>.<syntax kind>.<path>`, which carries no source offsets.\n */\nfunction isPositionlessNodeHandle(value: string): boolean {\n const [posText, secondText, thirdText] = value.split(\".\");\n return (\n isFiniteNumberText(posText) && isFiniteNumberText(secondText) && !isFiniteNumberText(thirdText)\n );\n}\n\nfunction isFiniteNumberText(text: string | undefined): boolean {\n return text !== undefined && text !== \"\" && Number.isFinite(Number(text));\n}\n\nfunction isRecoverableTransportError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"process is closed:\") ||\n message.includes(\"Broken pipe\") ||\n message.includes(\"EPIPE\") ||\n message.includes(\"failed to fill whole buffer\") ||\n message.includes(\"msgpack worker\") ||\n message.includes(\"msgpack stdin\") ||\n message.includes(\"msgpack stdout\") ||\n message.includes(\"jsonrpc reader\") ||\n message.includes(\"jsonrpc writer\") ||\n message.includes(\"jsonrpc connection\")\n );\n}\n\nfunction isMissingTypeHandleError(error: unknown): boolean {\n const message = errorMessage(error);\n return (\n message.includes(\"not found in snapshot registry\") || message.includes(\"empty type handle\")\n );\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction readFileOrUndefined(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;AAgDA,MAAM,YAAY;CAChB,QAAQ,KAAK;CACb,OAAO,KAAK;CACZ,iBAAiB,KAAK;CACtB,eAAe,KAAK;CACpB,cAAc,KAAK;CACnB,eAAe,KAAK;CACpB,aAAa,KAAK;CAClB,OAAO,KAAK;CACZ,cAAc,KAAK;AACrB;AAEA,MAAM,cAAc;CAClB,kBAAkB;CAClB,WAAW;CACX,QAAQ;AACV;AAEA,IAAa,sBAAb,MAAiC;CA0BpB;CACA;CA1BX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,mCAAmB,IAAI,IAAgC;CACvD,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;CACxC,iCAAiB,IAAI,IAAkC;CACvD,wCAAwB,IAAI,IAAkC;CAC9D,2CAA2B,IAAI,IAAkC;CACjE,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,2CAA2B,IAAI,IAAoB;CACnD,4CAA4B,IAAI,IAAuB;CACvD,6CAA6B,IAAI,IAAyB;CAC1D,sCAAsB,IAAI,IAAoB;CAC9C,gCAAgB,IAAI,IAAoB;CACxC,iBAAiB;CACjB,4BAA4B;CAC5B;CACA;CAEA,YACE,SACA,SACA;EAFS,KAAA,UAAA;EACA,KAAA,UAAA;CACR;CAEH,QAAc;EACZ,IAAI,KAAKA,WAAW;GAClB,KAAK,iBAAiB,KAAKA,SAAS;GACpC,KAAKA,YAAY,KAAA;EACnB;EACA,KAAK,eAAe;EACpB,KAAKC,UAAU,KAAA;EACf,KAAKC,0B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AC,KAAK,GAAG;CAAE;AAC5D;;;;;AAMA,SAAS,yBAAyB,OAAwB;CACxD,MAAM,CAAC,SAAS,YAAY,aAAa,MAAM,MAAM,GAAG;CACxD,OACE,mBAAmB,OAAO,KAAK,mBAAmB,UAAU,KAAK,CAAC,mBAAmB,SAAS;AAElG;AAEA,SAAS,mBAAmB,MAAmC;CAC7D,OAAO,SAAS,KAAA,KAAa,SAAS,MAAM,OAAO,SAAS,OAAO,IAAI,CAAC;AAC1E;AAEA,SAAS,4BAA4B,OAAyB;CAC5D,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,aAAa,KAC9B,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,yBAAyB,OAAyB;CACzD,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,gCAAgC,KAAK,QAAQ,SAAS,mBAAmB;AAE9F;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ interface CorsaNode {
|
|
|
42
42
|
readonly pos: number;
|
|
43
43
|
readonly end: number;
|
|
44
44
|
readonly range: readonly [number, number];
|
|
45
|
+
/**
|
|
46
|
+
* Set when the node was parsed from a compact TypeScript 7 declaration
|
|
47
|
+
* handle, whose leading number is a node id rather than a source offset. The
|
|
48
|
+
* range of such a node cannot anchor source-text scans.
|
|
49
|
+
*/
|
|
50
|
+
readonly positionless?: boolean;
|
|
45
51
|
}
|
|
46
52
|
interface CorsaSymbol {
|
|
47
53
|
readonly id: string;
|
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 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":";
|
|
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 * Set when the node was parsed from a compact TypeScript 7 declaration\n * handle, whose leading number is a node id rather than a source offset. The\n * range of such a node cannot anchor source-text scans.\n */\n readonly positionless?: boolean;\n}\n\nexport interface CorsaSymbol {\n readonly id: string;\n readonly name: string;\n readonly flags: number;\n readonly checkFlags: number;\n readonly declarations: readonly string[];\n readonly valueDeclaration?: string;\n}\n\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":";AAwFA,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.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Type-aware Oxlint helpers powered by Corsa",
|
|
5
5
|
"homepage": "https://github.com/ubugeeei-prod/corsa-bind/tree/main/src/bindings/nodejs/corsa_oxlint",
|
|
6
6
|
"bugs": {
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"./package.json": "./package.json"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@corsa-bind/napi": "1.
|
|
98
|
+
"@corsa-bind/napi": "1.7.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@oxlint/plugins": "1.76.0",
|