scip-query 0.4.2 → 0.5.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 (145) hide show
  1. package/dist/{chunk-OXX3QF24.js → chunk-2MQ5DPY6.js} +2 -2
  2. package/dist/{chunk-RL74LF47.js → chunk-2QTYIOJ5.js} +2 -2
  3. package/dist/{chunk-DUJNJQPO.js → chunk-3VI4YXCL.js} +3 -3
  4. package/dist/{chunk-XUVPQDXW.js → chunk-3VV2G6U7.js} +4 -4
  5. package/dist/{chunk-J47VSL6I.js → chunk-44PFXVXG.js} +3 -3
  6. package/dist/{chunk-SVLUJSY7.js → chunk-6SLFQR36.js} +4 -15
  7. package/dist/{chunk-JHVQB4Y5.js → chunk-7DBPRGMS.js} +12 -12
  8. package/dist/{chunk-A6XLXV6W.js → chunk-DTB724R3.js} +3 -3
  9. package/dist/{chunk-TWVXFKJA.js → chunk-FLOYI6I4.js} +4 -4
  10. package/dist/{chunk-MGNMHKX3.js → chunk-FO2CBB7U.js} +10 -2
  11. package/dist/{chunk-4TYLS5XX.js → chunk-GJT3MO2T.js} +9 -2
  12. package/dist/{chunk-EAGKJFDX.js → chunk-HAP4LJKX.js} +8 -29
  13. package/dist/{chunk-RE7POFGI.js → chunk-JCOJQ4I6.js} +2 -2
  14. package/dist/{chunk-VY2L4TP6.js → chunk-JGQMOS4V.js} +3 -3
  15. package/dist/{chunk-QMXSLHZP.js → chunk-JMD4WJ2Q.js} +2 -2
  16. package/dist/{chunk-43A4UCS7.js → chunk-JSQPZOPO.js} +11 -18
  17. package/dist/{chunk-PCU455MX.js → chunk-JSXGC2EH.js} +2 -2
  18. package/dist/chunk-JZN3DRCT.js +59 -0
  19. package/dist/{chunk-ZVZAIIB5.js → chunk-KMWYB3CX.js} +12 -36
  20. package/dist/{chunk-SYQR4QGK.js → chunk-MRM755FU.js} +8 -9
  21. package/dist/{chunk-R7HPHMRZ.js → chunk-N2XO3Z5F.js} +3 -3
  22. package/dist/{chunk-POLELLNM.js → chunk-OLW5UL36.js} +19 -25
  23. package/dist/{chunk-ALUFWH3U.js → chunk-OMCRXXDX.js} +187 -282
  24. package/dist/{chunk-Z5VSUOEE.js → chunk-OWJOHUZE.js} +2 -2
  25. package/dist/{chunk-RJ5GULL6.js → chunk-PEDH3D4G.js} +2 -2
  26. package/dist/{chunk-6UZU7DFL.js → chunk-POAN4SCR.js} +3 -3
  27. package/dist/{chunk-3NJSJ7TE.js → chunk-PTMGEBU3.js} +4 -15
  28. package/dist/{chunk-NXUIWD6K.js → chunk-PU44HK7P.js} +3 -3
  29. package/dist/{chunk-6CH23IAS.js → chunk-QJI7EECA.js} +22 -34
  30. package/dist/{chunk-KLNKDX6A.js → chunk-R5HICGMB.js} +4 -4
  31. package/dist/{chunk-6ECR2FLR.js → chunk-RJ2D6YWQ.js} +4 -15
  32. package/dist/{chunk-CBIWNZZZ.js → chunk-RZ5GYPBP.js} +3 -3
  33. package/dist/chunk-SRLQNO6O.js +101 -0
  34. package/dist/{chunk-JKXHHV4B.js → chunk-UGS7HJI4.js} +2 -2
  35. package/dist/{chunk-PU2254N2.js → chunk-VKUUXOE7.js} +5 -15
  36. package/dist/{chunk-W46L2BXT.js → chunk-VPUJSJCI.js} +2 -2
  37. package/dist/{chunk-UJWI5CBB.js → chunk-VRWVV3EP.js} +4 -7
  38. package/dist/{chunk-7BS4CPJX.js → chunk-WJWQEU4A.js} +3 -3
  39. package/dist/chunk-WJZHDUSB.js +40 -0
  40. package/dist/{chunk-FVJE4MQL.js → chunk-WWOCQ5W4.js} +5 -8
  41. package/dist/chunk-X3Q2OVRL.js +77 -0
  42. package/dist/chunk-Y3P7QKKN.js +27 -0
  43. package/dist/{chunk-VKBOLNYN.js → chunk-Y6FAHY4N.js} +10 -8
  44. package/dist/{chunk-TO3L4YNK.js → chunk-YMSJCSRG.js} +5 -1
  45. package/dist/{chunk-24LF6IZB.js → chunk-ZDL3U4W2.js} +3 -3
  46. package/dist/{chunk-KG4OFQEN.js → chunk-ZXNX5JRE.js} +3 -3
  47. package/dist/cli.js +368 -721
  48. package/dist/{db-C4rPbKkI.d.ts → db-6F9R9e_t.d.ts} +0 -4
  49. package/dist/index.d.ts +2 -4
  50. package/dist/index.js +46 -58
  51. package/dist/queries/affected.d.ts +1 -1
  52. package/dist/queries/affected.js +3 -3
  53. package/dist/queries/bottlenecks.d.ts +1 -1
  54. package/dist/queries/bottlenecks.js +3 -3
  55. package/dist/queries/by-kind.d.ts +1 -1
  56. package/dist/queries/by-kind.js +3 -3
  57. package/dist/queries/call-graph.d.ts +1 -1
  58. package/dist/queries/call-graph.js +3 -3
  59. package/dist/queries/change-surface.d.ts +4 -1
  60. package/dist/queries/change-surface.js +3 -3
  61. package/dist/queries/clean-signature.d.ts +9 -1
  62. package/dist/queries/clean-signature.js +5 -3
  63. package/dist/queries/code.d.ts +1 -1
  64. package/dist/queries/code.js +3 -3
  65. package/dist/queries/complexity-hotspots.d.ts +8 -1
  66. package/dist/queries/complexity-hotspots.js +3 -3
  67. package/dist/queries/complexity.d.ts +1 -1
  68. package/dist/queries/complexity.js +3 -3
  69. package/dist/queries/convergence.d.ts +1 -1
  70. package/dist/queries/convergence.js +3 -3
  71. package/dist/queries/coupling.d.ts +1 -1
  72. package/dist/queries/coupling.js +3 -3
  73. package/dist/queries/cycles.d.ts +1 -1
  74. package/dist/queries/cycles.js +3 -3
  75. package/dist/queries/dataflow.d.ts +1 -1
  76. package/dist/queries/dataflow.js +3 -3
  77. package/dist/queries/dead.d.ts +1 -1
  78. package/dist/queries/dead.js +4 -4
  79. package/dist/queries/deep-chains.d.ts +1 -1
  80. package/dist/queries/deep-chains.js +3 -3
  81. package/dist/queries/deps.d.ts +1 -1
  82. package/dist/queries/deps.js +3 -3
  83. package/dist/queries/diff-impact.d.ts +1 -1
  84. package/dist/queries/diff-impact.js +2 -2
  85. package/dist/queries/drift.d.ts +1 -1
  86. package/dist/queries/drift.js +3 -3
  87. package/dist/queries/extract-candidates.d.ts +1 -1
  88. package/dist/queries/extract-candidates.js +3 -3
  89. package/dist/queries/fan.d.ts +1 -1
  90. package/dist/queries/fan.js +3 -3
  91. package/dist/queries/files.d.ts +1 -1
  92. package/dist/queries/files.js +1 -1
  93. package/dist/queries/health.d.ts +1 -1
  94. package/dist/queries/health.js +14 -14
  95. package/dist/queries/hierarchy.d.ts +1 -1
  96. package/dist/queries/hierarchy.js +3 -3
  97. package/dist/queries/hotspots.d.ts +1 -1
  98. package/dist/queries/hotspots.js +3 -3
  99. package/dist/queries/imports.d.ts +1 -1
  100. package/dist/queries/imports.js +3 -3
  101. package/dist/queries/index.d.ts +1 -1
  102. package/dist/queries/index.js +46 -46
  103. package/dist/queries/isolated.d.ts +1 -1
  104. package/dist/queries/isolated.js +4 -4
  105. package/dist/queries/members.d.ts +4 -1
  106. package/dist/queries/members.js +3 -3
  107. package/dist/queries/methods.d.ts +1 -1
  108. package/dist/queries/methods.js +3 -3
  109. package/dist/queries/outline.d.ts +4 -1
  110. package/dist/queries/outline.js +3 -3
  111. package/dist/queries/passthrough-candidates.d.ts +1 -1
  112. package/dist/queries/passthrough-candidates.js +3 -3
  113. package/dist/queries/redundant-reexports.d.ts +1 -1
  114. package/dist/queries/redundant-reexports.js +4 -4
  115. package/dist/queries/refs.d.ts +1 -1
  116. package/dist/queries/refs.js +3 -3
  117. package/dist/queries/similar-chains.d.ts +1 -1
  118. package/dist/queries/similar-chains.js +3 -3
  119. package/dist/queries/similar-files.d.ts +1 -1
  120. package/dist/queries/similar-files.js +3 -3
  121. package/dist/queries/similar-signatures.d.ts +1 -1
  122. package/dist/queries/similar-signatures.js +3 -3
  123. package/dist/queries/similar.d.ts +2 -1
  124. package/dist/queries/similar.js +3 -3
  125. package/dist/queries/slice.d.ts +4 -3
  126. package/dist/queries/slice.js +3 -3
  127. package/dist/queries/stale-abstractions.d.ts +1 -1
  128. package/dist/queries/stale-abstractions.js +3 -3
  129. package/dist/queries/stats.d.ts +1 -1
  130. package/dist/queries/surface.d.ts +1 -1
  131. package/dist/queries/surface.js +3 -3
  132. package/dist/queries/symbols.d.ts +1 -1
  133. package/dist/queries/symbols.js +4 -4
  134. package/dist/queries/system.d.ts +6 -2
  135. package/dist/queries/system.js +4 -4
  136. package/dist/queries/trace.d.ts +1 -1
  137. package/dist/queries/trace.js +4 -4
  138. package/dist/queries/wrapper-candidates.d.ts +1 -1
  139. package/dist/queries/wrapper-candidates.js +3 -3
  140. package/package.json +1 -1
  141. package/dist/chunk-5GCORUNV.js +0 -100
  142. package/dist/chunk-ELFGD5EW.js +0 -130
  143. package/dist/chunk-GNAMV3JC.js +0 -37
  144. package/dist/chunk-J6QXMYAQ.js +0 -115
  145. package/dist/chunk-KYPXKV64.js +0 -51
@@ -5,7 +5,7 @@ import {
5
5
  leafSuffix,
6
6
  parseSymbol,
7
7
  shortenSymbol
8
- } from "./chunk-TO3L4YNK.js";
8
+ } from "./chunk-YMSJCSRG.js";
9
9
 
10
10
  // src/source-analysis.ts
11
11
  import {
@@ -1054,44 +1054,55 @@ function getCachedMap(cache, db) {
1054
1054
  function normalizePath(path) {
1055
1055
  return path.replace(/\\/g, "/");
1056
1056
  }
1057
+ var LANGUAGE_EXTENSION_FAMILIES = [
1058
+ SOURCE_EXTENSIONS,
1059
+ PYTHON_SOURCE_EXTENSIONS,
1060
+ JVM_SOURCE_EXTENSIONS,
1061
+ RUST_SOURCE_EXTENSIONS,
1062
+ RUBY_SOURCE_EXTENSIONS,
1063
+ C_LIKE_SOURCE_EXTENSIONS,
1064
+ DOTNET_SOURCE_EXTENSIONS,
1065
+ DART_SOURCE_EXTENSIONS,
1066
+ PHP_SOURCE_EXTENSIONS
1067
+ ];
1068
+ function hasExtensionIn(relativePath, extensions) {
1069
+ return extensions.includes(extname(relativePath).toLowerCase());
1070
+ }
1057
1071
  function isJavaScriptSourcePath(relativePath) {
1058
- return SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1072
+ return hasExtensionIn(relativePath, SOURCE_EXTENSIONS);
1059
1073
  }
1060
1074
  function isPythonSourcePath(relativePath) {
1061
- return PYTHON_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1075
+ return hasExtensionIn(relativePath, PYTHON_SOURCE_EXTENSIONS);
1062
1076
  }
1063
1077
  function isJvmSourcePath(relativePath) {
1064
- return JVM_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1078
+ return hasExtensionIn(relativePath, JVM_SOURCE_EXTENSIONS);
1065
1079
  }
1066
1080
  function isRustSourcePath(relativePath) {
1067
- return RUST_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1081
+ return hasExtensionIn(relativePath, RUST_SOURCE_EXTENSIONS);
1068
1082
  }
1069
1083
  function isRubySourcePath(relativePath) {
1070
- return RUBY_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1084
+ return hasExtensionIn(relativePath, RUBY_SOURCE_EXTENSIONS);
1071
1085
  }
1072
1086
  function isCLikeSourcePath(relativePath) {
1073
- return C_LIKE_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1087
+ return hasExtensionIn(relativePath, C_LIKE_SOURCE_EXTENSIONS);
1074
1088
  }
1075
1089
  function isDotNetSourcePath(relativePath) {
1076
- return DOTNET_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1090
+ return hasExtensionIn(relativePath, DOTNET_SOURCE_EXTENSIONS);
1077
1091
  }
1078
1092
  function isVisualBasicSourcePath(relativePath) {
1079
1093
  return extname(relativePath).toLowerCase() === ".vb";
1080
1094
  }
1081
1095
  function isDartSourcePath(relativePath) {
1082
- return DART_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1096
+ return hasExtensionIn(relativePath, DART_SOURCE_EXTENSIONS);
1083
1097
  }
1084
1098
  function isPhpSourcePath(relativePath) {
1085
- return PHP_SOURCE_EXTENSIONS.includes(extname(relativePath).toLowerCase());
1099
+ return hasExtensionIn(relativePath, PHP_SOURCE_EXTENSIONS);
1086
1100
  }
1087
1101
  function extensionFamilyFor(relativePath) {
1088
- if (isJvmSourcePath(relativePath)) return JVM_SOURCE_EXTENSIONS;
1089
- if (isDotNetSourcePath(relativePath)) return DOTNET_SOURCE_EXTENSIONS;
1090
- if (isPhpSourcePath(relativePath)) return PHP_SOURCE_EXTENSIONS;
1091
- if (isDartSourcePath(relativePath)) return DART_SOURCE_EXTENSIONS;
1092
- if (isCLikeSourcePath(relativePath)) return C_LIKE_SOURCE_EXTENSIONS;
1093
- if (isRustSourcePath(relativePath)) return RUST_SOURCE_EXTENSIONS;
1094
- if (isRubySourcePath(relativePath)) return RUBY_SOURCE_EXTENSIONS;
1102
+ const ext = extname(relativePath).toLowerCase();
1103
+ for (const family of LANGUAGE_EXTENSION_FAMILIES) {
1104
+ if (family.includes(ext)) return family;
1105
+ }
1095
1106
  return SOURCE_EXTENSIONS;
1096
1107
  }
1097
1108
  function getSourceText(db, relativePath) {
@@ -1139,10 +1150,6 @@ var TEST_FILE_PATTERNS = [
1139
1150
  var TEST_SUPPORT_PATH_PATTERNS = [
1140
1151
  "%/test-utils/%"
1141
1152
  ];
1142
- function testFileExclusionSql(alias, extraPatterns = []) {
1143
- const patterns = uniquePatterns([...TEST_FILE_PATTERNS, ...extraPatterns]);
1144
- return patterns.map((pattern) => `${alias}.relative_path NOT LIKE '${pattern}'`).join("\n AND ");
1145
- }
1146
1153
  function buildFileDepGraph(db, scope) {
1147
1154
  const scopeFilter = scope ? `AND d1.relative_path LIKE '%${scope}%'` : "";
1148
1155
  const edges = db.all(
@@ -1197,6 +1204,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
1197
1204
  const fileLineMatch = symbolPattern.match(/^(.+):(\d+)-(\d+)$/);
1198
1205
  if (fileLineMatch) {
1199
1206
  const [, filePath, startStr, endStr] = fileLineMatch;
1207
+ const userStart0 = Math.max(0, parseInt(startStr, 10) - 1);
1208
+ const userEnd0 = Math.max(userStart0, parseInt(endStr, 10) - 1);
1200
1209
  let row = db.get(
1201
1210
  `SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
1202
1211
  FROM global_symbols gs
@@ -1208,8 +1217,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
1208
1217
  ORDER BY (der.end_line - der.start_line) ASC
1209
1218
  LIMIT 1`,
1210
1219
  `%${filePath}%`,
1211
- parseInt(startStr, 10),
1212
- parseInt(endStr, 10)
1220
+ userStart0,
1221
+ userEnd0
1213
1222
  );
1214
1223
  if (!row) {
1215
1224
  row = db.get(
@@ -1226,8 +1235,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
1226
1235
  ORDER BY (MAX(c.end_line) - MIN(c.start_line)) ASC
1227
1236
  LIMIT 1`,
1228
1237
  `%${filePath}%`,
1229
- parseInt(startStr, 10),
1230
- parseInt(endStr, 10)
1238
+ userStart0,
1239
+ userEnd0
1231
1240
  );
1232
1241
  }
1233
1242
  if (row && !db.isIgnored(row.relative_path)) {
@@ -1519,6 +1528,59 @@ function getSourceReferenceSites(db, symbol) {
1519
1528
  }
1520
1529
  return sites;
1521
1530
  }
1531
+ function getResolvedReferenceSites(db, symbol) {
1532
+ const match = getFullSymbolMatch(db, symbol);
1533
+ if (!match) {
1534
+ return [];
1535
+ }
1536
+ const rows = db.all(
1537
+ `SELECT DISTINCT d.relative_path, c.start_line, c.end_line
1538
+ FROM mentions m
1539
+ JOIN chunks c ON m.chunk_id = c.id
1540
+ JOIN documents d ON c.document_id = d.id
1541
+ WHERE m.symbol_id = ?
1542
+ AND m.role != 1
1543
+ ${db.pathExclusionsFor("d")}
1544
+ ORDER BY d.relative_path, c.start_line`,
1545
+ match.symbolId
1546
+ );
1547
+ const chunksByFile = /* @__PURE__ */ new Map();
1548
+ for (const row of rows) {
1549
+ if (db.isIgnored(row.relative_path)) continue;
1550
+ let bucket = chunksByFile.get(row.relative_path);
1551
+ if (!bucket) {
1552
+ bucket = [];
1553
+ chunksByFile.set(row.relative_path, bucket);
1554
+ }
1555
+ bucket.push({ start_line: row.start_line, end_line: row.end_line });
1556
+ }
1557
+ const identifier = leafName(match.symbol);
1558
+ const sites = [];
1559
+ const seen = /* @__PURE__ */ new Set();
1560
+ for (const [file, chunks] of chunksByFile) {
1561
+ const definitions = getDefinitionsForFile(db, file);
1562
+ const excludeOpts = file === match.relativePath ? { excludeStartLine: match.startLine, excludeEndLine: match.endLine } : {};
1563
+ const allHits = identifier ? findIdentifierLines(db, file, identifier, excludeOpts) : [];
1564
+ for (const chunk of chunks) {
1565
+ const hitsInChunk = allHits.filter(
1566
+ (line) => line >= chunk.start_line && line <= chunk.end_line
1567
+ );
1568
+ const lines = hitsInChunk.length > 0 ? hitsInChunk : [chunk.start_line];
1569
+ for (const line of lines) {
1570
+ const enclosing = findEnclosingDefinition(definitions, line);
1571
+ const key = `${file}|${line}|${enclosing?.symbol ?? ""}`;
1572
+ if (seen.has(key)) continue;
1573
+ seen.add(key);
1574
+ sites.push({
1575
+ file,
1576
+ line,
1577
+ enclosingSymbol: enclosing?.symbol ?? null
1578
+ });
1579
+ }
1580
+ }
1581
+ }
1582
+ return sites;
1583
+ }
1522
1584
  function calleeQueryParams(symbol, limit) {
1523
1585
  const params = [
1524
1586
  symbol.documentId,
@@ -1548,56 +1610,41 @@ function findEnclosingDefinition(definitions, line) {
1548
1610
  }
1549
1611
  return best;
1550
1612
  }
1551
- function getPythonSourceCalleeRows(db, symbol, limit) {
1552
- const match = getFullSymbolMatch(db, symbol);
1553
- if (!match || !isPythonDocument(db, match.relativePath)) {
1554
- return [];
1555
- }
1556
- const definitions = getDefinitionsForFile(db, match.relativePath);
1557
- const current = definitions.find((definition) => definition.symbolId === match.symbolId);
1558
- if (!current) {
1559
- return [];
1560
- }
1561
- const imports = getSourceImports(db, match.relativePath);
1562
- const bindings = new Map(
1563
- getSourceConstructorBindings(db, match.relativePath, {
1564
- startLine: match.startLine,
1565
- endLine: match.endLine
1566
- }).map((binding) => [binding.localName, binding.typeName])
1567
- );
1568
- const rows = [];
1569
- const seen = /* @__PURE__ */ new Set();
1570
- for (const call of getSourceCalls(db, match.relativePath, {
1571
- startLine: match.startLine,
1572
- endLine: match.endLine
1573
- })) {
1574
- const resolved = resolvePythonCallTarget(
1575
- db,
1576
- current,
1577
- definitions,
1578
- imports,
1579
- bindings,
1580
- call.receiverName,
1581
- call.calleeName
1582
- );
1583
- if (!resolved || resolved.symbolId === match.symbolId || db.isIgnored(resolved.relativePath)) continue;
1584
- const chunkId = 1e9 + call.line;
1585
- const key = `${resolved.symbol}|${resolved.relativePath}|${chunkId}`;
1586
- if (seen.has(key)) continue;
1587
- seen.add(key);
1588
- rows.push({
1589
- symbol: resolved.symbol,
1590
- file: resolved.relativePath,
1591
- chunkId
1592
- });
1593
- }
1594
- return applyLimit(rows, limit);
1595
- }
1596
- function getJavaScriptSourceCalleeRows(db, symbol, limit) {
1597
- const match = getFullSymbolMatch(db, symbol);
1598
- if (!match || !isJavaScriptDocument(db, match.relativePath)) {
1599
- return [];
1600
- }
1613
+ var LANGUAGE_CALLEE_CONFIGS = [
1614
+ // Python (index 0) — complex resolver
1615
+ { kind: "complex", languageIndex: 0, resolver: resolvePythonCallTarget },
1616
+ // JavaScript/TypeScript (index 1) — complex resolver
1617
+ { kind: "complex", languageIndex: 1, resolver: resolveJavaScriptCallTarget },
1618
+ // Java (index 2) — simple with field bindings
1619
+ { kind: "simple", languageIndex: 2, parseBindings: (_db, source) => parseJavaFieldBindings(source) },
1620
+ // Kotlin (index 3) — simple with field bindings
1621
+ { kind: "simple", languageIndex: 3, parseBindings: (_db, source) => parseKotlinFieldBindings(source) },
1622
+ // Scala (index 4) — simple, no bindings
1623
+ { kind: "simple", languageIndex: 4, parseBindings: null },
1624
+ // C# (index 5) — simple, no bindings
1625
+ { kind: "simple", languageIndex: 5, parseBindings: null },
1626
+ // Visual Basic (index 6) — simple, no bindings
1627
+ { kind: "simple", languageIndex: 6, parseBindings: null },
1628
+ // C++ (index 7) simple with receiver bindings
1629
+ { kind: "simple", languageIndex: 7, parseBindings: (_db, source) => parseCppReceiverBindings(source) },
1630
+ // Rust (index 8) — simple, no bindings
1631
+ { kind: "simple", languageIndex: 8, parseBindings: null },
1632
+ // Ruby (index 9) simple with dual-attempt logic
1633
+ {
1634
+ kind: "simple",
1635
+ languageIndex: 9,
1636
+ parseBindings: (db, source) => parseRubyReceiverBindings(db, source),
1637
+ dualAttempt: {
1638
+ baseOpts: { allowInstanceVariables: true },
1639
+ extendedOpts: { allowInstanceVariables: true, allowBareMemberCalls: true }
1640
+ }
1641
+ },
1642
+ // Dart (index 10) — simple, no bindings
1643
+ { kind: "simple", languageIndex: 10, parseBindings: null },
1644
+ // PHP (index 11) — simple, no bindings
1645
+ { kind: "simple", languageIndex: 11, parseBindings: null }
1646
+ ];
1647
+ function getComplexSourceCalleeRows(db, match, config, limit) {
1601
1648
  const definitions = getDefinitionsForFile(db, match.relativePath);
1602
1649
  const current = definitions.find((definition) => definition.symbolId === match.symbolId);
1603
1650
  if (!current) {
@@ -1616,7 +1663,7 @@ function getJavaScriptSourceCalleeRows(db, symbol, limit) {
1616
1663
  startLine: match.startLine,
1617
1664
  endLine: match.endLine
1618
1665
  })) {
1619
- const resolved = resolveJavaScriptCallTarget(
1666
+ const resolved = config.resolver(
1620
1667
  db,
1621
1668
  current,
1622
1669
  definitions,
@@ -1638,134 +1685,31 @@ function getJavaScriptSourceCalleeRows(db, symbol, limit) {
1638
1685
  }
1639
1686
  return applyLimit(rows, limit);
1640
1687
  }
1641
- function getJavaSourceCalleeRows(db, symbol, limit) {
1642
- const match = getFullSymbolMatch(db, symbol);
1643
- if (!match || !isJavaDocument(db, match.relativePath)) {
1644
- return [];
1645
- }
1646
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1647
- const bindings = parseJavaFieldBindings(getSourceText(db, match.relativePath));
1648
- return resolveSimpleSourceCallees(db, match, calls, bindings, limit);
1649
- }
1650
- function getKotlinSourceCalleeRows(db, symbol, limit) {
1651
- const match = getFullSymbolMatch(db, symbol);
1652
- if (!match || !isKotlinDocument(db, match.relativePath)) {
1653
- return [];
1654
- }
1655
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1656
- const bindings = parseKotlinFieldBindings(getSourceText(db, match.relativePath));
1657
- return resolveSimpleSourceCallees(db, match, calls, bindings, limit);
1658
- }
1659
- function getScalaSourceCalleeRows(db, symbol, limit) {
1660
- const match = getFullSymbolMatch(db, symbol);
1661
- if (!match || !isScalaDocument(db, match.relativePath)) {
1662
- return [];
1663
- }
1664
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1665
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1666
- }
1667
- function getCSharpSourceCalleeRows(db, symbol, limit) {
1668
- const match = getFullSymbolMatch(db, symbol);
1669
- if (!match || !isCSharpDocument(db, match.relativePath)) {
1670
- return [];
1671
- }
1672
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1673
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1674
- }
1675
- function getVisualBasicSourceCalleeRows(db, symbol, limit) {
1676
- const match = getFullSymbolMatch(db, symbol);
1677
- if (!match || !isVisualBasicDocument(db, match.relativePath)) {
1678
- return [];
1679
- }
1680
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1681
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1682
- }
1683
- function getCppSourceCalleeRows(db, symbol, limit) {
1684
- const match = getFullSymbolMatch(db, symbol);
1685
- if (!match || !isCppDocument(db, match.relativePath)) {
1686
- return [];
1688
+ function getSimpleLanguageCalleeRows(db, match, config, limit) {
1689
+ let calls;
1690
+ if (config.dualAttempt) {
1691
+ const baseCalls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine, config.dualAttempt.baseOpts);
1692
+ const extendedCalls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine, config.dualAttempt.extendedOpts);
1693
+ calls = extendedCalls.length > 0 ? extendedCalls : baseCalls;
1694
+ } else {
1695
+ calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine, config.sourceCallOpts);
1687
1696
  }
1688
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1689
- const bindings = parseCppReceiverBindings(getSourceText(db, match.relativePath));
1697
+ const bindings = config.parseBindings ? config.parseBindings(db, getSourceText(db, match.relativePath)) : /* @__PURE__ */ new Map();
1690
1698
  return resolveSimpleSourceCallees(db, match, calls, bindings, limit);
1691
1699
  }
1692
- function getRustSourceCalleeRows(db, symbol, limit) {
1693
- const match = getFullSymbolMatch(db, symbol);
1694
- if (!match || !isRustDocument(db, match.relativePath)) {
1695
- return [];
1696
- }
1697
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1698
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1699
- }
1700
- function getRubySourceCalleeRows(db, symbol, limit) {
1701
- const match = getFullSymbolMatch(db, symbol);
1702
- if (!match || !isRubyDocument(db, match.relativePath)) {
1703
- return [];
1704
- }
1705
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine, { allowInstanceVariables: true });
1706
- const rubyCalls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine, {
1707
- allowInstanceVariables: true,
1708
- allowBareMemberCalls: true
1709
- });
1710
- const bindings = parseRubyReceiverBindings(db, getSourceText(db, match.relativePath));
1711
- return resolveSimpleSourceCallees(db, match, rubyCalls.length > 0 ? rubyCalls : calls, bindings, limit);
1712
- }
1713
- function getDartSourceCalleeRows(db, symbol, limit) {
1714
- const match = getFullSymbolMatch(db, symbol);
1715
- if (!match || !isDartDocument(db, match.relativePath)) {
1716
- return [];
1717
- }
1718
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1719
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1720
- }
1721
- function getPhpSourceCalleeRows(db, symbol, limit) {
1722
- const match = getFullSymbolMatch(db, symbol);
1723
- if (!match || !isPhpDocument(db, match.relativePath)) {
1724
- return [];
1725
- }
1726
- const calls = getSimpleSourceCalls(db, match.relativePath, match.startLine, match.endLine);
1727
- return resolveSimpleSourceCallees(db, match, calls, /* @__PURE__ */ new Map(), limit);
1728
- }
1729
1700
  function getSourceBackedCalleeRows(db, symbol, limit) {
1730
1701
  const match = getFullSymbolMatch(db, symbol);
1731
1702
  if (!match) {
1732
1703
  return [];
1733
1704
  }
1734
- if (isPythonDocument(db, match.relativePath)) {
1735
- return getPythonSourceCalleeRows(db, match, limit);
1736
- }
1737
- if (isJavaScriptDocument(db, match.relativePath)) {
1738
- return getJavaScriptSourceCalleeRows(db, match, limit);
1739
- }
1740
- if (isJavaDocument(db, match.relativePath)) {
1741
- return getJavaSourceCalleeRows(db, match, limit);
1742
- }
1743
- if (isScalaDocument(db, match.relativePath)) {
1744
- return getScalaSourceCalleeRows(db, match, limit);
1745
- }
1746
- if (isKotlinDocument(db, match.relativePath)) {
1747
- return getKotlinSourceCalleeRows(db, match, limit);
1748
- }
1749
- if (isCSharpDocument(db, match.relativePath)) {
1750
- return getCSharpSourceCalleeRows(db, match, limit);
1751
- }
1752
- if (isVisualBasicDocument(db, match.relativePath)) {
1753
- return getVisualBasicSourceCalleeRows(db, match, limit);
1754
- }
1755
- if (isCppDocument(db, match.relativePath)) {
1756
- return getCppSourceCalleeRows(db, match, limit);
1757
- }
1758
- if (isRustDocument(db, match.relativePath)) {
1759
- return getRustSourceCalleeRows(db, match, limit);
1760
- }
1761
- if (isRubyDocument(db, match.relativePath)) {
1762
- return getRubySourceCalleeRows(db, match, limit);
1763
- }
1764
- if (isDartDocument(db, match.relativePath)) {
1765
- return getDartSourceCalleeRows(db, match, limit);
1766
- }
1767
- if (isPhpDocument(db, match.relativePath)) {
1768
- return getPhpSourceCalleeRows(db, match, limit);
1705
+ for (const config of LANGUAGE_CALLEE_CONFIGS) {
1706
+ if (!isDocumentLanguage(db, match.relativePath, DOCUMENT_LANGUAGE_TABLE[config.languageIndex])) {
1707
+ continue;
1708
+ }
1709
+ if (config.kind === "complex") {
1710
+ return getComplexSourceCalleeRows(db, match, config, limit);
1711
+ }
1712
+ return getSimpleLanguageCalleeRows(db, match, config, limit);
1769
1713
  }
1770
1714
  return [];
1771
1715
  }
@@ -1775,9 +1719,11 @@ function getPythonSourceCallerRows(db, target, limit) {
1775
1719
  }
1776
1720
  const rows = [];
1777
1721
  const seen = /* @__PURE__ */ new Set();
1722
+ const pythonConfig = LANGUAGE_CALLEE_CONFIGS[0];
1778
1723
  for (const candidate of getAllFunctionLikeDefinitions(db)) {
1779
1724
  if (candidate.symbolId === target.symbolId) continue;
1780
- const callees = getPythonSourceCalleeRows(db, candidate);
1725
+ if (!isDocumentLanguage(db, candidate.relativePath, DOCUMENT_LANGUAGE_TABLE[pythonConfig.languageIndex])) continue;
1726
+ const callees = getComplexSourceCalleeRows(db, candidate, pythonConfig);
1781
1727
  if (!callees.some((callee) => callee.symbol === target.symbol)) continue;
1782
1728
  const key = `${candidate.symbol}|${candidate.relativePath}`;
1783
1729
  if (seen.has(key) || db.isIgnored(candidate.relativePath)) continue;
@@ -2000,7 +1946,16 @@ function resolveCallableDefinitionStartLine(lines, definition) {
2000
1946
  const escapedLeaf = escapeRegex2(definition.leaf);
2001
1947
  const strongPatterns = [
2002
1948
  new RegExp(`\\b(?:function|def|fn)\\s+${escapedLeaf}\\b`),
2003
- new RegExp(`\\b${escapedLeaf}\\b\\s*[:=]\\s*(?:async\\s*)?(?:function\\b|\\()`)
1949
+ new RegExp(`\\b${escapedLeaf}\\b\\s*[:=]\\s*(?:async\\s*)?(?:function\\b|\\()`),
1950
+ // Method/function declaration with optional TypeScript generic
1951
+ // parameters: matches `foo(`, `foo<T>(`, `foo<T = Record<string, unknown>>(`.
1952
+ // `[^(]*` with greedy backtracking handles nested generics as long as
1953
+ // the generic block itself doesn't contain a `(`. Anchored to start of
1954
+ // line content (optional leading whitespace + optional access modifiers)
1955
+ // so it prefers the declaration line over call sites.
1956
+ new RegExp(
1957
+ `^\\s*(?:export\\s+|public\\s+|private\\s+|protected\\s+|static\\s+|readonly\\s+|async\\s+|abstract\\s+|get\\s+|set\\s+)*${escapedLeaf}\\s*(?:<[^(]*>)?\\s*\\(`
1958
+ )
2004
1959
  ];
2005
1960
  const fallbackPatterns = [
2006
1961
  new RegExp(`\\b${escapedLeaf}\\b\\s*\\(`)
@@ -2119,6 +2074,17 @@ function getAllDefinitions(db, opts = {}) {
2119
2074
  );
2120
2075
  return rows.filter((row) => !db.isIgnored(row.relative_path)).flatMap((row) => getDefinitionsForFile(db, row.relative_path));
2121
2076
  }
2077
+ function getScopedDefinitions(db, scope) {
2078
+ const scopeFilter = scope ? `AND relative_path LIKE '%${scope}%'` : "";
2079
+ return db.all(
2080
+ `SELECT relative_path
2081
+ FROM documents
2082
+ WHERE 1 = 1
2083
+ ${db.pathExclusionsFor("documents")}
2084
+ ${scopeFilter}
2085
+ ORDER BY relative_path`
2086
+ ).flatMap((row) => getDefinitionsForFile(db, row.relative_path)).filter((row) => !db.isIgnored(row.relativePath));
2087
+ }
2122
2088
  function getAllFunctionLikeDefinitions(db) {
2123
2089
  return getAllDefinitions(db).filter((definition) => definition.isFunctionLike);
2124
2090
  }
@@ -2536,89 +2502,29 @@ function parentTypeName(rawSymbol) {
2536
2502
  }
2537
2503
  return null;
2538
2504
  }
2539
- function isPythonDocument(db, relativePath) {
2540
- const row = db.get(
2541
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2542
- relativePath
2543
- );
2544
- return row?.language === "python" || relativePath.endsWith(".py") || relativePath.endsWith(".pyi");
2545
- }
2546
- function isJavaScriptDocument(db, relativePath) {
2547
- const row = db.get(
2548
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2549
- relativePath
2550
- );
2551
- return row?.language === "typescript" || row?.language === "javascript" || /\.(?:[cm]?[jt]sx?)$/.test(relativePath);
2552
- }
2553
- function isJavaDocument(db, relativePath) {
2554
- const row = db.get(
2555
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2556
- relativePath
2557
- );
2558
- return row?.language === "java" || relativePath.endsWith(".java");
2559
- }
2560
- function isKotlinDocument(db, relativePath) {
2561
- const row = db.get(
2562
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2563
- relativePath
2564
- );
2565
- return row?.language === "kotlin" || relativePath.endsWith(".kt") || relativePath.endsWith(".kts");
2566
- }
2567
- function isScalaDocument(db, relativePath) {
2568
- const row = db.get(
2569
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2570
- relativePath
2571
- );
2572
- return row?.language === "scala" || relativePath.endsWith(".scala");
2573
- }
2574
- function isCSharpDocument(db, relativePath) {
2575
- const row = db.get(
2576
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2577
- relativePath
2578
- );
2579
- return row?.language === "C#" || relativePath.endsWith(".cs");
2580
- }
2581
- function isVisualBasicDocument(db, relativePath) {
2582
- const row = db.get(
2583
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2584
- relativePath
2585
- );
2586
- return row?.language === "Visual Basic" || relativePath.endsWith(".vb");
2587
- }
2588
- function isCppDocument(db, relativePath) {
2589
- const row = db.get(
2590
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2591
- relativePath
2592
- );
2593
- return row?.language === "CPP" || /\.(?:cc|cpp|cxx|hpp|hh|hxx)$/.test(relativePath);
2594
- }
2595
- function isRustDocument(db, relativePath) {
2596
- const row = db.get(
2597
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2598
- relativePath
2599
- );
2600
- return row?.language === "Rust" || relativePath.endsWith(".rs");
2601
- }
2602
- function isRubyDocument(db, relativePath) {
2603
- const row = db.get(
2604
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2605
- relativePath
2606
- );
2607
- return row?.language === "ruby" || relativePath.endsWith(".rb");
2608
- }
2609
- function isDartDocument(db, relativePath) {
2505
+ var DOCUMENT_LANGUAGE_TABLE = [
2506
+ { languages: ["python"], extensionPattern: /\.(?:py|pyi)$/ },
2507
+ { languages: ["typescript", "javascript"], extensionPattern: /\.(?:[cm]?[jt]sx?)$/ },
2508
+ { languages: ["java"], extensionPattern: /\.java$/ },
2509
+ { languages: ["kotlin"], extensionPattern: /\.(?:kt|kts)$/ },
2510
+ { languages: ["scala"], extensionPattern: /\.scala$/ },
2511
+ { languages: ["C#"], extensionPattern: /\.cs$/ },
2512
+ { languages: ["Visual Basic"], extensionPattern: /\.vb$/ },
2513
+ { languages: ["CPP"], extensionPattern: /\.(?:cc|cpp|cxx|hpp|hh|hxx)$/ },
2514
+ { languages: ["Rust"], extensionPattern: /\.rs$/ },
2515
+ { languages: ["ruby"], extensionPattern: /\.rb$/ },
2516
+ { languages: ["Dart"], extensionPattern: /\.dart$/ },
2517
+ { languages: ["PHP"], extensionPattern: /\.php$/ }
2518
+ ];
2519
+ function isDocumentLanguage(db, relativePath, entry) {
2610
2520
  const row = db.get(
2611
2521
  `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2612
2522
  relativePath
2613
2523
  );
2614
- return row?.language === "Dart" || relativePath.endsWith(".dart");
2524
+ return entry.languages.includes(row?.language ?? "") || entry.extensionPattern.test(relativePath);
2615
2525
  }
2616
- function isPhpDocument(db, relativePath) {
2617
- const row = db.get(
2618
- `SELECT language FROM documents WHERE relative_path = ? LIMIT 1`,
2619
- relativePath
2620
- );
2621
- return row?.language === "PHP" || relativePath.endsWith(".php");
2526
+ function isPythonDocument(db, relativePath) {
2527
+ return isDocumentLanguage(db, relativePath, DOCUMENT_LANGUAGE_TABLE[0]);
2622
2528
  }
2623
2529
  function applyLimit(values, limit) {
2624
2530
  return typeof limit === "number" ? values.slice(0, limit) : values;
@@ -2670,9 +2576,6 @@ function scoreDocumentPath(relativePath, rawPattern) {
2670
2576
  function normalizeLookupPath(filePattern) {
2671
2577
  return filePattern.trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\/+/, "").replace(/\/+$/, "");
2672
2578
  }
2673
- function uniquePatterns(patterns) {
2674
- return [...new Set(patterns)];
2675
- }
2676
2579
 
2677
2580
  export {
2678
2581
  getSourceImports,
@@ -2680,7 +2583,6 @@ export {
2680
2583
  getSourceText,
2681
2584
  TEST_FILE_PATTERNS,
2682
2585
  TEST_SUPPORT_PATH_PATTERNS,
2683
- testFileExclusionSql,
2684
2586
  buildFileDepGraph,
2685
2587
  findFirstSymbolMatch,
2686
2588
  findExactSymbolMatch,
@@ -2689,7 +2591,10 @@ export {
2689
2591
  getCalleeRowsForSymbol,
2690
2592
  getCallerRowsForSymbol,
2691
2593
  getSourceReferenceSites,
2594
+ getResolvedReferenceSites,
2595
+ findEnclosingDefinition,
2692
2596
  getDefinitionsForFile,
2693
- getAllDefinitions
2597
+ getAllDefinitions,
2598
+ getScopedDefinitions
2694
2599
  };
2695
- //# sourceMappingURL=chunk-ALUFWH3U.js.map
2600
+ //# sourceMappingURL=chunk-OMCRXXDX.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildFileDepGraph
3
- } from "./chunk-ALUFWH3U.js";
3
+ } from "./chunk-OMCRXXDX.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-Z5VSUOEE.js.map
44
+ //# sourceMappingURL=chunk-OWJOHUZE.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveIndexedFile
3
- } from "./chunk-ALUFWH3U.js";
3
+ } from "./chunk-OMCRXXDX.js";
4
4
 
5
5
  // src/queries/deps.ts
6
6
  function deps(db, filePattern) {
@@ -50,4 +50,4 @@ export {
50
50
  deps,
51
51
  rdeps
52
52
  };
53
- //# sourceMappingURL=chunk-RJ5GULL6.js.map
53
+ //# sourceMappingURL=chunk-PEDH3D4G.js.map
@@ -2,10 +2,10 @@ import {
2
2
  findFirstSymbolMatch,
3
3
  getCalleeRowsForSymbol,
4
4
  getCallerRowsForSymbol
5
- } from "./chunk-ALUFWH3U.js";
5
+ } from "./chunk-OMCRXXDX.js";
6
6
  import {
7
7
  shortenSymbol
8
- } from "./chunk-TO3L4YNK.js";
8
+ } from "./chunk-YMSJCSRG.js";
9
9
 
10
10
  // src/queries/call-graph.ts
11
11
  function callGraph(db, symbolPattern) {
@@ -43,4 +43,4 @@ function uniqueRows(rows) {
43
43
  export {
44
44
  callGraph
45
45
  };
46
- //# sourceMappingURL=chunk-6UZU7DFL.js.map
46
+ //# sourceMappingURL=chunk-POAN4SCR.js.map