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,9 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isLiveBarrel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JKXHHV4B.js";
|
|
4
4
|
import {
|
|
5
|
+
getDefinitionsForFile,
|
|
6
|
+
getSourceExports,
|
|
7
|
+
getSourceImports
|
|
8
|
+
} from "./chunk-ALUFWH3U.js";
|
|
9
|
+
import {
|
|
10
|
+
leafSuffix,
|
|
5
11
|
shortenSymbol
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TO3L4YNK.js";
|
|
7
13
|
|
|
8
14
|
// src/queries/redundant-reexports.ts
|
|
9
15
|
function redundantReexports(db, opts = {}) {
|
|
@@ -96,10 +102,84 @@ function redundantReexports(db, opts = {}) {
|
|
|
96
102
|
results.sort(
|
|
97
103
|
(a, b) => b.directConsumers - a.directConsumers || a.barrelFile.localeCompare(b.barrelFile) || a.shortName.localeCompare(b.shortName)
|
|
98
104
|
);
|
|
99
|
-
|
|
105
|
+
const withDartFallback = dedupeReexports([
|
|
106
|
+
...results,
|
|
107
|
+
...findSourceRedundantReexports(db, scope)
|
|
108
|
+
]);
|
|
109
|
+
withDartFallback.sort(
|
|
110
|
+
(a, b) => b.directConsumers - a.directConsumers || a.barrelFile.localeCompare(b.barrelFile) || a.shortName.localeCompare(b.shortName)
|
|
111
|
+
);
|
|
112
|
+
return limit ? withDartFallback.slice(0, limit) : withDartFallback;
|
|
113
|
+
}
|
|
114
|
+
function findSourceRedundantReexports(db, scope) {
|
|
115
|
+
const files = db.all(
|
|
116
|
+
`SELECT relative_path
|
|
117
|
+
FROM documents
|
|
118
|
+
WHERE 1 = 1
|
|
119
|
+
${scope ? "AND relative_path LIKE ?" : ""}
|
|
120
|
+
${db.pathExclusionsFor("documents")}
|
|
121
|
+
ORDER BY relative_path`,
|
|
122
|
+
...scope ? [`%${scope}%`] : []
|
|
123
|
+
);
|
|
124
|
+
const candidates = files.map((row) => row.relative_path).filter((relativePath) => !db.isIgnored(relativePath)).filter((relativePath) => getSourceExports(db, relativePath).length > 0);
|
|
125
|
+
const results = [];
|
|
126
|
+
for (const barrelPath of candidates) {
|
|
127
|
+
const exports = getSourceExports(db, barrelPath).filter((entry) => entry.sourcePath && !db.isIgnored(entry.sourcePath));
|
|
128
|
+
if (exports.length === 0) continue;
|
|
129
|
+
const barrelConsumers = countDirectImporters(db, barrelPath, barrelPath);
|
|
130
|
+
if (barrelConsumers > 0) continue;
|
|
131
|
+
for (const exported of exports) {
|
|
132
|
+
const sourcePath = exported.sourcePath;
|
|
133
|
+
const representative = representativeExportSymbol(db, sourcePath);
|
|
134
|
+
if (!representative) continue;
|
|
135
|
+
results.push({
|
|
136
|
+
barrelFile: barrelPath,
|
|
137
|
+
symbol: representative.symbol,
|
|
138
|
+
shortName: shortenSymbol(representative.symbol),
|
|
139
|
+
originalFile: sourcePath,
|
|
140
|
+
barrelConsumers: 0,
|
|
141
|
+
directConsumers: countDirectImporters(db, sourcePath, barrelPath)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return results;
|
|
146
|
+
}
|
|
147
|
+
function countDirectImporters(db, targetPath, excludedPath) {
|
|
148
|
+
const files = db.all(
|
|
149
|
+
`SELECT relative_path
|
|
150
|
+
FROM documents
|
|
151
|
+
WHERE 1 = 1
|
|
152
|
+
${db.pathExclusionsFor("documents")}
|
|
153
|
+
ORDER BY relative_path`
|
|
154
|
+
);
|
|
155
|
+
const importers = /* @__PURE__ */ new Set();
|
|
156
|
+
for (const row of files) {
|
|
157
|
+
if (db.isIgnored(row.relative_path) || row.relative_path === excludedPath) continue;
|
|
158
|
+
for (const imported of getSourceImports(db, row.relative_path)) {
|
|
159
|
+
if (imported.sourcePath === targetPath) {
|
|
160
|
+
importers.add(row.relative_path);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return importers.size;
|
|
165
|
+
}
|
|
166
|
+
function representativeExportSymbol(db, sourcePath) {
|
|
167
|
+
const definitions = getDefinitionsForFile(db, sourcePath);
|
|
168
|
+
return definitions.find((definition) => leafSuffix(definition.symbol) === "method") ?? definitions[0] ?? null;
|
|
169
|
+
}
|
|
170
|
+
function dedupeReexports(rows) {
|
|
171
|
+
const seen = /* @__PURE__ */ new Set();
|
|
172
|
+
const unique = [];
|
|
173
|
+
for (const row of rows) {
|
|
174
|
+
const key = `${row.barrelFile}|${row.symbol}|${row.originalFile}`;
|
|
175
|
+
if (seen.has(key)) continue;
|
|
176
|
+
seen.add(key);
|
|
177
|
+
unique.push(row);
|
|
178
|
+
}
|
|
179
|
+
return unique;
|
|
100
180
|
}
|
|
101
181
|
|
|
102
182
|
export {
|
|
103
183
|
redundantReexports
|
|
104
184
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
185
|
+
//# sourceMappingURL=chunk-TWVXFKJA.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDefinitionsForFile,
|
|
3
|
+
resolveIndexedPaths
|
|
4
|
+
} from "./chunk-ALUFWH3U.js";
|
|
5
|
+
import {
|
|
6
|
+
leafSuffix,
|
|
7
|
+
shortenSymbol
|
|
8
|
+
} from "./chunk-TO3L4YNK.js";
|
|
9
|
+
|
|
10
|
+
// src/queries/surface.ts
|
|
11
|
+
function surface(db, modulePattern) {
|
|
12
|
+
const matchedPaths = resolveIndexedPaths(db, modulePattern);
|
|
13
|
+
if (matchedPaths.length === 0) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const placeholders = matchedPaths.map(() => "?").join(", ");
|
|
17
|
+
const rows = db.all(
|
|
18
|
+
`SELECT DISTINCT d1.relative_path, gs.symbol
|
|
19
|
+
FROM mentions m
|
|
20
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
21
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
22
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
23
|
+
WHERE d1.relative_path NOT IN (${placeholders})
|
|
24
|
+
AND (
|
|
25
|
+
EXISTS (
|
|
26
|
+
SELECT 1
|
|
27
|
+
FROM defn_enclosing_ranges der
|
|
28
|
+
JOIN documents d2 ON der.document_id = d2.id
|
|
29
|
+
WHERE der.symbol_id = gs.id
|
|
30
|
+
AND d2.relative_path IN (${placeholders})
|
|
31
|
+
)
|
|
32
|
+
OR EXISTS (
|
|
33
|
+
SELECT 1
|
|
34
|
+
FROM mentions def_m
|
|
35
|
+
JOIN chunks def_c ON def_m.chunk_id = def_c.id
|
|
36
|
+
JOIN documents d2 ON def_c.document_id = d2.id
|
|
37
|
+
WHERE def_m.symbol_id = gs.id
|
|
38
|
+
AND def_m.role = 1
|
|
39
|
+
AND d2.relative_path IN (${placeholders})
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
AND m.role != 1
|
|
43
|
+
AND ${db.localSymbolPredicate}
|
|
44
|
+
${db.pathExclusionsFor("d1")}
|
|
45
|
+
ORDER BY d1.relative_path`,
|
|
46
|
+
...matchedPaths,
|
|
47
|
+
...matchedPaths,
|
|
48
|
+
...matchedPaths
|
|
49
|
+
);
|
|
50
|
+
const exposedDefinitions = matchedPaths.flatMap(
|
|
51
|
+
(relativePath) => getDefinitionsForFile(db, relativePath).filter((definition) => isCallableSymbol(definition.symbol)).map((definition) => ({
|
|
52
|
+
relative_path: relativePath,
|
|
53
|
+
symbol: definition.symbol
|
|
54
|
+
}))
|
|
55
|
+
);
|
|
56
|
+
const seen = /* @__PURE__ */ new Set();
|
|
57
|
+
return [...rows, ...exposedDefinitions].filter((r) => !db.isIgnored(r.relative_path)).filter((r) => {
|
|
58
|
+
const key = `${r.relative_path}|${r.symbol}`;
|
|
59
|
+
if (seen.has(key)) return false;
|
|
60
|
+
seen.add(key);
|
|
61
|
+
return true;
|
|
62
|
+
}).map((r) => ({
|
|
63
|
+
consumer: r.relative_path,
|
|
64
|
+
symbol: r.symbol,
|
|
65
|
+
shortName: shortenSymbol(r.symbol)
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function isCallableSymbol(rawSymbol) {
|
|
69
|
+
return rawSymbol.endsWith("().") || leafSuffix(rawSymbol) === "method";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
surface
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=chunk-UJWI5CBB.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findFirstSymbolMatch,
|
|
3
3
|
resolveIndexedFile
|
|
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/code.ts
|
|
10
10
|
import { readFileSync } from "fs";
|
|
@@ -76,4 +76,4 @@ function readFileRange(db, filePath, startLine, endLine, context) {
|
|
|
76
76
|
export {
|
|
77
77
|
code
|
|
78
78
|
};
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-VKBOLNYN.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllDefinitions,
|
|
3
|
+
getCallerRowsForSymbol
|
|
4
|
+
} from "./chunk-ALUFWH3U.js";
|
|
1
5
|
import {
|
|
2
6
|
shortenSymbol
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TO3L4YNK.js";
|
|
4
8
|
|
|
5
9
|
// src/queries/hotspots.ts
|
|
6
10
|
function hotspots(db, opts = {}) {
|
|
@@ -27,16 +31,29 @@ function hotspots(db, opts = {}) {
|
|
|
27
31
|
LIMIT ?`,
|
|
28
32
|
limit
|
|
29
33
|
);
|
|
30
|
-
|
|
34
|
+
const indexedResults = rows.filter((r) => !db.isIgnored(r.defined_in)).map((r) => ({
|
|
31
35
|
symbol: r.symbol,
|
|
32
36
|
shortName: shortenSymbol(r.symbol),
|
|
33
37
|
refCount: r.ref_count,
|
|
34
38
|
fileCount: r.file_count,
|
|
35
39
|
definedIn: r.defined_in
|
|
36
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);
|
|
37
54
|
}
|
|
38
55
|
|
|
39
56
|
export {
|
|
40
57
|
hotspots
|
|
41
58
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-VY2L4TP6.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIndexedFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ALUFWH3U.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-W46L2BXT.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEntrySurface
|
|
3
|
+
} from "./chunk-JKXHHV4B.js";
|
|
4
|
+
import {
|
|
5
|
+
getAllDefinitions,
|
|
6
|
+
getCalleeRowsForSymbol,
|
|
7
|
+
getCallerRowsForSymbol
|
|
8
|
+
} from "./chunk-ALUFWH3U.js";
|
|
9
|
+
import {
|
|
10
|
+
shortenSymbol
|
|
11
|
+
} from "./chunk-TO3L4YNK.js";
|
|
12
|
+
|
|
13
|
+
// src/queries/isolated.ts
|
|
14
|
+
function isolated(db, opts = {}) {
|
|
15
|
+
const { scope, minLoc = 3 } = opts;
|
|
16
|
+
return getAllDefinitions(db, { scope }).filter((definition) => !db.isIgnored(definition.relativePath)).filter((definition) => !isEntrySurface(db, definition.relativePath)).filter((definition) => definition.isFunctionLike).map((definition) => ({
|
|
17
|
+
definition,
|
|
18
|
+
loc: definition.endLine - definition.startLine + 1
|
|
19
|
+
})).filter((entry) => entry.loc >= minLoc).filter((entry) => getCallerRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).filter((entry) => getCalleeRowsForSymbol(db, entry.definition, { limit: 1 }).length === 0).sort(
|
|
20
|
+
(left, right) => right.loc - left.loc || left.definition.relativePath.localeCompare(right.definition.relativePath) || left.definition.startLine - right.definition.startLine
|
|
21
|
+
).map((entry) => ({
|
|
22
|
+
symbol: entry.definition.symbol,
|
|
23
|
+
shortName: shortenSymbol(entry.definition.symbol),
|
|
24
|
+
relativePath: entry.definition.relativePath,
|
|
25
|
+
startLine: entry.definition.startLine,
|
|
26
|
+
endLine: entry.definition.endLine,
|
|
27
|
+
loc: entry.loc
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
isolated
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-XUVPQDXW.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/queries/deep-chains.ts
|
|
6
6
|
function deepChains(db, opts = {}) {
|
|
@@ -41,4 +41,4 @@ function deepChains(db, opts = {}) {
|
|
|
41
41
|
export {
|
|
42
42
|
deepChains
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-Z5VSUOEE.js.map
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-4TYLS5XX.js";
|
|
4
4
|
import {
|
|
5
5
|
findFirstSymbolMatch,
|
|
6
|
-
getSourceReferenceSites
|
|
7
|
-
|
|
6
|
+
getSourceReferenceSites,
|
|
7
|
+
getSourceText
|
|
8
|
+
} from "./chunk-ALUFWH3U.js";
|
|
8
9
|
import {
|
|
9
10
|
isFunctionLikeSymbol,
|
|
10
11
|
shortenSymbol
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TO3L4YNK.js";
|
|
12
13
|
|
|
13
14
|
// src/queries/trace.ts
|
|
14
15
|
function trace(db, symbolPattern) {
|
|
@@ -16,24 +17,22 @@ function trace(db, symbolPattern) {
|
|
|
16
17
|
if (!match) {
|
|
17
18
|
return { definitions: [], referencedBy: [] };
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
`SELECT
|
|
20
|
+
const definitionMeta = db.get(
|
|
21
|
+
`SELECT
|
|
21
22
|
gs.display_name,
|
|
22
23
|
REPLACE(SUBSTR(gs.documentation, INSTR(gs.documentation, '|') + 1), char(10), ' ') AS sig
|
|
23
24
|
FROM global_symbols gs
|
|
24
|
-
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
25
|
-
JOIN documents d ON der.document_id = d.id
|
|
26
25
|
WHERE gs.id = ?
|
|
27
|
-
ORDER BY d.relative_path, der.start_line
|
|
28
26
|
LIMIT 10`,
|
|
29
27
|
match.symbolId
|
|
30
28
|
);
|
|
31
|
-
const definitions =
|
|
32
|
-
relativePath:
|
|
33
|
-
startLine:
|
|
34
|
-
endLine:
|
|
35
|
-
signature: buildTraceSignature(
|
|
36
|
-
|
|
29
|
+
const definitions = db.isIgnored(match.relativePath) ? [] : [{
|
|
30
|
+
relativePath: match.relativePath,
|
|
31
|
+
startLine: match.startLine,
|
|
32
|
+
endLine: match.endLine,
|
|
33
|
+
signature: buildTraceSignature(definitionMeta?.sig ?? null, definitionMeta?.display_name ?? null, match.symbol),
|
|
34
|
+
source: definitionSource(db, match.relativePath, match.startLine, match.endLine)
|
|
35
|
+
}];
|
|
37
36
|
const sourceSites = getSourceReferenceSites(db, match);
|
|
38
37
|
const referencedBy = sourceSites.length > 0 ? sourceSites.filter((site) => !db.isIgnored(site.file)).map((site) => ({
|
|
39
38
|
relativePath: site.file,
|
|
@@ -66,6 +65,15 @@ function trace(db, symbolPattern) {
|
|
|
66
65
|
}));
|
|
67
66
|
return { definitions, referencedBy };
|
|
68
67
|
}
|
|
68
|
+
function definitionSource(db, relativePath, startLine, endLine) {
|
|
69
|
+
const source = getSourceText(db, relativePath);
|
|
70
|
+
if (!source) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const lines = source.split("\n");
|
|
74
|
+
const slice = lines.slice(startLine, endLine + 1).join("\n").trimEnd();
|
|
75
|
+
return slice.length > 0 ? slice : null;
|
|
76
|
+
}
|
|
69
77
|
function buildTraceSignature(signature, displayName, rawSymbol) {
|
|
70
78
|
const cleaned = cleanSignature(signature);
|
|
71
79
|
if (cleaned && !looksBogusSignature(cleaned)) {
|
|
@@ -84,4 +92,4 @@ function looksBogusSignature(signature) {
|
|
|
84
92
|
export {
|
|
85
93
|
trace
|
|
86
94
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-ZVZAIIB5.js.map
|