scip-query 0.3.5 → 0.4.1
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/README.md +2 -1
- package/dist/{chunk-VMM4SYV4.js → chunk-24LF6IZB.js} +17 -4
- package/dist/{chunk-EPWLXXBL.js → chunk-3NJSJ7TE.js} +28 -30
- package/dist/{chunk-SMDCNPMK.js → chunk-43A4UCS7.js} +3 -3
- package/dist/{chunk-CHDJXYBG.js → chunk-5GCORUNV.js} +3 -3
- package/dist/{chunk-OIDHN6GD.js → chunk-6CH23IAS.js} +148 -7
- package/dist/chunk-6ECR2FLR.js +60 -0
- package/dist/{chunk-C7H5WBTJ.js → chunk-6UZU7DFL.js} +3 -3
- package/dist/chunk-7BS4CPJX.js +162 -0
- package/dist/{chunk-UGQKAVCD.js → chunk-A6XLXV6W.js} +3 -3
- package/dist/chunk-ALUFWH3U.js +2695 -0
- package/dist/{chunk-F7XU27LU.js → chunk-CBIWNZZZ.js} +27 -3
- package/dist/{chunk-26DOJ63W.js → chunk-DUJNJQPO.js} +14 -3
- package/dist/{chunk-GSH2FPKV.js → chunk-EAGKJFDX.js} +3 -3
- package/dist/{chunk-VIYSWZCO.js → chunk-ELFGD5EW.js} +32 -4
- package/dist/chunk-FVJE4MQL.js +37 -0
- package/dist/{chunk-NFS5W3PP.js → chunk-GNAMV3JC.js} +3 -3
- package/dist/{chunk-TRESG7OB.js → chunk-J47VSL6I.js} +3 -3
- package/dist/chunk-J6QXMYAQ.js +115 -0
- package/dist/{chunk-6FKIA6EI.js → chunk-JHVQB4Y5.js} +12 -12
- package/dist/{chunk-YY4QGUQ5.js → chunk-JKXHHV4B.js} +2 -2
- package/dist/{chunk-EN2Z2CLO.js → chunk-KG4OFQEN.js} +17 -20
- package/dist/chunk-KLNKDX6A.js +110 -0
- package/dist/{chunk-5OMVSV6E.js → chunk-KYPXKV64.js} +3 -3
- package/dist/chunk-NXUIWD6K.js +87 -0
- package/dist/{chunk-LFJQVJYJ.js → chunk-OXX3QF24.js} +2 -2
- package/dist/{chunk-NG5F43OU.js → chunk-P3VCDYMJ.js} +70 -1
- package/dist/{chunk-7HK5ZLOE.js → chunk-PCU455MX.js} +2 -2
- package/dist/{chunk-O7Q7FDUJ.js → chunk-POLELLNM.js} +3 -3
- package/dist/chunk-PU2254N2.js +115 -0
- package/dist/{chunk-WGAD3GNR.js → chunk-QMXSLHZP.js} +5 -5
- package/dist/{chunk-YDBXNPYU.js → chunk-R7HPHMRZ.js} +3 -3
- package/dist/{chunk-HLUS2HEB.js → chunk-RE7POFGI.js} +5 -4
- package/dist/{chunk-VT4JBH6L.js → chunk-RJ5GULL6.js} +2 -2
- package/dist/{chunk-7KIMF5PV.js → chunk-RL74LF47.js} +2 -2
- package/dist/chunk-SVLUJSY7.js +75 -0
- package/dist/chunk-SYQR4QGK.js +38 -0
- package/dist/{chunk-QIXNAB5K.js → chunk-TO3L4YNK.js} +1 -2
- package/dist/{chunk-P3E6L7KW.js → chunk-TWVXFKJA.js} +84 -4
- package/dist/chunk-UJWI5CBB.js +75 -0
- package/dist/{chunk-J3JSOSUO.js → chunk-VKBOLNYN.js} +3 -3
- package/dist/{chunk-KBOQX573.js → chunk-VY2L4TP6.js} +20 -3
- package/dist/{chunk-KKCHYLVI.js → chunk-W46L2BXT.js} +2 -2
- package/dist/chunk-XUVPQDXW.js +34 -0
- package/dist/{chunk-DH7G3DDV.js → chunk-Z5VSUOEE.js} +2 -2
- package/dist/{chunk-GEXE2T6I.js → chunk-ZVZAIIB5.js} +23 -15
- package/dist/cli.js +2838 -870
- package/dist/{db-viWlyVtv.d.ts → db-C4rPbKkI.d.ts} +6 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +376 -142
- package/dist/postinstall.js +9 -3
- 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 -2
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +3 -2
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +3 -3
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +3 -3
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +3 -3
- package/dist/queries/complexity-hotspots.d.ts +1 -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/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 -2
- 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 +44 -44
- package/dist/queries/isolated.d.ts +3 -4
- package/dist/queries/isolated.js +4 -4
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +3 -3
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +3 -2
- package/dist/queries/outline.d.ts +1 -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 +5 -3
- package/dist/queries/similar-signatures.js +3 -2
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +3 -3
- package/dist/queries/slice.d.ts +1 -1
- 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 +3 -3
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +3 -3
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +3 -3
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +3 -3
- package/dist/reindex-worker.js +216 -64
- package/package.json +5 -1
- package/skills/scip-language-playbook/SKILL.md +371 -0
- package/dist/chunk-4JCSOF2O.js +0 -97
- package/dist/chunk-AXQKUYKF.js +0 -1442
- package/dist/chunk-CPVAQJEC.js +0 -46
- package/dist/chunk-EOROMIFO.js +0 -41
- package/dist/chunk-GU2H5QRN.js +0 -28
- package/dist/chunk-LQJUPXQY.js +0 -109
- package/dist/chunk-MPGIHELS.js +0 -39
- package/dist/chunk-TOIEB3LG.js +0 -78
- package/dist/chunk-UQEQ6AHX.js +0 -60
- package/dist/chunk-VJJKSGIX.js +0 -121
- package/dist/chunk-YGGFLMTM.js +0 -83
- package/dist/chunk-ZEUCXQBN.js +0 -71
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCalleeRowsForSymbol,
|
|
4
|
+
getCallerRowsForSymbol
|
|
5
|
+
} from "./chunk-ALUFWH3U.js";
|
|
1
6
|
import {
|
|
2
7
|
shortenSymbol
|
|
3
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TO3L4YNK.js";
|
|
4
9
|
|
|
5
10
|
// src/queries/bottlenecks.ts
|
|
6
11
|
function bottlenecks(db, opts = {}) {
|
|
@@ -39,7 +44,7 @@ function bottlenecks(db, opts = {}) {
|
|
|
39
44
|
minFanOut,
|
|
40
45
|
limit
|
|
41
46
|
);
|
|
42
|
-
|
|
47
|
+
const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
|
|
43
48
|
symbol: r.symbol,
|
|
44
49
|
shortName: shortenSymbol(r.symbol),
|
|
45
50
|
fanIn: r.fan_in,
|
|
@@ -47,9 +52,28 @@ function bottlenecks(db, opts = {}) {
|
|
|
47
52
|
score: r.fan_in * r.fan_out,
|
|
48
53
|
definedIn: r.defined_in
|
|
49
54
|
}));
|
|
55
|
+
if (indexedResults.length > 0) {
|
|
56
|
+
return indexedResults;
|
|
57
|
+
}
|
|
58
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).map((definition) => {
|
|
59
|
+
const fanIn = new Set(
|
|
60
|
+
getCallerRowsForSymbol(db, definition, { limit: 500 }).map((row) => row.file)
|
|
61
|
+
).size;
|
|
62
|
+
const fanOut = new Set(
|
|
63
|
+
getCalleeRowsForSymbol(db, definition, { limit: 500 }).filter((row) => row.file !== definition.relativePath).map((row) => `${row.symbol}|${row.file}`)
|
|
64
|
+
).size;
|
|
65
|
+
return {
|
|
66
|
+
symbol: definition.symbol,
|
|
67
|
+
shortName: shortenSymbol(definition.symbol),
|
|
68
|
+
fanIn,
|
|
69
|
+
fanOut,
|
|
70
|
+
score: fanIn * fanOut,
|
|
71
|
+
definedIn: definition.relativePath
|
|
72
|
+
};
|
|
73
|
+
}).filter((row) => row.fanIn >= minFanIn && row.fanOut >= minFanOut).sort((left, right) => right.score - left.score || right.fanIn - left.fanIn).slice(0, limit);
|
|
50
74
|
}
|
|
51
75
|
|
|
52
76
|
export {
|
|
53
77
|
bottlenecks
|
|
54
78
|
};
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-CBIWNZZZ.js.map
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getSourceImports,
|
|
4
4
|
resolveIndexedFile
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALUFWH3U.js";
|
|
6
6
|
import {
|
|
7
7
|
isModuleLikeSymbol,
|
|
8
8
|
leafName,
|
|
9
9
|
shortenSymbol
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TO3L4YNK.js";
|
|
11
11
|
|
|
12
12
|
// src/queries/imports.ts
|
|
13
13
|
function imports(db, filePattern) {
|
|
@@ -79,6 +79,14 @@ function importedBy(db, symbolPattern) {
|
|
|
79
79
|
if (targetFile && normalizePath(entry.sourcePath) !== normalizePath(targetFile)) {
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
|
+
if (entry.kind === "side-effect") {
|
|
83
|
+
importers.add(row.relative_path);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (targetFile && isCLikeImporter(row.relative_path)) {
|
|
87
|
+
importers.add(row.relative_path);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
82
90
|
if (targetIsModule) {
|
|
83
91
|
importers.add(row.relative_path);
|
|
84
92
|
continue;
|
|
@@ -152,10 +160,13 @@ function renderImportSymbol(importedName, localName, kind) {
|
|
|
152
160
|
function normalizePath(path) {
|
|
153
161
|
return path.replace(/\\/g, "/");
|
|
154
162
|
}
|
|
163
|
+
function isCLikeImporter(relativePath) {
|
|
164
|
+
return /\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(relativePath);
|
|
165
|
+
}
|
|
155
166
|
|
|
156
167
|
export {
|
|
157
168
|
imports,
|
|
158
169
|
importedBy,
|
|
159
170
|
unusedImports
|
|
160
171
|
};
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
172
|
+
//# sourceMappingURL=chunk-DUJNJQPO.js.map
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getCalleeRowsForSymbol,
|
|
4
4
|
getSourceReferenceSites
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALUFWH3U.js";
|
|
6
6
|
import {
|
|
7
7
|
shortenSymbol
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TO3L4YNK.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/dataflow.ts
|
|
11
11
|
function dataflow(db, symbolPattern) {
|
|
@@ -84,4 +84,4 @@ function uniqueSymbolRows(rows) {
|
|
|
84
84
|
export {
|
|
85
85
|
dataflow
|
|
86
86
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-EAGKJFDX.js.map
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCalleeRowsForSymbol,
|
|
4
|
+
getCallerRowsForSymbol,
|
|
2
5
|
testFileExclusionSql
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ALUFWH3U.js";
|
|
4
7
|
import {
|
|
5
8
|
shortenSymbol
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TO3L4YNK.js";
|
|
7
10
|
|
|
8
11
|
// src/queries/complexity-hotspots.ts
|
|
9
12
|
function complexityHotspots(db, opts) {
|
|
@@ -80,7 +83,7 @@ function complexityHotspots(db, opts) {
|
|
|
80
83
|
minLoc,
|
|
81
84
|
limit
|
|
82
85
|
);
|
|
83
|
-
|
|
86
|
+
const indexedResults = rows.filter((r) => !db.isIgnored(r.file)).map((r) => ({
|
|
84
87
|
symbol: r.symbol,
|
|
85
88
|
shortName: shortenSymbol(r.symbol),
|
|
86
89
|
file: r.file,
|
|
@@ -94,9 +97,34 @@ function complexityHotspots(db, opts) {
|
|
|
94
97
|
r.loc / 50 * (r.fan_in / 5) * Math.max(r.fan_out / 5, 1) * 100
|
|
95
98
|
) / 100
|
|
96
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);
|
|
97
125
|
}
|
|
98
126
|
|
|
99
127
|
export {
|
|
100
128
|
complexityHotspots
|
|
101
129
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-ELFGD5EW.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findFirstSymbolMatch,
|
|
3
|
+
getDefinitionsForFile
|
|
4
|
+
} from "./chunk-ALUFWH3U.js";
|
|
5
|
+
import {
|
|
6
|
+
leafName,
|
|
7
|
+
leafSuffix
|
|
8
|
+
} from "./chunk-TO3L4YNK.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 isCallableSymbol(rawSymbol) {
|
|
28
|
+
return rawSymbol.endsWith("().") || leafSuffix(rawSymbol) === "method";
|
|
29
|
+
}
|
|
30
|
+
function stripExtension(relativePath) {
|
|
31
|
+
return relativePath.replace(/\.[^.]+$/, "");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
methods
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=chunk-FVJE4MQL.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ALUFWH3U.js";
|
|
4
4
|
import {
|
|
5
5
|
isDirectChildSymbol,
|
|
6
6
|
leafSuffix,
|
|
7
7
|
shortenSymbol
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TO3L4YNK.js";
|
|
9
9
|
|
|
10
10
|
// src/queries/members.ts
|
|
11
11
|
function members(db, symbolPattern) {
|
|
@@ -34,4 +34,4 @@ function members(db, symbolPattern) {
|
|
|
34
34
|
export {
|
|
35
35
|
members
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-GNAMV3JC.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
getCalleeRowsForSymbol
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ALUFWH3U.js";
|
|
5
5
|
import {
|
|
6
6
|
shortenSymbol
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TO3L4YNK.js";
|
|
8
8
|
|
|
9
9
|
// src/queries/convergence.ts
|
|
10
10
|
function convergence(db, symbolPatternA, symbolPatternB) {
|
|
@@ -73,4 +73,4 @@ function convergence(db, symbolPatternA, symbolPatternB) {
|
|
|
73
73
|
export {
|
|
74
74
|
convergence
|
|
75
75
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-J47VSL6I.js.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findFirstSymbolMatch,
|
|
3
|
+
getSourceReferenceSites,
|
|
4
|
+
getSourceText
|
|
5
|
+
} from "./chunk-ALUFWH3U.js";
|
|
6
|
+
import {
|
|
7
|
+
isFunctionLikeSymbol
|
|
8
|
+
} from "./chunk-TO3L4YNK.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-J6QXMYAQ.js.map
|
|
@@ -3,37 +3,37 @@ import {
|
|
|
3
3
|
} from "./chunk-74RFWB5T.js";
|
|
4
4
|
import {
|
|
5
5
|
wrapperCandidates
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PU2254N2.js";
|
|
7
7
|
import {
|
|
8
8
|
similarAll
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6CH23IAS.js";
|
|
10
10
|
import {
|
|
11
11
|
staleAbstractions
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SVLUJSY7.js";
|
|
13
13
|
import {
|
|
14
14
|
isolated
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XUVPQDXW.js";
|
|
16
16
|
import {
|
|
17
17
|
passthroughCandidates
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6ECR2FLR.js";
|
|
19
19
|
import {
|
|
20
20
|
drift
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-RL74LF47.js";
|
|
22
22
|
import {
|
|
23
23
|
extractCandidates
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-3NJSJ7TE.js";
|
|
25
25
|
import {
|
|
26
26
|
complexityHotspots
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-ELFGD5EW.js";
|
|
28
28
|
import {
|
|
29
29
|
cycles
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OXX3QF24.js";
|
|
31
31
|
import {
|
|
32
32
|
dead
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-KLNKDX6A.js";
|
|
34
34
|
import {
|
|
35
35
|
isEntrySurface
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-JKXHHV4B.js";
|
|
37
37
|
|
|
38
38
|
// src/queries/health.ts
|
|
39
39
|
function health(db, opts = {}) {
|
|
@@ -218,4 +218,4 @@ function health(db, opts = {}) {
|
|
|
218
218
|
export {
|
|
219
219
|
health
|
|
220
220
|
};
|
|
221
|
-
//# sourceMappingURL=chunk-
|
|
221
|
+
//# sourceMappingURL=chunk-JHVQB4Y5.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildFileDepGraph
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ALUFWH3U.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-JKXHHV4B.js.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllDefinitions
|
|
3
|
+
} from "./chunk-ALUFWH3U.js";
|
|
1
4
|
import {
|
|
2
5
|
leafSuffix,
|
|
3
6
|
parseSymbol,
|
|
4
7
|
shortenSymbol
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TO3L4YNK.js";
|
|
6
9
|
|
|
7
10
|
// src/queries/by-kind.ts
|
|
8
11
|
var KIND_NAMES = {
|
|
@@ -143,24 +146,18 @@ function kindCounts(db, opts = {}) {
|
|
|
143
146
|
}));
|
|
144
147
|
}
|
|
145
148
|
function loadKindRows(db, scope) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
JOIN documents d ON der.document_id = d.id
|
|
159
|
-
WHERE 1 = 1
|
|
160
|
-
${db.pathExclusionsFor("d")}
|
|
161
|
-
${scopeFilter}
|
|
162
|
-
ORDER BY d.relative_path, der.start_line`
|
|
163
|
-
).filter((row) => !db.isIgnored(row.relative_path));
|
|
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
|
+
};
|
|
164
161
|
}
|
|
165
162
|
function resolveKindNumber(row) {
|
|
166
163
|
if (row.kind !== null && row.kind !== 0) {
|
|
@@ -216,4 +213,4 @@ export {
|
|
|
216
213
|
byKind,
|
|
217
214
|
kindCounts
|
|
218
215
|
};
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
216
|
+
//# sourceMappingURL=chunk-KG4OFQEN.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInactiveBarrelPaths,
|
|
3
|
+
isEntrySurface
|
|
4
|
+
} from "./chunk-JKXHHV4B.js";
|
|
5
|
+
import {
|
|
6
|
+
TEST_FILE_PATTERNS,
|
|
7
|
+
TEST_SUPPORT_PATH_PATTERNS,
|
|
8
|
+
getAllDefinitions
|
|
9
|
+
} from "./chunk-ALUFWH3U.js";
|
|
10
|
+
import {
|
|
11
|
+
isFunctionLikeSymbol,
|
|
12
|
+
isModuleLikeSymbol,
|
|
13
|
+
shortenSymbol
|
|
14
|
+
} from "./chunk-TO3L4YNK.js";
|
|
15
|
+
|
|
16
|
+
// src/queries/dead.ts
|
|
17
|
+
function dead(db, opts = {}) {
|
|
18
|
+
const {
|
|
19
|
+
scope,
|
|
20
|
+
minLoc = 1,
|
|
21
|
+
includeTests = false,
|
|
22
|
+
skipBarrels = false,
|
|
23
|
+
includeMembers = false
|
|
24
|
+
} = opts;
|
|
25
|
+
const inactiveBarrelPaths = skipBarrels ? new Set(getInactiveBarrelPaths(db)) : /* @__PURE__ */ new Set();
|
|
26
|
+
const referenceRows = db.all(
|
|
27
|
+
`SELECT
|
|
28
|
+
m.symbol_id,
|
|
29
|
+
d.relative_path,
|
|
30
|
+
COUNT(*) AS ref_count
|
|
31
|
+
FROM mentions m
|
|
32
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
33
|
+
JOIN documents d ON c.document_id = d.id
|
|
34
|
+
WHERE m.role != 1
|
|
35
|
+
${db.pathExclusionsFor("d")}
|
|
36
|
+
GROUP BY m.symbol_id, d.relative_path`
|
|
37
|
+
);
|
|
38
|
+
const referencesBySymbol = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const row of referenceRows) {
|
|
40
|
+
if (db.isIgnored(row.relative_path)) continue;
|
|
41
|
+
if (inactiveBarrelPaths.has(row.relative_path)) continue;
|
|
42
|
+
let refsForSymbol = referencesBySymbol.get(row.symbol_id);
|
|
43
|
+
if (!refsForSymbol) {
|
|
44
|
+
refsForSymbol = /* @__PURE__ */ new Map();
|
|
45
|
+
referencesBySymbol.set(row.symbol_id, refsForSymbol);
|
|
46
|
+
}
|
|
47
|
+
refsForSymbol.set(row.relative_path, row.ref_count);
|
|
48
|
+
}
|
|
49
|
+
const definitions = getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isModuleLikeSymbol(definition.symbol)).filter((definition) => looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.isFunctionLike || !definition.enclosingSymbol || !looksValueLikeDefinition(definition.enclosingSymbol)).filter((definition) => includeTests || passesTestFileFilter(definition.relativePath)).filter((definition) => includeMembers || looksValueLikeDefinition(definition.symbol)).filter((definition) => definition.endLine - definition.startLine + 1 >= minLoc);
|
|
50
|
+
const rows = definitions.map((definition) => {
|
|
51
|
+
const refMap = referencesBySymbol.get(definition.symbolId) ?? /* @__PURE__ */ new Map();
|
|
52
|
+
const sameFileRefs = refMap.get(definition.relativePath) ?? 0;
|
|
53
|
+
let crossFileRefs = 0;
|
|
54
|
+
for (const [relativePath, count] of refMap) {
|
|
55
|
+
if (relativePath === definition.relativePath) continue;
|
|
56
|
+
crossFileRefs += count;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
relative_path: definition.relativePath,
|
|
60
|
+
start_line: definition.startLine,
|
|
61
|
+
end_line: definition.endLine,
|
|
62
|
+
loc: definition.endLine - definition.startLine + 1,
|
|
63
|
+
symbol: definition.symbol,
|
|
64
|
+
same_file_refs: sameFileRefs,
|
|
65
|
+
cross_file_refs: crossFileRefs
|
|
66
|
+
};
|
|
67
|
+
}).filter((row) => row.cross_file_refs === 0).sort((a, b) => b.loc - a.loc || a.relative_path.localeCompare(b.relative_path) || a.start_line - b.start_line);
|
|
68
|
+
let deadCodeCount = 0;
|
|
69
|
+
let fileInternalCount = 0;
|
|
70
|
+
let totalLoc = 0;
|
|
71
|
+
const symbols = rows.filter((r) => !db.isIgnored(r.relative_path)).filter((r) => !isEntrySurface(db, r.relative_path)).map((r) => {
|
|
72
|
+
const kind = r.same_file_refs === 0 ? "dead-code" : "file-internal";
|
|
73
|
+
if (kind === "dead-code") deadCodeCount++;
|
|
74
|
+
else fileInternalCount++;
|
|
75
|
+
totalLoc += r.loc;
|
|
76
|
+
return {
|
|
77
|
+
relativePath: r.relative_path,
|
|
78
|
+
startLine: r.start_line,
|
|
79
|
+
endLine: r.end_line,
|
|
80
|
+
loc: r.loc,
|
|
81
|
+
symbol: r.symbol,
|
|
82
|
+
shortName: shortenSymbol(r.symbol),
|
|
83
|
+
sameFileRefs: r.same_file_refs,
|
|
84
|
+
kind
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
symbols,
|
|
89
|
+
totalCount: symbols.length,
|
|
90
|
+
deadCodeCount,
|
|
91
|
+
fileInternalCount,
|
|
92
|
+
totalLoc
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function passesTestFileFilter(relativePath) {
|
|
96
|
+
const patterns = [.../* @__PURE__ */ new Set([...TEST_FILE_PATTERNS, ...TEST_SUPPORT_PATH_PATTERNS])];
|
|
97
|
+
return patterns.every((pattern) => !likeMatches(relativePath, pattern));
|
|
98
|
+
}
|
|
99
|
+
function likeMatches(value, pattern) {
|
|
100
|
+
const regex = new RegExp(`^${pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/%/g, ".*").replace(/_/g, ".")}$`);
|
|
101
|
+
return regex.test(value);
|
|
102
|
+
}
|
|
103
|
+
function looksValueLikeDefinition(rawSymbol) {
|
|
104
|
+
return isFunctionLikeSymbol(rawSymbol) || rawSymbol.endsWith("().") || rawSymbol.endsWith(".");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
dead
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=chunk-KLNKDX6A.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIndexedPaths
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ALUFWH3U.js";
|
|
4
4
|
import {
|
|
5
5
|
shortenSymbol
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TO3L4YNK.js";
|
|
7
7
|
|
|
8
8
|
// src/queries/outline.ts
|
|
9
9
|
function outline(db, filePattern) {
|
|
@@ -48,4 +48,4 @@ function outline(db, filePattern) {
|
|
|
48
48
|
export {
|
|
49
49
|
outline
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-KYPXKV64.js.map
|