devlensio 1.1.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/graph/buildLookup.d.ts +30 -0
  2. package/dist/graph/buildLookup.js +36 -1
  3. package/dist/graph/edges/aliasChain.d.ts +7 -0
  4. package/dist/graph/edges/aliasChain.js +63 -0
  5. package/dist/graph/edges/aliasResolution.test.d.ts +1 -0
  6. package/dist/graph/edges/aliasResolution.test.js +351 -0
  7. package/dist/graph/edges/callEdges.js +178 -18
  8. package/dist/graph/edges/callEdges.test.js +119 -0
  9. package/dist/graph/edges/callOrder.test.d.ts +1 -0
  10. package/dist/graph/edges/callOrder.test.js +227 -0
  11. package/dist/graph/edges/importEdges.js +124 -0
  12. package/dist/graph/edges/propEdges.js +6 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.js +1 -0
  15. package/dist/parser/callFlow.d.ts +15 -0
  16. package/dist/parser/callFlow.js +302 -0
  17. package/dist/parser/callOrder.test.d.ts +1 -0
  18. package/dist/parser/callOrder.test.js +407 -0
  19. package/dist/parser/declarationIds.d.ts +23 -0
  20. package/dist/parser/declarationIds.js +123 -0
  21. package/dist/parser/exportsMap.js +1 -90
  22. package/dist/parser/extractors/components.js +18 -28
  23. package/dist/parser/extractors/functions.d.ts +21 -1
  24. package/dist/parser/extractors/functions.js +92 -60
  25. package/dist/parser/extractors/moduleScope.d.ts +8 -0
  26. package/dist/parser/extractors/moduleScope.js +80 -0
  27. package/dist/parser/index.js +12 -0
  28. package/dist/parser/moduleScope.test.d.ts +1 -0
  29. package/dist/parser/moduleScope.test.js +176 -0
  30. package/dist/summarizer/index.js +53 -4
  31. package/dist/summarizer/prompts.js +111 -50
  32. package/dist/summarizer/prompts.test.d.ts +1 -0
  33. package/dist/summarizer/prompts.test.js +112 -0
  34. package/dist/types.d.ts +63 -0
  35. package/dist/version.d.ts +1 -0
  36. package/dist/version.js +2 -0
  37. package/extractors/go/bin/darwin-amd64/devlens_go_extractor +0 -0
  38. package/extractors/go/bin/darwin-arm64/devlens_go_extractor +0 -0
  39. package/extractors/go/bin/linux-amd64/devlens_go_extractor +0 -0
  40. package/extractors/go/bin/linux-arm64/devlens_go_extractor +0 -0
  41. package/extractors/go/bin/windows-amd64/devlens_go_extractor.exe +0 -0
  42. package/extractors/go/calls.go +131 -10
  43. package/extractors/go/nodes.go +29 -11
  44. package/extractors/go/parser.go +376 -41
  45. package/extractors/java/devlens_java_extractor.jar +0 -0
  46. package/extractors/java/src/devlens/extractor/Extractor.java +52 -12
  47. package/extractors/java/src/devlens/extractor/LookupMaps.java +2 -0
  48. package/extractors/java/src/devlens/extractor/Parser.java +420 -1
  49. package/extractors/java/src/devlens/extractor/edges/Calls.java +105 -5
  50. package/extractors/python/devlens_extractors_python/edges/calls.py +199 -36
  51. package/extractors/python/devlens_extractors_python/edges/imports.py +21 -1
  52. package/extractors/python/devlens_extractors_python/lookup.py +9 -0
  53. package/extractors/python/devlens_extractors_python/parser/__init__.py +11 -1
  54. package/extractors/python/devlens_extractors_python/parser/functions.py +199 -42
  55. package/extractors/rust/bin/darwin-amd64/devlens_rust_extractor +0 -0
  56. package/extractors/rust/bin/darwin-arm64/devlens_rust_extractor +0 -0
  57. package/extractors/rust/bin/linux-amd64/devlens_rust_extractor +0 -0
  58. package/extractors/rust/bin/linux-arm64/devlens_rust_extractor +0 -0
  59. package/extractors/rust/bin/windows-amd64/devlens_rust_extractor.exe +0 -0
  60. package/extractors/rust/src/calls.rs +114 -8
  61. package/extractors/rust/src/lookup.rs +66 -0
  62. package/extractors/rust/src/nodes.rs +29 -0
  63. package/extractors/rust/src/parser.rs +362 -27
  64. package/package.json +77 -73
@@ -1,6 +1,8 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
+ import { nodesFromLookup } from "../buildLookup.js";
3
4
  import { extractPackageName } from "../thirdPartyLibs.js";
5
+ import { buildNodeIndex, resolveDeclarationToNode } from "../../parser/declarationIds.js";
4
6
  import { Project } from "ts-morph";
5
7
  // Aliases we consider as local imports
6
8
  const LOCAL_PREFIXES = ["./", "../", "@/", "~/", "#/"];
@@ -169,6 +171,8 @@ export function detectImportEdges(lookupMp, repoPath) {
169
171
  // Records localAlias → importedName so callEdges can resolve
170
172
  // `US.get()` when `import { UserService as US } from "./services"`
171
173
  // (the dotted METHOD node is named `UserService.get`).
174
+ // Tier-3 fallback only — the binding-aware maps below carry the
175
+ // resolved file and drive tier-2 resolution.
172
176
  const localAliases = lookupMp.localImportSymbols.get(sourceRelative) ?? new Map();
173
177
  for (const specifier of importDecl.getNamedImports()) {
174
178
  const localAlias = specifier.getAliasNode()?.getText() ?? specifier.getName();
@@ -220,6 +224,11 @@ export function detectImportEdges(lookupMp, repoPath) {
220
224
  const targetFileNode = lookupMp.fileNodesByPath.get(targetRelative);
221
225
  if (!targetFileNode)
222
226
  continue;
227
+ // ─── Binding-aware import targets (drives tier-2 resolution) ──
228
+ // Recorded BEFORE the file-pair dedupe below: two import
229
+ // declarations from the same module (or an aliased second name)
230
+ // would otherwise lose their alias entries.
231
+ recordImportTargets(lookupMp, sourceRelative, targetRelative, importDecl);
223
232
  const edgeKey = `${sourceFileNode.id}→${targetFileNode.id}`;
224
233
  if (createdEdges.has(edgeKey))
225
234
  continue;
@@ -232,5 +241,120 @@ export function detectImportEdges(lookupMp, repoPath) {
232
241
  });
233
242
  }
234
243
  }
244
+ // ─── Export surface per module (one pass, reuses this Project) ────────
245
+ // TypeScript's checker already follows `export … from`, `export *`,
246
+ // defaults and path mappings, so a 20-hop re-export chain collapses into a
247
+ // single (file, name) → origin nodeId entry below.
248
+ buildExportSurface(lookupMp, project, repoPath);
235
249
  return { edges, thirdPartyMethodNodes: [...methodNodesMap.values()] };
236
250
  }
251
+ /** local name → resolved module + exported name, for every import kind. */
252
+ function recordImportTargets(lookupMp, sourceRelative, targetRelative, importDecl) {
253
+ const targets = lookupMp.importTargets.get(sourceRelative) ?? new Map();
254
+ for (const spec of importDecl.getNamedImports()) {
255
+ const localName = spec.getAliasNode()?.getText() ?? spec.getName();
256
+ targets.set(localName, {
257
+ targetFile: targetRelative,
258
+ importedName: spec.getName(),
259
+ kind: "named",
260
+ });
261
+ }
262
+ const defaultImport = importDecl.getDefaultImport();
263
+ if (defaultImport) {
264
+ targets.set(defaultImport.getText(), {
265
+ targetFile: targetRelative,
266
+ importedName: "default",
267
+ kind: "default",
268
+ });
269
+ }
270
+ const namespaceImport = importDecl.getNamespaceImport();
271
+ if (namespaceImport) {
272
+ targets.set(namespaceImport.getText(), {
273
+ targetFile: targetRelative,
274
+ importedName: "*",
275
+ kind: "namespace",
276
+ });
277
+ }
278
+ if (targets.size > 0)
279
+ lookupMp.importTargets.set(sourceRelative, targets);
280
+ }
281
+ /**
282
+ * Build the per-module export surface.
283
+ *
284
+ * `exportBindings[file][exportedName] = [origin nodeIds]` — the resolution
285
+ * table. `getExportedDeclarations()` returns the ORIGIN declaration of every
286
+ * exported name (re-exports, `export *`, barrels and defaults already followed
287
+ * by the checker), and `resolveDeclarationToNode` maps it to a node id using
288
+ * the shared overload-aware scheme — so `path::name#arity` ids are produced in
289
+ * exactly one place.
290
+ *
291
+ * `reexportLinks` / `reexportGlobs` record the hops themselves. They are NOT
292
+ * used for resolution (the chain is already collapsed); they exist so callers
293
+ * can show "how did this name get here" without inventing graph edges.
294
+ */
295
+ function buildExportSurface(lookupMp, project, repoPath) {
296
+ const nodeIndex = buildNodeIndex(nodesFromLookup(lookupMp));
297
+ if (nodeIndex.size === 0)
298
+ return;
299
+ for (const file of project.getSourceFiles()) {
300
+ const rel = path.relative(repoPath, file.getFilePath()).replace(/\\/g, "/");
301
+ // ── resolution table ─────────────────────────────────────────────
302
+ try {
303
+ const bindings = new Map();
304
+ for (const [exportedName, declarations] of file.getExportedDeclarations()) {
305
+ const ids = [];
306
+ for (const declaration of declarations) {
307
+ const hit = resolveDeclarationToNode(declaration, repoPath, nodeIndex);
308
+ if (hit)
309
+ ids.push(hit.id);
310
+ }
311
+ const unique = [...new Set(ids)];
312
+ if (unique.length > 0)
313
+ bindings.set(exportedName, unique);
314
+ }
315
+ if (bindings.size > 0)
316
+ lookupMp.exportBindings.set(rel, bindings);
317
+ }
318
+ catch {
319
+ // One unparseable file must not break edge detection — its imports
320
+ // simply fall through to the name-based tier.
321
+ }
322
+ // ── provenance hops (display only) ───────────────────────────────
323
+ try {
324
+ const links = new Map();
325
+ const globs = [];
326
+ for (const exportDecl of file.getExportDeclarations()) {
327
+ const target = exportDecl.getModuleSpecifierSourceFile();
328
+ const targetRel = target
329
+ ? path.relative(repoPath, target.getFilePath()).replace(/\\/g, "/")
330
+ : rel; // `export { a as b }` with no `from` — a local binding hop
331
+ const namespaceExport = exportDecl.getNamespaceExport();
332
+ if (namespaceExport) {
333
+ if (!target)
334
+ continue;
335
+ links.set(namespaceExport.getName(), { targetFile: targetRel, targetName: "*" });
336
+ continue;
337
+ }
338
+ const named = exportDecl.getNamedExports();
339
+ if (named.length === 0) {
340
+ if (!target)
341
+ continue;
342
+ // `export * from "./x"` — exported names mirror the target
343
+ globs.push(targetRel);
344
+ continue;
345
+ }
346
+ for (const spec of named) {
347
+ const exportedName = spec.getAliasNode()?.getText() ?? spec.getName();
348
+ links.set(exportedName, { targetFile: targetRel, targetName: spec.getName() });
349
+ }
350
+ }
351
+ if (links.size > 0)
352
+ lookupMp.reexportLinks.set(rel, links);
353
+ if (globs.length > 0)
354
+ lookupMp.reexportGlobs.set(rel, globs);
355
+ }
356
+ catch {
357
+ // provenance is best-effort
358
+ }
359
+ }
360
+ }
@@ -60,12 +60,17 @@ export function detectPropEdges(nodes, lookupMp, repoPath) {
60
60
  const jsxOpeningElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement);
61
61
  const jsxSelfClosingElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);
62
62
  // Filter to only JSX within this component's line range (meaning which lies between this component's startLine and endLine)
63
+ // Sorted by source position: JSX document order is render order for the
64
+ // element tree the component returns.
63
65
  const allJsxElements = [...jsxOpeningElements, ...jsxSelfClosingElements]
64
66
  .filter(el => {
65
67
  const line = el.getStartLineNumber();
66
68
  return line >= component.startLine && line <= component.endLine;
67
- });
69
+ })
70
+ .sort((a, b) => a.getStart() - b.getStart());
71
+ let renderOrder = 0;
68
72
  for (const jsxElement of allJsxElements) {
73
+ renderOrder++;
69
74
  const tagName = jsxElement.getTagNameNode().getText();
70
75
  // Skip HTML native elements — they start with lowercase
71
76
  if (/^[a-z]/.test(tagName))
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export { loadCatalog, findProvider, saveProvider, removeProvider, resetUserCatal
23
23
  export type { CatalogProvider, CatalogProviderInput } from "./config/providers/catalog.js";
24
24
  export { listModels } from "./summarizer/providers/models.js";
25
25
  export type { ListModelsOpts } from "./summarizer/providers/models.js";
26
+ export { engineVersion } from "./version.js";
package/dist/index.js CHANGED
@@ -25,3 +25,4 @@ export { buildGraphIndex, getBlastRadius, getKHop, getSubgraph, findCycles, } fr
25
25
  export { loadCatalog, findProvider, saveProvider, removeProvider, resetUserCatalog, listUserProviders, } from "./config/providers/catalog.js";
26
26
  // Dynamic model discovery (consumed by DevLens OSS CLI)
27
27
  export { listModels } from "./summarizer/providers/models.js";
28
+ export { engineVersion } from "./version.js";
@@ -0,0 +1,15 @@
1
+ import { type Node } from "ts-morph";
2
+ import type { CallScope, DeferKind } from "../types.js";
3
+ export interface CallAnnotations {
4
+ col: number;
5
+ scope: CallScope;
6
+ nested?: number;
7
+ awaited?: boolean;
8
+ defer?: DeferKind;
9
+ deferDetail?: string;
10
+ conc?: boolean;
11
+ repeat?: boolean;
12
+ maybe?: boolean;
13
+ }
14
+ export declare function isIifeCallee(callee: Node): boolean;
15
+ export declare function annotateCall(call: Node, owner: Node, isFileOwner: boolean, ordinals: Map<Node, number>): CallAnnotations;
@@ -0,0 +1,302 @@
1
+ import { SyntaxKind } from "ts-morph";
2
+ // callOrder/v1. See docs/CALL_ORDER.md. Everything here is metadata only: the
3
+ // set of recorded call sites is decided by the caller's walk, never by this file.
4
+ const FUNCTION_LIKE = new Set([
5
+ SyntaxKind.FunctionDeclaration,
6
+ SyntaxKind.FunctionExpression,
7
+ SyntaxKind.ArrowFunction,
8
+ SyntaxKind.MethodDeclaration,
9
+ SyntaxKind.Constructor,
10
+ SyntaxKind.GetAccessor,
11
+ SyntaxKind.SetAccessor,
12
+ SyntaxKind.ClassDeclaration,
13
+ SyntaxKind.ClassExpression,
14
+ ]);
15
+ const LOOP_KINDS = new Set([
16
+ SyntaxKind.ForStatement,
17
+ SyntaxKind.ForOfStatement,
18
+ SyntaxKind.ForInStatement,
19
+ SyntaxKind.WhileStatement,
20
+ SyntaxKind.DoStatement,
21
+ ]);
22
+ const TIMER_APIS = new Set(["setTimeout", "setInterval"]);
23
+ const MICROTASK_APIS = new Set(["queueMicrotask", "setImmediate", "nextTick"]);
24
+ const EVENT_APIS = new Set([
25
+ "addEventListener", "on", "once", "addListener", "prependListener", "subscribe",
26
+ ]);
27
+ const POST_RENDER_APIS = new Set([
28
+ "useEffect", "useLayoutEffect", "useInsertionEffect",
29
+ ]);
30
+ const PROMISE_APIS = new Set(["then", "catch", "finally"]);
31
+ const ITERATION_APIS = new Set([
32
+ "map", "forEach", "filter", "reduce", "reduceRight", "some", "every", "find",
33
+ "findIndex", "findLast", "flatMap", "sort", "toSorted",
34
+ ]);
35
+ const EXECUTOR_APIS = new Set(["submit", "execute"]);
36
+ const PARALLEL_COMBINATORS = new Set(["all", "allSettled", "race", "any"]);
37
+ function unwrapParens(node) {
38
+ let n = node;
39
+ while (n && n.getKind() === SyntaxKind.ParenthesizedExpression) {
40
+ n = n.getExpression();
41
+ }
42
+ return n;
43
+ }
44
+ export function isIifeCallee(callee) {
45
+ const expr = unwrapParens(callee);
46
+ if (!expr)
47
+ return false;
48
+ return (expr.getKind() === SyntaxKind.ArrowFunction ||
49
+ expr.getKind() === SyntaxKind.FunctionExpression);
50
+ }
51
+ function calleeText(call) {
52
+ const expression = call.getExpression?.();
53
+ return expression ? expression.getText() : "";
54
+ }
55
+ function memberName(text) {
56
+ const dot = text.lastIndexOf(".");
57
+ return dot === -1 ? text : text.slice(dot + 1);
58
+ }
59
+ // Nearest enclosing call expression, ignoring any that sit beyond a function
60
+ // boundary: arguments of a callback belong to the callback, not to the call that
61
+ // received it.
62
+ function enclosingCallWithinFrame(call, boundary) {
63
+ let child = call;
64
+ let parent = call.getParent();
65
+ while (parent && parent !== boundary) {
66
+ if (FUNCTION_LIKE.has(parent.getKind()))
67
+ return undefined;
68
+ if (parent.getKind() === SyntaxKind.CallExpression ||
69
+ parent.getKind() === SyntaxKind.NewExpression) {
70
+ return parent;
71
+ }
72
+ child = parent;
73
+ parent = parent.getParent();
74
+ }
75
+ return undefined;
76
+ }
77
+ function nearestEnclosingFunction(call, boundary) {
78
+ let parent = call.getParent();
79
+ while (parent && parent !== boundary) {
80
+ if (parent.getKind() === SyntaxKind.FunctionDeclaration ||
81
+ parent.getKind() === SyntaxKind.FunctionExpression ||
82
+ parent.getKind() === SyntaxKind.ArrowFunction ||
83
+ parent.getKind() === SyntaxKind.MethodDeclaration) {
84
+ return parent;
85
+ }
86
+ parent = parent.getParent();
87
+ }
88
+ return undefined;
89
+ }
90
+ function isInsideJsxHandler(call, boundary) {
91
+ let parent = call.getParent();
92
+ while (parent && parent !== boundary) {
93
+ if (parent.getKind() === SyntaxKind.JsxExpression) {
94
+ const attribute = parent.getParent();
95
+ if (attribute && attribute.getKind() === SyntaxKind.JsxAttribute) {
96
+ const holder = attribute.getParent();
97
+ if (holder &&
98
+ (holder.getKind() === SyntaxKind.JsxOpeningElement ||
99
+ holder.getKind() === SyntaxKind.JsxSelfClosingElement)) {
100
+ return true;
101
+ }
102
+ }
103
+ }
104
+ parent = parent.getParent();
105
+ }
106
+ return false;
107
+ }
108
+ function computeScope(call, owner, isFileOwner) {
109
+ if (isFileOwner)
110
+ return "module";
111
+ if (isInsideJsxHandler(call, owner))
112
+ return "handler";
113
+ const fn = nearestEnclosingFunction(call, owner);
114
+ if (!fn)
115
+ return "inline";
116
+ if (fn.getKind() === SyntaxKind.FunctionDeclaration)
117
+ return "nested";
118
+ const parent = unwrapParens(fn.getParent());
119
+ if (!parent)
120
+ return "callback";
121
+ if (parent.getKind() === SyntaxKind.VariableDeclaration)
122
+ return "nested";
123
+ if (parent.getKind() === SyntaxKind.PropertyAssignment)
124
+ return "nested";
125
+ if (parent.getKind() === SyntaxKind.JsxExpression)
126
+ return "handler";
127
+ return "callback";
128
+ }
129
+ // The call that receives `fn` as an argument, looking through arrays so
130
+ // Promise.all([...]) members are found too.
131
+ function callReceiving(fn) {
132
+ let node = unwrapParens(fn.getParent());
133
+ while (node) {
134
+ if (node.getKind() === SyntaxKind.CallExpression ||
135
+ node.getKind() === SyntaxKind.NewExpression) {
136
+ return node;
137
+ }
138
+ if (node.getKind() === SyntaxKind.ArrayLiteralExpression ||
139
+ node.getKind() === SyntaxKind.ParenthesizedExpression ||
140
+ node.getKind() === SyntaxKind.SpreadElement) {
141
+ node = unwrapParens(node.getParent());
142
+ continue;
143
+ }
144
+ return undefined;
145
+ }
146
+ return undefined;
147
+ }
148
+ function computeDefer(call, owner) {
149
+ const result = {};
150
+ const fn = nearestEnclosingFunction(call, owner);
151
+ if (fn) {
152
+ const receiver = callReceiving(fn);
153
+ if (receiver) {
154
+ const text = calleeText(receiver);
155
+ const member = memberName(text);
156
+ const root = text.split(".")[0];
157
+ if (TIMER_APIS.has(text) || TIMER_APIS.has(member)) {
158
+ result.defer = "timer";
159
+ result.deferDetail = text;
160
+ }
161
+ else if (MICROTASK_APIS.has(text) || MICROTASK_APIS.has(member)) {
162
+ result.defer = "microtask";
163
+ result.deferDetail = text;
164
+ }
165
+ else if (POST_RENDER_APIS.has(text)) {
166
+ result.defer = "postRender";
167
+ result.deferDetail = text;
168
+ }
169
+ else if (PROMISE_APIS.has(member) || text === "new Promise") {
170
+ result.defer = "promise";
171
+ result.deferDetail = text;
172
+ }
173
+ else if (EVENT_APIS.has(member) && root !== "Promise") {
174
+ result.defer = "event";
175
+ result.deferDetail = text;
176
+ }
177
+ else if (ITERATION_APIS.has(member)) {
178
+ result.repeat = true;
179
+ result.deferDetail = text;
180
+ }
181
+ else if (EXECUTOR_APIS.has(member)) {
182
+ result.conc = true;
183
+ result.deferDetail = text;
184
+ }
185
+ else if (root === "Promise" && PARALLEL_COMBINATORS.has(member)) {
186
+ result.conc = true;
187
+ result.deferDetail = text;
188
+ }
189
+ // An unrecognised callback argument is NOT a detachment claim. Most helpers that
190
+ // take a callback call it synchronously (runText, withRetry, map-like wrappers),
191
+ // so the honest record is scope "callback" with no defer. The "unknown" value is
192
+ // reserved for a position known to be detached whose scheduler cannot be named.
193
+ }
194
+ }
195
+ // Promise.all([a(), b()]) members run in parallel even though they are not
196
+ // callbacks. Walk to the call that owns the array literal.
197
+ let parent = call.getParent();
198
+ while (parent && parent !== owner) {
199
+ if (FUNCTION_LIKE.has(parent.getKind()))
200
+ break;
201
+ if (parent.getKind() === SyntaxKind.ArrayLiteralExpression &&
202
+ parent.getParent() &&
203
+ parent.getParent().getKind() === SyntaxKind.CallExpression) {
204
+ const ownerCall = parent.getParent();
205
+ const text = calleeText(ownerCall);
206
+ if (text.startsWith("Promise.") && PARALLEL_COMBINATORS.has(memberName(text))) {
207
+ result.conc = true;
208
+ result.deferDetail = text;
209
+ }
210
+ }
211
+ parent = parent.getParent();
212
+ }
213
+ return result;
214
+ }
215
+ function computeMaybeAndRepeat(call, owner) {
216
+ const result = {};
217
+ let child = call;
218
+ let parent = call.getParent();
219
+ while (parent && parent !== owner) {
220
+ if (FUNCTION_LIKE.has(parent.getKind()))
221
+ break;
222
+ const kind = parent.getKind();
223
+ if (kind === SyntaxKind.TryStatement) {
224
+ const finallyBlock = parent.getFinallyBlock?.();
225
+ if (finallyBlock && child === finallyBlock)
226
+ result.defer = "onReturn";
227
+ }
228
+ if (kind === SyntaxKind.IfStatement) {
229
+ const thenStatement = parent.getThenStatement?.();
230
+ const elseStatement = parent.getElseStatement?.();
231
+ if (child === thenStatement || child === elseStatement)
232
+ result.maybe = true;
233
+ }
234
+ if (kind === SyntaxKind.ConditionalExpression) {
235
+ const whenTrue = parent.getWhenTrue?.();
236
+ const whenFalse = parent.getWhenFalse?.();
237
+ if (child === whenTrue || child === whenFalse)
238
+ result.maybe = true;
239
+ }
240
+ if (kind === SyntaxKind.BinaryExpression) {
241
+ const operator = parent.getOperatorToken?.()?.getKind?.();
242
+ const right = parent.getRight?.();
243
+ const conditional = operator === SyntaxKind.AmpersandAmpersandToken ||
244
+ operator === SyntaxKind.BarBarToken ||
245
+ operator === SyntaxKind.QuestionQuestionToken;
246
+ if (conditional && child === right)
247
+ result.maybe = true;
248
+ }
249
+ if (kind === SyntaxKind.CaseClause || kind === SyntaxKind.DefaultClause || kind === SyntaxKind.CatchClause) {
250
+ result.maybe = true;
251
+ }
252
+ if (LOOP_KINDS.has(kind)) {
253
+ const body = parent.getStatement?.() ?? parent.getBody?.();
254
+ if (body && child === body)
255
+ result.repeat = true;
256
+ }
257
+ child = parent;
258
+ parent = parent.getParent();
259
+ }
260
+ return result;
261
+ }
262
+ function jsxAttributeName(call, boundary) {
263
+ let parent = call.getParent();
264
+ while (parent && parent !== boundary) {
265
+ if (parent.getKind() === SyntaxKind.JsxExpression) {
266
+ const attribute = parent.getParent();
267
+ if (attribute && attribute.getKind() === SyntaxKind.JsxAttribute) {
268
+ return attribute.getNameNode?.()?.getText?.();
269
+ }
270
+ }
271
+ parent = parent.getParent();
272
+ }
273
+ return undefined;
274
+ }
275
+ function isAwaited(call) {
276
+ const parent = call.getParent();
277
+ return Boolean(parent && parent.getKind() === SyntaxKind.AwaitExpression);
278
+ }
279
+ export function annotateCall(call, owner, isFileOwner, ordinals) {
280
+ const annotations = {
281
+ col: call.getStart() - call.getStartLinePos(),
282
+ scope: computeScope(call, owner, isFileOwner),
283
+ };
284
+ const enclosing = enclosingCallWithinFrame(call, owner);
285
+ if (enclosing) {
286
+ const order = ordinals.get(enclosing);
287
+ if (order !== undefined)
288
+ annotations.nested = order;
289
+ }
290
+ if (isAwaited(call))
291
+ annotations.awaited = true;
292
+ Object.assign(annotations, computeDefer(call, owner));
293
+ Object.assign(annotations, computeMaybeAndRepeat(call, owner));
294
+ // A JSX attribute handler is triggered by the user, never by the render pass.
295
+ if (annotations.scope === "handler" && !annotations.defer) {
296
+ annotations.defer = "event";
297
+ const attribute = jsxAttributeName(call, owner);
298
+ if (attribute)
299
+ annotations.deferDetail = `on${attribute.replace(/^on/, "")}`;
300
+ }
301
+ return annotations;
302
+ }
@@ -0,0 +1 @@
1
+ export {};