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.
- package/dist/{chunk-OXX3QF24.js → chunk-2MQ5DPY6.js} +2 -2
- package/dist/{chunk-RL74LF47.js → chunk-2QTYIOJ5.js} +2 -2
- package/dist/{chunk-DUJNJQPO.js → chunk-3VI4YXCL.js} +3 -3
- package/dist/{chunk-XUVPQDXW.js → chunk-3VV2G6U7.js} +4 -4
- package/dist/{chunk-J47VSL6I.js → chunk-44PFXVXG.js} +3 -3
- package/dist/{chunk-SVLUJSY7.js → chunk-6SLFQR36.js} +4 -15
- package/dist/{chunk-JHVQB4Y5.js → chunk-7DBPRGMS.js} +12 -12
- package/dist/{chunk-A6XLXV6W.js → chunk-DTB724R3.js} +3 -3
- package/dist/{chunk-TWVXFKJA.js → chunk-FLOYI6I4.js} +4 -4
- package/dist/{chunk-MGNMHKX3.js → chunk-FO2CBB7U.js} +10 -2
- package/dist/{chunk-4TYLS5XX.js → chunk-GJT3MO2T.js} +9 -2
- package/dist/{chunk-EAGKJFDX.js → chunk-HAP4LJKX.js} +8 -29
- package/dist/{chunk-RE7POFGI.js → chunk-JCOJQ4I6.js} +2 -2
- package/dist/{chunk-VY2L4TP6.js → chunk-JGQMOS4V.js} +3 -3
- package/dist/{chunk-QMXSLHZP.js → chunk-JMD4WJ2Q.js} +2 -2
- package/dist/{chunk-43A4UCS7.js → chunk-JSQPZOPO.js} +11 -18
- package/dist/{chunk-PCU455MX.js → chunk-JSXGC2EH.js} +2 -2
- package/dist/chunk-JZN3DRCT.js +59 -0
- package/dist/{chunk-ZVZAIIB5.js → chunk-KMWYB3CX.js} +12 -36
- package/dist/{chunk-SYQR4QGK.js → chunk-MRM755FU.js} +8 -9
- package/dist/{chunk-R7HPHMRZ.js → chunk-N2XO3Z5F.js} +3 -3
- package/dist/{chunk-POLELLNM.js → chunk-OLW5UL36.js} +19 -25
- package/dist/{chunk-ALUFWH3U.js → chunk-OMCRXXDX.js} +187 -282
- package/dist/{chunk-Z5VSUOEE.js → chunk-OWJOHUZE.js} +2 -2
- package/dist/{chunk-RJ5GULL6.js → chunk-PEDH3D4G.js} +2 -2
- package/dist/{chunk-6UZU7DFL.js → chunk-POAN4SCR.js} +3 -3
- package/dist/{chunk-3NJSJ7TE.js → chunk-PTMGEBU3.js} +4 -15
- package/dist/{chunk-NXUIWD6K.js → chunk-PU44HK7P.js} +3 -3
- package/dist/{chunk-6CH23IAS.js → chunk-QJI7EECA.js} +22 -34
- package/dist/{chunk-KLNKDX6A.js → chunk-R5HICGMB.js} +4 -4
- package/dist/{chunk-6ECR2FLR.js → chunk-RJ2D6YWQ.js} +4 -15
- package/dist/{chunk-CBIWNZZZ.js → chunk-RZ5GYPBP.js} +3 -3
- package/dist/chunk-SRLQNO6O.js +101 -0
- package/dist/{chunk-JKXHHV4B.js → chunk-UGS7HJI4.js} +2 -2
- package/dist/{chunk-PU2254N2.js → chunk-VKUUXOE7.js} +5 -15
- package/dist/{chunk-W46L2BXT.js → chunk-VPUJSJCI.js} +2 -2
- package/dist/{chunk-UJWI5CBB.js → chunk-VRWVV3EP.js} +4 -7
- package/dist/{chunk-7BS4CPJX.js → chunk-WJWQEU4A.js} +3 -3
- package/dist/chunk-WJZHDUSB.js +40 -0
- package/dist/{chunk-FVJE4MQL.js → chunk-WWOCQ5W4.js} +5 -8
- package/dist/chunk-X3Q2OVRL.js +77 -0
- package/dist/chunk-Y3P7QKKN.js +27 -0
- package/dist/{chunk-VKBOLNYN.js → chunk-Y6FAHY4N.js} +10 -8
- package/dist/{chunk-TO3L4YNK.js → chunk-YMSJCSRG.js} +5 -1
- package/dist/{chunk-24LF6IZB.js → chunk-ZDL3U4W2.js} +3 -3
- package/dist/{chunk-KG4OFQEN.js → chunk-ZXNX5JRE.js} +3 -3
- package/dist/cli.js +368 -721
- package/dist/{db-C4rPbKkI.d.ts → db-6F9R9e_t.d.ts} +0 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +46 -58
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +3 -3
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +3 -3
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +3 -3
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +3 -3
- package/dist/queries/change-surface.d.ts +4 -1
- package/dist/queries/change-surface.js +3 -3
- package/dist/queries/clean-signature.d.ts +9 -1
- package/dist/queries/clean-signature.js +5 -3
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +3 -3
- package/dist/queries/complexity-hotspots.d.ts +8 -1
- package/dist/queries/complexity-hotspots.js +3 -3
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +3 -3
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +3 -3
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +3 -3
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +3 -3
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +3 -3
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +4 -4
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +3 -3
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +3 -3
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +2 -2
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +3 -3
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +3 -3
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +3 -3
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +14 -14
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +3 -3
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +3 -3
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +3 -3
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +46 -46
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +4 -4
- package/dist/queries/members.d.ts +4 -1
- package/dist/queries/members.js +3 -3
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +3 -3
- package/dist/queries/outline.d.ts +4 -1
- package/dist/queries/outline.js +3 -3
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +3 -3
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +4 -4
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +3 -3
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +3 -3
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +3 -3
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +3 -3
- package/dist/queries/similar.d.ts +2 -1
- package/dist/queries/similar.js +3 -3
- package/dist/queries/slice.d.ts +4 -3
- package/dist/queries/slice.js +3 -3
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +3 -3
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +3 -3
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +4 -4
- package/dist/queries/system.d.ts +6 -2
- package/dist/queries/system.js +4 -4
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +4 -4
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-5GCORUNV.js +0 -100
- package/dist/chunk-ELFGD5EW.js +0 -130
- package/dist/chunk-GNAMV3JC.js +0 -37
- package/dist/chunk-J6QXMYAQ.js +0 -115
- package/dist/chunk-KYPXKV64.js +0 -51
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCalleeRowsForSymbol,
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
getScopedDefinitions
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isFunctionLikeSymbol,
|
|
7
7
|
shortenSymbol
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/extract-candidates.ts
|
|
11
11
|
function extractCandidates(db, opts = {}) {
|
|
@@ -91,17 +91,6 @@ function extractCandidates(db, opts = {}) {
|
|
|
91
91
|
results.sort((a, b) => b.clusters.length - a.clusters.length || b.loc - a.loc);
|
|
92
92
|
return results.slice(0, limit);
|
|
93
93
|
}
|
|
94
|
-
function getScopedDefinitions(db, scope) {
|
|
95
|
-
const scopeFilter = scope ? `AND relative_path LIKE '%${scope}%'` : "";
|
|
96
|
-
return db.all(
|
|
97
|
-
`SELECT relative_path
|
|
98
|
-
FROM documents
|
|
99
|
-
WHERE 1 = 1
|
|
100
|
-
${db.pathExclusionsFor("documents")}
|
|
101
|
-
${scopeFilter}
|
|
102
|
-
ORDER BY relative_path`
|
|
103
|
-
).flatMap((row) => getDefinitionsForFile(db, row.relative_path)).filter((row) => !db.isIgnored(row.relativePath));
|
|
104
|
-
}
|
|
105
94
|
function definitionLoc(definition) {
|
|
106
95
|
return definition.endLine - definition.startLine + 1;
|
|
107
96
|
}
|
|
@@ -109,4 +98,4 @@ function definitionLoc(definition) {
|
|
|
109
98
|
export {
|
|
110
99
|
extractCandidates
|
|
111
100
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
101
|
+
//# sourceMappingURL=chunk-PTMGEBU3.js.map
|
|
@@ -2,10 +2,10 @@ 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
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/affected.ts
|
|
11
11
|
function affected(db, symbolPattern, opts = {}) {
|
|
@@ -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,12 +3,12 @@ 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,
|
|
10
10
|
shortenSymbol
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YMSJCSRG.js";
|
|
12
12
|
|
|
13
13
|
// src/queries/similar.ts
|
|
14
14
|
function similar(db, symbolPattern, opts = {}) {
|
|
@@ -52,7 +52,7 @@ function similar(db, symbolPattern, opts = {}) {
|
|
|
52
52
|
return similarBySourceShape(db, symbolPattern, { minSimilarity, limit });
|
|
53
53
|
}
|
|
54
54
|
function similarAll(db, opts = {}) {
|
|
55
|
-
const { minSimilarity = 0.5, limit = 20, scope, minCallees = 4 } = opts;
|
|
55
|
+
const { minSimilarity = 0.5, limit = 20, scope, minCallees = 4, crossFileOnly = false } = opts;
|
|
56
56
|
const all = getAllCalleeFingerprints(db, { minCallees, scope });
|
|
57
57
|
const idfWeights = computeIdf(all);
|
|
58
58
|
const results = [];
|
|
@@ -60,14 +60,16 @@ function similarAll(db, opts = {}) {
|
|
|
60
60
|
for (let j = i + 1; j < all.length; j++) {
|
|
61
61
|
const a = all[i];
|
|
62
62
|
const b = all[j];
|
|
63
|
-
if (a.file === b.file) continue;
|
|
63
|
+
if (crossFileOnly && a.file === b.file) continue;
|
|
64
64
|
const { similarity, significantShared } = weightedSimilarity(
|
|
65
65
|
a.callees,
|
|
66
66
|
b.callees,
|
|
67
67
|
idfWeights
|
|
68
68
|
);
|
|
69
69
|
if (similarity < minSimilarity) continue;
|
|
70
|
-
|
|
70
|
+
const sharedCount = intersection(a.callees, b.callees).size;
|
|
71
|
+
if (significantShared.length < 2 && sharedCount < 4) continue;
|
|
72
|
+
const displayShared = significantShared.length > 0 ? significantShared : [...intersection(a.callees, b.callees)];
|
|
71
73
|
results.push({
|
|
72
74
|
symbolA: a.symbol,
|
|
73
75
|
shortNameA: shortenSymbol(a.symbol),
|
|
@@ -76,7 +78,7 @@ function similarAll(db, opts = {}) {
|
|
|
76
78
|
shortNameB: shortenSymbol(b.symbol),
|
|
77
79
|
fileB: b.file,
|
|
78
80
|
similarity,
|
|
79
|
-
sharedCallees:
|
|
81
|
+
sharedCallees: displayShared.map(shortenSymbol),
|
|
80
82
|
uniqueToA: [...difference(a.callees, b.callees)].map(shortenSymbol),
|
|
81
83
|
uniqueToB: [...difference(b.callees, a.callees)].map(shortenSymbol)
|
|
82
84
|
});
|
|
@@ -150,35 +152,21 @@ function findCallees(db, symbolPattern) {
|
|
|
150
152
|
}
|
|
151
153
|
function getAllCalleeFingerprints(db, opts) {
|
|
152
154
|
const { minCallees, scope, excludeSymbol } = opts;
|
|
153
|
-
const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
|
|
154
|
-
const excludeFilter = excludeSymbol ? `AND gs.symbol != '${excludeSymbol.replace(/'/g, "''")}'` : "";
|
|
155
|
-
const symbols = db.all(
|
|
156
|
-
`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
|
|
157
|
-
FROM global_symbols gs
|
|
158
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
159
|
-
JOIN documents d ON der.document_id = d.id
|
|
160
|
-
WHERE 1 = 1
|
|
161
|
-
${db.pathExclusionsFor("d")}
|
|
162
|
-
${db.symbolNoiseFor("gs")}
|
|
163
|
-
AND (der.end_line - der.start_line + 1) >= 5
|
|
164
|
-
${scopeFilter}
|
|
165
|
-
${excludeFilter}
|
|
166
|
-
ORDER BY d.relative_path`
|
|
167
|
-
);
|
|
168
155
|
const fingerprints = [];
|
|
169
|
-
for (const
|
|
170
|
-
if (db.isIgnored(
|
|
171
|
-
if (!
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
177
169
|
});
|
|
178
|
-
const callees = new Set(calleeRows.map((r) => r.symbol));
|
|
179
|
-
if (callees.size >= minCallees) {
|
|
180
|
-
fingerprints.push({ symbol: sym.symbol, file: sym.relative_path, callees });
|
|
181
|
-
}
|
|
182
170
|
}
|
|
183
171
|
return fingerprints;
|
|
184
172
|
}
|
|
@@ -336,4 +324,4 @@ export {
|
|
|
336
324
|
similar,
|
|
337
325
|
similarAll
|
|
338
326
|
};
|
|
339
|
-
//# sourceMappingURL=chunk-
|
|
327
|
+
//# sourceMappingURL=chunk-QJI7EECA.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
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,
|
|
13
13
|
shortenSymbol
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YMSJCSRG.js";
|
|
15
15
|
|
|
16
16
|
// src/queries/dead.ts
|
|
17
17
|
function dead(db, opts = {}) {
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCalleeRowsForSymbol,
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
getScopedDefinitions
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
isFunctionLikeSymbol,
|
|
7
7
|
shortenSymbol
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/passthrough-candidates.ts
|
|
11
11
|
function passthroughCandidates(db, opts) {
|
|
@@ -39,17 +39,6 @@ function passthroughCandidates(db, opts) {
|
|
|
39
39
|
results.sort((a, b) => a.loc - b.loc || a.file.localeCompare(b.file));
|
|
40
40
|
return results.slice(0, limit);
|
|
41
41
|
}
|
|
42
|
-
function getScopedDefinitions(db, scope) {
|
|
43
|
-
const scopeFilter = scope ? `AND relative_path LIKE '%${scope}%'` : "";
|
|
44
|
-
return db.all(
|
|
45
|
-
`SELECT relative_path
|
|
46
|
-
FROM documents
|
|
47
|
-
WHERE 1 = 1
|
|
48
|
-
${db.pathExclusionsFor("documents")}
|
|
49
|
-
${scopeFilter}
|
|
50
|
-
ORDER BY relative_path`
|
|
51
|
-
).flatMap((row) => getDefinitionsForFile(db, row.relative_path)).filter((row) => !db.isIgnored(row.relativePath));
|
|
52
|
-
}
|
|
53
42
|
function definitionLoc(definition) {
|
|
54
43
|
return definition.endLine - definition.startLine + 1;
|
|
55
44
|
}
|
|
@@ -57,4 +46,4 @@ function definitionLoc(definition) {
|
|
|
57
46
|
export {
|
|
58
47
|
passthroughCandidates
|
|
59
48
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-RJ2D6YWQ.js.map
|
|
@@ -2,10 +2,10 @@ 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
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/bottlenecks.ts
|
|
11
11
|
function bottlenecks(db, opts = {}) {
|
|
@@ -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
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph,
|
|
3
3
|
getCallerRowsForSymbol,
|
|
4
|
-
getDefinitionsForFile
|
|
5
|
-
|
|
4
|
+
getDefinitionsForFile,
|
|
5
|
+
getScopedDefinitions
|
|
6
|
+
} from "./chunk-OMCRXXDX.js";
|
|
6
7
|
import {
|
|
7
8
|
isFunctionLikeSymbol,
|
|
8
9
|
shortenSymbol
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YMSJCSRG.js";
|
|
10
11
|
|
|
11
12
|
// src/queries/wrapper-candidates.ts
|
|
12
13
|
import { basename, extname } from "path";
|
|
@@ -52,17 +53,6 @@ function wrapperCandidates(db, opts) {
|
|
|
52
53
|
function definitionLoc(definition) {
|
|
53
54
|
return definition.endLine - definition.startLine + 1;
|
|
54
55
|
}
|
|
55
|
-
function getScopedDefinitions(db, scope) {
|
|
56
|
-
const scopeFilter = scope ? `AND relative_path LIKE '%${scope}%'` : "";
|
|
57
|
-
return db.all(
|
|
58
|
-
`SELECT relative_path
|
|
59
|
-
FROM documents
|
|
60
|
-
WHERE 1 = 1
|
|
61
|
-
${db.pathExclusionsFor("documents")}
|
|
62
|
-
${scopeFilter}
|
|
63
|
-
ORDER BY relative_path`
|
|
64
|
-
).flatMap((row) => getDefinitionsForFile(db, row.relative_path)).filter((row) => !db.isIgnored(row.relativePath));
|
|
65
|
-
}
|
|
66
56
|
function dedupeRows(rows) {
|
|
67
57
|
const seen = /* @__PURE__ */ new Set();
|
|
68
58
|
const unique = [];
|
|
@@ -112,4 +102,4 @@ function fallbackCallerFanIn(db, reverseFanIn, callerFile) {
|
|
|
112
102
|
export {
|
|
113
103
|
wrapperCandidates
|
|
114
104
|
};
|
|
115
|
-
//# 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,11 +1,11 @@
|
|
|
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
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/surface.ts
|
|
11
11
|
function surface(db, modulePattern) {
|
|
@@ -65,11 +65,8 @@ function surface(db, modulePattern) {
|
|
|
65
65
|
shortName: shortenSymbol(r.symbol)
|
|
66
66
|
}));
|
|
67
67
|
}
|
|
68
|
-
function isCallableSymbol(rawSymbol) {
|
|
69
|
-
return rawSymbol.endsWith("().") || leafSuffix(rawSymbol) === "method";
|
|
70
|
-
}
|
|
71
68
|
|
|
72
69
|
export {
|
|
73
70
|
surface
|
|
74
71
|
};
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-VRWVV3EP.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAllDefinitions,
|
|
3
3
|
getSourceText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
6
|
shortenSymbol
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YMSJCSRG.js";
|
|
8
8
|
|
|
9
9
|
// src/queries/similar-signatures.ts
|
|
10
10
|
function similarSignatures(db, opts = {}) {
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getDefinitionsForFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OMCRXXDX.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
isCallableSymbol,
|
|
7
|
+
leafName
|
|
8
|
+
} from "./chunk-YMSJCSRG.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/methods.ts
|
|
11
11
|
import { basename } from "path";
|
|
@@ -24,9 +24,6 @@ function methods(db, className) {
|
|
|
24
24
|
name: leafName(definition.symbol)
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
|
-
function isCallableSymbol(rawSymbol) {
|
|
28
|
-
return rawSymbol.endsWith("().") || leafSuffix(rawSymbol) === "method";
|
|
29
|
-
}
|
|
30
27
|
function stripExtension(relativePath) {
|
|
31
28
|
return relativePath.replace(/\.[^.]+$/, "");
|
|
32
29
|
}
|
|
@@ -34,4 +31,4 @@ function stripExtension(relativePath) {
|
|
|
34
31
|
export {
|
|
35
32
|
methods
|
|
36
33
|
};
|
|
37
|
-
//# 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
|