corsa-oxlint 0.48.0 → 0.50.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/oxlint_utils.d.ts +4 -5
- package/dist/oxlint_utils.js.map +1 -1
- package/dist/parser_services.d.ts +4 -1
- package/dist/parser_services.js +9 -8
- package/dist/parser_services.js.map +1 -1
- package/dist/plugin.d.ts +14 -2
- package/dist/plugin.js.map +1 -1
- package/dist/session.d.ts +3 -0
- package/dist/session.js +20 -3
- package/dist/session.js.map +1 -1
- package/package.json +2 -2
package/dist/oxlint_utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ContextWithParserOptions, ParserServices } from "./types.js";
|
|
2
2
|
import { getParserServices } from "./parser_services.js";
|
|
3
|
-
import { Rule
|
|
4
|
-
import { Visitor } from "@oxlint/plugins";
|
|
3
|
+
import { Rule, RuleMetaWithMessages, Visitor } from "./plugin.js";
|
|
5
4
|
|
|
6
5
|
//#region src/bindings/nodejs/corsa_oxlint/ts/oxlint_utils.d.ts
|
|
7
6
|
type RuleCreatorRule<TOptions extends readonly unknown[] = readonly unknown[], TMessageIds extends string = string> = {
|
|
@@ -11,7 +10,7 @@ type RuleCreatorRule<TOptions extends readonly unknown[] = readonly unknown[], T
|
|
|
11
10
|
readonly create: (context: ContextWithParserOptions) => Visitor;
|
|
12
11
|
};
|
|
13
12
|
type RuleCreatorMeta<TMessageIds extends string = string> = RuleMetaWithMessages<TMessageIds>;
|
|
14
|
-
type RuleCreatorCreatedRule<TOptions extends readonly unknown[] = readonly [], TMeta extends RuleMetaWithMessages = RuleMetaWithMessages> = Rule
|
|
13
|
+
type RuleCreatorCreatedRule<TOptions extends readonly unknown[] = readonly [], TMeta extends RuleMetaWithMessages = RuleMetaWithMessages> = Rule & {
|
|
15
14
|
readonly defaultOptions: TOptions;
|
|
16
15
|
readonly meta: TMeta & {
|
|
17
16
|
readonly docs: NonNullable<TMeta["docs"]> & {
|
|
@@ -43,7 +42,7 @@ declare const NullThrowsReasons: Readonly<{
|
|
|
43
42
|
MissingToken: (token: string, thing: string) => string;
|
|
44
43
|
}>;
|
|
45
44
|
declare const RuleCreator: ((urlCreator: (ruleName: string) => string) => RuleCreatorFactory) & {
|
|
46
|
-
withoutDocs<TRule extends Omit<RuleCreatorRule, "name">>(rule: TRule): Rule
|
|
45
|
+
withoutDocs<TRule extends Omit<RuleCreatorRule, "name">>(rule: TRule): Rule & {
|
|
47
46
|
readonly defaultOptions: TRule extends {
|
|
48
47
|
readonly defaultOptions: infer TOptions;
|
|
49
48
|
} ? TOptions : readonly [];
|
|
@@ -59,7 +58,7 @@ declare const ESLintUtils: Readonly<{
|
|
|
59
58
|
MissingToken: (token: string, thing: string) => string;
|
|
60
59
|
}>;
|
|
61
60
|
RuleCreator: ((urlCreator: (ruleName: string) => string) => RuleCreatorFactory) & {
|
|
62
|
-
withoutDocs<TRule extends Omit<RuleCreatorRule, "name">>(rule: TRule): Rule
|
|
61
|
+
withoutDocs<TRule extends Omit<RuleCreatorRule, "name">>(rule: TRule): Rule & {
|
|
63
62
|
readonly defaultOptions: TRule extends {
|
|
64
63
|
readonly defaultOptions: infer TOptions;
|
|
65
64
|
} ? TOptions : readonly [];
|
package/dist/oxlint_utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint_utils.js","names":[],"sources":["../ts/oxlint_utils.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"oxlint_utils.js","names":[],"sources":["../ts/oxlint_utils.ts"],"sourcesContent":["import { getParserServices } from \"./parser_services\";\nimport { decorateRule } from \"./plugin\";\nimport type { Rule, RuleMetaWithMessages, Visitor } from \"./plugin\";\nimport type { ContextWithParserOptions } from \"./types\";\n\nexport type RuleCreatorRule<\n TOptions extends readonly unknown[] = readonly unknown[],\n TMessageIds extends string = string,\n> = {\n readonly name: string;\n readonly meta: RuleCreatorMeta<TMessageIds>;\n readonly defaultOptions?: TOptions;\n readonly create: (context: ContextWithParserOptions) => Visitor;\n};\n\nexport type RuleCreatorMeta<TMessageIds extends string = string> =\n RuleMetaWithMessages<TMessageIds>;\n\nexport type RuleCreatorCreatedRule<\n TOptions extends readonly unknown[] = readonly [],\n TMeta extends RuleMetaWithMessages = RuleMetaWithMessages,\n> = Rule & {\n readonly defaultOptions: TOptions;\n readonly meta: TMeta & {\n readonly docs: NonNullable<TMeta[\"docs\"]> & {\n readonly url: string;\n };\n };\n};\n\ntype RuleCreatorInput<\n TOptions extends readonly unknown[],\n TMessageIds extends string,\n TMeta extends RuleCreatorMeta<TMessageIds>,\n> = Omit<RuleCreatorRule<TOptions, TMessageIds>, \"defaultOptions\" | \"meta\"> & {\n readonly defaultOptions?: TOptions;\n readonly meta: TMeta;\n};\n\nexport interface RuleCreatorFactory {\n <\n TOptions extends readonly unknown[],\n TMessageIds extends string,\n TMeta extends RuleCreatorMeta<TMessageIds>,\n >(\n rule: RuleCreatorInput<TOptions, TMessageIds, TMeta> & {\n readonly defaultOptions: TOptions;\n },\n ): RuleCreatorCreatedRule<TOptions, TMeta>;\n <TMessageIds extends string, TMeta extends RuleCreatorMeta<TMessageIds>>(\n rule: RuleCreatorInput<readonly [], TMessageIds, TMeta> & {\n readonly defaultOptions?: undefined;\n },\n ): RuleCreatorCreatedRule<readonly [], TMeta>;\n}\n\n/**\n * Self-hosted type-aware utilities for Oxlint rules backed by Corsa.\n */\nexport const OxlintUtils = Object.freeze({\n RuleCreator(urlCreator: (ruleName: string) => string): RuleCreatorFactory {\n return ((rule: RuleCreatorRule) => {\n const docs = rule.meta?.docs;\n return decorateRule({\n ...rule,\n meta: {\n ...rule.meta,\n docs: {\n ...docs,\n url: urlCreator(rule.name),\n },\n },\n defaultOptions: rule.defaultOptions ?? [],\n } as unknown as Rule) as never;\n }) as RuleCreatorFactory;\n },\n getParserServices(context: ContextWithParserOptions, allowWithoutFullTypeInformation = false) {\n return getParserServices(context, allowWithoutFullTypeInformation);\n },\n});\n\nexport const NullThrowsReasons = Object.freeze({\n MissingParent: \"Expected node to have a parent.\",\n MissingToken: (token: string, thing: string) => `Expected to find a ${token} for the ${thing}.`,\n});\n\nexport const RuleCreator = Object.assign(OxlintUtils.RuleCreator, {\n withoutDocs<TRule extends Omit<RuleCreatorRule, \"name\">>(\n rule: TRule,\n ): Rule & {\n readonly defaultOptions: TRule extends { readonly defaultOptions: infer TOptions }\n ? TOptions\n : readonly [];\n } {\n return decorateRule({\n ...rule,\n defaultOptions: rule.defaultOptions ?? [],\n } as unknown as Rule) as never;\n },\n});\nexport { getParserServices } from \"./parser_services\";\n\nexport function applyDefault<User extends readonly unknown[], Defaults extends readonly unknown[]>(\n defaultOptions: Defaults,\n userOptions: User | null | undefined,\n): readonly unknown[] {\n const options = structuredClone(defaultOptions) as unknown as unknown[];\n if (userOptions == null) {\n return options;\n }\n options.forEach((option, index) => {\n if (userOptions[index] === undefined) {\n return;\n }\n const userOption = userOptions[index];\n options[index] =\n isObjectNotArray(option) && isObjectNotArray(userOption)\n ? deepMerge(option, userOption)\n : userOption;\n });\n return options;\n}\n\nexport function deepMerge<T>(base: T, override: unknown): T {\n if (isObject(base) && isObject(override)) {\n return Object.fromEntries(\n [...new Set([...Object.keys(base), ...Object.keys(override)])].map((key) => [\n key,\n key in base && key in override\n ? deepMerge((base as any)[key], (override as any)[key])\n : key in base\n ? (base as any)[key]\n : (override as any)[key],\n ]),\n ) as T;\n }\n return (override === undefined ? base : override) as T;\n}\n\nexport function nullThrows<T>(\n value: T | null | undefined,\n message = \"Expected value to be present\",\n): T {\n if (value == null) {\n throw new Error(`Non-null Assertion Failed: ${message}`);\n }\n return value;\n}\n\nexport function isObjectNotArray(value: unknown): value is Record<string, unknown> {\n return isObject(value);\n}\n\nexport const ESLintUtils = Object.freeze({\n NullThrowsReasons,\n RuleCreator,\n applyDefault,\n deepMerge,\n getParserServices,\n isObjectNotArray,\n nullThrows,\n});\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof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WAClB,UAAW,KAAa,MAAO,SAAiB,IAAI,IACpD,OAAO,OACJ,KAAa,OACb,SAAiB,IAC1B,CAAC,CACH;CAEF,OAAQ,aAAa,KAAA,IAAY,OAAO;AAC1C;AAEA,SAAgB,WACd,OACA,UAAU,gCACP;CACH,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8BAA8B,SAAS;CAEzD,OAAO;AACT;AAEA,SAAgB,iBAAiB,OAAkD;CACjF,OAAO,SAAS,KAAK;AACvB;AAEA,MAAa,cAAc,OAAO,OAAO;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ContextWithParserOptions, ParserServices } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/bindings/nodejs/corsa_oxlint/ts/parser_services.d.ts
|
|
4
|
+
type ParserServicesContext = Omit<ContextWithParserOptions, "options"> & {
|
|
5
|
+
readonly options?: readonly unknown[];
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Returns type-aware parser services backed by Corsa.
|
|
6
9
|
*
|
|
@@ -10,7 +13,7 @@ import { ContextWithParserOptions, ParserServices } from "./types.js";
|
|
|
10
13
|
* const checker = services.program.getTypeChecker();
|
|
11
14
|
* ```
|
|
12
15
|
*/
|
|
13
|
-
declare function getParserServices(context:
|
|
16
|
+
declare function getParserServices(context: ParserServicesContext, allowWithoutFullTypeInformation?: boolean): ParserServices;
|
|
14
17
|
//#endregion
|
|
15
18
|
export { getParserServices };
|
|
16
19
|
//# sourceMappingURL=parser_services.d.ts.map
|
package/dist/parser_services.js
CHANGED
|
@@ -15,24 +15,25 @@ const parserServices = /* @__PURE__ */ new WeakMap();
|
|
|
15
15
|
function getParserServices(context, allowWithoutFullTypeInformation = false) {
|
|
16
16
|
const current = parserServices.get(context);
|
|
17
17
|
if (current) return current;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const typedContext = context;
|
|
19
|
+
const parserOptions = resolveTypeAwareParserOptions(typedContext);
|
|
20
|
+
const eslintParserServices = resolveEslintParserServices(typedContext);
|
|
20
21
|
if (!parserOptions.corsa && eslintParserServices) {
|
|
21
22
|
const services = createEslintParserServices(eslintParserServices);
|
|
22
23
|
parserServices.set(context, services);
|
|
23
24
|
return services;
|
|
24
25
|
}
|
|
25
26
|
try {
|
|
26
|
-
const maps = createNodeMaps(
|
|
27
|
+
const maps = createNodeMaps(typedContext);
|
|
27
28
|
const services = {
|
|
28
|
-
program: createProgram(
|
|
29
|
+
program: createProgram(typedContext),
|
|
29
30
|
...maps,
|
|
30
31
|
hasFullTypeInformation: true,
|
|
31
32
|
getTypeAtLocation(node) {
|
|
32
|
-
return createTypeChecker(
|
|
33
|
+
return createTypeChecker(typedContext).getTypeAtLocation(node);
|
|
33
34
|
},
|
|
34
35
|
getSymbolAtLocation(node) {
|
|
35
|
-
return createTypeChecker(
|
|
36
|
+
return createTypeChecker(typedContext).getSymbolAtLocation(node);
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
parserServices.set(context, services);
|
|
@@ -40,8 +41,8 @@ function getParserServices(context, allowWithoutFullTypeInformation = false) {
|
|
|
40
41
|
} catch (error) {
|
|
41
42
|
if (!allowWithoutFullTypeInformation) throw error;
|
|
42
43
|
const fallback = {
|
|
43
|
-
program: createProgram(
|
|
44
|
-
...createNodeMaps(
|
|
44
|
+
program: createProgram(typedContext),
|
|
45
|
+
...createNodeMaps(typedContext),
|
|
45
46
|
hasFullTypeInformation: false,
|
|
46
47
|
getTypeAtLocation() {},
|
|
47
48
|
getSymbolAtLocation() {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser_services.js","names":[],"sources":["../ts/parser_services.ts"],"sourcesContent":["import { createProgram, createTypeChecker } from \"./checker\";\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { createNodeMaps } from \"./node_map\";\nimport type {\n ContextWithParserOptions,\n CorsaTypeCheckerShape,\n ParserServices,\n ParserServicesWithTypeInformation,\n} from \"./types\";\n\nconst parserServices = new WeakMap<object, ParserServices>();\n\n/**\n * Returns type-aware parser services backed by Corsa.\n *\n * @example\n * ```ts\n * const services = getParserServices(context);\n * const checker = services.program.getTypeChecker();\n * ```\n */\nexport function getParserServices(\n context: ContextWithParserOptions,\n allowWithoutFullTypeInformation = false,\n): ParserServices {\n const current = parserServices.get(context);\n if (current) {\n return current;\n }\n const parserOptions = resolveTypeAwareParserOptions(context);\n const eslintParserServices = resolveEslintParserServices(context);\n if (!parserOptions.corsa && eslintParserServices) {\n const services = createEslintParserServices(eslintParserServices);\n parserServices.set(context, services);\n return services;\n }\n try {\n const maps = createNodeMaps(context);\n const program = createProgram(context);\n const services: ParserServicesWithTypeInformation = {\n program,\n ...maps,\n hasFullTypeInformation: true,\n getTypeAtLocation(node) {\n return createTypeChecker(context).getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n return createTypeChecker(context).getSymbolAtLocation(node);\n },\n };\n parserServices.set(context, services);\n return services;\n } catch (error) {\n if (!allowWithoutFullTypeInformation) {\n throw error;\n }\n const fallback: ParserServices = {\n program: createProgram(context),\n ...createNodeMaps(context),\n hasFullTypeInformation: false,\n getTypeAtLocation() {\n return undefined;\n },\n getSymbolAtLocation() {\n return undefined;\n },\n };\n parserServices.set(context, fallback);\n return fallback;\n }\n}\n\nfunction createEslintParserServices(\n parserServices: ParserServices,\n): ParserServicesWithTypeInformation {\n const checker = createEslintTypeChecker(\n parserServices.program.getTypeChecker(),\n parserServices.esTreeNodeToTSNodeMap,\n );\n return {\n program: createEslintProgram(parserServices.program, checker),\n esTreeNodeToTSNodeMap: parserServices.esTreeNodeToTSNodeMap,\n tsNodeToESTreeNodeMap: parserServices.tsNodeToESTreeNodeMap,\n hasFullTypeInformation: true,\n getTypeAtLocation(node) {\n const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);\n return tsNode ? checker.getTypeAtLocation(tsNode) : undefined;\n },\n getSymbolAtLocation(node) {\n const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);\n return tsNode ? checker.getSymbolAtLocation(tsNode) : undefined;\n },\n };\n}\n\nfunction createEslintProgram(\n program: ParserServices[\"program\"],\n checker: CorsaTypeCheckerShape,\n): ParserServices[\"program\"] {\n return Object.assign(Object.create(program), {\n getTypeChecker() {\n return checker;\n },\n });\n}\n\nfunction createEslintTypeChecker(\n checker: CorsaTypeCheckerShape,\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n): CorsaTypeCheckerShape {\n const source = checker as unknown as Record<string, unknown>;\n return {\n ...checker,\n getTypeAtLocation(node) {\n return callChecker(source, \"getTypeAtLocation\", tsNodeFor(node, esTreeNodeToTSNodeMap));\n },\n getContextualType(node) {\n return (\n callChecker(source, \"getContextualType\", tsNodeFor(node, esTreeNodeToTSNodeMap)) ??\n this.getTypeAtLocation(node)\n );\n },\n getSymbolAtLocation(node) {\n return callChecker(source, \"getSymbolAtLocation\", tsNodeFor(node, esTreeNodeToTSNodeMap));\n },\n getSymbol(symbol) {\n return typeof symbol === \"object\" ? symbol : undefined;\n },\n getSymbolById(id) {\n return typeof id === \"object\" ? id : undefined;\n },\n getSymbolOfType(type) {\n return (\n callChecker(source, \"getSymbolOfType\", type) ??\n ((type as { readonly symbol?: unknown }).symbol as never)\n );\n },\n getNode(node) {\n return typeof node === \"object\" ? node : undefined;\n },\n getNodeById(id) {\n return typeof id === \"object\" ? id : undefined;\n },\n getTypeOfSymbol(symbol) {\n return callChecker(source, \"getTypeOfSymbol\", symbol);\n },\n getTypeOfSymbolById() {\n return undefined;\n },\n getDeclaredTypeOfSymbol(symbol) {\n return callChecker(source, \"getDeclaredTypeOfSymbol\", symbol);\n },\n getDeclaredTypeOfSymbolById() {\n return undefined;\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n callChecker(\n source,\n \"getTypeOfSymbolAtLocation\",\n symbol,\n tsNodeFor(node, esTreeNodeToTSNodeMap),\n ) ??\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n return (\n callChecker(\n source,\n \"typeToString\",\n type,\n enclosingDeclaration ? tsNodeFor(enclosingDeclaration, esTreeNodeToTSNodeMap) : undefined,\n flags,\n ) ?? \"\"\n );\n },\n getBaseTypeOfLiteralType(type) {\n return callChecker(source, \"getBaseTypeOfLiteralType\", type) ?? type;\n },\n getPropertiesOfType(type) {\n return asReadonlyArray(callChecker(source, \"getPropertiesOfType\", type));\n },\n getSignaturesOfType(type, kind) {\n return asReadonlyArray(callChecker(source, \"getSignaturesOfType\", type, kind));\n },\n getCallSignatureFacts() {\n return {};\n },\n getReturnTypeOfSignature(signature) {\n return callChecker(source, \"getReturnTypeOfSignature\", signature);\n },\n getTypePredicateOfSignature(signature) {\n return callChecker(source, \"getTypePredicateOfSignature\", signature);\n },\n getBaseTypes(type) {\n return asReadonlyArray(callChecker(source, \"getBaseTypes\", type));\n },\n getImplementedTypes(node) {\n return asReadonlyArray(\n callChecker(source, \"getImplementedTypes\", tsNodeFor(node, esTreeNodeToTSNodeMap)),\n );\n },\n getImplementedTypesOfType(type) {\n return asReadonlyArray(callChecker(source, \"getImplementedTypesOfType\", type));\n },\n getTypeArguments(type) {\n return asReadonlyArray(callChecker(source, \"getTypeArguments\", type));\n },\n getTypesOfType(type) {\n return asReadonlyArray((type as { readonly types?: unknown }).types);\n },\n getTargetOfType(type) {\n return (type as { readonly target?: unknown }).target as never;\n },\n getTypeParametersOfType(type) {\n return asReadonlyArray((type as { readonly typeParameters?: unknown }).typeParameters);\n },\n getOuterTypeParametersOfType(type) {\n return asReadonlyArray(\n (type as { readonly outerTypeParameters?: unknown }).outerTypeParameters,\n );\n },\n getLocalTypeParametersOfType(type) {\n return asReadonlyArray(\n (type as { readonly localTypeParameters?: unknown }).localTypeParameters,\n );\n },\n getObjectTypeOfType(type) {\n return (type as { readonly objectType?: unknown }).objectType as never;\n },\n getIndexTypeOfType(type) {\n return (type as { readonly indexType?: unknown }).indexType as never;\n },\n getCheckTypeOfType(type) {\n return (type as { readonly checkType?: unknown }).checkType as never;\n },\n getExtendsTypeOfType(type) {\n return (type as { readonly extendsType?: unknown }).extendsType as never;\n },\n getBaseTypeOfType(type) {\n return (type as { readonly baseType?: unknown }).baseType as never;\n },\n getConstraintOfType(type) {\n return callChecker(source, \"getBaseConstraintOfType\", type);\n },\n isUnionType(type) {\n const value = type as { readonly isUnion?: unknown };\n return typeof value.isUnion === \"function\" ? Boolean(value.isUnion()) : false;\n },\n isIntersectionType(type) {\n const value = type as { readonly isIntersection?: unknown };\n return typeof value.isIntersection === \"function\" ? Boolean(value.isIntersection()) : false;\n },\n } as CorsaTypeCheckerShape;\n}\n\nfunction callChecker(\n checker: Record<string, unknown>,\n method: string,\n ...args: readonly unknown[]\n): never | undefined {\n const candidate = checker[method];\n return typeof candidate === \"function\" ? candidate.apply(checker, args) : undefined;\n}\n\nfunction asReadonlyArray<T>(value: unknown): readonly T[] {\n return Array.isArray(value) ? value : [];\n}\n\nfunction tsNodeFor(\n node: unknown,\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n): unknown {\n return hasNode(esTreeNodeToTSNodeMap, node) ? esTreeNodeToTSNodeMap.get(node as never) : node;\n}\n\nfunction hasNode(\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n node: unknown,\n): boolean {\n return typeof node === \"object\" && node !== null && esTreeNodeToTSNodeMap.has(node as never);\n}\n\nfunction resolveEslintParserServices(\n context: ContextWithParserOptions,\n): ParserServices | undefined {\n const candidates = [context.parserServices, context.sourceCode.parserServices] as const;\n for (const candidate of candidates) {\n if (hasEslintParserServices(candidate)) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction hasEslintParserServices(value: unknown): value is ParserServices {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n \"program\" in value &&\n \"esTreeNodeToTSNodeMap\" in value &&\n \"tsNodeToESTreeNodeMap\" in value,\n );\n}\n"],"mappings":";;;;AAUA,MAAM,iCAAiB,IAAI,QAAgC;;;;;;;;;;AAW3D,SAAgB,kBACd,SACA,kCAAkC,OAClB;CAChB,MAAM,UAAU,eAAe,IAAI,OAAO;CAC1C,IAAI,SACF,OAAO;CAET,MAAM,gBAAgB,8BAA8B,OAAO;CAC3D,MAAM,uBAAuB,4BAA4B,OAAO;CAChE,IAAI,CAAC,cAAc,SAAS,sBAAsB;EAChD,MAAM,WAAW,2BAA2B,oBAAoB;EAChE,eAAe,IAAI,SAAS,QAAQ;EACpC,OAAO;CACT;CACA,IAAI;EACF,MAAM,OAAO,eAAe,OAAO;EAEnC,MAAM,WAA8C;GAClD,SAFc,cAAc,OAEtB;GACN,GAAG;GACH,wBAAwB;GACxB,kBAAkB,MAAM;IACtB,OAAO,kBAAkB,OAAO,EAAE,kBAAkB,IAAI;GAC1D;GACA,oBAAoB,MAAM;IACxB,OAAO,kBAAkB,OAAO,EAAE,oBAAoB,IAAI;GAC5D;EACF;EACA,eAAe,IAAI,SAAS,QAAQ;EACpC,OAAO;CACT,SAAS,OAAO;EACd,IAAI,CAAC,iCACH,MAAM;EAER,MAAM,WAA2B;GAC/B,SAAS,cAAc,OAAO;GAC9B,GAAG,eAAe,OAAO;GACzB,wBAAwB;GACxB,oBAAoB,CAEpB;GACA,sBAAsB,CAEtB;EACF;EACA,eAAe,IAAI,SAAS,QAAQ;EACpC,OAAO;CACT;AACF;AAEA,SAAS,2BACP,gBACmC;CACnC,MAAM,UAAU,wBACd,eAAe,QAAQ,eAAe,GACtC,eAAe,qBACjB;CACA,OAAO;EACL,SAAS,oBAAoB,eAAe,SAAS,OAAO;EAC5D,uBAAuB,eAAe;EACtC,uBAAuB,eAAe;EACtC,wBAAwB;EACxB,kBAAkB,MAAM;GACtB,MAAM,SAAS,eAAe,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,SAC3B,2BAA2B,KAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"parser_services.js","names":[],"sources":["../ts/parser_services.ts"],"sourcesContent":["import { createProgram, createTypeChecker } from \"./checker\";\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport { createNodeMaps } from \"./node_map\";\nimport type {\n ContextWithParserOptions,\n CorsaTypeCheckerShape,\n ParserServices,\n ParserServicesWithTypeInformation,\n} from \"./types\";\n\nconst parserServices = new WeakMap<object, ParserServices>();\ntype ParserServicesContext = Omit<ContextWithParserOptions, \"options\"> & {\n readonly options?: readonly unknown[];\n};\n\n/**\n * Returns type-aware parser services backed by Corsa.\n *\n * @example\n * ```ts\n * const services = getParserServices(context);\n * const checker = services.program.getTypeChecker();\n * ```\n */\nexport function getParserServices(\n context: ParserServicesContext,\n allowWithoutFullTypeInformation = false,\n): ParserServices {\n const current = parserServices.get(context);\n if (current) {\n return current;\n }\n const typedContext = context as ContextWithParserOptions;\n const parserOptions = resolveTypeAwareParserOptions(typedContext);\n const eslintParserServices = resolveEslintParserServices(typedContext);\n if (!parserOptions.corsa && eslintParserServices) {\n const services = createEslintParserServices(eslintParserServices);\n parserServices.set(context, services);\n return services;\n }\n try {\n const maps = createNodeMaps(typedContext);\n const program = createProgram(typedContext);\n const services: ParserServicesWithTypeInformation = {\n program,\n ...maps,\n hasFullTypeInformation: true,\n getTypeAtLocation(node) {\n return createTypeChecker(typedContext).getTypeAtLocation(node);\n },\n getSymbolAtLocation(node) {\n return createTypeChecker(typedContext).getSymbolAtLocation(node);\n },\n };\n parserServices.set(context, services);\n return services;\n } catch (error) {\n if (!allowWithoutFullTypeInformation) {\n throw error;\n }\n const fallback: ParserServices = {\n program: createProgram(typedContext),\n ...createNodeMaps(typedContext),\n hasFullTypeInformation: false,\n getTypeAtLocation() {\n return undefined;\n },\n getSymbolAtLocation() {\n return undefined;\n },\n };\n parserServices.set(context, fallback);\n return fallback;\n }\n}\n\nfunction createEslintParserServices(\n parserServices: ParserServices,\n): ParserServicesWithTypeInformation {\n const checker = createEslintTypeChecker(\n parserServices.program.getTypeChecker(),\n parserServices.esTreeNodeToTSNodeMap,\n );\n return {\n program: createEslintProgram(parserServices.program, checker),\n esTreeNodeToTSNodeMap: parserServices.esTreeNodeToTSNodeMap,\n tsNodeToESTreeNodeMap: parserServices.tsNodeToESTreeNodeMap,\n hasFullTypeInformation: true,\n getTypeAtLocation(node) {\n const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);\n return tsNode ? checker.getTypeAtLocation(tsNode) : undefined;\n },\n getSymbolAtLocation(node) {\n const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);\n return tsNode ? checker.getSymbolAtLocation(tsNode) : undefined;\n },\n };\n}\n\nfunction createEslintProgram(\n program: ParserServices[\"program\"],\n checker: CorsaTypeCheckerShape,\n): ParserServices[\"program\"] {\n return Object.assign(Object.create(program), {\n getTypeChecker() {\n return checker;\n },\n });\n}\n\nfunction createEslintTypeChecker(\n checker: CorsaTypeCheckerShape,\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n): CorsaTypeCheckerShape {\n const source = checker as unknown as Record<string, unknown>;\n return {\n ...checker,\n getTypeAtLocation(node) {\n return callChecker(source, \"getTypeAtLocation\", tsNodeFor(node, esTreeNodeToTSNodeMap));\n },\n getContextualType(node) {\n return (\n callChecker(source, \"getContextualType\", tsNodeFor(node, esTreeNodeToTSNodeMap)) ??\n this.getTypeAtLocation(node)\n );\n },\n getSymbolAtLocation(node) {\n return callChecker(source, \"getSymbolAtLocation\", tsNodeFor(node, esTreeNodeToTSNodeMap));\n },\n getSymbol(symbol) {\n return typeof symbol === \"object\" ? symbol : undefined;\n },\n getSymbolById(id) {\n return typeof id === \"object\" ? id : undefined;\n },\n getSymbolOfType(type) {\n return (\n callChecker(source, \"getSymbolOfType\", type) ??\n ((type as { readonly symbol?: unknown }).symbol as never)\n );\n },\n getNode(node) {\n return typeof node === \"object\" ? node : undefined;\n },\n getNodeById(id) {\n return typeof id === \"object\" ? id : undefined;\n },\n getTypeOfSymbol(symbol) {\n return callChecker(source, \"getTypeOfSymbol\", symbol);\n },\n getTypeOfSymbolById() {\n return undefined;\n },\n getDeclaredTypeOfSymbol(symbol) {\n return callChecker(source, \"getDeclaredTypeOfSymbol\", symbol);\n },\n getDeclaredTypeOfSymbolById() {\n return undefined;\n },\n getTypeOfSymbolAtLocation(symbol, node) {\n return (\n callChecker(\n source,\n \"getTypeOfSymbolAtLocation\",\n symbol,\n tsNodeFor(node, esTreeNodeToTSNodeMap),\n ) ??\n this.getTypeOfSymbol(symbol) ??\n this.getDeclaredTypeOfSymbol(symbol)\n );\n },\n typeToString(type, enclosingDeclaration, flags) {\n return (\n callChecker(\n source,\n \"typeToString\",\n type,\n enclosingDeclaration ? tsNodeFor(enclosingDeclaration, esTreeNodeToTSNodeMap) : undefined,\n flags,\n ) ?? \"\"\n );\n },\n getBaseTypeOfLiteralType(type) {\n return callChecker(source, \"getBaseTypeOfLiteralType\", type) ?? type;\n },\n getPropertiesOfType(type) {\n return asReadonlyArray(callChecker(source, \"getPropertiesOfType\", type));\n },\n getSignaturesOfType(type, kind) {\n return asReadonlyArray(callChecker(source, \"getSignaturesOfType\", type, kind));\n },\n getCallSignatureFacts() {\n return {};\n },\n getReturnTypeOfSignature(signature) {\n return callChecker(source, \"getReturnTypeOfSignature\", signature);\n },\n getTypePredicateOfSignature(signature) {\n return callChecker(source, \"getTypePredicateOfSignature\", signature);\n },\n getBaseTypes(type) {\n return asReadonlyArray(callChecker(source, \"getBaseTypes\", type));\n },\n getImplementedTypes(node) {\n return asReadonlyArray(\n callChecker(source, \"getImplementedTypes\", tsNodeFor(node, esTreeNodeToTSNodeMap)),\n );\n },\n getImplementedTypesOfType(type) {\n return asReadonlyArray(callChecker(source, \"getImplementedTypesOfType\", type));\n },\n getTypeArguments(type) {\n return asReadonlyArray(callChecker(source, \"getTypeArguments\", type));\n },\n getTypesOfType(type) {\n return asReadonlyArray((type as { readonly types?: unknown }).types);\n },\n getTargetOfType(type) {\n return (type as { readonly target?: unknown }).target as never;\n },\n getTypeParametersOfType(type) {\n return asReadonlyArray((type as { readonly typeParameters?: unknown }).typeParameters);\n },\n getOuterTypeParametersOfType(type) {\n return asReadonlyArray(\n (type as { readonly outerTypeParameters?: unknown }).outerTypeParameters,\n );\n },\n getLocalTypeParametersOfType(type) {\n return asReadonlyArray(\n (type as { readonly localTypeParameters?: unknown }).localTypeParameters,\n );\n },\n getObjectTypeOfType(type) {\n return (type as { readonly objectType?: unknown }).objectType as never;\n },\n getIndexTypeOfType(type) {\n return (type as { readonly indexType?: unknown }).indexType as never;\n },\n getCheckTypeOfType(type) {\n return (type as { readonly checkType?: unknown }).checkType as never;\n },\n getExtendsTypeOfType(type) {\n return (type as { readonly extendsType?: unknown }).extendsType as never;\n },\n getBaseTypeOfType(type) {\n return (type as { readonly baseType?: unknown }).baseType as never;\n },\n getConstraintOfType(type) {\n return callChecker(source, \"getBaseConstraintOfType\", type);\n },\n isUnionType(type) {\n const value = type as { readonly isUnion?: unknown };\n return typeof value.isUnion === \"function\" ? Boolean(value.isUnion()) : false;\n },\n isIntersectionType(type) {\n const value = type as { readonly isIntersection?: unknown };\n return typeof value.isIntersection === \"function\" ? Boolean(value.isIntersection()) : false;\n },\n } as CorsaTypeCheckerShape;\n}\n\nfunction callChecker(\n checker: Record<string, unknown>,\n method: string,\n ...args: readonly unknown[]\n): never | undefined {\n const candidate = checker[method];\n return typeof candidate === \"function\" ? candidate.apply(checker, args) : undefined;\n}\n\nfunction asReadonlyArray<T>(value: unknown): readonly T[] {\n return Array.isArray(value) ? value : [];\n}\n\nfunction tsNodeFor(\n node: unknown,\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n): unknown {\n return hasNode(esTreeNodeToTSNodeMap, node) ? esTreeNodeToTSNodeMap.get(node as never) : node;\n}\n\nfunction hasNode(\n esTreeNodeToTSNodeMap: ParserServices[\"esTreeNodeToTSNodeMap\"],\n node: unknown,\n): boolean {\n return typeof node === \"object\" && node !== null && esTreeNodeToTSNodeMap.has(node as never);\n}\n\nfunction resolveEslintParserServices(\n context: ContextWithParserOptions,\n): ParserServices | undefined {\n const candidates = [context.parserServices, context.sourceCode.parserServices] as const;\n for (const candidate of candidates) {\n if (hasEslintParserServices(candidate)) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction hasEslintParserServices(value: unknown): value is ParserServices {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n \"program\" in value &&\n \"esTreeNodeToTSNodeMap\" in value &&\n \"tsNodeToESTreeNodeMap\" in value,\n );\n}\n"],"mappings":";;;;AAUA,MAAM,iCAAiB,IAAI,QAAgC;;;;;;;;;;AAc3D,SAAgB,kBACd,SACA,kCAAkC,OAClB;CAChB,MAAM,UAAU,eAAe,IAAI,OAAO;CAC1C,IAAI,SACF,OAAO;CAET,MAAM,eAAe;CACrB,MAAM,gBAAgB,8BAA8B,YAAY;CAChE,MAAM,uBAAuB,4BAA4B,YAAY;CACrE,IAAI,CAAC,cAAc,SAAS,sBAAsB;EAChD,MAAM,WAAW,2BAA2B,oBAAoB;EAChE,eAAe,IAAI,SAAS,QAAQ;EACpC,OAAO;CACT;CACA,IAAI;EACF,MAAM,OAAO,eAAe,YAAY;EAExC,MAAM,WAA8C;GAClD,SAFc,cAAc,YAEtB;GACN,GAAG;GACH,wBAAwB;GACxB,kBAAkB,MAAM;IACtB,OAAO,kBAAkB,YAAY,EAAE,kBAAkB,IAAI;GAC/D;GACA,oBAAoB,MAAM;IACxB,OAAO,kBAAkB,YAAY,EAAE,oBAAoB,IAAI;GACjE;EACF;EACA,eAAe,IAAI,SAAS,QAAQ;EACpC,OAAO;CACT,SAAS,OAAO;EACd,IAAI,CAAC,iCACH,MAAM;EAER,MAAM,WAA2B;GAC/B,SAAS,cAAc,YAAY;GACnC,GAAG,eAAe,YAAY;GAC9B,wBAAwB;GACxB,oBAAoB,CAEpB;GACA,sBAAsB,CAEtB;EACF;EAC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AAY,SAAS,QAAQ,sBAAsB,IAAI,IAAa;AAC7F;AAEA,SAAS,4BACP,SAC4B;CAC5B,MAAM,aAAa,CAAC,QAAQ,gBAAgB,QAAQ,WAAW,cAAc;CAC7E,KAAK,MAAM,aAAa,YACtB,IAAI,wBAAwB,SAAS,GACnC,OAAO;AAIb;AAEA,SAAS,wBAAwB,OAAyC;CACxE,OAAO,QACL,SACA,OAAO,UAAU,YACjB,aAAa,SACb,2BAA2B,SAC3B,2BAA2B,KAC7B;AACF"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ContextWithParserOptions } from "./types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AST_NODE_TYPES } from "./compat.js";
|
|
3
|
+
import { ESTree as ESTree$1 } from "./index.js";
|
|
4
|
+
import { Diagnostic, Plugin as Plugin$1, Rule as Rule$1, RuleMeta } from "@oxlint/plugins";
|
|
3
5
|
|
|
4
6
|
//#region src/bindings/nodejs/corsa_oxlint/ts/plugin.d.ts
|
|
5
7
|
type Plugin = Omit<Plugin$1, "rules"> & {
|
|
@@ -28,6 +30,16 @@ type RuleMetaWithMessages<MessageId extends string = string> = Omit<RuleMeta, "d
|
|
|
28
30
|
readonly docs?: RuleDocs;
|
|
29
31
|
readonly messages?: Record<MessageId, string>;
|
|
30
32
|
};
|
|
33
|
+
type CorsaAstNodeType = keyof typeof AST_NODE_TYPES;
|
|
34
|
+
type BivariantVisitorHandler<Handler extends (...args: any[]) => any> = {
|
|
35
|
+
bivarianceHack(...args: Parameters<Handler>): ReturnType<Handler>;
|
|
36
|
+
}["bivarianceHack"];
|
|
37
|
+
type VisitorNode<Kind extends CorsaAstNodeType> = ESTree$1[Kind];
|
|
38
|
+
type Visitor = { [Kind in CorsaAstNodeType]?: BivariantVisitorHandler<(node: VisitorNode<Kind>) => void> } & { [Kind in CorsaAstNodeType as `${Kind}:exit`]?: BivariantVisitorHandler<(node: VisitorNode<Kind>) => void> } & Record<string, BivariantVisitorHandler<(node: ESTree$1.Node) => void> | undefined>;
|
|
39
|
+
type VisitorWithHooks = Visitor & {
|
|
40
|
+
readonly before?: () => boolean | void;
|
|
41
|
+
readonly after?: () => void;
|
|
42
|
+
};
|
|
31
43
|
type RuleDefinition<MessageId extends string = string, Options extends readonly unknown[] = readonly unknown[]> = Record<string, unknown> & {
|
|
32
44
|
readonly defaultOptions?: Options;
|
|
33
45
|
readonly meta?: RuleMetaWithMessages<MessageId>;
|
|
@@ -57,5 +69,5 @@ declare function defineRule<MessageId extends string = string, const Options ext
|
|
|
57
69
|
declare function compatPlugin(plugin: Plugin): Plugin;
|
|
58
70
|
declare function decorateRule(rule: Rule): Rule;
|
|
59
71
|
//#endregion
|
|
60
|
-
export { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleDocs, RuleMetaWithMessages, compatPlugin, decorateRule, definePlugin, defineRule };
|
|
72
|
+
export { Plugin, Rule, RuleContext, RuleDefinition, RuleDiagnostic, RuleDocs, RuleMetaWithMessages, Visitor, VisitorWithHooks, compatPlugin, decorateRule, definePlugin, defineRule };
|
|
61
73
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Diagnostic,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n RuleMeta as OxlintRuleMeta,\n
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../ts/plugin.ts"],"sourcesContent":["import * as oxlintPluginApi from \"@oxlint/plugins\";\nimport type {\n Context as OxlintContext,\n Diagnostic,\n Plugin as OxlintPlugin,\n Rule as OxlintRule,\n RuleMeta as OxlintRuleMeta,\n} from \"@oxlint/plugins\";\n\nimport { AST_NODE_TYPES } from \"./compat\";\nimport { resolveTypeAwareParserOptions } from \"./context\";\nimport type { ESTree as PublicESTree } from \"./index\";\nimport { getParserServices } from \"./parser_services\";\nimport type { ContextWithParserOptions, ParserServices } from \"./types\";\n\nexport type Plugin = Omit<OxlintPlugin, \"rules\"> & {\n readonly rules: Record<string, Rule>;\n} & Record<string, unknown>;\nexport type Rule = OxlintRule & Record<string, unknown>;\nexport type RuleDiagnostic<MessageId extends string = string> = Diagnostic & {\n readonly messageId?: MessageId | null | undefined;\n};\nexport type RuleContext<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Omit<ContextWithParserOptions, \"options\" | \"report\"> & {\n readonly options: Readonly<Options>;\n report(this: void, diagnostic: RuleDiagnostic<MessageId>): void;\n};\nexport type RuleDocs = {\n readonly description?: string;\n readonly recommended?: unknown;\n readonly url?: string;\n /**\n * Enables corsa-oxlint's type-aware parser service defaults for this rule.\n *\n * @default false\n */\n readonly requiresTypeChecking?: boolean;\n};\nexport type RuleMetaWithMessages<MessageId extends string = string> = Omit<\n OxlintRuleMeta,\n \"docs\" | \"messages\"\n> & {\n readonly docs?: RuleDocs;\n readonly messages?: Record<MessageId, string>;\n};\ntype CorsaAstNodeType = keyof typeof AST_NODE_TYPES;\ntype BivariantVisitorHandler<Handler extends (...args: any[]) => any> = {\n bivarianceHack(...args: Parameters<Handler>): ReturnType<Handler>;\n}[\"bivarianceHack\"];\ntype VisitorNode<Kind extends CorsaAstNodeType> = PublicESTree[Kind];\n\nexport type Visitor = {\n [Kind in CorsaAstNodeType]?: BivariantVisitorHandler<(node: VisitorNode<Kind>) => void>;\n} & {\n [Kind in CorsaAstNodeType as `${Kind}:exit`]?: BivariantVisitorHandler<\n (node: VisitorNode<Kind>) => void\n >;\n} & Record<string, BivariantVisitorHandler<(node: PublicESTree.Node) => void> | undefined>;\n\nexport type VisitorWithHooks = Visitor & {\n readonly before?: () => boolean | void;\n readonly after?: () => void;\n};\nexport type RuleDefinition<\n MessageId extends string = string,\n Options extends readonly unknown[] = readonly unknown[],\n> = Record<string, unknown> & {\n readonly defaultOptions?: Options;\n readonly meta?: RuleMetaWithMessages<MessageId>;\n} & (\n | {\n readonly create: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce?: never;\n }\n | {\n readonly create?: (context: RuleContext<MessageId, Options>) => Visitor;\n readonly createOnce: (context: RuleContext<MessageId, Options>) => VisitorWithHooks;\n }\n );\n\nconst defineOxlintPlugin = oxlintPluginApi.definePlugin;\nconst defineOxlintRule = oxlintPluginApi.defineRule;\nconst baseCompatPlugin = Reflect.get(\n oxlintPluginApi as object,\n [\"es\", \"lintCompatPlugin\"].join(\"\"),\n) as typeof oxlintPluginApi.definePlugin;\n\nexport function definePlugin(plugin: Plugin): Plugin {\n return defineOxlintPlugin({\n ...plugin,\n rules: wrapRules(plugin.rules ?? {}),\n } as OxlintPlugin) as Plugin;\n}\n\n/**\n * Defines a single Oxlint rule with type-aware parser services.\n *\n * @example\n * ```ts\n * export default defineRule({\n * meta: { schema: [], messages: { demo: \"demo\" } },\n * create(context) {\n * const services = context.parserServices;\n * return {};\n * },\n * });\n * ```\n */\nexport function defineRule<\n MessageId extends string = string,\n const Options extends readonly unknown[] = readonly unknown[],\n>(rule: RuleDefinition<MessageId, Options>): Rule;\nexport function defineRule(rule: RuleDefinition): Rule {\n return defineOxlintRule(decorateRule(rule as unknown as Rule) as OxlintRule) as Rule;\n}\n\nexport function compatPlugin(plugin: Plugin): Plugin {\n return baseCompatPlugin(definePlugin(plugin)) as Plugin;\n}\n\nexport function decorateRule(rule: Rule): Rule {\n if (rule.create) {\n return {\n ...rule,\n create(context) {\n return rule.create!(decorateContext(context, rule));\n },\n } as Rule;\n }\n if (\"createOnce\" in rule && typeof (rule as any).createOnce === \"function\") {\n return {\n ...rule,\n createOnce(context) {\n return (rule as any).createOnce(decorateContext(context, rule));\n },\n } as Rule;\n }\n return rule;\n}\n\nfunction wrapRules(rules: Record<string, Rule>): Record<string, Rule> {\n return Object.fromEntries(\n Object.entries(rules).map(([name, rule]) => [name, decorateRule(rule)]),\n );\n}\n\nfunction decorateContext(context: ContextWithParserOptions, rule: Rule): ContextWithParserOptions {\n const typeAware = requiresTypeChecking(rule);\n const parserOptions = Object.freeze(\n resolveTypeAwareParserOptions(context, {\n corsa: typeAware,\n projectService: typeAware,\n }),\n );\n const baseLanguageOptions = context.languageOptions;\n const languageOptions = Object.freeze({\n ...baseLanguageOptions,\n parserOptions,\n });\n return Object.create(context as OxlintContext, {\n languageOptions: {\n configurable: true,\n enumerable: true,\n get() {\n return languageOptions;\n },\n },\n parserOptions: {\n configurable: true,\n enumerable: false,\n get() {\n return parserOptions;\n },\n },\n parserServices: {\n configurable: true,\n enumerable: false,\n get(): ParserServices {\n return getParserServices(context);\n },\n },\n }) as ContextWithParserOptions;\n}\n\nfunction requiresTypeChecking(rule: Rule): boolean {\n return (\n (rule.meta as { readonly docs?: { readonly requiresTypeChecking?: unknown } } | undefined)?.docs\n ?.requiresTypeChecking === true\n );\n}\n"],"mappings":";;;;AAkFA,MAAM,qBAAqB,gBAAgB;AAC3C,MAAM,mBAAmB,gBAAgB;AACzC,MAAM,mBAAmB,QAAQ,IAC/B,iBACA,CAAC,MAAM,kBAAkB,EAAE,KAAK,EAAE,CACpC;AAEA,SAAgB,aAAa,QAAwB;CACnD,OAAO,mBAAmB;EACxB,GAAG;EACH,OAAO,UAAU,OAAO,SAAS,CAAC,CAAC;CACrC,CAAiB;AACnB;AAoBA,SAAgB,WAAW,MAA4B;CACrD,OAAO,iBAAiB,aAAa,IAAuB,CAAe;AAC7E;AAEA,SAAgB,aAAa,QAAwB;CACnD,OAAO,iBAAiB,aAAa,MAAM,CAAC;AAC9C;AAEA,SAAgB,aAAa,MAAkB;CAC7C,IAAI,KAAK,QACP,OAAO;EACL,GAAG;EACH,OAAO,SAAS;GACd,OAAO,KAAK,OAAQ,gBAAgB,SAAS,IAAI,CAAC;EACpD;CACF;CAEF,IAAI,gBAAgB,QAAQ,OAAQ,KAAa,eAAe,YAC9D,OAAO;EACL,GAAG;EACH,WAAW,SAAS;GAClB,OAAQ,KAAa,WAAW,gBAAgB,SAAS,IAAI,CAAC;EAChE;CACF;CAEF,OAAO;AACT;AAEA,SAAS,UAAU,OAAmD;CACpE,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,aAAa,IAAI,CAAC,CAAC,CACxE;AACF;AAEA,SAAS,gBAAgB,SAAmC,MAAsC;CAChG,MAAM,YAAY,qBAAqB,IAAI;CAC3C,MAAM,gBAAgB,OAAO,OAC3B,8BAA8B,SAAS;EACrC,OAAO;EACP,gBAAgB;CAClB,CAAC,CACH;CACA,MAAM,sBAAsB,QAAQ;CACpC,MAAM,kBAAkB,OAAO,OAAO;EACpC,GAAG;EACH;CACF,CAAC;CACD,OAAO,OAAO,OAAO,SAA0B;EAC7C,iBAAiB;GACf,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;GACT;EACF;EACA,eAAe;GACb,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,OAAO;GACT;EACF;EACA,gBAAgB;GACd,cAAc;GACd,YAAY;GACZ,MAAsB;IACpB,OAAO,kBAAkB,OAAO;GAClC;EACF;CACF,CAAC;AACH;AAEA,SAAS,qBAAqB,MAAqB;CACjD,OACG,KAAK,MAAsF,MACxF,yBAAyB;AAEjC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ declare class CorsaProjectSession {
|
|
|
16
16
|
getSymbolAtPosition(fileName: string, position: number, sourceText?: string): CorsaSymbol | undefined;
|
|
17
17
|
private getSymbolAtPositionUnchecked;
|
|
18
18
|
getSymbol(symbol: string | CorsaSymbol): CorsaSymbol | undefined;
|
|
19
|
+
private getSymbolUnchecked;
|
|
19
20
|
getSymbolOfType(type: CorsaType): CorsaSymbol | undefined;
|
|
21
|
+
private getSymbolOfTypeUnchecked;
|
|
22
|
+
private getSymbolOfTypeById;
|
|
20
23
|
getNode(node: string | CorsaNode): CorsaNode | undefined;
|
|
21
24
|
getSourceTextForPath(path: string): string | undefined;
|
|
22
25
|
getTypeOfSymbol(symbol: CorsaSymbol): CorsaType | undefined;
|
package/dist/session.js
CHANGED
|
@@ -99,21 +99,35 @@ var CorsaProjectSession = class {
|
|
|
99
99
|
return this.rememberSymbol(state.symbolByPosition.get(position));
|
|
100
100
|
}
|
|
101
101
|
getSymbol(symbol) {
|
|
102
|
+
return this.withTransportRecovery(() => this.getSymbolUnchecked(symbol), "looking up a symbol");
|
|
103
|
+
}
|
|
104
|
+
getSymbolUnchecked(symbol) {
|
|
102
105
|
if (typeof symbol !== "string") return this.rememberSymbol(symbol);
|
|
103
106
|
const cached = this.#symbolsById.get(symbol);
|
|
104
107
|
if (cached) return cached;
|
|
105
108
|
const typeId = this.#symbolTypeById.get(symbol);
|
|
106
109
|
if (!typeId || !this.#snapshot) return;
|
|
107
|
-
const resolved = this.
|
|
108
|
-
return resolved?.id === symbol ?
|
|
110
|
+
const resolved = this.getSymbolOfTypeById(typeId);
|
|
111
|
+
return resolved?.id === symbol ? resolved : void 0;
|
|
109
112
|
}
|
|
110
113
|
getSymbolOfType(type) {
|
|
114
|
+
return this.withTransportRecovery(() => this.getSymbolOfTypeUnchecked(type), "looking up a symbol");
|
|
115
|
+
}
|
|
116
|
+
getSymbolOfTypeUnchecked(type) {
|
|
111
117
|
if (type.symbol) {
|
|
112
118
|
const symbol = this.getSymbol(type.symbol);
|
|
113
119
|
if (isUsableSymbol(symbol)) return symbol;
|
|
114
120
|
}
|
|
121
|
+
return this.getSymbolOfTypeById(type.id);
|
|
122
|
+
}
|
|
123
|
+
getSymbolOfTypeById(typeId) {
|
|
115
124
|
if (!this.#snapshot) return;
|
|
116
|
-
|
|
125
|
+
try {
|
|
126
|
+
return this.rememberUsableSymbol(this.client().getSymbolOfType(this.#snapshot, typeId));
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (isStaleHandleError(error)) return;
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
117
131
|
}
|
|
118
132
|
getNode(node) {
|
|
119
133
|
if (typeof node !== "string") return node;
|
|
@@ -596,6 +610,9 @@ function isRecoverableTransportError(error) {
|
|
|
596
610
|
const message = errorMessage(error);
|
|
597
611
|
return message.includes("process is closed:") || message.includes("Broken pipe") || message.includes("EPIPE") || message.includes("failed to fill whole buffer") || message.includes("msgpack worker") || message.includes("msgpack stdin") || message.includes("msgpack stdout") || message.includes("jsonrpc reader") || message.includes("jsonrpc writer") || message.includes("jsonrpc connection");
|
|
598
612
|
}
|
|
613
|
+
function isStaleHandleError(error) {
|
|
614
|
+
return errorMessage(error).includes("not found in snapshot registry");
|
|
615
|
+
}
|
|
599
616
|
function errorMessage(error) {
|
|
600
617
|
return error instanceof Error ? error.message : String(error);
|
|
601
618
|
}
|
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 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.client().getSymbolOfType(this.#snapshot, typeId) as CorsaSymbol | null;\n return resolved?.id === symbol ? this.rememberUsableSymbol(resolved) : undefined;\n }\n\n getSymbolOfType(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 if (!this.#snapshot) {\n return undefined;\n }\n return this.rememberUsableSymbol(\n this.client().getSymbolOfType(this.#snapshot, type.id) as CorsaSymbol | null,\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.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\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 getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\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 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 if (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 getTypeArguments(type: CorsaType): readonly CorsaType[] {\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 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.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\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 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 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 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 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 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;CACxC,kCAAkB,IAAI,IAAwB;CAC9C,kCAAkB,IAAI,IAAyB;CAC/C,gCAAgB,IAAI,IAAoB;CACxC,iBAAiB;CACjB,4BAA4B;CAC5B;CACA;CAEA,YACE,SACA,SACA;EAFS,KAAA,UAAA;EACA,KAAA,UAAA;CACR;CAEH,QAAc;EACZ,IAAI,KAAKA,WAAW;GAClB,KAAK,iBAAiB,KAAKA,SAAS;GACpC,KAAKA,YAAY,KAAA;EACnB;EACA,KAAK,eAAe;EACpB,KAAKC,UAAU,KAAA;EACf,KAAKC,0BAA0B,KAAA;EAC/B,KAAKC,OAAO,MAAM;EAClB,KAAK,kBAAkB;E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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,aAAa,OAAwB;CAC5C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAEA,SAAS,oBAAoB,MAAkC;CAC7D,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"session.js","names":["#snapshot","#client","#supportsOverlayChanges","#files","#typeTextById","#typeLookupById","#symbolsById","#symbolTypeById","#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 return this.getSymbolOfTypeById(type.id);\n }\n\n private getSymbolOfTypeById(typeId: string): CorsaSymbol | undefined {\n if (!this.#snapshot) {\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 (isStaleHandleError(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.rememberType(\n this.client().callJson(\"getBaseTypeOfLiteralType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }),\n );\n }\n\n getPropertiesOfType(type: CorsaType): readonly CorsaSymbol[] {\n return this.rememberSymbols(\n this.client().callJson(\"getPropertiesOfType\", {\n snapshot: this.#snapshot,\n project: this.projectId(),\n type: type.id,\n }) ?? [],\n );\n }\n\n getSignaturesOfType(type: CorsaType, kind: number): readonly CorsaSignature[] {\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 getCallSignatureFacts(\n type: CorsaType,\n kind: number,\n argumentTypeTexts: readonly (readonly string[])[],\n explicitTypeArgumentTexts: readonly string[],\n ): CorsaCallSignatureFacts {\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 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 if (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 getTypeArguments(type: CorsaType): readonly CorsaType[] {\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 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.rememberType(\n this.client().getConstraintOfType(this.#snapshot!, this.projectId(), type.id) as\n | CorsaType\n | undefined,\n );\n }\n\n private callType(method: string, type: CorsaType): CorsaType | undefined {\n return this.rememberType(\n this.client().callJson<CorsaType | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\n }) ?? undefined,\n );\n }\n\n private callTypeArray(method: string, type: CorsaType): readonly CorsaType[] {\n return this.rememberTypes(\n this.client().callJson<readonly CorsaType[] | null>(method, {\n snapshot: this.#snapshot,\n type: type.id,\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 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 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 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 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 isStaleHandleError(error: unknown): boolean {\n return errorMessage(error).includes(\"not found in snapshot registry\");\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;CACxC,kCAAkB,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;EACN;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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": "0.
|
|
104
|
+
"@corsa-bind/napi": "0.50.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@oxlint/plugins": "1.69.0",
|