scip-query 0.4.3 → 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.
- package/dist/{chunk-46ZTW4AI.js → chunk-2MQ5DPY6.js} +2 -2
- package/dist/{chunk-FIMTTUGE.js → chunk-2QTYIOJ5.js} +2 -2
- package/dist/{chunk-YQIWS5V6.js → chunk-3VI4YXCL.js} +2 -2
- package/dist/{chunk-UIRCHPOU.js → chunk-3VV2G6U7.js} +3 -3
- package/dist/{chunk-PKDFXASW.js → chunk-44PFXVXG.js} +2 -2
- package/dist/{chunk-XJSPWHNT.js → chunk-6SLFQR36.js} +2 -2
- package/dist/{chunk-334PCFO3.js → chunk-7DBPRGMS.js} +12 -12
- package/dist/{chunk-B7LDMCUS.js → chunk-DTB724R3.js} +2 -2
- package/dist/{chunk-R2QBMQQN.js → chunk-FLOYI6I4.js} +3 -3
- package/dist/{chunk-4TYLS5XX.js → chunk-GJT3MO2T.js} +9 -2
- package/dist/{chunk-7KGTWDAX.js → chunk-HAP4LJKX.js} +7 -28
- package/dist/{chunk-E74RY6AQ.js → chunk-JCOJQ4I6.js} +2 -2
- package/dist/{chunk-J34HAAEQ.js → chunk-JGQMOS4V.js} +2 -2
- package/dist/{chunk-T6UVM534.js → chunk-JMD4WJ2Q.js} +2 -2
- package/dist/{chunk-UNS6ZQVX.js → chunk-JSQPZOPO.js} +10 -17
- package/dist/{chunk-ZPEI7DRJ.js → chunk-JZN3DRCT.js} +14 -21
- package/dist/{chunk-NYZ6INK3.js → chunk-KMWYB3CX.js} +11 -35
- package/dist/{chunk-B747RITP.js → chunk-MRM755FU.js} +7 -8
- package/dist/{chunk-AEBM56CO.js → chunk-N2XO3Z5F.js} +2 -2
- package/dist/{chunk-PSK5BPFE.js → chunk-OLW5UL36.js} +18 -24
- package/dist/{chunk-FMAYH7GS.js → chunk-OMCRXXDX.js} +72 -14
- package/dist/{chunk-6PVHJ332.js → chunk-OWJOHUZE.js} +2 -2
- package/dist/{chunk-IC5NTO47.js → chunk-PEDH3D4G.js} +2 -2
- package/dist/{chunk-U74VYTLX.js → chunk-POAN4SCR.js} +2 -2
- package/dist/{chunk-5YB6UXQ3.js → chunk-PTMGEBU3.js} +2 -2
- package/dist/{chunk-LQXBFCP2.js → chunk-PU44HK7P.js} +2 -2
- package/dist/{chunk-QZ4FRB65.js → chunk-QJI7EECA.js} +15 -29
- package/dist/{chunk-C2VSV54P.js → chunk-R5HICGMB.js} +3 -3
- package/dist/{chunk-NWXTQGUE.js → chunk-RJ2D6YWQ.js} +2 -2
- package/dist/{chunk-PGQXIAJF.js → chunk-RZ5GYPBP.js} +2 -2
- package/dist/chunk-SRLQNO6O.js +101 -0
- package/dist/{chunk-OMVF3BHY.js → chunk-UGS7HJI4.js} +2 -2
- package/dist/{chunk-7OGXSMLY.js → chunk-VKUUXOE7.js} +2 -2
- package/dist/{chunk-XMZAC2VU.js → chunk-VPUJSJCI.js} +2 -2
- package/dist/{chunk-NNFP4ZRF.js → chunk-VRWVV3EP.js} +2 -2
- package/dist/{chunk-HESWGDIV.js → chunk-WJWQEU4A.js} +2 -2
- package/dist/chunk-WJZHDUSB.js +40 -0
- package/dist/{chunk-HL2LXSBW.js → chunk-WWOCQ5W4.js} +2 -2
- package/dist/chunk-X3Q2OVRL.js +77 -0
- package/dist/chunk-Y3P7QKKN.js +27 -0
- package/dist/{chunk-DIYEUFVP.js → chunk-Y6FAHY4N.js} +2 -2
- package/dist/{chunk-4YN3PE57.js → chunk-ZDL3U4W2.js} +2 -2
- package/dist/{chunk-HW76DVE4.js → chunk-ZXNX5JRE.js} +2 -2
- package/dist/cli.js +175 -355
- package/dist/index.js +43 -43
- package/dist/queries/affected.js +2 -2
- package/dist/queries/bottlenecks.js +2 -2
- package/dist/queries/by-kind.js +2 -2
- package/dist/queries/call-graph.js +2 -2
- package/dist/queries/change-surface.d.ts +3 -0
- package/dist/queries/change-surface.js +2 -2
- package/dist/queries/clean-signature.d.ts +9 -1
- package/dist/queries/clean-signature.js +5 -3
- package/dist/queries/code.js +2 -2
- package/dist/queries/complexity-hotspots.d.ts +7 -0
- package/dist/queries/complexity-hotspots.js +2 -2
- package/dist/queries/complexity.js +2 -2
- package/dist/queries/convergence.js +2 -2
- package/dist/queries/coupling.js +2 -2
- package/dist/queries/cycles.js +2 -2
- package/dist/queries/dataflow.js +2 -2
- package/dist/queries/dead.js +3 -3
- package/dist/queries/deep-chains.js +2 -2
- package/dist/queries/deps.js +2 -2
- package/dist/queries/drift.js +2 -2
- package/dist/queries/extract-candidates.js +2 -2
- package/dist/queries/fan.js +2 -2
- package/dist/queries/health.js +13 -13
- package/dist/queries/hierarchy.js +2 -2
- package/dist/queries/hotspots.js +2 -2
- package/dist/queries/imports.js +2 -2
- package/dist/queries/index.js +43 -43
- package/dist/queries/isolated.js +3 -3
- package/dist/queries/members.d.ts +3 -0
- package/dist/queries/members.js +2 -2
- package/dist/queries/methods.js +2 -2
- package/dist/queries/outline.d.ts +3 -0
- package/dist/queries/outline.js +2 -2
- package/dist/queries/passthrough-candidates.js +2 -2
- package/dist/queries/redundant-reexports.js +3 -3
- package/dist/queries/refs.js +2 -2
- package/dist/queries/similar-chains.js +2 -2
- package/dist/queries/similar-files.js +2 -2
- package/dist/queries/similar-signatures.js +2 -2
- package/dist/queries/similar.js +2 -2
- package/dist/queries/slice.js +2 -2
- package/dist/queries/stale-abstractions.js +2 -2
- package/dist/queries/surface.js +2 -2
- package/dist/queries/symbols.js +3 -3
- package/dist/queries/system.d.ts +5 -1
- package/dist/queries/system.js +3 -3
- package/dist/queries/trace.js +3 -3
- package/dist/queries/wrapper-candidates.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-NML6M5AS.js +0 -37
- package/dist/chunk-T3ALCNCP.js +0 -113
- package/dist/chunk-VJMTX3OR.js +0 -115
- package/dist/chunk-Y7FKURZG.js +0 -130
|
@@ -1150,10 +1150,6 @@ var TEST_FILE_PATTERNS = [
|
|
|
1150
1150
|
var TEST_SUPPORT_PATH_PATTERNS = [
|
|
1151
1151
|
"%/test-utils/%"
|
|
1152
1152
|
];
|
|
1153
|
-
function testFileExclusionSql(alias, extraPatterns = []) {
|
|
1154
|
-
const patterns = uniquePatterns([...TEST_FILE_PATTERNS, ...extraPatterns]);
|
|
1155
|
-
return patterns.map((pattern) => `${alias}.relative_path NOT LIKE '${pattern}'`).join("\n AND ");
|
|
1156
|
-
}
|
|
1157
1153
|
function buildFileDepGraph(db, scope) {
|
|
1158
1154
|
const scopeFilter = scope ? `AND d1.relative_path LIKE '%${scope}%'` : "";
|
|
1159
1155
|
const edges = db.all(
|
|
@@ -1208,6 +1204,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
|
|
|
1208
1204
|
const fileLineMatch = symbolPattern.match(/^(.+):(\d+)-(\d+)$/);
|
|
1209
1205
|
if (fileLineMatch) {
|
|
1210
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);
|
|
1211
1209
|
let row = db.get(
|
|
1212
1210
|
`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
|
|
1213
1211
|
FROM global_symbols gs
|
|
@@ -1219,8 +1217,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
|
|
|
1219
1217
|
ORDER BY (der.end_line - der.start_line) ASC
|
|
1220
1218
|
LIMIT 1`,
|
|
1221
1219
|
`%${filePath}%`,
|
|
1222
|
-
|
|
1223
|
-
|
|
1220
|
+
userStart0,
|
|
1221
|
+
userEnd0
|
|
1224
1222
|
);
|
|
1225
1223
|
if (!row) {
|
|
1226
1224
|
row = db.get(
|
|
@@ -1237,8 +1235,8 @@ function findFirstSymbolMatch(db, symbolPattern) {
|
|
|
1237
1235
|
ORDER BY (MAX(c.end_line) - MIN(c.start_line)) ASC
|
|
1238
1236
|
LIMIT 1`,
|
|
1239
1237
|
`%${filePath}%`,
|
|
1240
|
-
|
|
1241
|
-
|
|
1238
|
+
userStart0,
|
|
1239
|
+
userEnd0
|
|
1242
1240
|
);
|
|
1243
1241
|
}
|
|
1244
1242
|
if (row && !db.isIgnored(row.relative_path)) {
|
|
@@ -1530,6 +1528,59 @@ function getSourceReferenceSites(db, symbol) {
|
|
|
1530
1528
|
}
|
|
1531
1529
|
return sites;
|
|
1532
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
|
+
}
|
|
1533
1584
|
function calleeQueryParams(symbol, limit) {
|
|
1534
1585
|
const params = [
|
|
1535
1586
|
symbol.documentId,
|
|
@@ -1895,7 +1946,16 @@ function resolveCallableDefinitionStartLine(lines, definition) {
|
|
|
1895
1946
|
const escapedLeaf = escapeRegex2(definition.leaf);
|
|
1896
1947
|
const strongPatterns = [
|
|
1897
1948
|
new RegExp(`\\b(?:function|def|fn)\\s+${escapedLeaf}\\b`),
|
|
1898
|
-
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
|
+
)
|
|
1899
1959
|
];
|
|
1900
1960
|
const fallbackPatterns = [
|
|
1901
1961
|
new RegExp(`\\b${escapedLeaf}\\b\\s*\\(`)
|
|
@@ -2516,9 +2576,6 @@ function scoreDocumentPath(relativePath, rawPattern) {
|
|
|
2516
2576
|
function normalizeLookupPath(filePattern) {
|
|
2517
2577
|
return filePattern.trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
2518
2578
|
}
|
|
2519
|
-
function uniquePatterns(patterns) {
|
|
2520
|
-
return [...new Set(patterns)];
|
|
2521
|
-
}
|
|
2522
2579
|
|
|
2523
2580
|
export {
|
|
2524
2581
|
getSourceImports,
|
|
@@ -2526,7 +2583,6 @@ export {
|
|
|
2526
2583
|
getSourceText,
|
|
2527
2584
|
TEST_FILE_PATTERNS,
|
|
2528
2585
|
TEST_SUPPORT_PATH_PATTERNS,
|
|
2529
|
-
testFileExclusionSql,
|
|
2530
2586
|
buildFileDepGraph,
|
|
2531
2587
|
findFirstSymbolMatch,
|
|
2532
2588
|
findExactSymbolMatch,
|
|
@@ -2535,8 +2591,10 @@ export {
|
|
|
2535
2591
|
getCalleeRowsForSymbol,
|
|
2536
2592
|
getCallerRowsForSymbol,
|
|
2537
2593
|
getSourceReferenceSites,
|
|
2594
|
+
getResolvedReferenceSites,
|
|
2595
|
+
findEnclosingDefinition,
|
|
2538
2596
|
getDefinitionsForFile,
|
|
2539
2597
|
getAllDefinitions,
|
|
2540
2598
|
getScopedDefinitions
|
|
2541
2599
|
};
|
|
2542
|
-
//# sourceMappingURL=chunk-
|
|
2600
|
+
//# sourceMappingURL=chunk-OMCRXXDX.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
44
|
+
//# sourceMappingURL=chunk-OWJOHUZE.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIndexedFile
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
53
|
+
//# sourceMappingURL=chunk-PEDH3D4G.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getCalleeRowsForSymbol,
|
|
4
4
|
getCallerRowsForSymbol
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OMCRXXDX.js";
|
|
6
6
|
import {
|
|
7
7
|
shortenSymbol
|
|
8
8
|
} from "./chunk-YMSJCSRG.js";
|
|
@@ -43,4 +43,4 @@ function uniqueRows(rows) {
|
|
|
43
43
|
export {
|
|
44
44
|
callGraph
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
46
|
+
//# sourceMappingURL=chunk-POAN4SCR.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCalleeRowsForSymbol,
|
|
3
3
|
getScopedDefinitions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isFunctionLikeSymbol,
|
|
7
7
|
shortenSymbol
|
|
@@ -98,4 +98,4 @@ function definitionLoc(definition) {
|
|
|
98
98
|
export {
|
|
99
99
|
extractCandidates
|
|
100
100
|
};
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-PTMGEBU3.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
findExactSymbolMatch,
|
|
3
3
|
findFirstSymbolMatch,
|
|
4
4
|
getCallerRowsForSymbol
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OMCRXXDX.js";
|
|
6
6
|
import {
|
|
7
7
|
shortenSymbol
|
|
8
8
|
} from "./chunk-YMSJCSRG.js";
|
|
@@ -84,4 +84,4 @@ function getDirectAffectedRows(db, target, scope) {
|
|
|
84
84
|
export {
|
|
85
85
|
affected
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-PU44HK7P.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getAllDefinitions,
|
|
4
4
|
getCalleeRowsForSymbol,
|
|
5
5
|
getSourceText
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMCRXXDX.js";
|
|
7
7
|
import {
|
|
8
8
|
isFunctionLikeSymbol,
|
|
9
9
|
leafName,
|
|
@@ -152,35 +152,21 @@ function findCallees(db, symbolPattern) {
|
|
|
152
152
|
}
|
|
153
153
|
function getAllCalleeFingerprints(db, opts) {
|
|
154
154
|
const { minCallees, scope, excludeSymbol } = opts;
|
|
155
|
-
const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
|
|
156
|
-
const excludeFilter = excludeSymbol ? `AND gs.symbol != '${excludeSymbol.replace(/'/g, "''")}'` : "";
|
|
157
|
-
const symbols = db.all(
|
|
158
|
-
`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
|
|
159
|
-
FROM global_symbols gs
|
|
160
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
161
|
-
JOIN documents d ON der.document_id = d.id
|
|
162
|
-
WHERE 1 = 1
|
|
163
|
-
${db.pathExclusionsFor("d")}
|
|
164
|
-
${db.symbolNoiseFor("gs")}
|
|
165
|
-
AND (der.end_line - der.start_line + 1) >= 5
|
|
166
|
-
${scopeFilter}
|
|
167
|
-
${excludeFilter}
|
|
168
|
-
ORDER BY d.relative_path`
|
|
169
|
-
);
|
|
170
155
|
const fingerprints = [];
|
|
171
|
-
for (const
|
|
172
|
-
if (db.isIgnored(
|
|
173
|
-
if (!
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
156
|
+
for (const definition of getAllDefinitions(db, { scope })) {
|
|
157
|
+
if (db.isIgnored(definition.relativePath)) continue;
|
|
158
|
+
if (!definition.isFunctionLike) continue;
|
|
159
|
+
if (excludeSymbol && definition.symbol === excludeSymbol) continue;
|
|
160
|
+
if (definition.endLine - definition.startLine + 1 < 5) continue;
|
|
161
|
+
const callees = new Set(
|
|
162
|
+
getCalleeRowsForSymbol(db, definition).map((row) => row.symbol)
|
|
163
|
+
);
|
|
164
|
+
if (callees.size < minCallees) continue;
|
|
165
|
+
fingerprints.push({
|
|
166
|
+
symbol: definition.symbol,
|
|
167
|
+
file: definition.relativePath,
|
|
168
|
+
callees
|
|
179
169
|
});
|
|
180
|
-
const callees = new Set(calleeRows.map((r) => r.symbol));
|
|
181
|
-
if (callees.size >= minCallees) {
|
|
182
|
-
fingerprints.push({ symbol: sym.symbol, file: sym.relative_path, callees });
|
|
183
|
-
}
|
|
184
170
|
}
|
|
185
171
|
return fingerprints;
|
|
186
172
|
}
|
|
@@ -338,4 +324,4 @@ export {
|
|
|
338
324
|
similar,
|
|
339
325
|
similarAll
|
|
340
326
|
};
|
|
341
|
-
//# sourceMappingURL=chunk-
|
|
327
|
+
//# sourceMappingURL=chunk-QJI7EECA.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getInactiveBarrelPaths,
|
|
3
3
|
isEntrySurface
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UGS7HJI4.js";
|
|
5
5
|
import {
|
|
6
6
|
TEST_FILE_PATTERNS,
|
|
7
7
|
TEST_SUPPORT_PATH_PATTERNS,
|
|
8
8
|
getAllDefinitions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OMCRXXDX.js";
|
|
10
10
|
import {
|
|
11
11
|
isFunctionLikeSymbol,
|
|
12
12
|
isModuleLikeSymbol,
|
|
@@ -107,4 +107,4 @@ function looksValueLikeDefinition(rawSymbol) {
|
|
|
107
107
|
export {
|
|
108
108
|
dead
|
|
109
109
|
};
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-R5HICGMB.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCalleeRowsForSymbol,
|
|
3
3
|
getScopedDefinitions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isFunctionLikeSymbol,
|
|
7
7
|
shortenSymbol
|
|
@@ -46,4 +46,4 @@ function definitionLoc(definition) {
|
|
|
46
46
|
export {
|
|
47
47
|
passthroughCandidates
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-RJ2D6YWQ.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getAllDefinitions,
|
|
3
3
|
getCalleeRowsForSymbol,
|
|
4
4
|
getCallerRowsForSymbol
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OMCRXXDX.js";
|
|
6
6
|
import {
|
|
7
7
|
shortenSymbol
|
|
8
8
|
} from "./chunk-YMSJCSRG.js";
|
|
@@ -76,4 +76,4 @@ function bottlenecks(db, opts = {}) {
|
|
|
76
76
|
export {
|
|
77
77
|
bottlenecks
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-RZ5GYPBP.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findEnclosingDefinition,
|
|
3
|
+
findExactSymbolMatch,
|
|
4
|
+
findFirstSymbolMatch,
|
|
5
|
+
getCalleeRowsForSymbol,
|
|
6
|
+
getDefinitionsForFile,
|
|
7
|
+
getResolvedReferenceSites,
|
|
8
|
+
getSourceReferenceSites
|
|
9
|
+
} from "./chunk-OMCRXXDX.js";
|
|
10
|
+
import {
|
|
11
|
+
shortenSymbol
|
|
12
|
+
} from "./chunk-YMSJCSRG.js";
|
|
13
|
+
|
|
14
|
+
// src/queries/slice.ts
|
|
15
|
+
function slice(db, symbolPattern, opts = {}) {
|
|
16
|
+
const { direction = "backward", maxDepth = 3 } = opts;
|
|
17
|
+
const match = findFirstSymbolMatch(db, symbolPattern);
|
|
18
|
+
if (!match) return null;
|
|
19
|
+
if (direction === "backward") {
|
|
20
|
+
return backwardSlice(db, match, maxDepth);
|
|
21
|
+
} else {
|
|
22
|
+
return forwardSlice(db, match);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function backwardSlice(db, match, maxDepth) {
|
|
26
|
+
const connected = [];
|
|
27
|
+
const visited = /* @__PURE__ */ new Set([match.symbol]);
|
|
28
|
+
let frontier = [match];
|
|
29
|
+
for (let depth = 1; depth <= maxDepth; depth++) {
|
|
30
|
+
if (frontier.length === 0) break;
|
|
31
|
+
const nextFrontier = [];
|
|
32
|
+
for (const current of frontier) {
|
|
33
|
+
const callees = getCalleeRowsForSymbol(db, current);
|
|
34
|
+
for (const c of callees) {
|
|
35
|
+
if (visited.has(c.symbol)) continue;
|
|
36
|
+
visited.add(c.symbol);
|
|
37
|
+
connected.push({
|
|
38
|
+
symbol: c.symbol,
|
|
39
|
+
shortName: shortenSymbol(c.symbol),
|
|
40
|
+
file: c.file,
|
|
41
|
+
relationship: depth === 1 ? "referenced within definition (callee)" : `depth ${depth} callee`
|
|
42
|
+
});
|
|
43
|
+
const calleeMatch = findExactSymbolMatch(db, c.symbol);
|
|
44
|
+
if (calleeMatch && !db.isIgnored(calleeMatch.relativePath)) {
|
|
45
|
+
nextFrontier.push(calleeMatch);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
frontier = nextFrontier;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
symbol: match.symbol,
|
|
53
|
+
shortName: shortenSymbol(match.symbol),
|
|
54
|
+
direction: "backward",
|
|
55
|
+
connectedSymbols: connected
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function forwardSlice(db, match) {
|
|
59
|
+
const sourceRefs = getSourceReferenceSites(db, match);
|
|
60
|
+
const refs = sourceRefs.length > 0 ? sourceRefs : getResolvedReferenceSites(db, match);
|
|
61
|
+
const seenOutputs = /* @__PURE__ */ new Set();
|
|
62
|
+
const connected = [];
|
|
63
|
+
for (const ref of refs) {
|
|
64
|
+
if (connected.length >= 30) break;
|
|
65
|
+
if (db.isIgnored(ref.file)) continue;
|
|
66
|
+
const enclosingSymbol = ref.enclosingSymbol ?? findEnclosingDefinition(
|
|
67
|
+
getDefinitionsForFile(db, ref.file),
|
|
68
|
+
ref.line
|
|
69
|
+
)?.symbol ?? null;
|
|
70
|
+
if (!enclosingSymbol || enclosingSymbol === match.symbol) continue;
|
|
71
|
+
const enclosingMatch = findExactSymbolMatch(db, enclosingSymbol);
|
|
72
|
+
if (!enclosingMatch) continue;
|
|
73
|
+
for (const callee of getCalleeRowsForSymbol(db, enclosingMatch)) {
|
|
74
|
+
if (callee.symbol === match.symbol) continue;
|
|
75
|
+
if (callee.symbol === enclosingSymbol) continue;
|
|
76
|
+
if (callee.file === ref.file) continue;
|
|
77
|
+
if (db.isIgnored(callee.file)) continue;
|
|
78
|
+
if (seenOutputs.has(callee.symbol)) continue;
|
|
79
|
+
seenOutputs.add(callee.symbol);
|
|
80
|
+
connected.push({
|
|
81
|
+
symbol: callee.symbol,
|
|
82
|
+
shortName: shortenSymbol(callee.symbol),
|
|
83
|
+
file: callee.file,
|
|
84
|
+
relationship: `used alongside target in ${shortenSymbol(enclosingSymbol)}`
|
|
85
|
+
});
|
|
86
|
+
if (connected.length >= 30) break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
connected.sort((a, b) => a.file.localeCompare(b.file));
|
|
90
|
+
return {
|
|
91
|
+
symbol: match.symbol,
|
|
92
|
+
shortName: shortenSymbol(match.symbol),
|
|
93
|
+
direction: "forward",
|
|
94
|
+
connectedSymbols: connected
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
slice
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=chunk-SRLQNO6O.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OMCRXXDX.js";
|
|
4
4
|
|
|
5
5
|
// src/entry-surfaces.ts
|
|
6
6
|
var liveBarrelCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -81,4 +81,4 @@ export {
|
|
|
81
81
|
isEntrySurface,
|
|
82
82
|
getInactiveBarrelPaths
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-UGS7HJI4.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getCallerRowsForSymbol,
|
|
4
4
|
getDefinitionsForFile,
|
|
5
5
|
getScopedDefinitions
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMCRXXDX.js";
|
|
7
7
|
import {
|
|
8
8
|
isFunctionLikeSymbol,
|
|
9
9
|
shortenSymbol
|
|
@@ -102,4 +102,4 @@ function fallbackCallerFanIn(db, reverseFanIn, callerFile) {
|
|
|
102
102
|
export {
|
|
103
103
|
wrapperCandidates
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-VKUUXOE7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIndexedFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OMCRXXDX.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-
|
|
84
|
+
//# sourceMappingURL=chunk-VPUJSJCI.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDefinitionsForFile,
|
|
3
3
|
resolveIndexedPaths
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isCallableSymbol,
|
|
7
7
|
shortenSymbol
|
|
@@ -69,4 +69,4 @@ function surface(db, modulePattern) {
|
|
|
69
69
|
export {
|
|
70
70
|
surface
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-VRWVV3EP.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAllDefinitions,
|
|
3
3
|
getSourceText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
shortenSymbol
|
|
7
7
|
} from "./chunk-YMSJCSRG.js";
|
|
@@ -159,4 +159,4 @@ function escapeRegex(value) {
|
|
|
159
159
|
export {
|
|
160
160
|
similarSignatures
|
|
161
161
|
};
|
|
162
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-WJWQEU4A.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCalleeRowsForSymbol,
|
|
4
|
+
getCallerRowsForSymbol
|
|
5
|
+
} from "./chunk-OMCRXXDX.js";
|
|
6
|
+
import {
|
|
7
|
+
shortenSymbol
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
|
+
|
|
10
|
+
// src/queries/complexity-hotspots.ts
|
|
11
|
+
function complexityHotspots(db, opts) {
|
|
12
|
+
const { scope, minLoc = 10, limit = 30 } = opts ?? {};
|
|
13
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
14
|
+
const loc = definition.endLine - definition.startLine + 1;
|
|
15
|
+
const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
|
|
16
|
+
const calleeRows = getCalleeRowsForSymbol(db, definition, { limit: 500 });
|
|
17
|
+
const fanIn = new Set(callerRows.map((row) => row.file)).size;
|
|
18
|
+
const fanOut = new Set(
|
|
19
|
+
calleeRows.filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
|
|
20
|
+
).size;
|
|
21
|
+
const calleeCount = new Set(calleeRows.map((row) => `${row.symbol}|${row.file}`)).size;
|
|
22
|
+
return {
|
|
23
|
+
symbol: definition.symbol,
|
|
24
|
+
shortName: shortenSymbol(definition.symbol),
|
|
25
|
+
file: definition.relativePath,
|
|
26
|
+
startLine: definition.startLine,
|
|
27
|
+
endLine: definition.endLine,
|
|
28
|
+
loc,
|
|
29
|
+
fanIn,
|
|
30
|
+
fanOut,
|
|
31
|
+
calleeCount,
|
|
32
|
+
score: Math.round(loc / 50 * (fanIn / 5) * Math.max(fanOut / 5, 1) * 100) / 100
|
|
33
|
+
};
|
|
34
|
+
}).filter((row) => row.loc >= minLoc).sort((left, right) => right.score - left.score || right.loc - left.loc).slice(0, limit);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
complexityHotspots
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-WJZHDUSB.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getDefinitionsForFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isCallableSymbol,
|
|
7
7
|
leafName
|
|
@@ -31,4 +31,4 @@ function stripExtension(relativePath) {
|
|
|
31
31
|
export {
|
|
32
32
|
methods
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-WWOCQ5W4.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findFirstSymbolMatch,
|
|
3
|
+
getResolvedReferenceSites,
|
|
4
|
+
getSourceReferenceSites,
|
|
5
|
+
getSourceText
|
|
6
|
+
} from "./chunk-OMCRXXDX.js";
|
|
7
|
+
import {
|
|
8
|
+
isFunctionLikeSymbol
|
|
9
|
+
} from "./chunk-YMSJCSRG.js";
|
|
10
|
+
|
|
11
|
+
// src/queries/refs.ts
|
|
12
|
+
function refs(db, symbolPattern) {
|
|
13
|
+
const match = findFirstSymbolMatch(db, symbolPattern);
|
|
14
|
+
if (!match) return [];
|
|
15
|
+
const includeDefinitionSite = !isFunctionLikeSymbol(match.symbol);
|
|
16
|
+
const definitionRows = includeDefinitionSite && !db.isIgnored(match.relativePath) ? [{ relativePath: match.relativePath, line: match.startLine }] : [];
|
|
17
|
+
const sourceSites = getSourceReferenceSites(db, match);
|
|
18
|
+
const referenceSites = (sourceSites.length > 0 ? sourceSites : getResolvedReferenceSites(db, match)).filter((site) => !db.isIgnored(site.file)).map((site) => ({ relativePath: site.file, line: site.line }));
|
|
19
|
+
const rubySites = getRubySemanticRefs(db, match);
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
const out = [];
|
|
22
|
+
for (const row of [...definitionRows, ...referenceSites, ...rubySites]) {
|
|
23
|
+
const key = `${row.relativePath}:${row.line}`;
|
|
24
|
+
if (seen.has(key)) continue;
|
|
25
|
+
seen.add(key);
|
|
26
|
+
out.push(row);
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
function getRubySemanticRefs(db, match) {
|
|
31
|
+
if (!match.relativePath.endsWith(".rb")) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const tokens = rubyReferenceTokens(match.symbol);
|
|
35
|
+
if (tokens.length === 0) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const rows = db.all(
|
|
39
|
+
`SELECT relative_path
|
|
40
|
+
FROM documents
|
|
41
|
+
WHERE relative_path LIKE '%.rb'
|
|
42
|
+
${db.pathExclusionsFor("documents")}
|
|
43
|
+
ORDER BY relative_path`
|
|
44
|
+
);
|
|
45
|
+
const results = [];
|
|
46
|
+
for (const row of rows) {
|
|
47
|
+
if (db.isIgnored(row.relative_path)) continue;
|
|
48
|
+
const source = getSourceText(db, row.relative_path);
|
|
49
|
+
if (!source) continue;
|
|
50
|
+
const lines = source.split("\n");
|
|
51
|
+
for (let index = 0; index < lines.length; index++) {
|
|
52
|
+
const line = lines[index] ?? "";
|
|
53
|
+
if (tokens.some((token) => new RegExp(`@${token}\\b|\\b${token}:`).test(line))) {
|
|
54
|
+
results.push({
|
|
55
|
+
relativePath: row.relative_path,
|
|
56
|
+
line: index
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
}
|
|
63
|
+
function rubyReferenceTokens(rawSymbol) {
|
|
64
|
+
const leaf = rawSymbol.split(":").pop() ?? rawSymbol;
|
|
65
|
+
const snake = leaf.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9_]+/g, "_").toLowerCase().replace(/^_+|_+$/g, "");
|
|
66
|
+
const parts = snake.split("_").filter(Boolean);
|
|
67
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
68
|
+
if (snake) candidates.add(snake);
|
|
69
|
+
if (parts.length >= 1) candidates.add(parts[parts.length - 1]);
|
|
70
|
+
if (parts.length >= 2) candidates.add(parts.slice(-2).join("_"));
|
|
71
|
+
return [...candidates];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
refs
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chunk-X3Q2OVRL.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findFirstSymbolMatch,
|
|
3
|
+
getDefinitionsForFile
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
|
+
import {
|
|
6
|
+
isDirectChildSymbol,
|
|
7
|
+
leafSuffix,
|
|
8
|
+
shortenSymbol
|
|
9
|
+
} from "./chunk-YMSJCSRG.js";
|
|
10
|
+
|
|
11
|
+
// src/queries/members.ts
|
|
12
|
+
function members(db, symbolPattern) {
|
|
13
|
+
const parent = findFirstSymbolMatch(db, symbolPattern);
|
|
14
|
+
if (!parent) return [];
|
|
15
|
+
return getDefinitionsForFile(db, parent.relativePath).filter((definition) => definition.symbol !== parent.symbol).filter((definition) => isDirectChildSymbol(parent.symbol, definition.symbol)).sort((a, b) => a.startLine - b.startLine || a.endLine - b.endLine).map((definition) => ({
|
|
16
|
+
symbol: definition.symbol,
|
|
17
|
+
shortName: shortenSymbol(definition.symbol),
|
|
18
|
+
startLine: definition.startLine,
|
|
19
|
+
endLine: definition.endLine,
|
|
20
|
+
kind: leafSuffix(definition.symbol) ?? "unknown"
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
members
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-Y3P7QKKN.js.map
|