corsa-oxlint 1.0.0-beta.4 → 1.1.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 +82 -7
- package/dist/checker.js.map +1 -1
- package/dist/session.d.ts +6 -0
- package/dist/session.js +116 -27
- package/dist/session.js.map +1 -1
- package/package.json +2 -2
package/dist/checker.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createNodeMaps, toPosition } from "./node_map.js";
|
|
|
2
2
|
import { sessionForContext } from "./registry.js";
|
|
3
3
|
import "./types.js";
|
|
4
4
|
//#region src/bindings/nodejs/corsa_oxlint/ts/checker.ts
|
|
5
|
+
const implementingClassNamesBySession = /* @__PURE__ */ new WeakMap();
|
|
5
6
|
function createProgram(context) {
|
|
6
7
|
return {
|
|
7
8
|
nodeMaps: createNodeMaps(context),
|
|
@@ -30,7 +31,9 @@ function createTypeChecker(context) {
|
|
|
30
31
|
getTypeAtLocation(node) {
|
|
31
32
|
if (node.type === "NewExpression") return typeOfNewExpression(node, this);
|
|
32
33
|
const lookupNode = nodeForTypeLookup(node);
|
|
33
|
-
|
|
34
|
+
const type = sessionForContext(context).session.getTypeAtSourceRange(filenameFor(context, lookupNode), toPosition(lookupNode), endPosition(lookupNode), sourceTextFor(context, lookupNode), nodeKind(lookupNode));
|
|
35
|
+
primeImplementedTypesCacheFromNode(context, node, type, this);
|
|
36
|
+
return type;
|
|
34
37
|
},
|
|
35
38
|
getContextualType(node) {
|
|
36
39
|
return this.getTypeAtLocation(node);
|
|
@@ -154,6 +157,14 @@ function createTypeChecker(context) {
|
|
|
154
157
|
}
|
|
155
158
|
};
|
|
156
159
|
}
|
|
160
|
+
function primeImplementedTypesCacheFromNode(context, node, type, checker) {
|
|
161
|
+
if (!type || "pos" in node) return;
|
|
162
|
+
const kind = node.type;
|
|
163
|
+
if (kind !== "ClassDeclaration" && kind !== "ClassExpression") return;
|
|
164
|
+
const session = sessionForContext(context).session;
|
|
165
|
+
if (session.getCachedOwnImplementedTypes(type.id)) return;
|
|
166
|
+
session.cacheOwnImplementedTypes(type.id, checker.getImplementedTypes(node));
|
|
167
|
+
}
|
|
157
168
|
const typeFlags = {
|
|
158
169
|
union: 1 << 27,
|
|
159
170
|
intersection: 1 << 28
|
|
@@ -162,9 +173,12 @@ function sourceTextFor(context, node) {
|
|
|
162
173
|
return sourceTextForPath(context, filenameFor(context, node));
|
|
163
174
|
}
|
|
164
175
|
function sourceTextForPath(context, fileName) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
return pathsReferToSameFile(fileName, context.filename) ? context.sourceCode.text : sessionForContext(context).session.getSourceTextForPath(fileName);
|
|
177
|
+
}
|
|
178
|
+
function pathsReferToSameFile(left, right) {
|
|
179
|
+
const normalizedLeft = left.replaceAll("\\", "/").toLowerCase();
|
|
180
|
+
const normalizedRight = right.replaceAll("\\", "/").toLowerCase();
|
|
181
|
+
return normalizedLeft === normalizedRight || normalizedLeft.endsWith(`/${normalizedRight}`) || normalizedRight.endsWith(`/${normalizedLeft}`);
|
|
168
182
|
}
|
|
169
183
|
function typeOfNewExpression(node, checker) {
|
|
170
184
|
const callee = childNode(node, "callee");
|
|
@@ -231,6 +245,9 @@ function corsaNodeFromEstree(context, node) {
|
|
|
231
245
|
};
|
|
232
246
|
}
|
|
233
247
|
function implementedTypesFromTypeAndBases(context, type, checker) {
|
|
248
|
+
const session = sessionForContext(context).session;
|
|
249
|
+
const cached = session.getCachedImplementedTypes(type.id);
|
|
250
|
+
if (cached) return cached;
|
|
234
251
|
const seenTypes = /* @__PURE__ */ new Set();
|
|
235
252
|
const seenImplementedTypes = /* @__PURE__ */ new Set();
|
|
236
253
|
const implemented = [];
|
|
@@ -253,15 +270,73 @@ function implementedTypesFromTypeAndBases(context, type, checker) {
|
|
|
253
270
|
stack.push(baseType);
|
|
254
271
|
}
|
|
255
272
|
}
|
|
256
|
-
return implemented;
|
|
273
|
+
return session.cacheImplementedTypes(type.id, implemented);
|
|
257
274
|
}
|
|
258
275
|
function implementedTypesFromTypeDeclaration(context, type, checker) {
|
|
259
276
|
const session = sessionForContext(context).session;
|
|
277
|
+
const cached = session.getCachedOwnImplementedTypes(type.id);
|
|
278
|
+
if (cached) return cached;
|
|
260
279
|
const symbol = type.symbol ? session.getSymbol(type.symbol) : void 0;
|
|
261
280
|
const declaration = symbol?.valueDeclaration ?? symbol?.declarations?.[0];
|
|
262
281
|
const declarationNode = declaration ? session.getNode(declaration) : void 0;
|
|
263
|
-
const
|
|
264
|
-
|
|
282
|
+
const resolvedDeclarationNode = (declarationNode && pathsReferToSameFile(declarationNode.fileName, context.filename) ? implementingClassDeclaration(context, type, symbol) : void 0) ?? declarationNode ?? implementingClassDeclaration(context, type, symbol);
|
|
283
|
+
const sourceText = resolvedDeclarationNode ? sourceTextForPath(context, resolvedDeclarationNode.fileName) : void 0;
|
|
284
|
+
const implemented = resolvedDeclarationNode && sourceText ? implementedTypesFromSourceText(context, resolvedDeclarationNode, sourceText, checker) : [];
|
|
285
|
+
return session.cacheOwnImplementedTypes(type.id, implemented);
|
|
286
|
+
}
|
|
287
|
+
function implementingClassDeclaration(context, type, symbol) {
|
|
288
|
+
const name = implementingClassName(type, symbol);
|
|
289
|
+
if (!name) return;
|
|
290
|
+
const range = implementingClassDeclarations(context).get(name);
|
|
291
|
+
return range ? {
|
|
292
|
+
fileName: context.filename,
|
|
293
|
+
pos: range[0],
|
|
294
|
+
end: range[1],
|
|
295
|
+
range
|
|
296
|
+
} : void 0;
|
|
297
|
+
}
|
|
298
|
+
function implementingClassName(type, symbol) {
|
|
299
|
+
return symbol?.name || typeSymbolName(type.texts ?? []);
|
|
300
|
+
}
|
|
301
|
+
function typeSymbolName(texts) {
|
|
302
|
+
for (const text of texts) {
|
|
303
|
+
const match = /^(?:typeof\s+)?(?:[$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}]*\.)*([$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}]*)(?:\s*<|$)/u.exec(text.trim());
|
|
304
|
+
if (match?.[1]) return match[1];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function implementingClassDeclarations(context) {
|
|
308
|
+
const session = sessionForContext(context).session;
|
|
309
|
+
let byFile = implementingClassNamesBySession.get(session);
|
|
310
|
+
if (!byFile) {
|
|
311
|
+
byFile = /* @__PURE__ */ new Map();
|
|
312
|
+
implementingClassNamesBySession.set(session, byFile);
|
|
313
|
+
}
|
|
314
|
+
const sourceText = context.sourceCode.text;
|
|
315
|
+
const cached = byFile.get(context.filename);
|
|
316
|
+
if (cached?.sourceText === sourceText) return cached.declarations;
|
|
317
|
+
const declarations = collectImplementingClassDeclarations(sourceText);
|
|
318
|
+
byFile.set(context.filename, {
|
|
319
|
+
sourceText,
|
|
320
|
+
declarations
|
|
321
|
+
});
|
|
322
|
+
return declarations;
|
|
323
|
+
}
|
|
324
|
+
function collectImplementingClassDeclarations(sourceText) {
|
|
325
|
+
const declarations = /* @__PURE__ */ new Map();
|
|
326
|
+
let offset = 0;
|
|
327
|
+
while (offset < sourceText.length) {
|
|
328
|
+
const classOffset = findKeywordOutsideTrivia(sourceText.slice(offset), "class");
|
|
329
|
+
if (classOffset < 0) break;
|
|
330
|
+
const declarationStart = offset + classOffset + 5;
|
|
331
|
+
const rest = sourceText.slice(declarationStart);
|
|
332
|
+
const match = /^\s*([$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}]*)/u.exec(rest);
|
|
333
|
+
if (match?.[1]) {
|
|
334
|
+
const bodyOpen = findClassBodyOpen(rest, 0);
|
|
335
|
+
if (findKeywordOutsideTrivia(rest.slice(0, bodyOpen >= 0 ? bodyOpen : rest.length), "implements") >= 0) declarations.set(match[1], [offset + classOffset, sourceText.length]);
|
|
336
|
+
}
|
|
337
|
+
offset = declarationStart;
|
|
338
|
+
}
|
|
339
|
+
return declarations;
|
|
265
340
|
}
|
|
266
341
|
function implementedTypesFromSourceText(context, node, sourceText, checker) {
|
|
267
342
|
if (node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) 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 { SignatureKind } from \"./types\";\nimport type {\n ContextWithParserOptions,\n CorsaNode,\n CorsaProgramShape,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypeCheckerShape,\n} from \"./types\";\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): CorsaProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getTypeAtSourceRange(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n endPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n nodeKind(lookupNode),\n );\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\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 const normalizedFileName = fileName.toLowerCase();\n const normalizedContextFilename = context.filename.toLowerCase();\n return normalizedFileName === normalizedContextFilename ||\n normalizedFileName.endsWith(normalizedContextFilename) ||\n normalizedContextFilename.endsWith(normalizedFileName)\n ? context.sourceCode.text\n : sessionForContext(context).session.getSourceTextForPath(fileName);\n}\n\nfunction typeOfNewExpression(node: Node, checker: CorsaTypeCheckerShape): CorsaType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, SignatureKind.Construct)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | CorsaNode): Node | CorsaNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction endPosition(node: Node | CorsaNode): number {\n if (\"end\" in node) {\n return node.end;\n }\n const range = (node as Node & { readonly range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range[1];\n}\n\nfunction nodeKind(node: Node | CorsaNode): string | undefined {\n return \"pos\" in node ? undefined : (node as { readonly type?: string }).type;\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | CorsaNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromCorsaNode(\n context: ContextWithParserOptions,\n node: CorsaNode,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n return implementedTypesFromSourceText(context, node, sourceText, checker);\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction corsaNodeFromEstree(context: ContextWithParserOptions, node: Node): CorsaNode | undefined {\n const range = (node as { readonly range?: unknown }).range;\n if (\n !Array.isArray(range) ||\n range.length < 2 ||\n typeof range[0] !== \"number\" ||\n typeof range[1] !== \"number\"\n ) {\n return undefined;\n }\n return {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range: [range[0], range[1]] as const,\n };\n}\n\nfunction implementedTypesFromTypeAndBases(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n // 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 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 symbol = 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 sourceText = declarationNode\n ? sourceTextForPath(context, declarationNode.fileName)\n : undefined;\n return declarationNode && sourceText\n ? implementedTypesFromSourceText(context, declarationNode, sourceText, checker)\n : [];\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":";;;;AAeA,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,OAEvB;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,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"}
|
|
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 ImplementingClassCache = {\n readonly sourceText: string;\n readonly declarations: ReadonlyMap<string, readonly [start: number, end: number]>;\n};\n\nconst implementingClassNamesBySession = new WeakMap<\n CorsaProjectSession,\n Map<string, ImplementingClassCache>\n>();\n\nexport function createProgram(\n context: ContextWithParserOptions,\n): CorsaProgramShape & { readonly nodeMaps: ReturnType<typeof createNodeMaps> } {\n const nodeMaps = createNodeMaps(context);\n return {\n nodeMaps,\n getCompilerOptions() {\n return sessionForContext(context).session.getCompilerOptions();\n },\n getCurrentDirectory() {\n return sessionForContext(context).project.rootDir;\n },\n getRootFileNames() {\n return sessionForContext(context).session.getRootFileNames();\n },\n getSourceFile(fileName = context.filename) {\n return { fileName, text: context.sourceCode.text };\n },\n getTypeChecker() {\n return createTypeChecker(context);\n },\n };\n}\n\nexport function createTypeChecker(context: ContextWithParserOptions): CorsaTypeCheckerShape {\n return {\n getTypeAtLocation(node) {\n if ((node as { readonly type?: string }).type === \"NewExpression\") {\n return typeOfNewExpression(node as Node, this);\n }\n const lookupNode = nodeForTypeLookup(node);\n const type = sessionForContext(context).session.getTypeAtSourceRange(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n endPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n nodeKind(lookupNode),\n );\n primeImplementedTypesCacheFromNode(context, node, type, this);\n return type;\n },\n getContextualType(node) {\n return this.getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n const lookupNode = nodeForTypeLookup(node);\n return sessionForContext(context).session.getSymbolAtPosition(\n filenameFor(context, lookupNode),\n toPosition(lookupNode),\n sourceTextFor(context, lookupNode),\n );\n },\n getSymbol(symbol) {\n return sessionForContext(context).session.getSymbol(symbol);\n },\n getSymbolById(id) {\n return sessionForContext(context).session.getSymbol(id);\n },\n getSymbolOfType(type) {\n return sessionForContext(context).session.getSymbolOfType(type);\n },\n getNode(node) {\n return sessionForContext(context).session.getNode(node);\n },\n getNodeById(id) {\n return sessionForContext(context).session.getNode(id);\n },\n getTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getTypeOfSymbol(symbol);\n },\n getTypeOfSymbolById(id) {\n return sessionForContext(context).session.getTypeOfSymbolById(id);\n },\n getDeclaredTypeOfSymbol(symbol) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbol(symbol);\n },\n getDeclaredTypeOfSymbolById(id) {\n return sessionForContext(context).session.getDeclaredTypeOfSymbolById(id);\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol) ??\n this.getTypeAtLocation(node)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n void enclosingDeclaration;\n return sessionForContext(context).session.typeToString(type, flags);\n },\n getBaseTypeOfLiteralType(type) {\n return sessionForContext(context).session.getBaseTypeOfLiteralType(type);\n },\n getPropertiesOfType(type) {\n return sessionForContext(context).session.getPropertiesOfType(type);\n },\n getSignaturesOfType(type, kind) {\n return sessionForContext(context).session.getSignaturesOfType(type, kind);\n },\n getCallSignatureFacts(type, kind, argumentTypeTexts, explicitTypeArgumentTexts) {\n return sessionForContext(context).session.getCallSignatureFacts(\n type,\n kind,\n argumentTypeTexts,\n explicitTypeArgumentTexts,\n );\n },\n getReturnTypeOfSignature(signature) {\n return sessionForContext(context).session.getReturnTypeOfSignature(signature);\n },\n getTypePredicateOfSignature(signature) {\n return sessionForContext(context).session.getTypePredicateOfSignature(signature);\n },\n getBaseTypes(type) {\n return sessionForContext(context).session.getBaseTypes(type);\n },\n getImplementedTypes(node) {\n if (\"pos\" in node) {\n return implementedTypesFromCorsaNode(context, node, this);\n }\n const sourceText = sourceTextFor(context, node);\n const sourceNode = sourceText ? corsaNodeFromEstree(context, node) : undefined;\n if (sourceText && sourceNode) {\n const implemented = implementedTypesFromSourceText(context, sourceNode, sourceText, this);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n return implementedClauseNodes(node)\n .map((clause) => {\n const expression = implementedClauseChildNode(clause, \"expression\") ?? clause;\n const symbol = this.getSymbolAtLocation(expression) ?? this.getSymbolAtLocation(clause);\n return symbol\n ? (this.getDeclaredTypeOfSymbol(symbol) ?? this.getTypeOfSymbol(symbol))\n : (this.getTypeAtLocation(expression) ?? this.getTypeAtLocation(clause));\n })\n .filter((type): type is CorsaType => type !== undefined);\n },\n getImplementedTypesOfType(type) {\n return implementedTypesFromTypeAndBases(context, type, this);\n },\n getTypeArguments(type) {\n return sessionForContext(context).session.getTypeArguments(type);\n },\n getTypesOfType(type) {\n return sessionForContext(context).session.getTypesOfType(type);\n },\n getTargetOfType(type) {\n return sessionForContext(context).session.getTargetOfType(type);\n },\n getTypeParametersOfType(type) {\n return sessionForContext(context).session.getTypeParametersOfType(type);\n },\n getOuterTypeParametersOfType(type) {\n return sessionForContext(context).session.getOuterTypeParametersOfType(type);\n },\n getLocalTypeParametersOfType(type) {\n return sessionForContext(context).session.getLocalTypeParametersOfType(type);\n },\n getObjectTypeOfType(type) {\n return sessionForContext(context).session.getObjectTypeOfType(type);\n },\n getIndexTypeOfType(type) {\n return sessionForContext(context).session.getIndexTypeOfType(type);\n },\n getCheckTypeOfType(type) {\n return sessionForContext(context).session.getCheckTypeOfType(type);\n },\n getExtendsTypeOfType(type) {\n return sessionForContext(context).session.getExtendsTypeOfType(type);\n },\n getBaseTypeOfType(type) {\n return sessionForContext(context).session.getBaseTypeOfType(type);\n },\n getConstraintOfType(type) {\n return sessionForContext(context).session.getConstraintOfType(type);\n },\n isUnionType(type) {\n return (type.flags & typeFlags.union) !== 0;\n },\n isIntersectionType(type) {\n return (type.flags & typeFlags.intersection) !== 0;\n },\n };\n}\n\nfunction primeImplementedTypesCacheFromNode(\n context: ContextWithParserOptions,\n node: Node | CorsaNode,\n type: CorsaType | undefined,\n checker: CorsaTypeCheckerShape,\n): void {\n if (!type || \"pos\" in node) {\n return;\n }\n const kind = (node as { readonly type?: string }).type;\n if (kind !== \"ClassDeclaration\" && kind !== \"ClassExpression\") {\n return;\n }\n const session = sessionForContext(context).session;\n if (session.getCachedOwnImplementedTypes(type.id)) {\n return;\n }\n session.cacheOwnImplementedTypes(type.id, checker.getImplementedTypes(node));\n}\n\nconst typeFlags = {\n union: 1 << 27,\n intersection: 1 << 28,\n} as const;\n\nfunction sourceTextFor(\n context: ContextWithParserOptions,\n node: Node | CorsaNode | CorsaType | CorsaSymbol | CorsaSignature,\n): string | undefined {\n return sourceTextForPath(context, filenameFor(context, node));\n}\n\nfunction sourceTextForPath(\n context: ContextWithParserOptions,\n fileName: string,\n): string | undefined {\n return pathsReferToSameFile(fileName, context.filename)\n ? context.sourceCode.text\n : sessionForContext(context).session.getSourceTextForPath(fileName);\n}\n\nfunction pathsReferToSameFile(left: string, right: string): boolean {\n const normalizedLeft = left.replaceAll(\"\\\\\", \"/\").toLowerCase();\n const normalizedRight = right.replaceAll(\"\\\\\", \"/\").toLowerCase();\n return (\n normalizedLeft === normalizedRight ||\n normalizedLeft.endsWith(`/${normalizedRight}`) ||\n normalizedRight.endsWith(`/${normalizedLeft}`)\n );\n}\n\nfunction typeOfNewExpression(node: Node, checker: CorsaTypeCheckerShape): CorsaType | undefined {\n const callee = childNode(node, \"callee\");\n if (!callee) {\n return undefined;\n }\n const calleeType = checker.getTypeAtLocation(callee);\n if (!calleeType) {\n return undefined;\n }\n const constructSignature = checker.getSignaturesOfType(calleeType, SignatureKind.Construct)[0];\n return constructSignature\n ? (checker.getReturnTypeOfSignature(constructSignature) ?? calleeType)\n : calleeType;\n}\n\nfunction nodeForTypeLookup(node: Node | CorsaNode): Node | CorsaNode {\n if (\"pos\" in node) {\n return node;\n }\n switch ((node as { readonly type?: string }).type) {\n case \"ClassDeclaration\":\n case \"ClassExpression\":\n return childNode(node, \"id\") ?? node;\n case \"TSPropertySignature\":\n return childNode(node, \"key\") ?? node;\n default:\n return node;\n }\n}\n\nfunction endPosition(node: Node | CorsaNode): number {\n if (\"end\" in node) {\n return node.end;\n }\n const range = (node as Node & { readonly range?: readonly [number, number] }).range;\n if (!range) {\n throw new Error(\"corsa oxlint requires ESTree nodes with range data\");\n }\n return range[1];\n}\n\nfunction nodeKind(node: Node | CorsaNode): string | undefined {\n return \"pos\" in node ? undefined : (node as { readonly type?: string }).type;\n}\n\nfunction childNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedClauseNodes(node: Node | CorsaNode): readonly Node[] {\n if (\"pos\" in node) {\n return [];\n }\n const clauses = (node as unknown as { readonly implements?: unknown }).implements;\n if (!Array.isArray(clauses)) {\n return [];\n }\n return clauses.filter(isNode);\n}\n\nfunction implementedClauseChildNode(node: Node, key: string): Node | undefined {\n const value = (node as unknown as Record<string, unknown>)[key];\n if (isNode(value)) {\n return value;\n }\n return undefined;\n}\n\nfunction implementedTypesFromCorsaNode(\n context: ContextWithParserOptions,\n node: CorsaNode,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const symbol = checker.getSymbolAtLocation(node);\n if (symbol) {\n const declaredType = checker.getDeclaredTypeOfSymbol(symbol) ?? checker.getTypeOfSymbol(symbol);\n if (declaredType) {\n const implemented = checker.getImplementedTypesOfType(declaredType);\n if (implemented.length > 0) {\n return implemented;\n }\n }\n }\n const sourceText = sourceTextFor(context, node);\n if (sourceText) {\n return implementedTypesFromSourceText(context, node, sourceText, checker);\n }\n const type = checker.getTypeAtLocation(node);\n return type ? checker.getImplementedTypesOfType(type) : [];\n}\n\nfunction corsaNodeFromEstree(context: ContextWithParserOptions, node: Node): CorsaNode | undefined {\n const range = (node as { readonly range?: unknown }).range;\n if (\n !Array.isArray(range) ||\n range.length < 2 ||\n typeof range[0] !== \"number\" ||\n typeof range[1] !== \"number\"\n ) {\n return undefined;\n }\n return {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range: [range[0], range[1]] as const,\n };\n}\n\nfunction implementedTypesFromTypeAndBases(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n // Iterative DFS over the base chain so we don't pay for one closure call\n // and one `push(...subResult)` spread per base (each spread used to copy\n // the entire growing accumulator). Visit order doesn't matter because we\n // dedupe by `type.id`.\n const seenTypes = new Set<string>();\n const seenImplementedTypes = new Set<string>();\n const implemented: CorsaType[] = [];\n const stack: CorsaType[] = [type];\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (seenTypes.has(current.id)) {\n continue;\n }\n seenTypes.add(current.id);\n\n const ownImplemented = implementedTypesFromTypeDeclaration(context, current, checker);\n for (let index = 0; index < ownImplemented.length; index += 1) {\n const ownType = ownImplemented[index]!;\n if (seenImplementedTypes.has(ownType.id)) {\n continue;\n }\n seenImplementedTypes.add(ownType.id);\n implemented.push(ownType);\n }\n\n const bases = checker.getBaseTypes(current);\n // Push in reverse so the natural visit order matches the recursive form.\n for (let index = bases.length - 1; index >= 0; index -= 1) {\n const baseType = bases[index]!;\n if (seenTypes.has(baseType.id)) {\n continue;\n }\n stack.push(baseType);\n }\n }\n return session.cacheImplementedTypes(type.id, implemented);\n}\n\nfunction implementedTypesFromTypeDeclaration(\n context: ContextWithParserOptions,\n type: CorsaType,\n checker: CorsaTypeCheckerShape,\n): readonly CorsaType[] {\n const session = sessionForContext(context).session;\n const cached = session.getCachedOwnImplementedTypes(type.id);\n if (cached) {\n return cached;\n }\n const symbol = 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 localImplementingDeclaration =\n declarationNode && pathsReferToSameFile(declarationNode.fileName, context.filename)\n ? implementingClassDeclaration(context, type, symbol)\n : undefined;\n const resolvedDeclarationNode =\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): CorsaNode | undefined {\n const name = implementingClassName(type, symbol);\n if (!name) {\n return undefined;\n }\n const range = implementingClassDeclarations(context).get(name);\n return range\n ? {\n fileName: context.filename,\n pos: range[0],\n end: range[1],\n range,\n }\n : undefined;\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): ReadonlyMap<string, readonly [start: number, end: number]> {\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(\n sourceText: string,\n): ReadonlyMap<string, readonly [start: number, end: number]> {\n const declarations = new Map<string, readonly [start: number, end: number]>();\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 bodyOpen = findClassBodyOpen(rest, 0);\n const header = rest.slice(0, bodyOpen >= 0 ? bodyOpen : rest.length);\n if (findKeywordOutsideTrivia(header, \"implements\") >= 0) {\n declarations.set(match[1], [offset + classOffset, sourceText.length]);\n }\n }\n offset = declarationStart;\n }\n return declarations;\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":";;;;AAqBA,MAAM,kDAAkC,IAAI,QAG1C;AAEF,SAAgB,cACd,SAC8E;CAE9E,OAAO;EACL,UAFe,eAAe,OAEvB;EACP,qBAAqB;GACnB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,mBAAmB;EAC/D;EACA,sBAAsB;GACpB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ;EAC5C;EACA,mBAAmB;GACjB,OAAO,kBAAkB,OAAO,CAAC,CAAC,QAAQ,iBAAiB;EAC7D;EACA,cAAc,WAAW,QAAQ,UAAU;GACzC,OAAO;IAAE;IAAU,MAAM,QAAQ,WAAW;GAAK;EACnD;EACA,iBAAiB;GACf,OAAO,kBAAkB,OAAO;EAClC;CACF;AACF;AAEA,SAAgB,kBAAkB,SAA0D;CAC1F,OAAO;EACL,kBAAkB,MAAM;GACtB,IAAK,KAAoC,SAAS,iBA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AO,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/session.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare class CorsaProjectSession {
|
|
|
20
20
|
getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;
|
|
21
21
|
private getSymbolOfTypeUnchecked;
|
|
22
22
|
private getSymbolOfTypeAtLookup;
|
|
23
|
+
private getNearbyTypeSymbol;
|
|
23
24
|
private getSymbolOfTypeById;
|
|
24
25
|
getNode(node: string | CorsaNode): CorsaNode | undefined;
|
|
25
26
|
getSourceTextForPath(path: string): string | undefined;
|
|
@@ -36,6 +37,10 @@ declare class CorsaProjectSession {
|
|
|
36
37
|
getReturnTypeOfSignature(signature: CorsaSignature): CorsaType | undefined;
|
|
37
38
|
getTypePredicateOfSignature(signature: CorsaSignature): CorsaTypePredicate | undefined;
|
|
38
39
|
getBaseTypes(type: CorsaType): readonly CorsaType[];
|
|
40
|
+
getCachedImplementedTypes(typeId: string): readonly CorsaType[] | undefined;
|
|
41
|
+
cacheImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[];
|
|
42
|
+
getCachedOwnImplementedTypes(typeId: string): readonly CorsaType[] | undefined;
|
|
43
|
+
cacheOwnImplementedTypes(typeId: string, types: readonly CorsaType[]): readonly CorsaType[];
|
|
39
44
|
getTypeArguments(type: CorsaType): readonly CorsaType[];
|
|
40
45
|
getTypesOfType(type: CorsaType): readonly CorsaType[];
|
|
41
46
|
getTargetOfType(type: CorsaType): CorsaType | undefined;
|
|
@@ -67,6 +72,7 @@ declare class CorsaProjectSession {
|
|
|
67
72
|
private rememberSignature;
|
|
68
73
|
private rememberNode;
|
|
69
74
|
private clearHandleCaches;
|
|
75
|
+
private sourceLengthForPath;
|
|
70
76
|
private sourceSliceForHandle;
|
|
71
77
|
private sourceTextForPath;
|
|
72
78
|
private withTransportRecovery;
|
package/dist/session.js
CHANGED
|
@@ -26,10 +26,15 @@ var CorsaProjectSession = class {
|
|
|
26
26
|
#projects = [];
|
|
27
27
|
#files = /* @__PURE__ */ new Map();
|
|
28
28
|
#symbolsById = /* @__PURE__ */ new Map();
|
|
29
|
+
#symbolsByTypeId = /* @__PURE__ */ new Map();
|
|
29
30
|
#symbolTypeById = /* @__PURE__ */ new Map();
|
|
30
31
|
#nodesById = /* @__PURE__ */ new Map();
|
|
32
|
+
#baseTypesById = /* @__PURE__ */ new Map();
|
|
33
|
+
#implementedTypesById = /* @__PURE__ */ new Map();
|
|
34
|
+
#ownImplementedTypesById = /* @__PURE__ */ new Map();
|
|
31
35
|
#typeLookupById = /* @__PURE__ */ new Map();
|
|
32
36
|
#typeSourceById = /* @__PURE__ */ new Map();
|
|
37
|
+
#sourceLengthByPath = /* @__PURE__ */ new Map();
|
|
33
38
|
#typeTextById = /* @__PURE__ */ new Map();
|
|
34
39
|
#lastRefreshMs = 0;
|
|
35
40
|
#snapshotHasIssuedHandles = false;
|
|
@@ -114,25 +119,56 @@ var CorsaProjectSession = class {
|
|
|
114
119
|
return this.withTransportRecovery(() => this.getSymbolOfTypeUnchecked(type), "looking up a symbol");
|
|
115
120
|
}
|
|
116
121
|
getSymbolOfTypeUnchecked(type) {
|
|
122
|
+
const cached = this.#symbolsByTypeId.get(type.id);
|
|
123
|
+
if (cached !== void 0) return cached ?? void 0;
|
|
117
124
|
if (type.symbol) {
|
|
118
125
|
const symbol = this.getSymbol(type.symbol);
|
|
119
|
-
if (isUsableSymbol(symbol))
|
|
126
|
+
if (isUsableSymbol(symbol)) {
|
|
127
|
+
this.#symbolsByTypeId.set(type.id, symbol);
|
|
128
|
+
return symbol;
|
|
129
|
+
}
|
|
120
130
|
}
|
|
121
131
|
const symbol = this.getSymbolOfTypeById(type.id);
|
|
122
|
-
if (symbol)
|
|
123
|
-
|
|
132
|
+
if (symbol) {
|
|
133
|
+
this.#symbolsByTypeId.set(type.id, symbol);
|
|
134
|
+
return symbol;
|
|
135
|
+
}
|
|
136
|
+
const lookupSymbol = this.getSymbolOfTypeAtLookup(type);
|
|
137
|
+
if (lookupSymbol) {
|
|
138
|
+
this.#symbolsByTypeId.set(type.id, lookupSymbol);
|
|
139
|
+
return lookupSymbol;
|
|
140
|
+
}
|
|
141
|
+
this.#symbolsByTypeId.set(type.id, null);
|
|
124
142
|
}
|
|
125
143
|
getSymbolOfTypeAtLookup(type) {
|
|
126
144
|
const lookup = this.#typeLookupById.get(type.id);
|
|
127
145
|
if (!lookup) return;
|
|
128
146
|
const symbol = this.getSymbolAtPosition(lookup.fileName, lookup.position, lookup.sourceText);
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
const texts = [...this.typeTexts(type)];
|
|
148
|
+
if (isUsableSymbol(symbol)) {
|
|
149
|
+
if (texts.some((text) => text.trim() === symbol.name)) return symbol;
|
|
150
|
+
}
|
|
151
|
+
const sourceText = lookup.sourceText ?? this.sourceTextForPath(lookup.fileName);
|
|
152
|
+
let typeSymbolName = typeSymbolNameFromTexts(texts);
|
|
153
|
+
if (isUsableSymbol(symbol) && sourceText && typeSymbolName) {
|
|
154
|
+
const typeSymbol = this.getNearbyTypeSymbol(lookup, sourceText, typeSymbolName);
|
|
155
|
+
if (typeSymbol) return typeSymbol;
|
|
135
156
|
}
|
|
157
|
+
if (isUsableSymbol(symbol)) {
|
|
158
|
+
try {
|
|
159
|
+
const rendered = this.typeToString(type);
|
|
160
|
+
if (!texts.includes(rendered)) texts.unshift(rendered);
|
|
161
|
+
} catch {}
|
|
162
|
+
if (texts.some((text) => text.trim() === symbol.name)) return symbol;
|
|
163
|
+
typeSymbolName = typeSymbolNameFromTexts(texts);
|
|
164
|
+
}
|
|
165
|
+
if (isUsableSymbol(symbol) && sourceText && typeSymbolName) return this.getNearbyTypeSymbol(lookup, sourceText, typeSymbolName);
|
|
166
|
+
}
|
|
167
|
+
getNearbyTypeSymbol(lookup, sourceText, typeSymbolName) {
|
|
168
|
+
const typePosition = findIdentifierPosition(sourceText, typeSymbolName, lookup.position, lookup.position + 512);
|
|
169
|
+
if (typePosition === void 0 || typePosition === lookup.position) return;
|
|
170
|
+
const typeSymbol = this.getSymbolAtPosition(lookup.fileName, typePosition, lookup.sourceText);
|
|
171
|
+
return isUsableSymbol(typeSymbol) && typeSymbol.name === typeSymbolName ? typeSymbol : void 0;
|
|
136
172
|
}
|
|
137
173
|
getSymbolOfTypeById(typeId) {
|
|
138
174
|
if (!this.#snapshot || typeId.trim().length === 0) return;
|
|
@@ -247,14 +283,32 @@ var CorsaProjectSession = class {
|
|
|
247
283
|
getBaseTypes(type) {
|
|
248
284
|
return this.withMissingTypeHandleFallback(type, [], () => {
|
|
249
285
|
if (isSyntheticTypeHandle(type.id) || isArrayOrTupleLikeType(this, type)) return [];
|
|
250
|
-
|
|
286
|
+
const cached = this.#baseTypesById.get(type.id);
|
|
287
|
+
if (cached) return cached;
|
|
288
|
+
const baseTypes = this.rememberTypes(this.client().callJson("getBaseTypes", {
|
|
251
289
|
snapshot: this.#snapshot,
|
|
252
290
|
project: this.projectId(),
|
|
253
291
|
type: type.id,
|
|
254
292
|
texts: this.typeTexts(type)
|
|
255
293
|
}) ?? []);
|
|
294
|
+
this.#baseTypesById.set(type.id, baseTypes);
|
|
295
|
+
return baseTypes;
|
|
256
296
|
});
|
|
257
297
|
}
|
|
298
|
+
getCachedImplementedTypes(typeId) {
|
|
299
|
+
return this.#implementedTypesById.get(typeId);
|
|
300
|
+
}
|
|
301
|
+
cacheImplementedTypes(typeId, types) {
|
|
302
|
+
this.#implementedTypesById.set(typeId, types);
|
|
303
|
+
return types;
|
|
304
|
+
}
|
|
305
|
+
getCachedOwnImplementedTypes(typeId) {
|
|
306
|
+
return this.#ownImplementedTypesById.get(typeId);
|
|
307
|
+
}
|
|
308
|
+
cacheOwnImplementedTypes(typeId, types) {
|
|
309
|
+
this.#ownImplementedTypesById.set(typeId, types);
|
|
310
|
+
return types;
|
|
311
|
+
}
|
|
258
312
|
getTypeArguments(type) {
|
|
259
313
|
return this.withMissingTypeHandleFallback(type, [], () => {
|
|
260
314
|
const source = this.sourceSliceForType(type);
|
|
@@ -368,10 +422,7 @@ var CorsaProjectSession = class {
|
|
|
368
422
|
end,
|
|
369
423
|
range: [start, end]
|
|
370
424
|
};
|
|
371
|
-
this.#typeSourceById.set(type.id, {
|
|
372
|
-
node,
|
|
373
|
-
text: sourceText.slice(start, end)
|
|
374
|
-
});
|
|
425
|
+
this.#typeSourceById.set(type.id, { node });
|
|
375
426
|
}
|
|
376
427
|
cacheTypeText(type) {
|
|
377
428
|
if (!type || this.#typeTextById.has(type.id)) return;
|
|
@@ -408,8 +459,6 @@ var CorsaProjectSession = class {
|
|
|
408
459
|
normalizeSymbol(symbol);
|
|
409
460
|
this.#snapshotHasIssuedHandles = true;
|
|
410
461
|
this.#symbolsById.set(symbol.id, symbol);
|
|
411
|
-
for (const declaration of symbol.declarations ?? []) this.rememberNode(declaration);
|
|
412
|
-
if (symbol.valueDeclaration) this.rememberNode(symbol.valueDeclaration);
|
|
413
462
|
return symbol;
|
|
414
463
|
}
|
|
415
464
|
rememberUsableSymbol(symbol) {
|
|
@@ -431,31 +480,42 @@ var CorsaProjectSession = class {
|
|
|
431
480
|
return signature;
|
|
432
481
|
}
|
|
433
482
|
rememberNode(handle) {
|
|
434
|
-
const parsed = parseNodeHandle(handle);
|
|
483
|
+
const parsed = parseNodeHandle(handle, (fileName) => this.sourceLengthForPath(fileName));
|
|
435
484
|
if (!parsed) return;
|
|
436
485
|
this.#nodesById.set(handle, parsed);
|
|
437
486
|
return parsed;
|
|
438
487
|
}
|
|
439
488
|
clearHandleCaches() {
|
|
440
489
|
this.#symbolsById.clear();
|
|
490
|
+
this.#symbolsByTypeId.clear();
|
|
441
491
|
this.#symbolTypeById.clear();
|
|
442
492
|
this.#nodesById.clear();
|
|
493
|
+
this.#baseTypesById.clear();
|
|
494
|
+
this.#implementedTypesById.clear();
|
|
495
|
+
this.#ownImplementedTypesById.clear();
|
|
443
496
|
this.#typeLookupById.clear();
|
|
444
497
|
this.#typeSourceById.clear();
|
|
498
|
+
this.#sourceLengthByPath.clear();
|
|
445
499
|
this.#snapshotHasIssuedHandles = false;
|
|
446
500
|
}
|
|
501
|
+
sourceLengthForPath(path) {
|
|
502
|
+
const cached = this.#sourceLengthByPath.get(path);
|
|
503
|
+
if (cached !== void 0) return cached;
|
|
504
|
+
const length = this.sourceTextForPath(path)?.length;
|
|
505
|
+
if (length !== void 0) this.#sourceLengthByPath.set(path, length);
|
|
506
|
+
return length;
|
|
507
|
+
}
|
|
447
508
|
sourceSliceForHandle(handle) {
|
|
448
509
|
const node = this.getNode(handle);
|
|
449
510
|
if (!node) return;
|
|
450
511
|
const sourceText = this.sourceTextForPath(node.fileName);
|
|
451
512
|
if (!sourceText || node.pos < 0 || node.end > sourceText.length || node.pos >= node.end) return;
|
|
452
|
-
return {
|
|
453
|
-
node,
|
|
454
|
-
text: sourceText.slice(node.pos, node.end)
|
|
455
|
-
};
|
|
513
|
+
return { node };
|
|
456
514
|
}
|
|
457
515
|
sourceTextForPath(path) {
|
|
458
|
-
|
|
516
|
+
const direct = this.#files.get(path);
|
|
517
|
+
if (direct) return direct.lintSourceText ?? direct.sourceText ?? readFileOrUndefined(path);
|
|
518
|
+
for (const [fileName, cached] of this.#files) if (pathsReferToSameFile(fileName, path)) return cached.lintSourceText ?? cached.sourceText ?? readFileOrUndefined(fileName);
|
|
459
519
|
return readFileOrUndefined(path) ?? readFileOrUndefined(`${this.runtime.cwd}/${path}`);
|
|
460
520
|
}
|
|
461
521
|
withTransportRecovery(operation, action) {
|
|
@@ -610,6 +670,30 @@ function isUsableSymbol(symbol) {
|
|
|
610
670
|
function isSyntheticTypeHandle(handle) {
|
|
611
671
|
return handle.startsWith("synthetic-");
|
|
612
672
|
}
|
|
673
|
+
function typeSymbolNameFromTexts(texts) {
|
|
674
|
+
for (const text of texts) {
|
|
675
|
+
const match = /^(?:typeof\s+)?(?:[$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}]*\.)*([$_\p{ID_Start}][$_\u200c\u200d\p{ID_Continue}]*)(?:\s*<|$)/u.exec(text.trim());
|
|
676
|
+
if (match?.[1]) return match[1];
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function findIdentifierPosition(sourceText, identifier, start, end) {
|
|
680
|
+
const boundedEnd = Math.min(sourceText.length, end);
|
|
681
|
+
let position = sourceText.indexOf(identifier, Math.max(0, start));
|
|
682
|
+
while (position >= 0 && position < boundedEnd) {
|
|
683
|
+
const before = position > 0 ? sourceText[position - 1] : void 0;
|
|
684
|
+
const after = sourceText[position + identifier.length];
|
|
685
|
+
if (!isIdentifierPart(before) && !isIdentifierPart(after)) return position;
|
|
686
|
+
position = sourceText.indexOf(identifier, position + identifier.length);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function isIdentifierPart(char) {
|
|
690
|
+
return char !== void 0 && /[$_\u200c\u200d\p{ID_Continue}]/u.test(char);
|
|
691
|
+
}
|
|
692
|
+
function pathsReferToSameFile(left, right) {
|
|
693
|
+
const normalizedLeft = left.replaceAll("\\", "/").toLowerCase();
|
|
694
|
+
const normalizedRight = right.replaceAll("\\", "/").toLowerCase();
|
|
695
|
+
return normalizedLeft === normalizedRight || normalizedLeft.endsWith(`/${normalizedRight}`) || normalizedRight.endsWith(`/${normalizedLeft}`);
|
|
696
|
+
}
|
|
613
697
|
function normalizeType(type) {
|
|
614
698
|
const mutable = type;
|
|
615
699
|
mutable.id = handleString(type.id);
|
|
@@ -662,12 +746,17 @@ function languageIdFor(fileName) {
|
|
|
662
746
|
if (fileName.endsWith(".js")) return "javascript";
|
|
663
747
|
return "typescript";
|
|
664
748
|
}
|
|
665
|
-
function parseNodeHandle(value) {
|
|
666
|
-
const [posText,
|
|
749
|
+
function parseNodeHandle(value, sourceLengthForPath) {
|
|
750
|
+
const [posText, secondText, thirdText, ...remainingParts] = value.split(".");
|
|
667
751
|
const pos = Number(posText);
|
|
668
|
-
const
|
|
669
|
-
const
|
|
670
|
-
if (!Number.isFinite(pos) || !Number.isFinite(
|
|
752
|
+
const second = Number(secondText);
|
|
753
|
+
const third = Number(thirdText);
|
|
754
|
+
if (!Number.isFinite(pos) || !Number.isFinite(second)) return;
|
|
755
|
+
const hasEndPosition = Number.isFinite(third);
|
|
756
|
+
const fileName = (hasEndPosition ? remainingParts : [thirdText, ...remainingParts]).join(".");
|
|
757
|
+
if (!fileName) return;
|
|
758
|
+
const end = hasEndPosition ? second : sourceLengthForPath(fileName) ?? pos + 1;
|
|
759
|
+
if (end < pos) return;
|
|
671
760
|
return {
|
|
672
761
|
id: value,
|
|
673
762
|
fileName,
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#nodesById","#typeSourceById","#snapshotHasIssuedHandles","#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 text: string;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\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 #symbolTypeById = new Map<string, string>();\n #nodesById = new Map<string, CorsaNode>();\n #typeLookupById = new Map<string, TypeLookup>();\n #typeSourceById = new Map<string, SourceSlice>();\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 if (type.symbol) {\n const symbol = this.getSymbol(type.symbol);\n if (isUsableSymbol(symbol)) {\n return symbol;\n }\n }\n const symbol = this.getSymbolOfTypeById(type.id);\n if (symbol) {\n return symbol;\n }\n return 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 if (!isUsableSymbol(symbol)) {\n return undefined;\n }\n const texts = this.typeTexts(type);\n if (texts.some((text) => text.trim() === symbol.name)) {\n return symbol;\n }\n try {\n return this.typeToString(type).trim() === symbol.name ? symbol : undefined;\n } catch {\n return undefined;\n }\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 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 return this.rememberTypes(\n this.client().callJson(\"getBaseTypes\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n texts: this.typeTexts(type),\n }) ?? [],\n );\n });\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 text: sourceText.slice(start, end),\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 for (const declaration of symbol.declarations ?? []) {\n this.rememberNode(declaration);\n }\n if (symbol.valueDeclaration) {\n this.rememberNode(symbol.valueDeclaration);\n }\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);\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.#symbolTypeById.clear();\n this.#nodesById.clear();\n this.#typeLookupById.clear();\n this.#typeSourceById.clear();\n this.#snapshotHasIssuedHandles = false;\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 text: sourceText.slice(node.pos, node.end),\n };\n }\n\n private sourceTextForPath(path: string): string | undefined {\n for (const [fileName, cached] of this.#files) {\n if (fileName === path || fileName.endsWith(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 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(value: string): CorsaNode | undefined {\n const [posText, endText, _kindText, ...pathParts] = value.split(\".\");\n const pos = Number(posText);\n const end = Number(endText);\n const fileName = pathParts.join(\".\");\n if (!Number.isFinite(pos) || !Number.isFinite(end) || !fileName) {\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":";;;AAyCA,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;CAkBpB;CACA;CAlBX;CACA;CACA;CACA,YAA+B,CAAC;CAChC,yBAAS,IAAI,IAAuB;CACpC,+BAAe,IAAI,IAAyB;CAC5C,kCAAkB,IAAI,IAAoB;CAC1C,6BAAa,IAAI,IAAuB;C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,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#symbolsByTypeId","#nodesById","#baseTypesById","#implementedTypesById","#ownImplementedTypesById","#typeSourceById","#snapshotHasIssuedHandles","#sourceLengthByPath","#fatalTransportError","#config","#projects","#lastRefreshMs"],"sources":["../ts/session.ts"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\n\nimport { type ProjectResponse, CorsaApiClient } from \"@corsa-bind/napi\";\n\nimport type {\n CorsaCallSignatureFacts,\n CorsaNode,\n CorsaSignature,\n CorsaSymbol,\n CorsaType,\n CorsaTypePredicate,\n} from \"./types\";\nimport type { ResolvedProjectConfig, ResolvedRuntimeOptions } from \"./types\";\n\ntype FileCache = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n projectId: string;\n typeByPosition: Map<number, CorsaType | undefined>;\n typeBySourceRange: Map<string, CorsaType | undefined>;\n symbolByPosition: Map<number, CorsaSymbol | undefined>;\n};\n\ntype PreparedFileState = {\n mtimeMs: number;\n lintSourceText?: string;\n sourceText?: string;\n};\n\ntype SourceSlice = {\n node: CorsaNode;\n};\n\ntype TypeLookup = {\n fileName: string;\n position: number;\n sourceText?: string;\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 #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(lookup, sourceText, typeSymbolName);\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(lookup, sourceText, typeSymbolName);\n }\n return undefined;\n }\n\n private getNearbyTypeSymbol(\n lookup: TypeLookup,\n sourceText: string,\n typeSymbolName: string,\n ): CorsaSymbol | undefined {\n const typePosition = findIdentifierPosition(\n sourceText,\n typeSymbolName,\n lookup.position,\n lookup.position + 512,\n );\n if (typePosition === undefined || typePosition === lookup.position) {\n return undefined;\n }\n const typeSymbol = this.getSymbolAtPosition(lookup.fileName, typePosition, lookup.sourceText);\n return isUsableSymbol(typeSymbol) && typeSymbol.name === typeSymbolName\n ? typeSymbol\n : undefined;\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 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 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 this.#baseTypesById.set(type.id, baseTypes);\n return baseTypes;\n });\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.#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\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":";;;AAwCA,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;CAuBpB;CACA;CAvBX;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,IAA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K,OAAO,CAAC,KAAK,GAAG;CAAE;AAC5D;AAEA,SAAS,4BAA4B,OAAyB;CAC5D,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,oBAAoB,KACrC,QAAQ,SAAS,aAAa,KAC9B,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,6BAA6B,KAC9C,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,eAAe,KAChC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,oBAAoB;AAEzC;AAEA,SAAS,yBAAyB,OAAyB;CACzD,MAAM,UAAU,aAAa,KAAK;CAClC,OACE,QAAQ,SAAS,gCAAgC,KAAK,QAAQ,SAAS,mBAAmB;AAE9F;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"./package.json": "./package.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@corsa-bind/napi": "1.
|
|
104
|
+
"@corsa-bind/napi": "1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@oxlint/plugins": "1.72.0",
|