scip-query 0.3.5 → 0.4.1

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 (152) hide show
  1. package/README.md +2 -1
  2. package/dist/{chunk-VMM4SYV4.js → chunk-24LF6IZB.js} +17 -4
  3. package/dist/{chunk-EPWLXXBL.js → chunk-3NJSJ7TE.js} +28 -30
  4. package/dist/{chunk-SMDCNPMK.js → chunk-43A4UCS7.js} +3 -3
  5. package/dist/{chunk-CHDJXYBG.js → chunk-5GCORUNV.js} +3 -3
  6. package/dist/{chunk-OIDHN6GD.js → chunk-6CH23IAS.js} +148 -7
  7. package/dist/chunk-6ECR2FLR.js +60 -0
  8. package/dist/{chunk-C7H5WBTJ.js → chunk-6UZU7DFL.js} +3 -3
  9. package/dist/chunk-7BS4CPJX.js +162 -0
  10. package/dist/{chunk-UGQKAVCD.js → chunk-A6XLXV6W.js} +3 -3
  11. package/dist/chunk-ALUFWH3U.js +2695 -0
  12. package/dist/{chunk-F7XU27LU.js → chunk-CBIWNZZZ.js} +27 -3
  13. package/dist/{chunk-26DOJ63W.js → chunk-DUJNJQPO.js} +14 -3
  14. package/dist/{chunk-GSH2FPKV.js → chunk-EAGKJFDX.js} +3 -3
  15. package/dist/{chunk-VIYSWZCO.js → chunk-ELFGD5EW.js} +32 -4
  16. package/dist/chunk-FVJE4MQL.js +37 -0
  17. package/dist/{chunk-NFS5W3PP.js → chunk-GNAMV3JC.js} +3 -3
  18. package/dist/{chunk-TRESG7OB.js → chunk-J47VSL6I.js} +3 -3
  19. package/dist/chunk-J6QXMYAQ.js +115 -0
  20. package/dist/{chunk-6FKIA6EI.js → chunk-JHVQB4Y5.js} +12 -12
  21. package/dist/{chunk-YY4QGUQ5.js → chunk-JKXHHV4B.js} +2 -2
  22. package/dist/{chunk-EN2Z2CLO.js → chunk-KG4OFQEN.js} +17 -20
  23. package/dist/chunk-KLNKDX6A.js +110 -0
  24. package/dist/{chunk-5OMVSV6E.js → chunk-KYPXKV64.js} +3 -3
  25. package/dist/chunk-NXUIWD6K.js +87 -0
  26. package/dist/{chunk-LFJQVJYJ.js → chunk-OXX3QF24.js} +2 -2
  27. package/dist/{chunk-NG5F43OU.js → chunk-P3VCDYMJ.js} +70 -1
  28. package/dist/{chunk-7HK5ZLOE.js → chunk-PCU455MX.js} +2 -2
  29. package/dist/{chunk-O7Q7FDUJ.js → chunk-POLELLNM.js} +3 -3
  30. package/dist/chunk-PU2254N2.js +115 -0
  31. package/dist/{chunk-WGAD3GNR.js → chunk-QMXSLHZP.js} +5 -5
  32. package/dist/{chunk-YDBXNPYU.js → chunk-R7HPHMRZ.js} +3 -3
  33. package/dist/{chunk-HLUS2HEB.js → chunk-RE7POFGI.js} +5 -4
  34. package/dist/{chunk-VT4JBH6L.js → chunk-RJ5GULL6.js} +2 -2
  35. package/dist/{chunk-7KIMF5PV.js → chunk-RL74LF47.js} +2 -2
  36. package/dist/chunk-SVLUJSY7.js +75 -0
  37. package/dist/chunk-SYQR4QGK.js +38 -0
  38. package/dist/{chunk-QIXNAB5K.js → chunk-TO3L4YNK.js} +1 -2
  39. package/dist/{chunk-P3E6L7KW.js → chunk-TWVXFKJA.js} +84 -4
  40. package/dist/chunk-UJWI5CBB.js +75 -0
  41. package/dist/{chunk-J3JSOSUO.js → chunk-VKBOLNYN.js} +3 -3
  42. package/dist/{chunk-KBOQX573.js → chunk-VY2L4TP6.js} +20 -3
  43. package/dist/{chunk-KKCHYLVI.js → chunk-W46L2BXT.js} +2 -2
  44. package/dist/chunk-XUVPQDXW.js +34 -0
  45. package/dist/{chunk-DH7G3DDV.js → chunk-Z5VSUOEE.js} +2 -2
  46. package/dist/{chunk-GEXE2T6I.js → chunk-ZVZAIIB5.js} +23 -15
  47. package/dist/cli.js +2838 -870
  48. package/dist/{db-viWlyVtv.d.ts → db-C4rPbKkI.d.ts} +6 -1
  49. package/dist/index.d.ts +4 -4
  50. package/dist/index.js +376 -142
  51. package/dist/postinstall.js +9 -3
  52. package/dist/queries/affected.d.ts +1 -1
  53. package/dist/queries/affected.js +3 -3
  54. package/dist/queries/bottlenecks.d.ts +1 -1
  55. package/dist/queries/bottlenecks.js +3 -2
  56. package/dist/queries/by-kind.d.ts +1 -1
  57. package/dist/queries/by-kind.js +3 -2
  58. package/dist/queries/call-graph.d.ts +1 -1
  59. package/dist/queries/call-graph.js +3 -3
  60. package/dist/queries/change-surface.d.ts +1 -1
  61. package/dist/queries/change-surface.js +3 -3
  62. package/dist/queries/code.d.ts +1 -1
  63. package/dist/queries/code.js +3 -3
  64. package/dist/queries/complexity-hotspots.d.ts +1 -1
  65. package/dist/queries/complexity-hotspots.js +3 -3
  66. package/dist/queries/complexity.d.ts +1 -1
  67. package/dist/queries/complexity.js +3 -3
  68. package/dist/queries/convergence.d.ts +1 -1
  69. package/dist/queries/convergence.js +3 -3
  70. package/dist/queries/coupling.d.ts +1 -1
  71. package/dist/queries/coupling.js +3 -3
  72. package/dist/queries/cycles.d.ts +1 -1
  73. package/dist/queries/cycles.js +3 -3
  74. package/dist/queries/dataflow.d.ts +1 -1
  75. package/dist/queries/dataflow.js +3 -3
  76. package/dist/queries/dead.d.ts +1 -1
  77. package/dist/queries/dead.js +4 -4
  78. package/dist/queries/deep-chains.d.ts +1 -1
  79. package/dist/queries/deep-chains.js +3 -3
  80. package/dist/queries/deps.d.ts +1 -1
  81. package/dist/queries/deps.js +3 -3
  82. package/dist/queries/diff-impact.d.ts +1 -1
  83. package/dist/queries/diff-impact.js +2 -2
  84. package/dist/queries/drift.d.ts +1 -1
  85. package/dist/queries/drift.js +3 -3
  86. package/dist/queries/extract-candidates.d.ts +1 -1
  87. package/dist/queries/extract-candidates.js +3 -3
  88. package/dist/queries/fan.d.ts +1 -1
  89. package/dist/queries/fan.js +3 -3
  90. package/dist/queries/files.d.ts +1 -1
  91. package/dist/queries/health.d.ts +1 -1
  92. package/dist/queries/health.js +14 -14
  93. package/dist/queries/hierarchy.d.ts +1 -1
  94. package/dist/queries/hierarchy.js +3 -3
  95. package/dist/queries/hotspots.d.ts +1 -1
  96. package/dist/queries/hotspots.js +3 -2
  97. package/dist/queries/imports.d.ts +1 -1
  98. package/dist/queries/imports.js +3 -3
  99. package/dist/queries/index.d.ts +1 -1
  100. package/dist/queries/index.js +44 -44
  101. package/dist/queries/isolated.d.ts +3 -4
  102. package/dist/queries/isolated.js +4 -4
  103. package/dist/queries/members.d.ts +1 -1
  104. package/dist/queries/members.js +3 -3
  105. package/dist/queries/methods.d.ts +1 -1
  106. package/dist/queries/methods.js +3 -2
  107. package/dist/queries/outline.d.ts +1 -1
  108. package/dist/queries/outline.js +3 -3
  109. package/dist/queries/passthrough-candidates.d.ts +1 -1
  110. package/dist/queries/passthrough-candidates.js +3 -3
  111. package/dist/queries/redundant-reexports.d.ts +1 -1
  112. package/dist/queries/redundant-reexports.js +4 -4
  113. package/dist/queries/refs.d.ts +1 -1
  114. package/dist/queries/refs.js +3 -3
  115. package/dist/queries/similar-chains.d.ts +1 -1
  116. package/dist/queries/similar-chains.js +3 -3
  117. package/dist/queries/similar-files.d.ts +1 -1
  118. package/dist/queries/similar-files.js +3 -3
  119. package/dist/queries/similar-signatures.d.ts +5 -3
  120. package/dist/queries/similar-signatures.js +3 -2
  121. package/dist/queries/similar.d.ts +1 -1
  122. package/dist/queries/similar.js +3 -3
  123. package/dist/queries/slice.d.ts +1 -1
  124. package/dist/queries/slice.js +3 -3
  125. package/dist/queries/stale-abstractions.d.ts +1 -1
  126. package/dist/queries/stale-abstractions.js +3 -3
  127. package/dist/queries/stats.d.ts +1 -1
  128. package/dist/queries/surface.d.ts +1 -1
  129. package/dist/queries/surface.js +3 -3
  130. package/dist/queries/symbols.d.ts +1 -1
  131. package/dist/queries/symbols.js +3 -3
  132. package/dist/queries/system.d.ts +1 -1
  133. package/dist/queries/system.js +3 -3
  134. package/dist/queries/trace.d.ts +1 -1
  135. package/dist/queries/trace.js +3 -3
  136. package/dist/queries/wrapper-candidates.d.ts +1 -1
  137. package/dist/queries/wrapper-candidates.js +3 -3
  138. package/dist/reindex-worker.js +216 -64
  139. package/package.json +5 -1
  140. package/skills/scip-language-playbook/SKILL.md +371 -0
  141. package/dist/chunk-4JCSOF2O.js +0 -97
  142. package/dist/chunk-AXQKUYKF.js +0 -1442
  143. package/dist/chunk-CPVAQJEC.js +0 -46
  144. package/dist/chunk-EOROMIFO.js +0 -41
  145. package/dist/chunk-GU2H5QRN.js +0 -28
  146. package/dist/chunk-LQJUPXQY.js +0 -109
  147. package/dist/chunk-MPGIHELS.js +0 -39
  148. package/dist/chunk-TOIEB3LG.js +0 -78
  149. package/dist/chunk-UQEQ6AHX.js +0 -60
  150. package/dist/chunk-VJJKSGIX.js +0 -121
  151. package/dist/chunk-YGGFLMTM.js +0 -83
  152. package/dist/chunk-ZEUCXQBN.js +0 -71
@@ -1,9 +1,15 @@
1
1
  import {
2
2
  isLiveBarrel
3
- } from "./chunk-YY4QGUQ5.js";
3
+ } from "./chunk-JKXHHV4B.js";
4
4
  import {
5
+ getDefinitionsForFile,
6
+ getSourceExports,
7
+ getSourceImports
8
+ } from "./chunk-ALUFWH3U.js";
9
+ import {
10
+ leafSuffix,
5
11
  shortenSymbol
6
- } from "./chunk-QIXNAB5K.js";
12
+ } from "./chunk-TO3L4YNK.js";
7
13
 
8
14
  // src/queries/redundant-reexports.ts
9
15
  function redundantReexports(db, opts = {}) {
@@ -96,10 +102,84 @@ function redundantReexports(db, opts = {}) {
96
102
  results.sort(
97
103
  (a, b) => b.directConsumers - a.directConsumers || a.barrelFile.localeCompare(b.barrelFile) || a.shortName.localeCompare(b.shortName)
98
104
  );
99
- return limit ? results.slice(0, limit) : results;
105
+ const withDartFallback = dedupeReexports([
106
+ ...results,
107
+ ...findSourceRedundantReexports(db, scope)
108
+ ]);
109
+ withDartFallback.sort(
110
+ (a, b) => b.directConsumers - a.directConsumers || a.barrelFile.localeCompare(b.barrelFile) || a.shortName.localeCompare(b.shortName)
111
+ );
112
+ return limit ? withDartFallback.slice(0, limit) : withDartFallback;
113
+ }
114
+ function findSourceRedundantReexports(db, scope) {
115
+ const files = db.all(
116
+ `SELECT relative_path
117
+ FROM documents
118
+ WHERE 1 = 1
119
+ ${scope ? "AND relative_path LIKE ?" : ""}
120
+ ${db.pathExclusionsFor("documents")}
121
+ ORDER BY relative_path`,
122
+ ...scope ? [`%${scope}%`] : []
123
+ );
124
+ const candidates = files.map((row) => row.relative_path).filter((relativePath) => !db.isIgnored(relativePath)).filter((relativePath) => getSourceExports(db, relativePath).length > 0);
125
+ const results = [];
126
+ for (const barrelPath of candidates) {
127
+ const exports = getSourceExports(db, barrelPath).filter((entry) => entry.sourcePath && !db.isIgnored(entry.sourcePath));
128
+ if (exports.length === 0) continue;
129
+ const barrelConsumers = countDirectImporters(db, barrelPath, barrelPath);
130
+ if (barrelConsumers > 0) continue;
131
+ for (const exported of exports) {
132
+ const sourcePath = exported.sourcePath;
133
+ const representative = representativeExportSymbol(db, sourcePath);
134
+ if (!representative) continue;
135
+ results.push({
136
+ barrelFile: barrelPath,
137
+ symbol: representative.symbol,
138
+ shortName: shortenSymbol(representative.symbol),
139
+ originalFile: sourcePath,
140
+ barrelConsumers: 0,
141
+ directConsumers: countDirectImporters(db, sourcePath, barrelPath)
142
+ });
143
+ }
144
+ }
145
+ return results;
146
+ }
147
+ function countDirectImporters(db, targetPath, excludedPath) {
148
+ const files = db.all(
149
+ `SELECT relative_path
150
+ FROM documents
151
+ WHERE 1 = 1
152
+ ${db.pathExclusionsFor("documents")}
153
+ ORDER BY relative_path`
154
+ );
155
+ const importers = /* @__PURE__ */ new Set();
156
+ for (const row of files) {
157
+ if (db.isIgnored(row.relative_path) || row.relative_path === excludedPath) continue;
158
+ for (const imported of getSourceImports(db, row.relative_path)) {
159
+ if (imported.sourcePath === targetPath) {
160
+ importers.add(row.relative_path);
161
+ }
162
+ }
163
+ }
164
+ return importers.size;
165
+ }
166
+ function representativeExportSymbol(db, sourcePath) {
167
+ const definitions = getDefinitionsForFile(db, sourcePath);
168
+ return definitions.find((definition) => leafSuffix(definition.symbol) === "method") ?? definitions[0] ?? null;
169
+ }
170
+ function dedupeReexports(rows) {
171
+ const seen = /* @__PURE__ */ new Set();
172
+ const unique = [];
173
+ for (const row of rows) {
174
+ const key = `${row.barrelFile}|${row.symbol}|${row.originalFile}`;
175
+ if (seen.has(key)) continue;
176
+ seen.add(key);
177
+ unique.push(row);
178
+ }
179
+ return unique;
100
180
  }
101
181
 
102
182
  export {
103
183
  redundantReexports
104
184
  };
105
- //# sourceMappingURL=chunk-P3E6L7KW.js.map
185
+ //# sourceMappingURL=chunk-TWVXFKJA.js.map
@@ -0,0 +1,75 @@
1
+ import {
2
+ getDefinitionsForFile,
3
+ resolveIndexedPaths
4
+ } from "./chunk-ALUFWH3U.js";
5
+ import {
6
+ leafSuffix,
7
+ shortenSymbol
8
+ } from "./chunk-TO3L4YNK.js";
9
+
10
+ // src/queries/surface.ts
11
+ function surface(db, modulePattern) {
12
+ const matchedPaths = resolveIndexedPaths(db, modulePattern);
13
+ if (matchedPaths.length === 0) {
14
+ return [];
15
+ }
16
+ const placeholders = matchedPaths.map(() => "?").join(", ");
17
+ const rows = db.all(
18
+ `SELECT DISTINCT d1.relative_path, gs.symbol
19
+ FROM mentions m
20
+ JOIN chunks c ON m.chunk_id = c.id
21
+ JOIN documents d1 ON c.document_id = d1.id
22
+ JOIN global_symbols gs ON m.symbol_id = gs.id
23
+ WHERE d1.relative_path NOT IN (${placeholders})
24
+ AND (
25
+ EXISTS (
26
+ SELECT 1
27
+ FROM defn_enclosing_ranges der
28
+ JOIN documents d2 ON der.document_id = d2.id
29
+ WHERE der.symbol_id = gs.id
30
+ AND d2.relative_path IN (${placeholders})
31
+ )
32
+ OR EXISTS (
33
+ SELECT 1
34
+ FROM mentions def_m
35
+ JOIN chunks def_c ON def_m.chunk_id = def_c.id
36
+ JOIN documents d2 ON def_c.document_id = d2.id
37
+ WHERE def_m.symbol_id = gs.id
38
+ AND def_m.role = 1
39
+ AND d2.relative_path IN (${placeholders})
40
+ )
41
+ )
42
+ AND m.role != 1
43
+ AND ${db.localSymbolPredicate}
44
+ ${db.pathExclusionsFor("d1")}
45
+ ORDER BY d1.relative_path`,
46
+ ...matchedPaths,
47
+ ...matchedPaths,
48
+ ...matchedPaths
49
+ );
50
+ const exposedDefinitions = matchedPaths.flatMap(
51
+ (relativePath) => getDefinitionsForFile(db, relativePath).filter((definition) => isCallableSymbol(definition.symbol)).map((definition) => ({
52
+ relative_path: relativePath,
53
+ symbol: definition.symbol
54
+ }))
55
+ );
56
+ const seen = /* @__PURE__ */ new Set();
57
+ return [...rows, ...exposedDefinitions].filter((r) => !db.isIgnored(r.relative_path)).filter((r) => {
58
+ const key = `${r.relative_path}|${r.symbol}`;
59
+ if (seen.has(key)) return false;
60
+ seen.add(key);
61
+ return true;
62
+ }).map((r) => ({
63
+ consumer: r.relative_path,
64
+ symbol: r.symbol,
65
+ shortName: shortenSymbol(r.symbol)
66
+ }));
67
+ }
68
+ function isCallableSymbol(rawSymbol) {
69
+ return rawSymbol.endsWith("().") || leafSuffix(rawSymbol) === "method";
70
+ }
71
+
72
+ export {
73
+ surface
74
+ };
75
+ //# sourceMappingURL=chunk-UJWI5CBB.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  findFirstSymbolMatch,
3
3
  resolveIndexedFile
4
- } from "./chunk-AXQKUYKF.js";
4
+ } from "./chunk-ALUFWH3U.js";
5
5
  import {
6
6
  shortenSymbol
7
- } from "./chunk-QIXNAB5K.js";
7
+ } from "./chunk-TO3L4YNK.js";
8
8
 
9
9
  // src/queries/code.ts
10
10
  import { readFileSync } from "fs";
@@ -76,4 +76,4 @@ function readFileRange(db, filePath, startLine, endLine, context) {
76
76
  export {
77
77
  code
78
78
  };
79
- //# sourceMappingURL=chunk-J3JSOSUO.js.map
79
+ //# sourceMappingURL=chunk-VKBOLNYN.js.map
@@ -1,6 +1,10 @@
1
+ import {
2
+ getAllDefinitions,
3
+ getCallerRowsForSymbol
4
+ } from "./chunk-ALUFWH3U.js";
1
5
  import {
2
6
  shortenSymbol
3
- } from "./chunk-QIXNAB5K.js";
7
+ } from "./chunk-TO3L4YNK.js";
4
8
 
5
9
  // src/queries/hotspots.ts
6
10
  function hotspots(db, opts = {}) {
@@ -27,16 +31,29 @@ function hotspots(db, opts = {}) {
27
31
  LIMIT ?`,
28
32
  limit
29
33
  );
30
- return rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
34
+ const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
31
35
  symbol: r.symbol,
32
36
  shortName: shortenSymbol(r.symbol),
33
37
  refCount: r.ref_count,
34
38
  fileCount: r.file_count,
35
39
  definedIn: r.defined_in
36
40
  }));
41
+ if (indexedResults.length > 0) {
42
+ return indexedResults;
43
+ }
44
+ return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
45
+ const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
46
+ return {
47
+ symbol: definition.symbol,
48
+ shortName: shortenSymbol(definition.symbol),
49
+ refCount: callerRows.length,
50
+ fileCount: new Set(callerRows.map((row) => row.file)).size,
51
+ definedIn: definition.relativePath
52
+ };
53
+ }).filter((row) => row.refCount > 0).sort((left, right) => right.refCount - left.refCount || right.fileCount - left.fileCount).slice(0, limit);
37
54
  }
38
55
 
39
56
  export {
40
57
  hotspots
41
58
  };
42
- //# sourceMappingURL=chunk-KBOQX573.js.map
59
+ //# sourceMappingURL=chunk-VY2L4TP6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveIndexedFile
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-ALUFWH3U.js";
4
4
 
5
5
  // src/queries/coupling.ts
6
6
  function coupling(db, file1, file2) {
@@ -81,4 +81,4 @@ export {
81
81
  coupling,
82
82
  topCoupling
83
83
  };
84
- //# sourceMappingURL=chunk-KKCHYLVI.js.map
84
+ //# sourceMappingURL=chunk-W46L2BXT.js.map
@@ -0,0 +1,34 @@
1
+ import {
2
+ isEntrySurface
3
+ } from "./chunk-JKXHHV4B.js";
4
+ import {
5
+ getAllDefinitions,
6
+ getCalleeRowsForSymbol,
7
+ getCallerRowsForSymbol
8
+ } from "./chunk-ALUFWH3U.js";
9
+ import {
10
+ shortenSymbol
11
+ } from "./chunk-TO3L4YNK.js";
12
+
13
+ // src/queries/isolated.ts
14
+ function isolated(db, opts = {}) {
15
+ const { scope, minLoc = 3 } = opts;
16
+ return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isEntrySurface(db, definition.relativePath)).filter((definition) => definition.isFunctionLike).map((definition) => ({
17
+ definition,
18
+ loc: definition.endLine - definition.startLine + 1
19
+ })).filter((entry) => entry.loc >= minLoc).filter((entry) => getCallerRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).filter((entry) => getCalleeRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).sort(
20
+ (left, right) => right.loc - left.loc || left.definition.relativePath.localeCompare(right.definition.relativePath) || left.definition.startLine - right.definition.startLine
21
+ ).map((entry) => ({
22
+ symbol: entry.definition.symbol,
23
+ shortName: shortenSymbol(entry.definition.symbol),
24
+ relativePath: entry.definition.relativePath,
25
+ startLine: entry.definition.startLine,
26
+ endLine: entry.definition.endLine,
27
+ loc: entry.loc
28
+ }));
29
+ }
30
+
31
+ export {
32
+ isolated
33
+ };
34
+ //# sourceMappingURL=chunk-XUVPQDXW.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-AXQKUYKF.js";
3
+ } from "./chunk-ALUFWH3U.js";
4
4
 
5
5
  // src/queries/deep-chains.ts
6
6
  function deepChains(db, opts = {}) {
@@ -41,4 +41,4 @@ function deepChains(db, opts = {}) {
41
41
  export {
42
42
  deepChains
43
43
  };
44
- //# sourceMappingURL=chunk-DH7G3DDV.js.map
44
+ //# sourceMappingURL=chunk-Z5VSUOEE.js.map
@@ -3,12 +3,13 @@ import {
3
3
  } from "./chunk-4TYLS5XX.js";
4
4
  import {
5
5
  findFirstSymbolMatch,
6
- getSourceReferenceSites
7
- } from "./chunk-AXQKUYKF.js";
6
+ getSourceReferenceSites,
7
+ getSourceText
8
+ } from "./chunk-ALUFWH3U.js";
8
9
  import {
9
10
  isFunctionLikeSymbol,
10
11
  shortenSymbol
11
- } from "./chunk-QIXNAB5K.js";
12
+ } from "./chunk-TO3L4YNK.js";
12
13
 
13
14
  // src/queries/trace.ts
14
15
  function trace(db, symbolPattern) {
@@ -16,24 +17,22 @@ function trace(db, symbolPattern) {
16
17
  if (!match) {
17
18
  return { definitions: [], referencedBy: [] };
18
19
  }
19
- const defRows = db.all(
20
- `SELECT d.relative_path, der.start_line, der.end_line,
20
+ const definitionMeta = db.get(
21
+ `SELECT
21
22
  gs.display_name,
22
23
  REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig
23
24
  FROM global_symbols gs
24
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
25
- JOIN documents d ON der.document_id = d.id
26
25
  WHERE gs.id = ?
27
- ORDER BY d.relative_path, der.start_line
28
26
  LIMIT 10`,
29
27
  match.symbolId
30
28
  );
31
- const definitions = defRows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
32
- relativePath: r.relative_path,
33
- startLine: r.start_line,
34
- endLine: r.end_line,
35
- signature: buildTraceSignature(r.sig, r.display_name, match.symbol)
36
- }));
29
+ const definitions = db.isIgnored(match.relativePath) ? [] : [{
30
+ relativePath: match.relativePath,
31
+ startLine: match.startLine,
32
+ endLine: match.endLine,
33
+ signature: buildTraceSignature(definitionMeta?.sig ?? null, definitionMeta?.display_name ?? null, match.symbol),
34
+ source: definitionSource(db, match.relativePath, match.startLine, match.endLine)
35
+ }];
37
36
  const sourceSites = getSourceReferenceSites(db, match);
38
37
  const referencedBy = sourceSites.length > 0 ? sourceSites.filter((site) => !db.isIgnored(site.file)).map((site) => ({
39
38
  relativePath: site.file,
@@ -66,6 +65,15 @@ function trace(db, symbolPattern) {
66
65
  }));
67
66
  return { definitions, referencedBy };
68
67
  }
68
+ function definitionSource(db, relativePath, startLine, endLine) {
69
+ const source = getSourceText(db, relativePath);
70
+ if (!source) {
71
+ return null;
72
+ }
73
+ const lines = source.split("\n");
74
+ const slice = lines.slice(startLine, endLine + 1).join("\n").trimEnd();
75
+ return slice.length > 0 ? slice : null;
76
+ }
69
77
  function buildTraceSignature(signature, displayName, rawSymbol) {
70
78
  const cleaned = cleanSignature(signature);
71
79
  if (cleaned && !looksBogusSignature(cleaned)) {
@@ -84,4 +92,4 @@ function looksBogusSignature(signature) {
84
92
  export {
85
93
  trace
86
94
  };
87
- //# sourceMappingURL=chunk-GEXE2T6I.js.map
95
+ //# sourceMappingURL=chunk-ZVZAIIB5.js.map