scip-query 0.4.3 → 0.6.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-2DSS2NGF.js +10 -0
- package/dist/chunk-2RLP74AO.js +2 -0
- package/dist/chunk-4QJ7LVW5.js +2 -0
- package/dist/chunk-4TYGGOLO.js +5 -0
- package/dist/chunk-5IADAU5B.js +7 -0
- package/dist/chunk-7754WFFV.js +18 -0
- package/dist/chunk-7VOF4ZG6.js +2 -0
- package/dist/chunk-7Z4COVMC.js +2 -0
- package/dist/chunk-AJ5PWKD4.js +2 -0
- package/dist/chunk-BDBRZPX3.js +7 -0
- package/dist/chunk-BE6EQIWY.js +2 -0
- package/dist/chunk-BQ3INTYT.js +8 -0
- package/dist/chunk-D7KLLMPB.js +2 -0
- package/dist/chunk-D7YBWSON.js +29 -0
- package/dist/chunk-DE5ZBHMK.js +39 -0
- package/dist/chunk-DHYIJHXZ.js +33 -0
- package/dist/chunk-EEF3YEHW.js +2 -0
- package/dist/chunk-F2LLHRRZ.js +2 -0
- package/dist/chunk-FCC3XJTI.js +2 -0
- package/dist/chunk-GNXRLK5G.js +2 -0
- package/dist/chunk-GXVB36TG.js +62 -0
- package/dist/chunk-HMKJTAZD.js +2 -0
- package/dist/chunk-IBGBI3VU.js +2 -0
- package/dist/chunk-IYFZS4PV.js +84 -0
- package/dist/chunk-JH3A7HTU.js +2 -0
- package/dist/chunk-JS2RNIC7.js +2 -0
- package/dist/chunk-K5FQFCSN.js +41 -0
- package/dist/chunk-K6GBKEQE.js +6 -0
- package/dist/chunk-KO7YJRWP.js +12 -0
- package/dist/chunk-KYT47WU2.js +4 -0
- package/dist/chunk-LORWXBOO.js +2 -0
- package/dist/chunk-LX4H4LLG.js +89 -0
- package/dist/chunk-N3Z2SJCR.js +2 -0
- package/dist/chunk-NTDA4A2D.js +25 -0
- package/dist/chunk-NXMYYHDO.js +24 -0
- package/dist/chunk-PZ6ESKRH.js +7 -0
- package/dist/chunk-QXE6EDY2.js +6 -0
- package/dist/chunk-RJ7SPBJ5.js +5 -0
- package/dist/chunk-RWE6FHG3.js +3 -0
- package/dist/chunk-SDX6MDBL.js +2 -0
- package/dist/chunk-SG35Y7J2.js +2 -0
- package/dist/chunk-STOGKRJH.js +4 -0
- package/dist/chunk-TINPMWJK.js +2 -0
- package/dist/chunk-UJB62HV3.js +2 -0
- package/dist/chunk-VEUMRDHW.js +2 -0
- package/dist/chunk-WCDXJGYT.js +65 -0
- package/dist/chunk-WTSTDJZ7.js +6 -0
- package/dist/chunk-XAZTIDST.js +2 -0
- package/dist/chunk-XVDASCN7.js +35 -0
- package/dist/chunk-Y7H6D2EV.js +2 -0
- package/dist/chunk-Y7LOQSWY.js +2 -0
- package/dist/chunk-YIPCV7M7.js +70 -0
- package/dist/chunk-ZSRXMNMK.js +5 -0
- package/dist/chunk-ZXKURFVB.js +56 -0
- package/dist/cli.js +509 -8938
- package/dist/{db-6F9R9e_t.d.ts → db-BSTtBG_H.d.ts} +146 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +13 -1616
- package/dist/postinstall.js +4 -100
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -8
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -8
- package/dist/queries/by-kind.d.ts +1 -4
- package/dist/queries/by-kind.js +1 -10
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -8
- package/dist/queries/change-surface.d.ts +4 -1
- package/dist/queries/change-surface.js +1 -8
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -8
- package/dist/queries/complexity-hotspots.d.ts +5 -3
- package/dist/queries/complexity-hotspots.js +1 -8
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -8
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -8
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -10
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -8
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -8
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -9
- package/dist/queries/deep-chains.d.ts +9 -1
- package/dist/queries/deep-chains.js +1 -8
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -10
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -7
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -8
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -8
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -14
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -6
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -20
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -8
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -8
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -12
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +1 -197
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -9
- package/dist/queries/members.d.ts +4 -1
- package/dist/queries/members.js +1 -8
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -8
- package/dist/queries/outline.d.ts +4 -1
- package/dist/queries/outline.js +1 -8
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -8
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -9
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -8
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -8
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -8
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -8
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -10
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -8
- package/dist/queries/stale-abstractions.d.ts +15 -5
- package/dist/queries/stale-abstractions.js +1 -8
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/stats.js +1 -6
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -8
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -9
- package/dist/queries/system.d.ts +6 -2
- package/dist/queries/system.js +1 -9
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -9
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -8
- package/dist/reindex-worker.js +7 -672
- package/package.json +20 -2
- package/dist/chunk-334PCFO3.js +0 -221
- package/dist/chunk-46ZTW4AI.js +0 -61
- package/dist/chunk-4TYLS5XX.js +0 -10
- package/dist/chunk-4YN3PE57.js +0 -124
- package/dist/chunk-5YB6UXQ3.js +0 -101
- package/dist/chunk-6PVHJ332.js +0 -44
- package/dist/chunk-74RFWB5T.js +0 -24
- package/dist/chunk-7KGTWDAX.js +0 -87
- package/dist/chunk-7OGXSMLY.js +0 -105
- package/dist/chunk-AEBM56CO.js +0 -69
- package/dist/chunk-B747RITP.js +0 -38
- package/dist/chunk-B7LDMCUS.js +0 -110
- package/dist/chunk-C2VSV54P.js +0 -110
- package/dist/chunk-DIYEUFVP.js +0 -81
- package/dist/chunk-E74RY6AQ.js +0 -93
- package/dist/chunk-FIMTTUGE.js +0 -165
- package/dist/chunk-FMAYH7GS.js +0 -2542
- package/dist/chunk-FO2CBB7U.js +0 -23
- package/dist/chunk-HESWGDIV.js +0 -162
- package/dist/chunk-HL2LXSBW.js +0 -34
- package/dist/chunk-HW76DVE4.js +0 -216
- package/dist/chunk-IC5NTO47.js +0 -53
- package/dist/chunk-J34HAAEQ.js +0 -59
- package/dist/chunk-JSXGC2EH.js +0 -151
- package/dist/chunk-LQXBFCP2.js +0 -87
- package/dist/chunk-NML6M5AS.js +0 -37
- package/dist/chunk-NNFP4ZRF.js +0 -72
- package/dist/chunk-NWXTQGUE.js +0 -49
- package/dist/chunk-NYZ6INK3.js +0 -95
- package/dist/chunk-OMVF3BHY.js +0 -84
- package/dist/chunk-P3VCDYMJ.js +0 -269
- package/dist/chunk-PGQXIAJF.js +0 -79
- package/dist/chunk-PKDFXASW.js +0 -76
- package/dist/chunk-PSK5BPFE.js +0 -82
- package/dist/chunk-QZ4FRB65.js +0 -341
- package/dist/chunk-R2QBMQQN.js +0 -185
- package/dist/chunk-T3ALCNCP.js +0 -113
- package/dist/chunk-T6UVM534.js +0 -213
- package/dist/chunk-U74VYTLX.js +0 -46
- package/dist/chunk-UIRCHPOU.js +0 -34
- package/dist/chunk-UNS6ZQVX.js +0 -71
- package/dist/chunk-VJMTX3OR.js +0 -115
- package/dist/chunk-XJSPWHNT.js +0 -64
- package/dist/chunk-XMZAC2VU.js +0 -84
- package/dist/chunk-Y7FKURZG.js +0 -130
- package/dist/chunk-YMSJCSRG.js +0 -213
- package/dist/chunk-YQIWS5V6.js +0 -172
- package/dist/chunk-ZPEI7DRJ.js +0 -66
- package/dist/queries/clean-signature.d.ts +0 -9
- package/dist/queries/clean-signature.js +0 -7
package/dist/chunk-FO2CBB7U.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/queries/files.ts
|
|
2
|
-
function globToLike(pattern) {
|
|
3
|
-
const hasGlobChars = /[*?]/.test(pattern);
|
|
4
|
-
if (!hasGlobChars) {
|
|
5
|
-
return `%${pattern}%`;
|
|
6
|
-
}
|
|
7
|
-
return pattern.replace(/\*\*/g, "%").replace(/\*/g, "%").replace(/\?/g, "_");
|
|
8
|
-
}
|
|
9
|
-
function files(db, pattern) {
|
|
10
|
-
const likePattern = globToLike(pattern);
|
|
11
|
-
const rows = db.all(
|
|
12
|
-
`SELECT relative_path FROM documents
|
|
13
|
-
WHERE relative_path LIKE ?
|
|
14
|
-
ORDER BY relative_path`,
|
|
15
|
-
likePattern
|
|
16
|
-
);
|
|
17
|
-
return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({ relativePath: r.relative_path }));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
files
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=chunk-FO2CBB7U.js.map
|
package/dist/chunk-HESWGDIV.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAllDefinitions,
|
|
3
|
-
getSourceText
|
|
4
|
-
} from "./chunk-FMAYH7GS.js";
|
|
5
|
-
import {
|
|
6
|
-
shortenSymbol
|
|
7
|
-
} from "./chunk-YMSJCSRG.js";
|
|
8
|
-
|
|
9
|
-
// src/queries/similar-signatures.ts
|
|
10
|
-
function similarSignatures(db, opts = {}) {
|
|
11
|
-
const { scope, minLoc = 1, limit } = opts;
|
|
12
|
-
const sigGroups = /* @__PURE__ */ new Map();
|
|
13
|
-
for (const definition of getAllDefinitions(db, { scope })) {
|
|
14
|
-
if (!definition.isFunctionLike || db.isIgnored(definition.relativePath)) continue;
|
|
15
|
-
const loc = definition.endLine - definition.startLine + 1;
|
|
16
|
-
if (loc < minLoc) continue;
|
|
17
|
-
const normalized = resolveNormalizedSignature(db, definition);
|
|
18
|
-
if (!normalized) continue;
|
|
19
|
-
const entry = {
|
|
20
|
-
symbol: definition.symbol,
|
|
21
|
-
shortName: shortenSymbol(definition.symbol),
|
|
22
|
-
file: definition.relativePath,
|
|
23
|
-
startLine: definition.startLine,
|
|
24
|
-
endLine: definition.endLine,
|
|
25
|
-
loc
|
|
26
|
-
};
|
|
27
|
-
const existing = sigGroups.get(normalized);
|
|
28
|
-
if (existing) {
|
|
29
|
-
existing.push(entry);
|
|
30
|
-
} else {
|
|
31
|
-
sigGroups.set(normalized, [entry]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const results = [];
|
|
35
|
-
for (const [signature, functions] of sigGroups) {
|
|
36
|
-
if (functions.length < 2) continue;
|
|
37
|
-
results.push({ signature, functions });
|
|
38
|
-
}
|
|
39
|
-
results.sort((a, b) => {
|
|
40
|
-
const sizeDiff = b.functions.length - a.functions.length;
|
|
41
|
-
if (sizeDiff !== 0) return sizeDiff;
|
|
42
|
-
const locA = a.functions.reduce((sum, f) => sum + f.loc, 0);
|
|
43
|
-
const locB = b.functions.reduce((sum, f) => sum + f.loc, 0);
|
|
44
|
-
return locB - locA;
|
|
45
|
-
});
|
|
46
|
-
return limit ? results.slice(0, limit) : results;
|
|
47
|
-
}
|
|
48
|
-
function resolveNormalizedSignature(db, definition) {
|
|
49
|
-
const documented = extractDocumentedSignature(definition.documentation);
|
|
50
|
-
const normalizedDocumented = documented ? normalizeSignature(documented) : null;
|
|
51
|
-
if (normalizedDocumented) {
|
|
52
|
-
return normalizedDocumented;
|
|
53
|
-
}
|
|
54
|
-
return normalizeSourceSignature(
|
|
55
|
-
extractDeclarationHead(db, definition.relativePath, definition.startLine, definition.endLine, definition.leaf),
|
|
56
|
-
definition.leaf
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
function extractDocumentedSignature(documentation) {
|
|
60
|
-
if (!documentation || !documentation.includes("|")) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const extracted = documentation.slice(documentation.indexOf("|") + 1).replace(/\n/g, " ").trim();
|
|
64
|
-
return extracted.length > 0 ? extracted : null;
|
|
65
|
-
}
|
|
66
|
-
function extractDeclarationHead(db, relativePath, startLine, endLine, leaf) {
|
|
67
|
-
const source = getSourceText(db, relativePath);
|
|
68
|
-
if (!source) return null;
|
|
69
|
-
const lines = source.split(/\r?\n/);
|
|
70
|
-
const candidates = declarationStartLines(lines, startLine, endLine, leaf);
|
|
71
|
-
for (const candidate of candidates) {
|
|
72
|
-
const maxLine = Math.min(lines.length - 1, Math.max(candidate, candidate + 4));
|
|
73
|
-
let collected = "";
|
|
74
|
-
for (let lineIndex = candidate; lineIndex <= maxLine; lineIndex += 1) {
|
|
75
|
-
const line = lines[lineIndex]?.trim();
|
|
76
|
-
if (!line) continue;
|
|
77
|
-
collected = collected ? `${collected} ${line}` : line;
|
|
78
|
-
if (looksCompleteDeclaration(collected)) {
|
|
79
|
-
return collected;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (collected && collected.includes("(")) {
|
|
83
|
-
return collected;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
function looksCompleteDeclaration(declaration) {
|
|
89
|
-
const normalized = declaration.replace(/\s+/g, " ").trim();
|
|
90
|
-
if (!normalized.includes("(")) return false;
|
|
91
|
-
if (parenBalance(normalized) > 0) return false;
|
|
92
|
-
return /[;{]$/.test(normalized) || /\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(normalized) || /\)\s*As\s+.+$/i.test(normalized);
|
|
93
|
-
}
|
|
94
|
-
function normalizeSignature(raw) {
|
|
95
|
-
if (!raw || !raw.trim()) return null;
|
|
96
|
-
let sig = raw.replace(/^```\w*\s*/, "").replace(/\s*```$/, "").replace(/^\(method\)\s*/, "").replace(/^\(property\)\s*/, "").replace(/^\(function\)\s*/, "").replace(/^\(class\)\s*/, "").replace(/^\(interface\)\s*/, "").replace(/^\(enum\)\s*/, "").replace(/^\(type alias\)\s*/, "").replace(/^\(const\)\s*/, "").replace(/^\(var\)\s*/, "").trim();
|
|
97
|
-
const parenIdx = sig.indexOf("(");
|
|
98
|
-
if (parenIdx === -1) return null;
|
|
99
|
-
sig = sig.slice(parenIdx);
|
|
100
|
-
sig = sig.replace(/\s+/g, "").toLowerCase();
|
|
101
|
-
if (sig.length < 3) return null;
|
|
102
|
-
return sig;
|
|
103
|
-
}
|
|
104
|
-
function normalizeSourceSignature(raw, leaf) {
|
|
105
|
-
if (!raw || !raw.trim()) return null;
|
|
106
|
-
const declaration = raw.replace(/\s+/g, " ").trim();
|
|
107
|
-
const parenIdx = declaration.indexOf("(");
|
|
108
|
-
if (parenIdx === -1) return null;
|
|
109
|
-
let prefix = declaration.slice(0, parenIdx);
|
|
110
|
-
const leafPattern = new RegExp(`\\b${escapeRegex(leaf)}\\b`, "i");
|
|
111
|
-
const leafMatch = leafPattern.exec(prefix);
|
|
112
|
-
if (leafMatch && typeof leafMatch.index === "number") {
|
|
113
|
-
prefix = prefix.slice(0, leafMatch.index);
|
|
114
|
-
}
|
|
115
|
-
prefix = prefix.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi, " ").replace(/\s+/g, " ").trim();
|
|
116
|
-
const suffix = declaration.slice(parenIdx).replace(/\s*\{[\s\S]*$/, "").replace(/\s*=>[\s\S]*$/, "").replace(/\)\s*=\s*[\s\S]*$/, ")").replace(/\s+throws\s+[^={]+$/i, "").replace(/\s+where\s+.+$/i, "").replace(/\s+/g, " ").trim();
|
|
117
|
-
if (!suffix.startsWith("(")) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const normalized = `${prefix ? `${prefix} ` : ""}${suffix}`.replace(/\s+/g, "").toLowerCase();
|
|
121
|
-
return normalized.length >= 3 ? normalized : null;
|
|
122
|
-
}
|
|
123
|
-
function declarationStartLines(lines, startLine, endLine, leaf) {
|
|
124
|
-
const escapedLeaf = escapeRegex(leaf);
|
|
125
|
-
const callablePattern = new RegExp(`\\b${escapedLeaf}\\b\\s*\\(`, "i");
|
|
126
|
-
const rubyPattern = new RegExp(`\\bdef\\s+${escapedLeaf}\\b`, "i");
|
|
127
|
-
const candidates = [];
|
|
128
|
-
const seen = /* @__PURE__ */ new Set();
|
|
129
|
-
const preferredStart = Math.max(0, Math.min(startLine, lines.length - 1));
|
|
130
|
-
const preferredEnd = Math.max(preferredStart, Math.min(lines.length - 1, Math.max(endLine, startLine + 4)));
|
|
131
|
-
for (let lineIndex = preferredStart; lineIndex <= preferredEnd; lineIndex += 1) {
|
|
132
|
-
const line = lines[lineIndex] ?? "";
|
|
133
|
-
if ((callablePattern.test(line) || rubyPattern.test(line)) && !seen.has(lineIndex)) {
|
|
134
|
-
seen.add(lineIndex);
|
|
135
|
-
candidates.push(lineIndex);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
139
|
-
const line = lines[lineIndex] ?? "";
|
|
140
|
-
if ((callablePattern.test(line) || rubyPattern.test(line)) && !seen.has(lineIndex)) {
|
|
141
|
-
seen.add(lineIndex);
|
|
142
|
-
candidates.push(lineIndex);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return candidates;
|
|
146
|
-
}
|
|
147
|
-
function parenBalance(value) {
|
|
148
|
-
let balance = 0;
|
|
149
|
-
for (const char of value) {
|
|
150
|
-
if (char === "(") balance += 1;
|
|
151
|
-
if (char === ")") balance -= 1;
|
|
152
|
-
}
|
|
153
|
-
return balance;
|
|
154
|
-
}
|
|
155
|
-
function escapeRegex(value) {
|
|
156
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export {
|
|
160
|
-
similarSignatures
|
|
161
|
-
};
|
|
162
|
-
//# sourceMappingURL=chunk-HESWGDIV.js.map
|
package/dist/chunk-HL2LXSBW.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
findFirstSymbolMatch,
|
|
3
|
-
getDefinitionsForFile
|
|
4
|
-
} from "./chunk-FMAYH7GS.js";
|
|
5
|
-
import {
|
|
6
|
-
isCallableSymbol,
|
|
7
|
-
leafName
|
|
8
|
-
} from "./chunk-YMSJCSRG.js";
|
|
9
|
-
|
|
10
|
-
// src/queries/methods.ts
|
|
11
|
-
import { basename } from "path";
|
|
12
|
-
function methods(db, className) {
|
|
13
|
-
const classMatch = findFirstSymbolMatch(db, className);
|
|
14
|
-
if (!classMatch) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const ownerName = leafName(classMatch.symbol);
|
|
18
|
-
const definitions = getDefinitionsForFile(db, classMatch.relativePath).filter((definition) => isCallableSymbol(definition.symbol));
|
|
19
|
-
const directMethods = definitions.filter((definition) => definition.parentTypeName === ownerName || definition.symbol.includes(ownerName));
|
|
20
|
-
const fileScopedMethods = directMethods.length > 0 ? directMethods : stripExtension(basename(classMatch.relativePath)) === ownerName ? definitions.filter((definition) => definition.symbol.includes("<invalid-global-code>")) : [];
|
|
21
|
-
return fileScopedMethods.map((definition) => ({
|
|
22
|
-
startLine: definition.startLine,
|
|
23
|
-
endLine: definition.endLine,
|
|
24
|
-
name: leafName(definition.symbol)
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
function stripExtension(relativePath) {
|
|
28
|
-
return relativePath.replace(/\.[^.]+$/, "");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
methods
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=chunk-HL2LXSBW.js.map
|
package/dist/chunk-HW76DVE4.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAllDefinitions
|
|
3
|
-
} from "./chunk-FMAYH7GS.js";
|
|
4
|
-
import {
|
|
5
|
-
leafSuffix,
|
|
6
|
-
parseSymbol,
|
|
7
|
-
shortenSymbol
|
|
8
|
-
} from "./chunk-YMSJCSRG.js";
|
|
9
|
-
|
|
10
|
-
// src/queries/by-kind.ts
|
|
11
|
-
var KIND_NAMES = {
|
|
12
|
-
0: "UnspecifiedKind",
|
|
13
|
-
1: "AbstractMethod",
|
|
14
|
-
2: "Accessor",
|
|
15
|
-
3: "Array",
|
|
16
|
-
4: "Assertion",
|
|
17
|
-
5: "AssociatedType",
|
|
18
|
-
6: "Attribute",
|
|
19
|
-
7: "Axiom",
|
|
20
|
-
8: "Boolean",
|
|
21
|
-
9: "Class",
|
|
22
|
-
10: "Constant",
|
|
23
|
-
11: "Constructor",
|
|
24
|
-
12: "Contract",
|
|
25
|
-
13: "DataFamily",
|
|
26
|
-
14: "DefinitionMacro",
|
|
27
|
-
15: "Delegate",
|
|
28
|
-
16: "Enum",
|
|
29
|
-
17: "EnumMember",
|
|
30
|
-
18: "Error",
|
|
31
|
-
19: "Event",
|
|
32
|
-
20: "Fact",
|
|
33
|
-
21: "Field",
|
|
34
|
-
22: "File",
|
|
35
|
-
23: "Function",
|
|
36
|
-
24: "Getter",
|
|
37
|
-
25: "Grammar",
|
|
38
|
-
26: "Instance",
|
|
39
|
-
27: "Interface",
|
|
40
|
-
28: "Key",
|
|
41
|
-
29: "Lang",
|
|
42
|
-
30: "Lemma",
|
|
43
|
-
31: "Library",
|
|
44
|
-
32: "Macro",
|
|
45
|
-
33: "Method",
|
|
46
|
-
34: "MethodAlias",
|
|
47
|
-
35: "MethodReceiver",
|
|
48
|
-
36: "MethodSpecification",
|
|
49
|
-
37: "Message",
|
|
50
|
-
38: "Modifier",
|
|
51
|
-
39: "Module",
|
|
52
|
-
40: "Namespace",
|
|
53
|
-
41: "Null",
|
|
54
|
-
42: "Number",
|
|
55
|
-
43: "Object",
|
|
56
|
-
44: "Operator",
|
|
57
|
-
45: "Package",
|
|
58
|
-
46: "PackageObject",
|
|
59
|
-
47: "Parameter",
|
|
60
|
-
48: "ParameterLabel",
|
|
61
|
-
49: "Pattern",
|
|
62
|
-
50: "Predicate",
|
|
63
|
-
51: "Property",
|
|
64
|
-
52: "Protocol",
|
|
65
|
-
53: "ProtocolMethod",
|
|
66
|
-
54: "PureVirtualMethod",
|
|
67
|
-
55: "Quasiquoter",
|
|
68
|
-
56: "SelfParameter",
|
|
69
|
-
57: "Setter",
|
|
70
|
-
58: "Signature",
|
|
71
|
-
59: "SingletonClass",
|
|
72
|
-
60: "SingletonMethod",
|
|
73
|
-
61: "StaticDataMember",
|
|
74
|
-
62: "StaticEvent",
|
|
75
|
-
63: "StaticField",
|
|
76
|
-
64: "StaticMethod",
|
|
77
|
-
65: "StaticProperty",
|
|
78
|
-
66: "StaticVariable",
|
|
79
|
-
67: "String",
|
|
80
|
-
68: "Struct",
|
|
81
|
-
69: "Subscript",
|
|
82
|
-
70: "Tactic",
|
|
83
|
-
71: "Theorem",
|
|
84
|
-
72: "ThisParameter",
|
|
85
|
-
73: "Trait",
|
|
86
|
-
74: "TraitMethod",
|
|
87
|
-
75: "Type",
|
|
88
|
-
76: "TypeAlias",
|
|
89
|
-
77: "TypeClass",
|
|
90
|
-
78: "TypeClassMethod",
|
|
91
|
-
79: "TypeFamily",
|
|
92
|
-
80: "TypeParameter",
|
|
93
|
-
81: "Union",
|
|
94
|
-
82: "Value",
|
|
95
|
-
83: "Variable"
|
|
96
|
-
};
|
|
97
|
-
var KIND_BY_NAME = /* @__PURE__ */ new Map();
|
|
98
|
-
for (const [k, v] of Object.entries(KIND_NAMES)) {
|
|
99
|
-
KIND_BY_NAME.set(v.toLowerCase(), Number(k));
|
|
100
|
-
}
|
|
101
|
-
function byKind(db, kindQuery, opts = {}) {
|
|
102
|
-
const { scope, limit = 100 } = opts;
|
|
103
|
-
let kindNum = null;
|
|
104
|
-
const asNum = parseInt(kindQuery, 10);
|
|
105
|
-
if (!isNaN(asNum)) {
|
|
106
|
-
kindNum = asNum;
|
|
107
|
-
} else {
|
|
108
|
-
kindNum = KIND_BY_NAME.get(kindQuery.toLowerCase()) ?? null;
|
|
109
|
-
if (kindNum === null) {
|
|
110
|
-
for (const [name, num] of KIND_BY_NAME) {
|
|
111
|
-
if (name.includes(kindQuery.toLowerCase())) {
|
|
112
|
-
kindNum = num;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (kindNum === null) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
const rows = loadKindRows(db, scope).map((row) => ({
|
|
122
|
-
row,
|
|
123
|
-
resolvedKind: resolveKindNumber(row)
|
|
124
|
-
})).filter((entry) => entry.resolvedKind === kindNum).slice(0, limit);
|
|
125
|
-
return rows.map(({ row, resolvedKind }) => ({
|
|
126
|
-
symbol: row.symbol,
|
|
127
|
-
shortName: shortenSymbol(row.symbol),
|
|
128
|
-
kind: resolvedKind,
|
|
129
|
-
kindName: KIND_NAMES[resolvedKind] ?? "Unknown",
|
|
130
|
-
relativePath: row.relative_path,
|
|
131
|
-
startLine: row.start_line,
|
|
132
|
-
endLine: row.end_line
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
function kindCounts(db, opts = {}) {
|
|
136
|
-
const counts = /* @__PURE__ */ new Map();
|
|
137
|
-
for (const row of loadKindRows(db, opts.scope)) {
|
|
138
|
-
const kind = resolveKindNumber(row);
|
|
139
|
-
if (kind === null || kind === 0) continue;
|
|
140
|
-
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
141
|
-
}
|
|
142
|
-
return [...counts.entries()].sort((a, b) => b[1] - a[1] || a[0] - b[0]).map(([kind, count]) => ({
|
|
143
|
-
kind,
|
|
144
|
-
kindName: KIND_NAMES[kind] ?? "Unknown",
|
|
145
|
-
count
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
function loadKindRows(db, scope) {
|
|
149
|
-
return getAllDefinitions(db, { scope }).map(mapDefinitionToKindRow);
|
|
150
|
-
}
|
|
151
|
-
function mapDefinitionToKindRow(definition) {
|
|
152
|
-
return {
|
|
153
|
-
symbol: definition.symbol,
|
|
154
|
-
kind: definition.kind,
|
|
155
|
-
documentation: definition.documentation,
|
|
156
|
-
enclosing_symbol: definition.enclosingSymbol,
|
|
157
|
-
relative_path: definition.relativePath,
|
|
158
|
-
start_line: definition.startLine,
|
|
159
|
-
end_line: definition.endLine
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
function resolveKindNumber(row) {
|
|
163
|
-
if (row.kind !== null && row.kind !== 0) {
|
|
164
|
-
return normalizeIndexedKind(row.kind, row.symbol, row.documentation);
|
|
165
|
-
}
|
|
166
|
-
return inferKindNumber(row.symbol, row.documentation, row.enclosing_symbol);
|
|
167
|
-
}
|
|
168
|
-
function normalizeIndexedKind(kind, symbol, documentation) {
|
|
169
|
-
const signature = (documentation ?? "").toLowerCase();
|
|
170
|
-
const suffix = leafSuffix(symbol);
|
|
171
|
-
if (suffix === "type") {
|
|
172
|
-
if (signature.includes("type ")) return 76;
|
|
173
|
-
if (signature.includes("interface ")) return 27;
|
|
174
|
-
if (signature.includes("struct ")) return 68;
|
|
175
|
-
if (signature.includes("trait ")) return 73;
|
|
176
|
-
if (signature.includes("class ")) return 9;
|
|
177
|
-
}
|
|
178
|
-
return kind;
|
|
179
|
-
}
|
|
180
|
-
function inferKindNumber(symbol, documentation, enclosingSymbol) {
|
|
181
|
-
const parsed = parseSymbol(symbol);
|
|
182
|
-
if ("kind" in parsed) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
const descriptors = parsed.descriptors;
|
|
186
|
-
const parent = descriptors[descriptors.length - 2] ?? null;
|
|
187
|
-
const suffix = leafSuffix(symbol);
|
|
188
|
-
const signature = (documentation ?? "").toLowerCase();
|
|
189
|
-
if (suffix === "type") {
|
|
190
|
-
if (signature.includes("type ")) return 76;
|
|
191
|
-
if (signature.includes("interface ")) return 27;
|
|
192
|
-
if (signature.includes("struct ")) return 68;
|
|
193
|
-
if (signature.includes("trait ")) return 73;
|
|
194
|
-
if (signature.includes("class ")) return 9;
|
|
195
|
-
return 9;
|
|
196
|
-
}
|
|
197
|
-
if (suffix === "method") {
|
|
198
|
-
return parent?.suffix === "type" ? 33 : 23;
|
|
199
|
-
}
|
|
200
|
-
if (suffix === "namespace") return 39;
|
|
201
|
-
if (suffix !== "term") return null;
|
|
202
|
-
if (signature.includes("async def ") || signature.includes("def ")) {
|
|
203
|
-
return 23;
|
|
204
|
-
}
|
|
205
|
-
const enclosingSuffix = enclosingSymbol ? leafSuffix(enclosingSymbol) : parent?.suffix ?? null;
|
|
206
|
-
if (enclosingSuffix === "type") {
|
|
207
|
-
return 21;
|
|
208
|
-
}
|
|
209
|
-
return 83;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export {
|
|
213
|
-
byKind,
|
|
214
|
-
kindCounts
|
|
215
|
-
};
|
|
216
|
-
//# sourceMappingURL=chunk-HW76DVE4.js.map
|
package/dist/chunk-IC5NTO47.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveIndexedFile
|
|
3
|
-
} from "./chunk-FMAYH7GS.js";
|
|
4
|
-
|
|
5
|
-
// src/queries/deps.ts
|
|
6
|
-
function deps(db, filePattern) {
|
|
7
|
-
const resolvedFile = resolveIndexedFile(db, filePattern);
|
|
8
|
-
if (!resolvedFile) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const rows = db.all(
|
|
12
|
-
`SELECT DISTINCT d2.relative_path
|
|
13
|
-
FROM mentions m
|
|
14
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
15
|
-
JOIN documents d1 ON c.document_id = d1.id
|
|
16
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
17
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
18
|
-
JOIN documents d2 ON der.document_id = d2.id
|
|
19
|
-
WHERE d1.relative_path = ?
|
|
20
|
-
AND d2.relative_path <> d1.relative_path
|
|
21
|
-
AND ${db.localSymbolPredicate}
|
|
22
|
-
ORDER BY d2.relative_path`,
|
|
23
|
-
resolvedFile
|
|
24
|
-
);
|
|
25
|
-
return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({ relativePath: r.relative_path }));
|
|
26
|
-
}
|
|
27
|
-
function rdeps(db, filePattern) {
|
|
28
|
-
const resolvedFile = resolveIndexedFile(db, filePattern);
|
|
29
|
-
if (!resolvedFile) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
const rows = db.all(
|
|
33
|
-
`SELECT DISTINCT d1.relative_path
|
|
34
|
-
FROM mentions m
|
|
35
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
36
|
-
JOIN documents d1 ON c.document_id = d1.id
|
|
37
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
38
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
39
|
-
JOIN documents d2 ON der.document_id = d2.id
|
|
40
|
-
WHERE d2.relative_path = ?
|
|
41
|
-
AND d1.relative_path != ?
|
|
42
|
-
ORDER BY d1.relative_path`,
|
|
43
|
-
resolvedFile,
|
|
44
|
-
resolvedFile
|
|
45
|
-
);
|
|
46
|
-
return rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({ relativePath: r.relative_path }));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
deps,
|
|
51
|
-
rdeps
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=chunk-IC5NTO47.js.map
|
package/dist/chunk-J34HAAEQ.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAllDefinitions,
|
|
3
|
-
getCallerRowsForSymbol
|
|
4
|
-
} from "./chunk-FMAYH7GS.js";
|
|
5
|
-
import {
|
|
6
|
-
shortenSymbol
|
|
7
|
-
} from "./chunk-YMSJCSRG.js";
|
|
8
|
-
|
|
9
|
-
// src/queries/hotspots.ts
|
|
10
|
-
function hotspots(db, opts = {}) {
|
|
11
|
-
const { limit = 30, scope } = opts;
|
|
12
|
-
const scopeFilter = scope ? `AND def_d.relative_path LIKE '%${scope}%'` : "";
|
|
13
|
-
const rows = db.all(
|
|
14
|
-
`SELECT
|
|
15
|
-
gs.symbol,
|
|
16
|
-
COUNT(*) AS ref_count,
|
|
17
|
-
COUNT(DISTINCT ref_d.id) AS file_count,
|
|
18
|
-
def_d.relative_path AS defined_in
|
|
19
|
-
FROM mentions m
|
|
20
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
21
|
-
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
22
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
23
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
24
|
-
JOIN documents def_d ON der.document_id = def_d.id
|
|
25
|
-
WHERE m.role != 1
|
|
26
|
-
${db.pathExclusionsFor("def_d")}
|
|
27
|
-
${db.symbolNoiseFor("gs")}
|
|
28
|
-
${scopeFilter}
|
|
29
|
-
GROUP BY gs.id
|
|
30
|
-
ORDER BY ref_count DESC
|
|
31
|
-
LIMIT ?`,
|
|
32
|
-
limit
|
|
33
|
-
);
|
|
34
|
-
const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
|
|
35
|
-
symbol: r.symbol,
|
|
36
|
-
shortName: shortenSymbol(r.symbol),
|
|
37
|
-
refCount: r.ref_count,
|
|
38
|
-
fileCount: r.file_count,
|
|
39
|
-
definedIn: r.defined_in
|
|
40
|
-
}));
|
|
41
|
-
if (indexedResults.length > 0) {
|
|
42
|
-
return indexedResults;
|
|
43
|
-
}
|
|
44
|
-
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
45
|
-
const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
|
|
46
|
-
return {
|
|
47
|
-
symbol: definition.symbol,
|
|
48
|
-
shortName: shortenSymbol(definition.symbol),
|
|
49
|
-
refCount: callerRows.length,
|
|
50
|
-
fileCount: new Set(callerRows.map((row) => row.file)).size,
|
|
51
|
-
definedIn: definition.relativePath
|
|
52
|
-
};
|
|
53
|
-
}).filter((row) => row.refCount > 0).sort((left, right) => right.refCount - left.refCount || right.fileCount - left.fileCount).slice(0, limit);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
hotspots
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-J34HAAEQ.js.map
|
package/dist/chunk-JSXGC2EH.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
shortenSymbol
|
|
3
|
-
} from "./chunk-YMSJCSRG.js";
|
|
4
|
-
|
|
5
|
-
// src/queries/diff-impact.ts
|
|
6
|
-
import { execFileSync } from "child_process";
|
|
7
|
-
function diffImpact(db, opts = {}) {
|
|
8
|
-
const { base = "HEAD" } = opts;
|
|
9
|
-
let changedFileLines;
|
|
10
|
-
try {
|
|
11
|
-
changedFileLines = getChangedFiles(db.config.projectRoot, base);
|
|
12
|
-
} catch {
|
|
13
|
-
return {
|
|
14
|
-
changedFiles: [],
|
|
15
|
-
changedSymbols: [],
|
|
16
|
-
affectedConsumers: [],
|
|
17
|
-
summary: {
|
|
18
|
-
totalChangedFiles: 0,
|
|
19
|
-
totalChangedSymbols: 0,
|
|
20
|
-
totalAffectedFiles: 0,
|
|
21
|
-
note: "Unable to compute git diff."
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (changedFileLines.length === 0) {
|
|
26
|
-
return {
|
|
27
|
-
changedFiles: [],
|
|
28
|
-
changedSymbols: [],
|
|
29
|
-
affectedConsumers: [],
|
|
30
|
-
summary: {
|
|
31
|
-
totalChangedFiles: 0,
|
|
32
|
-
totalChangedSymbols: 0,
|
|
33
|
-
totalAffectedFiles: 0,
|
|
34
|
-
note: "No changed files found."
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const changedFiles = [];
|
|
39
|
-
const changedDocIds = [];
|
|
40
|
-
for (const file of changedFileLines) {
|
|
41
|
-
const doc = db.get(
|
|
42
|
-
`SELECT id, relative_path FROM documents
|
|
43
|
-
WHERE relative_path LIKE ?
|
|
44
|
-
LIMIT 1`,
|
|
45
|
-
`%${file}`
|
|
46
|
-
);
|
|
47
|
-
if (doc && !db.isIgnored(doc.relative_path)) {
|
|
48
|
-
changedFiles.push(doc.relative_path);
|
|
49
|
-
changedDocIds.push(doc.id);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (changedDocIds.length === 0) {
|
|
53
|
-
return {
|
|
54
|
-
changedFiles: changedFileLines,
|
|
55
|
-
changedSymbols: [],
|
|
56
|
-
affectedConsumers: [],
|
|
57
|
-
summary: {
|
|
58
|
-
totalChangedFiles: changedFileLines.length,
|
|
59
|
-
totalChangedSymbols: 0,
|
|
60
|
-
totalAffectedFiles: 0,
|
|
61
|
-
note: "Changed files are not present in the current SCIP index."
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const docPlaceholders = changedDocIds.map(() => "?").join(",");
|
|
66
|
-
const syms = db.all(
|
|
67
|
-
`SELECT DISTINCT gs.id AS symbol_id, gs.symbol, d.relative_path
|
|
68
|
-
FROM defn_enclosing_ranges der
|
|
69
|
-
JOIN global_symbols gs ON der.symbol_id = gs.id
|
|
70
|
-
JOIN documents d ON der.document_id = d.id
|
|
71
|
-
WHERE der.document_id IN (${docPlaceholders})
|
|
72
|
-
${db.symbolNoiseFor("gs")}
|
|
73
|
-
ORDER BY d.relative_path`,
|
|
74
|
-
...changedDocIds
|
|
75
|
-
);
|
|
76
|
-
const changedSymbols = [];
|
|
77
|
-
const consumerMap = /* @__PURE__ */ new Map();
|
|
78
|
-
for (const sym of syms) {
|
|
79
|
-
const fanInRow = db.get(
|
|
80
|
-
`SELECT COUNT(DISTINCT c.document_id) AS fan_in
|
|
81
|
-
FROM mentions m
|
|
82
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
83
|
-
WHERE m.symbol_id = ?
|
|
84
|
-
AND m.role != 1`,
|
|
85
|
-
sym.symbol_id
|
|
86
|
-
);
|
|
87
|
-
const fanIn = fanInRow?.fan_in ?? 0;
|
|
88
|
-
const shortName = shortenSymbol(sym.symbol);
|
|
89
|
-
changedSymbols.push({
|
|
90
|
-
symbol: sym.symbol,
|
|
91
|
-
shortName,
|
|
92
|
-
file: sym.relative_path,
|
|
93
|
-
fanIn
|
|
94
|
-
});
|
|
95
|
-
const consumers = db.all(
|
|
96
|
-
`SELECT DISTINCT ref_d.relative_path
|
|
97
|
-
FROM mentions m
|
|
98
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
99
|
-
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
100
|
-
WHERE m.symbol_id = ?
|
|
101
|
-
AND m.role != 1
|
|
102
|
-
AND ref_d.relative_path NOT IN (${changedFiles.map(() => "?").join(",")})
|
|
103
|
-
${db.pathExclusionsFor("ref_d")}`,
|
|
104
|
-
sym.symbol_id,
|
|
105
|
-
...changedFiles
|
|
106
|
-
);
|
|
107
|
-
for (const consumer of consumers) {
|
|
108
|
-
if (db.isIgnored(consumer.relative_path)) continue;
|
|
109
|
-
if (!consumerMap.has(consumer.relative_path)) {
|
|
110
|
-
consumerMap.set(consumer.relative_path, /* @__PURE__ */ new Set());
|
|
111
|
-
}
|
|
112
|
-
consumerMap.get(consumer.relative_path).add(shortName);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const affectedConsumers = [...consumerMap.entries()].map(([file, symbols]) => ({ file, consumedSymbols: symbols.size })).sort((a, b) => b.consumedSymbols - a.consumedSymbols);
|
|
116
|
-
return {
|
|
117
|
-
changedFiles,
|
|
118
|
-
changedSymbols,
|
|
119
|
-
affectedConsumers,
|
|
120
|
-
summary: {
|
|
121
|
-
totalChangedFiles: changedFiles.length,
|
|
122
|
-
totalChangedSymbols: changedSymbols.length,
|
|
123
|
-
totalAffectedFiles: affectedConsumers.length
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function getChangedFiles(projectRoot, base) {
|
|
128
|
-
const diff = execFileSync("git", ["diff", "--name-only", base], {
|
|
129
|
-
encoding: "utf-8",
|
|
130
|
-
cwd: projectRoot,
|
|
131
|
-
timeout: 1e4
|
|
132
|
-
});
|
|
133
|
-
const staged = execFileSync("git", ["diff", "--name-only", "--cached", base], {
|
|
134
|
-
encoding: "utf-8",
|
|
135
|
-
cwd: projectRoot,
|
|
136
|
-
timeout: 1e4
|
|
137
|
-
});
|
|
138
|
-
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], {
|
|
139
|
-
encoding: "utf-8",
|
|
140
|
-
cwd: projectRoot,
|
|
141
|
-
timeout: 1e4
|
|
142
|
-
});
|
|
143
|
-
return [...new Set(
|
|
144
|
-
[diff, staged, untracked].flatMap((chunk) => chunk.split("\n")).map((line) => line.trim()).filter((line) => line.length > 0)
|
|
145
|
-
)];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export {
|
|
149
|
-
diffImpact
|
|
150
|
-
};
|
|
151
|
-
//# sourceMappingURL=chunk-JSXGC2EH.js.map
|