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
package/dist/chunk-VJMTX3OR.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
findFirstSymbolMatch,
|
|
3
|
-
getSourceReferenceSites,
|
|
4
|
-
getSourceText
|
|
5
|
-
} from "./chunk-FMAYH7GS.js";
|
|
6
|
-
import {
|
|
7
|
-
isFunctionLikeSymbol
|
|
8
|
-
} from "./chunk-YMSJCSRG.js";
|
|
9
|
-
|
|
10
|
-
// src/queries/refs.ts
|
|
11
|
-
function refs(db, symbolPattern) {
|
|
12
|
-
const match = findFirstSymbolMatch(db, symbolPattern);
|
|
13
|
-
if (match) {
|
|
14
|
-
const includeDefinitionSite = !isFunctionLikeSymbol(match.symbol);
|
|
15
|
-
const definitionRows = includeDefinitionSite ? [{
|
|
16
|
-
relativePath: match.relativePath,
|
|
17
|
-
line: match.startLine
|
|
18
|
-
}] : [];
|
|
19
|
-
const sourceSites = getSourceReferenceSites(db, match).filter((site) => !db.isIgnored(site.file)).map((site) => ({
|
|
20
|
-
relativePath: site.file,
|
|
21
|
-
line: site.line
|
|
22
|
-
}));
|
|
23
|
-
if (sourceSites.length > 0) {
|
|
24
|
-
const seen2 = /* @__PURE__ */ new Set();
|
|
25
|
-
const rows2 = [...definitionRows, ...sourceSites, ...getRubySemanticRefs(db, match)].filter((site) => {
|
|
26
|
-
const key = `${site.relativePath}:${site.line}`;
|
|
27
|
-
if (seen2.has(key)) return false;
|
|
28
|
-
seen2.add(key);
|
|
29
|
-
return true;
|
|
30
|
-
});
|
|
31
|
-
return rows2;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const rows = db.all(
|
|
35
|
-
`SELECT DISTINCT d.relative_path, c.start_line
|
|
36
|
-
FROM mentions m
|
|
37
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
38
|
-
JOIN documents d ON c.document_id = d.id
|
|
39
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
40
|
-
WHERE m.symbol_id = ?
|
|
41
|
-
AND ${db.localSymbolPredicate}
|
|
42
|
-
AND m.role != 1
|
|
43
|
-
ORDER BY d.relative_path, c.start_line`,
|
|
44
|
-
match?.symbolId ?? -1
|
|
45
|
-
);
|
|
46
|
-
const referenceRows = rows.filter((r) => !db.isIgnored(r.relative_path)).map((r) => ({
|
|
47
|
-
relativePath: r.relative_path,
|
|
48
|
-
line: r.start_line
|
|
49
|
-
}));
|
|
50
|
-
if (!match || db.isIgnored(match.relativePath) || isFunctionLikeSymbol(match.symbol)) {
|
|
51
|
-
return referenceRows;
|
|
52
|
-
}
|
|
53
|
-
const seen = new Set(referenceRows.map((row) => `${row.relativePath}:${row.line}`));
|
|
54
|
-
if (!seen.has(`${match.relativePath}:${match.startLine}`)) {
|
|
55
|
-
referenceRows.unshift({
|
|
56
|
-
relativePath: match.relativePath,
|
|
57
|
-
line: match.startLine
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
for (const row of getRubySemanticRefs(db, match)) {
|
|
61
|
-
const key = `${row.relativePath}:${row.line}`;
|
|
62
|
-
if (seen.has(key)) continue;
|
|
63
|
-
seen.add(key);
|
|
64
|
-
referenceRows.push(row);
|
|
65
|
-
}
|
|
66
|
-
return referenceRows;
|
|
67
|
-
}
|
|
68
|
-
function getRubySemanticRefs(db, match) {
|
|
69
|
-
if (!match.relativePath.endsWith(".rb")) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
const tokens = rubyReferenceTokens(match.symbol);
|
|
73
|
-
if (tokens.length === 0) {
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
const rows = db.all(
|
|
77
|
-
`SELECT relative_path
|
|
78
|
-
FROM documents
|
|
79
|
-
WHERE relative_path LIKE '%.rb'
|
|
80
|
-
${db.pathExclusionsFor("documents")}
|
|
81
|
-
ORDER BY relative_path`
|
|
82
|
-
);
|
|
83
|
-
const results = [];
|
|
84
|
-
for (const row of rows) {
|
|
85
|
-
if (db.isIgnored(row.relative_path)) continue;
|
|
86
|
-
const source = getSourceText(db, row.relative_path);
|
|
87
|
-
if (!source) continue;
|
|
88
|
-
const lines = source.split("\n");
|
|
89
|
-
for (let index = 0; index < lines.length; index++) {
|
|
90
|
-
const line = lines[index] ?? "";
|
|
91
|
-
if (tokens.some((token) => new RegExp(`@${token}\\b|\\b${token}:`).test(line))) {
|
|
92
|
-
results.push({
|
|
93
|
-
relativePath: row.relative_path,
|
|
94
|
-
line: index
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return results;
|
|
100
|
-
}
|
|
101
|
-
function rubyReferenceTokens(rawSymbol) {
|
|
102
|
-
const leaf = rawSymbol.split(":").pop() ?? rawSymbol;
|
|
103
|
-
const snake = leaf.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9_]+/g, "_").toLowerCase().replace(/^_+|_+$/g, "");
|
|
104
|
-
const parts = snake.split("_").filter(Boolean);
|
|
105
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
106
|
-
if (snake) candidates.add(snake);
|
|
107
|
-
if (parts.length >= 1) candidates.add(parts[parts.length - 1]);
|
|
108
|
-
if (parts.length >= 2) candidates.add(parts.slice(-2).join("_"));
|
|
109
|
-
return [...candidates];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
refs
|
|
114
|
-
};
|
|
115
|
-
//# sourceMappingURL=chunk-VJMTX3OR.js.map
|
package/dist/chunk-Y7FKURZG.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAllDefinitions,
|
|
3
|
-
getCalleeRowsForSymbol,
|
|
4
|
-
getCallerRowsForSymbol,
|
|
5
|
-
testFileExclusionSql
|
|
6
|
-
} from "./chunk-FMAYH7GS.js";
|
|
7
|
-
import {
|
|
8
|
-
shortenSymbol
|
|
9
|
-
} from "./chunk-YMSJCSRG.js";
|
|
10
|
-
|
|
11
|
-
// src/queries/complexity-hotspots.ts
|
|
12
|
-
function complexityHotspots(db, opts) {
|
|
13
|
-
const { scope, minLoc = 10, limit = 30 } = opts ?? {};
|
|
14
|
-
const scopeFilter = scope ? `AND d.relative_path LIKE '%${scope}%'` : "";
|
|
15
|
-
const rows = db.all(
|
|
16
|
-
`SELECT
|
|
17
|
-
gs.symbol,
|
|
18
|
-
d.relative_path AS file,
|
|
19
|
-
der.start_line,
|
|
20
|
-
der.end_line,
|
|
21
|
-
(der.end_line - der.start_line + 1) AS loc,
|
|
22
|
-
-- fanIn: distinct files that reference this symbol
|
|
23
|
-
(SELECT COUNT(DISTINCT ref_c.document_id)
|
|
24
|
-
FROM mentions ref_m
|
|
25
|
-
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
26
|
-
WHERE ref_m.symbol_id = gs.id AND ref_m.role != 1
|
|
27
|
-
) AS fan_in,
|
|
28
|
-
-- fanOut: distinct symbols referenced within this definition range
|
|
29
|
-
-- that are defined in different files
|
|
30
|
-
(SELECT COUNT(DISTINCT out_gs.id)
|
|
31
|
-
FROM mentions out_m
|
|
32
|
-
JOIN chunks out_c ON out_m.chunk_id = out_c.id
|
|
33
|
-
JOIN global_symbols out_gs ON out_m.symbol_id = out_gs.id
|
|
34
|
-
JOIN defn_enclosing_ranges out_der ON out_gs.id = out_der.symbol_id
|
|
35
|
-
WHERE out_c.document_id = der.document_id
|
|
36
|
-
AND out_c.start_line >= der.start_line
|
|
37
|
-
AND out_c.end_line <= der.end_line
|
|
38
|
-
AND out_m.role != 1
|
|
39
|
-
AND out_gs.id != gs.id
|
|
40
|
-
AND out_der.document_id != der.document_id
|
|
41
|
-
) AS fan_out,
|
|
42
|
-
-- calleeCount: total distinct callees within definition range
|
|
43
|
-
(SELECT COUNT(DISTINCT callee_gs.id)
|
|
44
|
-
FROM mentions callee_m
|
|
45
|
-
JOIN chunks callee_c ON callee_m.chunk_id = callee_c.id
|
|
46
|
-
JOIN global_symbols callee_gs ON callee_m.symbol_id = callee_gs.id
|
|
47
|
-
WHERE callee_c.document_id = der.document_id
|
|
48
|
-
AND callee_c.start_line >= der.start_line
|
|
49
|
-
AND callee_c.end_line <= der.end_line
|
|
50
|
-
AND callee_m.role != 1
|
|
51
|
-
AND callee_gs.id != gs.id
|
|
52
|
-
) AS callee_count
|
|
53
|
-
FROM global_symbols gs
|
|
54
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
55
|
-
JOIN documents d ON der.document_id = d.id
|
|
56
|
-
WHERE 1 = 1
|
|
57
|
-
${db.pathExclusionsFor("d")}
|
|
58
|
-
AND ${testFileExclusionSql("d")}
|
|
59
|
-
${db.symbolNoiseFor("gs")}
|
|
60
|
-
AND (der.end_line - der.start_line + 1) >= ?
|
|
61
|
-
${scopeFilter}
|
|
62
|
-
ORDER BY (
|
|
63
|
-
CAST((der.end_line - der.start_line + 1) AS REAL) / 50.0
|
|
64
|
-
* CAST((SELECT COUNT(DISTINCT ref_c2.document_id)
|
|
65
|
-
FROM mentions ref_m2
|
|
66
|
-
JOIN chunks ref_c2 ON ref_m2.chunk_id = ref_c2.id
|
|
67
|
-
WHERE ref_m2.symbol_id = gs.id AND ref_m2.role != 1
|
|
68
|
-
) AS REAL) / 5.0
|
|
69
|
-
* MAX(CAST((SELECT COUNT(DISTINCT out_gs2.id)
|
|
70
|
-
FROM mentions out_m2
|
|
71
|
-
JOIN chunks out_c2 ON out_m2.chunk_id = out_c2.id
|
|
72
|
-
JOIN global_symbols out_gs2 ON out_m2.symbol_id = out_gs2.id
|
|
73
|
-
JOIN defn_enclosing_ranges out_der2 ON out_gs2.id = out_der2.symbol_id
|
|
74
|
-
WHERE out_c2.document_id = der.document_id
|
|
75
|
-
AND out_c2.start_line >= der.start_line
|
|
76
|
-
AND out_c2.end_line <= der.end_line
|
|
77
|
-
AND out_m2.role != 1
|
|
78
|
-
AND out_gs2.id != gs.id
|
|
79
|
-
AND out_der2.document_id != der.document_id
|
|
80
|
-
) AS REAL) / 5.0, 1.0)
|
|
81
|
-
) DESC
|
|
82
|
-
LIMIT ?`,
|
|
83
|
-
minLoc,
|
|
84
|
-
limit
|
|
85
|
-
);
|
|
86
|
-
const indexedResults = rows.filter((r) => !db.isIgnored(r.file)).map((r) => ({
|
|
87
|
-
symbol: r.symbol,
|
|
88
|
-
shortName: shortenSymbol(r.symbol),
|
|
89
|
-
file: r.file,
|
|
90
|
-
startLine: r.start_line,
|
|
91
|
-
endLine: r.end_line,
|
|
92
|
-
loc: r.loc,
|
|
93
|
-
fanIn: r.fan_in,
|
|
94
|
-
fanOut: r.fan_out,
|
|
95
|
-
calleeCount: r.callee_count,
|
|
96
|
-
score: Math.round(
|
|
97
|
-
r.loc / 50 * (r.fan_in / 5) * Math.max(r.fan_out / 5, 1) * 100
|
|
98
|
-
) / 100
|
|
99
|
-
}));
|
|
100
|
-
if (indexedResults.length > 0) {
|
|
101
|
-
return indexedResults;
|
|
102
|
-
}
|
|
103
|
-
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
104
|
-
const loc = definition.endLine - definition.startLine + 1;
|
|
105
|
-
const callerRows = getCallerRowsForSymbol(db, definition, { limit: 500 });
|
|
106
|
-
const calleeRows = getCalleeRowsForSymbol(db, definition, { limit: 500 });
|
|
107
|
-
const fanIn = new Set(callerRows.map((row) => row.file)).size;
|
|
108
|
-
const fanOut = new Set(
|
|
109
|
-
calleeRows.filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
|
|
110
|
-
).size;
|
|
111
|
-
const calleeCount = new Set(calleeRows.map((row) => `${row.symbol}|${row.file}`)).size;
|
|
112
|
-
return {
|
|
113
|
-
symbol: definition.symbol,
|
|
114
|
-
shortName: shortenSymbol(definition.symbol),
|
|
115
|
-
file: definition.relativePath,
|
|
116
|
-
startLine: definition.startLine,
|
|
117
|
-
endLine: definition.endLine,
|
|
118
|
-
loc,
|
|
119
|
-
fanIn,
|
|
120
|
-
fanOut,
|
|
121
|
-
calleeCount,
|
|
122
|
-
score: Math.round(loc / 50 * (fanIn / 5) * Math.max(fanOut / 5, 1) * 100) / 100
|
|
123
|
-
};
|
|
124
|
-
}).filter((row) => row.loc >= minLoc).sort((left, right) => right.score - left.score || right.loc - left.loc).slice(0, limit);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
128
|
-
complexityHotspots
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=chunk-Y7FKURZG.js.map
|