scip-query 0.5.0 → 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 -8758
- 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 +1 -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 -10
- 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 +1 -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 +1 -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 +1 -1
- 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-2MQ5DPY6.js +0 -61
- package/dist/chunk-2QTYIOJ5.js +0 -165
- package/dist/chunk-3VI4YXCL.js +0 -172
- package/dist/chunk-3VV2G6U7.js +0 -34
- package/dist/chunk-44PFXVXG.js +0 -76
- package/dist/chunk-6SLFQR36.js +0 -64
- package/dist/chunk-74RFWB5T.js +0 -24
- package/dist/chunk-7DBPRGMS.js +0 -221
- package/dist/chunk-DTB724R3.js +0 -110
- package/dist/chunk-FLOYI6I4.js +0 -185
- package/dist/chunk-FO2CBB7U.js +0 -23
- package/dist/chunk-GJT3MO2T.js +0 -17
- package/dist/chunk-HAP4LJKX.js +0 -66
- package/dist/chunk-JCOJQ4I6.js +0 -93
- package/dist/chunk-JGQMOS4V.js +0 -59
- package/dist/chunk-JMD4WJ2Q.js +0 -213
- package/dist/chunk-JSQPZOPO.js +0 -64
- package/dist/chunk-JSXGC2EH.js +0 -151
- package/dist/chunk-JZN3DRCT.js +0 -59
- package/dist/chunk-KMWYB3CX.js +0 -71
- package/dist/chunk-MRM755FU.js +0 -37
- package/dist/chunk-N2XO3Z5F.js +0 -69
- package/dist/chunk-OLW5UL36.js +0 -76
- package/dist/chunk-OMCRXXDX.js +0 -2600
- package/dist/chunk-OWJOHUZE.js +0 -44
- package/dist/chunk-P3VCDYMJ.js +0 -269
- package/dist/chunk-PEDH3D4G.js +0 -53
- package/dist/chunk-POAN4SCR.js +0 -46
- package/dist/chunk-PTMGEBU3.js +0 -101
- package/dist/chunk-PU44HK7P.js +0 -87
- package/dist/chunk-QJI7EECA.js +0 -327
- package/dist/chunk-R5HICGMB.js +0 -110
- package/dist/chunk-RJ2D6YWQ.js +0 -49
- package/dist/chunk-RZ5GYPBP.js +0 -79
- package/dist/chunk-SRLQNO6O.js +0 -101
- package/dist/chunk-UGS7HJI4.js +0 -84
- package/dist/chunk-VKUUXOE7.js +0 -105
- package/dist/chunk-VPUJSJCI.js +0 -84
- package/dist/chunk-VRWVV3EP.js +0 -72
- package/dist/chunk-WJWQEU4A.js +0 -162
- package/dist/chunk-WJZHDUSB.js +0 -40
- package/dist/chunk-WWOCQ5W4.js +0 -34
- package/dist/chunk-X3Q2OVRL.js +0 -77
- package/dist/chunk-Y3P7QKKN.js +0 -27
- package/dist/chunk-Y6FAHY4N.js +0 -81
- package/dist/chunk-YMSJCSRG.js +0 -213
- package/dist/chunk-ZDL3U4W2.js +0 -124
- package/dist/chunk-ZXNX5JRE.js +0 -216
- package/dist/queries/clean-signature.d.ts +0 -17
- package/dist/queries/clean-signature.js +0 -9
package/dist/reindex-worker.js
CHANGED
|
@@ -1,673 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
tryInstallIndexer,
|
|
9
|
-
tryInstallScipCli
|
|
10
|
-
} from "./chunk-P3VCDYMJ.js";
|
|
11
|
-
|
|
12
|
-
// src/reindex/index.ts
|
|
13
|
-
import { execFileSync } from "child_process";
|
|
14
|
-
import { existsSync as existsSync3, renameSync, rmSync } from "fs";
|
|
15
|
-
import { basename, dirname, extname as extname2, join as join3 } from "path";
|
|
16
|
-
|
|
17
|
-
// src/reindex/detect.ts
|
|
18
|
-
import { existsSync, readdirSync } from "fs";
|
|
19
|
-
import { extname, join } from "path";
|
|
20
|
-
var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
21
|
-
".git",
|
|
22
|
-
".hg",
|
|
23
|
-
".svn",
|
|
24
|
-
".idea",
|
|
25
|
-
".vscode",
|
|
26
|
-
"node_modules",
|
|
27
|
-
"vendor",
|
|
28
|
-
"dist",
|
|
29
|
-
"build",
|
|
30
|
-
"target",
|
|
31
|
-
"bin",
|
|
32
|
-
"obj",
|
|
33
|
-
".dart_tool",
|
|
34
|
-
".gradle",
|
|
35
|
-
".next",
|
|
36
|
-
".venv",
|
|
37
|
-
"venv",
|
|
38
|
-
"__pycache__"
|
|
39
|
-
]);
|
|
40
|
-
var LANGUAGE_MARKERS = [
|
|
41
|
-
{ language: "typescript", files: ["tsconfig.json", "tsconfig.base.json"], extensions: [".ts", ".tsx", ".mts", ".cts"] },
|
|
42
|
-
{ language: "rust", files: ["Cargo.toml"], extensions: [".rs"] },
|
|
43
|
-
{ language: "go", files: ["go.mod"], extensions: [".go"] },
|
|
44
|
-
{ language: "java", files: ["pom.xml", "build.gradle", "build.gradle.kts"], extensions: [".java"] },
|
|
45
|
-
{ language: "kotlin", files: ["build.gradle.kts"], extensions: [".kt", ".kts"] },
|
|
46
|
-
{ language: "scala", files: ["build.sbt"], extensions: [".scala"] },
|
|
47
|
-
{ language: "python", files: ["pyproject.toml", "setup.py", "setup.cfg", "Pipfile"], extensions: [".py", ".pyi"] },
|
|
48
|
-
{ language: "ruby", files: ["Gemfile"], extensions: [".rb"] },
|
|
49
|
-
{ language: "cpp", files: ["compile_commands.json", "CMakeLists.txt", "Makefile"], extensions: [".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx"] },
|
|
50
|
-
{ language: "c", files: ["compile_commands.json", "CMakeLists.txt", "Makefile"], extensions: [".c", ".h"] },
|
|
51
|
-
{ language: "csharp", globs: ["*.csproj", "*.sln"], extensions: [".cs"] },
|
|
52
|
-
{ language: "vb", globs: ["*.vbproj"], extensions: [".vb"] },
|
|
53
|
-
{ language: "dart", files: ["pubspec.yaml"], extensions: [".dart"] },
|
|
54
|
-
{ language: "php", files: ["composer.json"], extensions: [".php"] },
|
|
55
|
-
{ language: "javascript", files: ["package.json"], extensions: [".js", ".jsx", ".mjs", ".cjs"] }
|
|
56
|
-
// Last — very common
|
|
57
|
-
];
|
|
58
|
-
function detectLanguages(projectRoot2) {
|
|
59
|
-
const detected = [];
|
|
60
|
-
const rootEntries = safeReadDir(projectRoot2);
|
|
61
|
-
const extensionSet = collectExtensions(projectRoot2);
|
|
62
|
-
for (const marker of LANGUAGE_MARKERS) {
|
|
63
|
-
if (hasMarkerFile(projectRoot2, marker.files)) {
|
|
64
|
-
detected.push(marker.language);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (matchesRootGlob(rootEntries, marker.globs)) {
|
|
68
|
-
detected.push(marker.language);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (hasExtension(extensionSet, marker.extensions)) {
|
|
72
|
-
detected.push(marker.language);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (detected.includes("typescript")) {
|
|
76
|
-
removeLanguage(detected, "javascript");
|
|
77
|
-
}
|
|
78
|
-
if (detected.includes("cpp") && !extensionSet.has(".c")) {
|
|
79
|
-
removeLanguage(detected, "c");
|
|
80
|
-
}
|
|
81
|
-
return detected;
|
|
82
|
-
}
|
|
83
|
-
function safeReadDir(projectRoot2) {
|
|
84
|
-
try {
|
|
85
|
-
return readdirSync(projectRoot2);
|
|
86
|
-
} catch {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function hasMarkerFile(projectRoot2, files) {
|
|
91
|
-
if (!files?.length) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
return files.some((file) => existsSync(join(projectRoot2, file)));
|
|
95
|
-
}
|
|
96
|
-
function matchesRootGlob(entries, globs) {
|
|
97
|
-
if (!globs?.length) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return entries.some((entry) => globs.some((glob) => matchesSimpleGlob(entry, glob)));
|
|
101
|
-
}
|
|
102
|
-
function matchesSimpleGlob(entry, pattern) {
|
|
103
|
-
if (pattern === "*") {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
if (!pattern.includes("*")) {
|
|
107
|
-
return entry === pattern;
|
|
108
|
-
}
|
|
109
|
-
const [prefix, suffix] = pattern.split("*");
|
|
110
|
-
return entry.startsWith(prefix ?? "") && entry.endsWith(suffix ?? "");
|
|
111
|
-
}
|
|
112
|
-
function collectExtensions(projectRoot2) {
|
|
113
|
-
const found = /* @__PURE__ */ new Set();
|
|
114
|
-
const stack = [projectRoot2];
|
|
115
|
-
while (stack.length > 0) {
|
|
116
|
-
const current = stack.pop();
|
|
117
|
-
if (!current) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
let entries;
|
|
121
|
-
try {
|
|
122
|
-
entries = readdirSync(current, { withFileTypes: true });
|
|
123
|
-
} catch {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
for (const entry of entries) {
|
|
127
|
-
if (entry.name.startsWith(".") && !entry.name.endsWith("proj") && !entry.name.endsWith("sln")) {
|
|
128
|
-
if (entry.isDirectory()) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const fullPath = join(current, entry.name);
|
|
133
|
-
if (entry.isDirectory()) {
|
|
134
|
-
if (!IGNORED_DIRS.has(entry.name)) {
|
|
135
|
-
stack.push(fullPath);
|
|
136
|
-
}
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
const extension = extname(entry.name).toLowerCase();
|
|
140
|
-
if (extension) {
|
|
141
|
-
found.add(extension);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return found;
|
|
146
|
-
}
|
|
147
|
-
function hasExtension(extensionSet, extensions) {
|
|
148
|
-
if (!extensions?.length) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return extensions.some((extension) => extensionSet.has(extension));
|
|
152
|
-
}
|
|
153
|
-
function removeLanguage(detected, language) {
|
|
154
|
-
const index = detected.indexOf(language);
|
|
155
|
-
if (index !== -1) {
|
|
156
|
-
detected.splice(index, 1);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// src/reindex/indexers.ts
|
|
161
|
-
import { existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
|
|
162
|
-
import { join as join2 } from "path";
|
|
163
|
-
var INDEXER_CONFIGS = {
|
|
164
|
-
typescript: {
|
|
165
|
-
language: "typescript",
|
|
166
|
-
indexerBinary: "scip-typescript",
|
|
167
|
-
checkCommand: "npx scip-typescript --version",
|
|
168
|
-
indexArgs: ({ outputPath, pnpmWorkspaces: pnpmWorkspaces2 }) => {
|
|
169
|
-
const args = ["scip-typescript", "index", "--infer-tsconfig", "--output", outputPath, "--no-progress-bar"];
|
|
170
|
-
if (pnpmWorkspaces2) args.splice(2, 0, "--pnpm-workspaces");
|
|
171
|
-
return { binary: "npx", args };
|
|
172
|
-
},
|
|
173
|
-
markerFiles: ["tsconfig.json"],
|
|
174
|
-
installMethods: [
|
|
175
|
-
{ label: "npm", prerequisite: "npm", binary: "npm", args: ["install", "-g", "@sourcegraph/scip-typescript"] }
|
|
176
|
-
],
|
|
177
|
-
installUrl: "https://github.com/sourcegraph/scip-typescript"
|
|
178
|
-
},
|
|
179
|
-
javascript: {
|
|
180
|
-
language: "javascript",
|
|
181
|
-
indexerBinary: "scip-typescript",
|
|
182
|
-
checkCommand: "npx scip-typescript --version",
|
|
183
|
-
indexArgs: ({ outputPath }) => ({
|
|
184
|
-
binary: "npx",
|
|
185
|
-
args: ["scip-typescript", "index", "--infer-tsconfig", "--output", outputPath, "--no-progress-bar"]
|
|
186
|
-
}),
|
|
187
|
-
markerFiles: ["package.json"],
|
|
188
|
-
installMethods: [
|
|
189
|
-
{ label: "npm", prerequisite: "npm", binary: "npm", args: ["install", "-g", "@sourcegraph/scip-typescript"] }
|
|
190
|
-
],
|
|
191
|
-
installUrl: "https://github.com/sourcegraph/scip-typescript"
|
|
192
|
-
},
|
|
193
|
-
java: {
|
|
194
|
-
language: "java",
|
|
195
|
-
indexerBinary: "scip-java",
|
|
196
|
-
checkCommand: "scip-java --version",
|
|
197
|
-
indexArgs: ({ outputPath }) => ({
|
|
198
|
-
binary: "scip-java",
|
|
199
|
-
args: ["index", "--output", outputPath]
|
|
200
|
-
}),
|
|
201
|
-
markerFiles: ["pom.xml", "build.gradle"],
|
|
202
|
-
installMethods: [],
|
|
203
|
-
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
204
|
-
},
|
|
205
|
-
scala: {
|
|
206
|
-
language: "scala",
|
|
207
|
-
indexerBinary: "scip-java",
|
|
208
|
-
checkCommand: "scip-java --version",
|
|
209
|
-
indexArgs: ({ outputPath }) => ({
|
|
210
|
-
binary: "scip-java",
|
|
211
|
-
args: ["index", "--output", outputPath]
|
|
212
|
-
}),
|
|
213
|
-
markerFiles: ["build.sbt"],
|
|
214
|
-
installMethods: [],
|
|
215
|
-
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
216
|
-
},
|
|
217
|
-
kotlin: {
|
|
218
|
-
language: "kotlin",
|
|
219
|
-
indexerBinary: "scip-java",
|
|
220
|
-
checkCommand: "scip-java --version",
|
|
221
|
-
indexArgs: ({ outputPath }) => ({
|
|
222
|
-
binary: "scip-java",
|
|
223
|
-
args: ["index", "--output", outputPath]
|
|
224
|
-
}),
|
|
225
|
-
markerFiles: ["build.gradle.kts"],
|
|
226
|
-
installMethods: [],
|
|
227
|
-
installUrl: "https://github.com/sourcegraph/scip-java/releases"
|
|
228
|
-
},
|
|
229
|
-
rust: {
|
|
230
|
-
language: "rust",
|
|
231
|
-
indexerBinary: "rust-analyzer",
|
|
232
|
-
checkCommand: "rust-analyzer --version",
|
|
233
|
-
indexArgs: ({ outputPath }) => ({
|
|
234
|
-
binary: "rust-analyzer",
|
|
235
|
-
args: ["scip", ".", "--output", outputPath]
|
|
236
|
-
}),
|
|
237
|
-
markerFiles: ["Cargo.toml"],
|
|
238
|
-
installMethods: [
|
|
239
|
-
{ label: "rustup", prerequisite: "rustup", binary: "rustup", args: ["component", "add", "rust-analyzer"] }
|
|
240
|
-
],
|
|
241
|
-
installUrl: "https://github.com/rust-lang/rust-analyzer"
|
|
242
|
-
},
|
|
243
|
-
python: {
|
|
244
|
-
language: "python",
|
|
245
|
-
indexerBinary: "scip-python",
|
|
246
|
-
binaryAliases: ["scip-python-plus"],
|
|
247
|
-
checkCommand: "scip-python --version",
|
|
248
|
-
indexArgs: ({ outputPath, indexerBinary }) => ({
|
|
249
|
-
binary: indexerBinary,
|
|
250
|
-
args: ["index", "--output", outputPath, "--project-name", "project"]
|
|
251
|
-
}),
|
|
252
|
-
markerFiles: ["pyproject.toml", "setup.py"],
|
|
253
|
-
installMethods: [
|
|
254
|
-
{ label: "npm", prerequisite: "npm", binary: "npm", args: ["install", "-g", "scip-python-plus"] }
|
|
255
|
-
],
|
|
256
|
-
installUrl: "https://github.com/PlunderStruck/scip-python"
|
|
257
|
-
},
|
|
258
|
-
ruby: {
|
|
259
|
-
language: "ruby",
|
|
260
|
-
indexerBinary: "scip-ruby",
|
|
261
|
-
checkCommand: "scip-ruby --version",
|
|
262
|
-
indexArgs: ({ indexerBinary }) => ({
|
|
263
|
-
binary: indexerBinary,
|
|
264
|
-
args: ["--dir", "."]
|
|
265
|
-
}),
|
|
266
|
-
defaultOutputPath: "index.scip",
|
|
267
|
-
markerFiles: ["Gemfile"],
|
|
268
|
-
installMethods: [],
|
|
269
|
-
installUrl: "https://github.com/sourcegraph/scip-ruby/releases"
|
|
270
|
-
},
|
|
271
|
-
go: {
|
|
272
|
-
language: "go",
|
|
273
|
-
indexerBinary: "scip-go",
|
|
274
|
-
checkCommand: "scip-go --version",
|
|
275
|
-
indexArgs: ({ outputPath }) => ({
|
|
276
|
-
binary: "scip-go",
|
|
277
|
-
args: ["--output", outputPath]
|
|
278
|
-
}),
|
|
279
|
-
markerFiles: ["go.mod"],
|
|
280
|
-
installMethods: [
|
|
281
|
-
{ label: "go install", prerequisite: "go", binary: "go", args: ["install", "github.com/sourcegraph/scip-go@latest"] }
|
|
282
|
-
],
|
|
283
|
-
installUrl: "https://github.com/sourcegraph/scip-go"
|
|
284
|
-
},
|
|
285
|
-
cpp: {
|
|
286
|
-
language: "cpp",
|
|
287
|
-
indexerBinary: "scip-clang",
|
|
288
|
-
checkCommand: "scip-clang --version",
|
|
289
|
-
indexArgs: ({ outputPath }) => ({
|
|
290
|
-
binary: "scip-clang",
|
|
291
|
-
args: ["--compdb-path", "compile_commands.json", "--index-output-path", outputPath]
|
|
292
|
-
}),
|
|
293
|
-
markerFiles: ["CMakeLists.txt", "Makefile"],
|
|
294
|
-
installMethods: [],
|
|
295
|
-
installUrl: "https://github.com/sourcegraph/scip-clang/releases"
|
|
296
|
-
},
|
|
297
|
-
c: {
|
|
298
|
-
language: "c",
|
|
299
|
-
indexerBinary: "scip-clang",
|
|
300
|
-
checkCommand: "scip-clang --version",
|
|
301
|
-
indexArgs: ({ outputPath }) => ({
|
|
302
|
-
binary: "scip-clang",
|
|
303
|
-
args: ["--compdb-path", "compile_commands.json", "--index-output-path", outputPath]
|
|
304
|
-
}),
|
|
305
|
-
markerFiles: ["CMakeLists.txt", "Makefile"],
|
|
306
|
-
installMethods: [],
|
|
307
|
-
installUrl: "https://github.com/sourcegraph/scip-clang/releases"
|
|
308
|
-
},
|
|
309
|
-
csharp: {
|
|
310
|
-
language: "csharp",
|
|
311
|
-
indexerBinary: "scip-dotnet",
|
|
312
|
-
checkCommand: "scip-dotnet --version",
|
|
313
|
-
indexArgs: ({ projectRoot: projectRoot2, outputPath }) => ({
|
|
314
|
-
binary: "scip-dotnet",
|
|
315
|
-
args: ["index", resolveDotnetProject(projectRoot2, [".sln", ".csproj"]) ?? projectRoot2, "--output", outputPath, "--working-directory", projectRoot2]
|
|
316
|
-
}),
|
|
317
|
-
markerFiles: ["*.csproj", "*.sln"],
|
|
318
|
-
installMethods: [
|
|
319
|
-
{ label: "dotnet", prerequisite: "dotnet", binary: "dotnet", args: ["tool", "install", "--global", "scip-dotnet"] }
|
|
320
|
-
],
|
|
321
|
-
installUrl: "https://github.com/sourcegraph/scip-dotnet/releases"
|
|
322
|
-
},
|
|
323
|
-
vb: {
|
|
324
|
-
language: "vb",
|
|
325
|
-
indexerBinary: "scip-dotnet",
|
|
326
|
-
checkCommand: "scip-dotnet --version",
|
|
327
|
-
indexArgs: ({ projectRoot: projectRoot2, outputPath }) => ({
|
|
328
|
-
binary: "scip-dotnet",
|
|
329
|
-
args: ["index", resolveDotnetProject(projectRoot2, [".sln", ".vbproj"]) ?? projectRoot2, "--output", outputPath, "--working-directory", projectRoot2]
|
|
330
|
-
}),
|
|
331
|
-
markerFiles: ["*.vbproj", "*.sln"],
|
|
332
|
-
installMethods: [
|
|
333
|
-
{ label: "dotnet", prerequisite: "dotnet", binary: "dotnet", args: ["tool", "install", "--global", "scip-dotnet"] }
|
|
334
|
-
],
|
|
335
|
-
installUrl: "https://github.com/sourcegraph/scip-dotnet/releases"
|
|
336
|
-
},
|
|
337
|
-
dart: {
|
|
338
|
-
language: "dart",
|
|
339
|
-
indexerBinary: "scip-dart",
|
|
340
|
-
checkCommand: "scip-dart --version",
|
|
341
|
-
indexArgs: ({ indexerBinary, outputPath }) => ({
|
|
342
|
-
binary: indexerBinary,
|
|
343
|
-
args: ["--output", outputPath]
|
|
344
|
-
}),
|
|
345
|
-
markerFiles: ["pubspec.yaml"],
|
|
346
|
-
installMethods: [
|
|
347
|
-
{ label: "dart pub", prerequisite: "dart", binary: "dart", args: ["pub", "global", "activate", "scip_dart"] }
|
|
348
|
-
],
|
|
349
|
-
installUrl: "https://github.com/Workiva/scip-dart/releases"
|
|
350
|
-
},
|
|
351
|
-
php: {
|
|
352
|
-
language: "php",
|
|
353
|
-
indexerBinary: "scip-php",
|
|
354
|
-
projectLocalBinaries: ["vendor/davidrjenni/scip-php/bin/scip-php", "vendor/bin/scip-php"],
|
|
355
|
-
checkCommand: "scip-php --version",
|
|
356
|
-
indexArgs: ({ projectRoot: projectRoot2, indexerBinary }) => {
|
|
357
|
-
const localBinary = join2(projectRoot2, "vendor", "bin", "scip-php");
|
|
358
|
-
const nestedLocalBinary = join2(projectRoot2, "vendor", "davidrjenni", "scip-php", "bin", "scip-php");
|
|
359
|
-
const targetBinary = existsSync2(nestedLocalBinary) ? nestedLocalBinary : existsSync2(localBinary) ? localBinary : indexerBinary;
|
|
360
|
-
return {
|
|
361
|
-
binary: "php",
|
|
362
|
-
args: [
|
|
363
|
-
"-d",
|
|
364
|
-
"error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",
|
|
365
|
-
targetBinary
|
|
366
|
-
]
|
|
367
|
-
};
|
|
368
|
-
},
|
|
369
|
-
defaultOutputPath: "index.scip",
|
|
370
|
-
markerFiles: ["composer.json"],
|
|
371
|
-
installMethods: [],
|
|
372
|
-
installUrl: "https://github.com/davidrjenni/scip-php/releases"
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
function getIndexerConfig(language) {
|
|
376
|
-
return INDEXER_CONFIGS[language];
|
|
377
|
-
}
|
|
378
|
-
function resolveDotnetProject(projectRoot2, suffixes) {
|
|
379
|
-
let entries;
|
|
380
|
-
try {
|
|
381
|
-
entries = readdirSync2(projectRoot2);
|
|
382
|
-
} catch {
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
for (const entry of entries) {
|
|
386
|
-
if (suffixes.some((suffix) => entry.endsWith(suffix))) {
|
|
387
|
-
return join2(projectRoot2, entry);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// src/reindex/merge.ts
|
|
394
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
395
|
-
import { create } from "@bufbuild/protobuf";
|
|
396
|
-
import {
|
|
397
|
-
deserializeSCIP,
|
|
398
|
-
serializeSCIP,
|
|
399
|
-
DocumentSchema,
|
|
400
|
-
IndexSchema,
|
|
401
|
-
SymbolInformationSchema
|
|
402
|
-
} from "@c4312/scip";
|
|
403
|
-
function mergeScipIndexes(indexes) {
|
|
404
|
-
if (indexes.length === 0) {
|
|
405
|
-
throw new Error("Cannot merge zero SCIP indexes");
|
|
406
|
-
}
|
|
407
|
-
if (indexes.length === 1) {
|
|
408
|
-
return indexes[0];
|
|
409
|
-
}
|
|
410
|
-
const metadata = mergeMetadata(indexes);
|
|
411
|
-
const documents = mergeDocuments(indexes.flatMap((index) => index.documents ?? []));
|
|
412
|
-
const externalSymbols = mergeSymbolInfos(indexes.flatMap((index) => index.externalSymbols ?? []));
|
|
413
|
-
return create(IndexSchema, {
|
|
414
|
-
metadata,
|
|
415
|
-
documents,
|
|
416
|
-
externalSymbols
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
function mergeScipFiles(inputPaths, outputPath) {
|
|
420
|
-
if (inputPaths.length === 0) {
|
|
421
|
-
throw new Error("Cannot merge zero SCIP files");
|
|
422
|
-
}
|
|
423
|
-
const indexes = inputPaths.map((path) => deserializeSCIP(readFileSync(path)));
|
|
424
|
-
const merged = mergeScipIndexes(indexes);
|
|
425
|
-
writeFileSync(outputPath, Buffer.from(serializeSCIP(merged)));
|
|
426
|
-
return {
|
|
427
|
-
documentCount: merged.documents.length,
|
|
428
|
-
externalSymbolCount: merged.externalSymbols.length,
|
|
429
|
-
inputCount: inputPaths.length
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
function mergeMetadata(indexes) {
|
|
433
|
-
const first = indexes[0]?.metadata;
|
|
434
|
-
if (!first) {
|
|
435
|
-
return void 0;
|
|
436
|
-
}
|
|
437
|
-
const expectedProjectRoot = first.projectRoot;
|
|
438
|
-
for (const index of indexes.slice(1)) {
|
|
439
|
-
const actualProjectRoot = index.metadata?.projectRoot;
|
|
440
|
-
if (expectedProjectRoot && actualProjectRoot && actualProjectRoot !== expectedProjectRoot) {
|
|
441
|
-
throw new Error(
|
|
442
|
-
`Cannot merge SCIP indexes with different project roots: ${expectedProjectRoot} vs ${actualProjectRoot}`
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
return first;
|
|
447
|
-
}
|
|
448
|
-
function mergeDocuments(documents) {
|
|
449
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
450
|
-
for (const document of documents) {
|
|
451
|
-
const existing = byPath.get(document.relativePath);
|
|
452
|
-
if (!existing) {
|
|
453
|
-
byPath.set(document.relativePath, document);
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
byPath.set(document.relativePath, create(DocumentSchema, {
|
|
457
|
-
language: existing.language || document.language,
|
|
458
|
-
relativePath: existing.relativePath || document.relativePath,
|
|
459
|
-
occurrences: [...existing.occurrences, ...document.occurrences],
|
|
460
|
-
symbols: mergeSymbolInfos([...existing.symbols, ...document.symbols]),
|
|
461
|
-
text: chooseText(existing.text, document.text),
|
|
462
|
-
positionEncoding: existing.positionEncoding || document.positionEncoding
|
|
463
|
-
}));
|
|
464
|
-
}
|
|
465
|
-
return [...byPath.values()];
|
|
466
|
-
}
|
|
467
|
-
function mergeSymbolInfos(symbols) {
|
|
468
|
-
const bySymbol = /* @__PURE__ */ new Map();
|
|
469
|
-
for (const symbol of symbols) {
|
|
470
|
-
const existing = bySymbol.get(symbol.symbol);
|
|
471
|
-
if (!existing) {
|
|
472
|
-
bySymbol.set(symbol.symbol, symbol);
|
|
473
|
-
continue;
|
|
474
|
-
}
|
|
475
|
-
bySymbol.set(symbol.symbol, create(SymbolInformationSchema, {
|
|
476
|
-
symbol: existing.symbol,
|
|
477
|
-
documentation: uniqueStrings([...existing.documentation, ...symbol.documentation]),
|
|
478
|
-
relationships: mergeRelationships([...existing.relationships, ...symbol.relationships]),
|
|
479
|
-
kind: existing.kind || symbol.kind,
|
|
480
|
-
displayName: existing.displayName || symbol.displayName,
|
|
481
|
-
enclosingSymbol: existing.enclosingSymbol || symbol.enclosingSymbol,
|
|
482
|
-
signatureDocumentation: existing.signatureDocumentation ?? symbol.signatureDocumentation
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
return [...bySymbol.values()];
|
|
486
|
-
}
|
|
487
|
-
function mergeRelationships(relationships) {
|
|
488
|
-
const seen = /* @__PURE__ */ new Set();
|
|
489
|
-
const merged = [];
|
|
490
|
-
for (const relationship of relationships) {
|
|
491
|
-
const key = [
|
|
492
|
-
relationship.symbol,
|
|
493
|
-
relationship.isReference ? "1" : "0",
|
|
494
|
-
relationship.isImplementation ? "1" : "0",
|
|
495
|
-
relationship.isTypeDefinition ? "1" : "0",
|
|
496
|
-
relationship.isDefinition ? "1" : "0"
|
|
497
|
-
].join("|");
|
|
498
|
-
if (seen.has(key)) {
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
seen.add(key);
|
|
502
|
-
merged.push(relationship);
|
|
503
|
-
}
|
|
504
|
-
return merged;
|
|
505
|
-
}
|
|
506
|
-
function chooseText(left, right) {
|
|
507
|
-
if (!left) return right;
|
|
508
|
-
if (!right) return left;
|
|
509
|
-
return left.length >= right.length ? left : right;
|
|
510
|
-
}
|
|
511
|
-
function uniqueStrings(values) {
|
|
512
|
-
return [...new Set(values)];
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// src/reindex/index.ts
|
|
516
|
-
async function reindex(opts) {
|
|
517
|
-
const {
|
|
518
|
-
projectRoot: projectRoot2,
|
|
519
|
-
maxHeapMb = 8192,
|
|
520
|
-
onStatus = console.log,
|
|
521
|
-
skipAutoInstall = false
|
|
522
|
-
} = opts;
|
|
523
|
-
const outputScip2 = opts.outputScip ?? join3(projectRoot2, "index.scip");
|
|
524
|
-
const outputDb2 = opts.outputDb ?? join3(projectRoot2, "index.db");
|
|
525
|
-
const start = Date.now();
|
|
526
|
-
const languages2 = opts.languages ?? detectLanguages(projectRoot2);
|
|
527
|
-
if (languages2.length === 0) {
|
|
528
|
-
throw new Error(
|
|
529
|
-
"No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc."
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
onStatus(`Detected languages: ${languages2.join(", ")}`);
|
|
533
|
-
if (!isBinaryAvailable("scip")) {
|
|
534
|
-
if (skipAutoInstall) {
|
|
535
|
-
throw new Error(
|
|
536
|
-
"The scip CLI is required but not found on PATH.\nInstall from: https://github.com/sourcegraph/scip/releases"
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
onStatus("scip CLI not found on PATH. Attempting auto-install...");
|
|
540
|
-
if (!tryInstallScipCli(onStatus)) {
|
|
541
|
-
throw new Error(
|
|
542
|
-
"The scip CLI is required but could not be installed.\nInstall manually from: https://github.com/sourcegraph/scip/releases"
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
const env = {
|
|
547
|
-
...process.env,
|
|
548
|
-
NODE_OPTIONS: `--max-old-space-size=${maxHeapMb}`
|
|
549
|
-
};
|
|
550
|
-
const languageOutputs = languages2.map((language, index) => ({
|
|
551
|
-
language,
|
|
552
|
-
scipPath: languages2.length > 1 ? tempScipPath(outputScip2, language, index) : outputScip2
|
|
553
|
-
}));
|
|
554
|
-
for (const { language: lang, scipPath } of languageOutputs) {
|
|
555
|
-
const config = getIndexerConfig(lang);
|
|
556
|
-
const binaryLabel = describeIndexerBinary(config);
|
|
557
|
-
const projectLocalBinary = resolveProjectLocalIndexerBinary(config, projectRoot2);
|
|
558
|
-
if (!projectLocalBinary && !isIndexerInstalled(config)) {
|
|
559
|
-
if (skipAutoInstall) {
|
|
560
|
-
throw new Error(
|
|
561
|
-
`${binaryLabel} is required to index ${lang} but not found on PATH.
|
|
562
|
-
` + (config.installUrl ? `Install from: ${config.installUrl}` : `Make sure ${binaryLabel} is installed and available on PATH.`)
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
onStatus(`${binaryLabel} not found. Attempting auto-install...`);
|
|
566
|
-
if (!tryInstallIndexer(config, onStatus)) {
|
|
567
|
-
throw new Error(
|
|
568
|
-
`${binaryLabel} is required to index ${lang} but could not be installed.
|
|
569
|
-
` + (config.installUrl ? `Install manually from: ${config.installUrl}` : `Make sure ${binaryLabel} is installed and available on PATH.`)
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
const resolvedBinary = projectLocalBinary ?? resolveIndexerBinary(config);
|
|
574
|
-
if (!resolvedBinary) {
|
|
575
|
-
throw new Error(
|
|
576
|
-
`${binaryLabel} is required to index ${lang} but was not found on PATH after installation checks.
|
|
577
|
-
` + (config.installUrl ? `Install manually from: ${config.installUrl}` : `Make sure ${binaryLabel} is installed and available on PATH.`)
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
onStatus(`Indexing ${lang} with ${resolvedBinary}...`);
|
|
581
|
-
const indexerEnv = getIndexerExecutionEnv(config, env, resolvedBinary);
|
|
582
|
-
const { binary, args } = config.indexArgs({
|
|
583
|
-
projectRoot: projectRoot2,
|
|
584
|
-
outputPath: scipPath,
|
|
585
|
-
pnpmWorkspaces: opts.pnpmWorkspaces,
|
|
586
|
-
indexerBinary: resolvedBinary
|
|
587
|
-
});
|
|
588
|
-
try {
|
|
589
|
-
execFileSync(binary, args, {
|
|
590
|
-
cwd: projectRoot2,
|
|
591
|
-
env: indexerEnv,
|
|
592
|
-
stdio: "pipe",
|
|
593
|
-
maxBuffer: 50 * 1024 * 1024
|
|
594
|
-
});
|
|
595
|
-
} catch (err) {
|
|
596
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
597
|
-
throw new Error(
|
|
598
|
-
`Failed to index ${lang} with ${resolvedBinary}: ${msg}
|
|
599
|
-
Make sure ${binaryLabel} is installed and available on PATH.`,
|
|
600
|
-
{ cause: err }
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
moveDefaultOutputIfNeeded(config, projectRoot2, scipPath);
|
|
604
|
-
}
|
|
605
|
-
if (languageOutputs.length > 1) {
|
|
606
|
-
onStatus(`Merging ${languageOutputs.length} language indexes...`);
|
|
607
|
-
mergeScipFiles(languageOutputs.map((entry) => entry.scipPath), outputScip2);
|
|
608
|
-
}
|
|
609
|
-
onStatus("Converting to SQLite...");
|
|
610
|
-
if (!existsSync3(outputScip2)) {
|
|
611
|
-
throw new Error(`SCIP index not found at ${outputScip2} after indexing`);
|
|
612
|
-
}
|
|
613
|
-
try {
|
|
614
|
-
execFileSync("scip", ["expt-convert", "--output", outputDb2, outputScip2], {
|
|
615
|
-
env,
|
|
616
|
-
stdio: "pipe",
|
|
617
|
-
maxBuffer: 50 * 1024 * 1024
|
|
618
|
-
});
|
|
619
|
-
} catch (err) {
|
|
620
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
621
|
-
throw new Error(`Failed to convert SCIP index to SQLite: ${msg}`, { cause: err });
|
|
622
|
-
} finally {
|
|
623
|
-
for (const { scipPath } of languageOutputs) {
|
|
624
|
-
if (scipPath !== outputScip2) {
|
|
625
|
-
rmSync(scipPath, { force: true });
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const durationMs = Date.now() - start;
|
|
630
|
-
onStatus(`Done in ${(durationMs / 1e3).toFixed(1)}s`);
|
|
631
|
-
return { languages: languages2, indexPath: outputScip2, dbPath: outputDb2, durationMs };
|
|
632
|
-
}
|
|
633
|
-
function moveDefaultOutputIfNeeded(config, projectRoot2, outputScip2) {
|
|
634
|
-
if (!config.defaultOutputPath) {
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
const defaultOutputPath = join3(projectRoot2, config.defaultOutputPath);
|
|
638
|
-
if (outputScip2 !== defaultOutputPath && existsSync3(defaultOutputPath)) {
|
|
639
|
-
renameSync(defaultOutputPath, outputScip2);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
function tempScipPath(outputScip2, language, index) {
|
|
643
|
-
const extension = extname2(outputScip2) || ".scip";
|
|
644
|
-
const stem = basename(outputScip2, extension);
|
|
645
|
-
return join3(dirname(outputScip2), `${stem}.${index + 1}.${language}${extension}`);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// src/reindex-worker.ts
|
|
649
|
-
var projectRoot = process.env["SCIP_REINDEX_PROJECT_ROOT"];
|
|
650
|
-
var outputScip = process.env["SCIP_REINDEX_OUTPUT_SCIP"];
|
|
651
|
-
var outputDb = process.env["SCIP_REINDEX_OUTPUT_DB"];
|
|
652
|
-
var languagesRaw = process.env["SCIP_REINDEX_LANGUAGES"];
|
|
653
|
-
var pnpmWorkspaces = process.env["SCIP_REINDEX_PNPM_WORKSPACES"] === "1";
|
|
654
|
-
if (!projectRoot || !outputScip || !outputDb) {
|
|
655
|
-
console.error("reindex-worker: missing required env vars");
|
|
656
|
-
process.exit(1);
|
|
657
|
-
}
|
|
658
|
-
var languages = languagesRaw ? languagesRaw.split(",").filter(Boolean) : void 0;
|
|
659
|
-
reindex({
|
|
660
|
-
projectRoot,
|
|
661
|
-
outputScip,
|
|
662
|
-
outputDb,
|
|
663
|
-
languages: languages?.length ? languages : void 0,
|
|
664
|
-
pnpmWorkspaces,
|
|
665
|
-
onStatus: (msg) => process.stderr.write(`[reindex] ${msg}
|
|
666
|
-
`)
|
|
667
|
-
}).then(() => {
|
|
668
|
-
process.exit(0);
|
|
669
|
-
}).catch((err) => {
|
|
670
|
-
console.error(`reindex-worker error: ${err}`);
|
|
671
|
-
process.exit(1);
|
|
672
|
-
});
|
|
1
|
+
import{d as L}from"./chunk-4TYGGOLO.js";import{execFileSync as K}from"child_process";import{existsSync as Q,renameSync as V,rmSync as Ue}from"fs";import{basename as Oe,dirname as Te,extname as Fe,join as v}from"path";import{existsSync as le,readdirSync as w}from"fs";import{extname as ce,join as R}from"path";var pe=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ue=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function N(e){let n=[],r=ge(e),t=he(e);for(let s of ue){if(de(e,s.files)){n.push(s.language);continue}if(me(r,s.globs)){n.push(s.language);continue}xe(t,s.extensions)&&n.push(s.language)}return n.includes("typescript")&&D(n,"javascript"),n.includes("cpp")&&!t.has(".c")&&D(n,"c"),n}function ge(e){try{return w(e)}catch{return[]}}function de(e,n){return n?.length?n.some(r=>le(R(e,r))):!1}function me(e,n){return n?.length?e.some(r=>n.some(t=>fe(r,t))):!1}function fe(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[r,t]=n.split("*");return e.startsWith(r??"")&&e.endsWith(t??"")}function he(e){let n=new Set,r=[e];for(;r.length>0;){let t=r.pop();if(!t)continue;let s;try{s=w(t,{withFileTypes:!0})}catch{continue}for(let o of s){if(o.name.startsWith(".")&&!o.name.endsWith("proj")&&!o.name.endsWith("sln")&&o.isDirectory())continue;let u=R(t,o.name);if(o.isDirectory()){pe.has(o.name)||r.push(u);continue}let x=ce(o.name).toLowerCase();x&&n.add(x)}}return n}function xe(e,n){return n?.length?n.some(r=>e.has(r)):!1}function D(e,n){let r=e.indexOf(n);r!==-1&&e.splice(r,1)}import{existsSync as M,readdirSync as ye}from"fs";import{join as I}from"path";var be={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n})=>{let r=["scip-typescript","index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(2,0,"--pnpm-workspaces"),{binary:"npx",args:r}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e})=>({binary:"npx",args:["scip-typescript","index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python",binaryAliases:["scip-python-plus"],checkCommand:"npx scip-python --version",indexArgs:({outputPath:e})=>({binary:"npx",args:["scip-python","index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",_(e,[".sln",".csproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",_(e,[".sln",".vbproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:n})=>({binary:e,args:["--output",n]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:n})=>{let r=I(e,"vendor","bin","scip-php"),t=I(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",M(t)?t:M(r)?r:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function A(e){return be[e]}function _(e,n){let r;try{r=ye(e)}catch{return null}for(let t of r)if(n.some(s=>t.endsWith(s)))return I(e,t);return null}import{readFileSync as ve,writeFileSync as Ie}from"fs";import{create as S}from"@bufbuild/protobuf";import{deserializeSCIP as Se,serializeSCIP as ke,DocumentSchema as Ce,IndexSchema as je,SymbolInformationSchema as Pe}from"@c4312/scip";function Ee(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=$e(e),r=Be(e.flatMap(s=>s.documents??[])),t=O(e.flatMap(s=>s.externalSymbols??[]));return S(je,{metadata:n,documents:r,externalSymbols:t})}function U(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(s=>Se(ve(s))),t=Ee(r);return Ie(n,Buffer.from(ke(t))),{documentCount:t.documents.length,externalSymbolCount:t.externalSymbols.length,inputCount:e.length}}function $e(e){let n=e[0]?.metadata;if(!n)return;let r=n.projectRoot;for(let t of e.slice(1)){let s=t.metadata?.projectRoot;if(r&&s&&s!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${s}`)}return n}function Be(e){let n=new Map;for(let r of e){let t=n.get(r.relativePath);if(!t){n.set(r.relativePath,r);continue}n.set(r.relativePath,S(Ce,{language:t.language||r.language,relativePath:t.relativePath||r.relativePath,occurrences:[...t.occurrences,...r.occurrences],symbols:O([...t.symbols,...r.symbols]),text:De(t.text,r.text),positionEncoding:t.positionEncoding||r.positionEncoding}))}return[...n.values()]}function O(e){let n=new Map;for(let r of e){let t=n.get(r.symbol);if(!t){n.set(r.symbol,r);continue}n.set(r.symbol,S(Pe,{symbol:t.symbol,documentation:we([...t.documentation,...r.documentation]),relationships:Le([...t.relationships,...r.relationships]),kind:t.kind||r.kind,displayName:t.displayName||r.displayName,enclosingSymbol:t.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:t.signatureDocumentation??r.signatureDocumentation}))}return[...n.values()]}function Le(e){let n=new Set,r=[];for(let t of e){let s=[t.symbol,t.isReference?"1":"0",t.isImplementation?"1":"0",t.isTypeDefinition?"1":"0",t.isDefinition?"1":"0"].join("|");n.has(s)||(n.add(s),r.push(t))}return r}function De(e,n){return e?n?e.length>=n.length?e:n:e:n}function we(e){return[...new Set(e)]}import{execFileSync as y}from"child_process";import{existsSync as k}from"fs";import{createRequire as Re}from"module";import{platform as T}from"os";import{join as F}from"path";var Ne=Re(import.meta.url),Me=T()==="win32";function h(e){let n=Me?"where":"which";try{return y(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function q(e){return[e.indexerBinary,...e.binaryAliases??[]]}function C(e){let n=q(e);return n.length===1?n[0]:n.join(" or ")}function b(e){for(let n of q(e))if(h(n))return n;return G(e)?e.indexerBinary:null}function W(e){return b(e)!==null||G(e)}function G(e){if(!e.bundledNpmPackage)return!1;try{return Ne.resolve(`${e.bundledNpmPackage}/package.json`),!0}catch{return!1}}function z(e,n){for(let r of e.projectLocalBinaries??[]){let t=F(n,r);if(k(t))return t}return null}function H(e,n=process.env,r=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||J(r,n))return n;let t=_e(r,n);return t?{...n,DOTNET_ROOT:t}:n}function X(e,n){let r=e.installMethods,t=C(e);if(!r?.length)return n(`No auto-install method available for ${t}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let s of r)if(h(s.prerequisite)){n(`Installing ${t} via ${s.label}...`);try{y(s.binary,s.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=b(e);if(o){let u=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${t} via ${s.label}${u}`),!0}n(`${s.label} command completed but ${t} was not found on PATH`)}catch(o){let u=o instanceof Error?o.message:String(o);n(`${s.label} install failed: ${u}`)}}return n(`Could not auto-install ${t}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function _e(e,n){for(let r of Ae(n))if(J(e,{...n,DOTNET_ROOT:r}))return r;return null}function Ae(e){let n=[],r=e.DOTNET_ROOT;if(r&&k(r)&&n.push(r),T()==="darwin"&&h("brew"))try{let t=y("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),s=F(t,"libexec");k(s)&&!n.includes(s)&&n.push(s)}catch{}return n}function J(e,n){try{return y(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}async function Y(e){let{projectRoot:n,maxHeapMb:r=8192,onStatus:t=console.log,skipAutoInstall:s=!1}=e,o=e.outputScip??v(n,"index.scip"),u=e.outputDb??v(n,"index.db"),x=Date.now(),d=e.languages??N(n);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");if(t(`Detected languages: ${d.join(", ")}`),!h("scip")){if(s)throw new Error(`The scip CLI is required but not found on PATH.
|
|
2
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!L(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
3
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}let j={...process.env,NODE_OPTIONS:`--max-old-space-size=${r}`},P=d.map((i,c)=>({language:i,scipPath:d.length>1?We(o,i,c):o})),p=[],g=[];for(let{language:i,scipPath:c}of P){let l=A(i),m=C(l),$=z(l,n);if(!$&&!W(l)){if(s){let a=`${m} not found on PATH (auto-install disabled). ${l.installUrl??""}`.trim();t(`Skipping ${i}: ${a}`),g.push({language:i,reason:a});continue}if(t(`${m} not found. Attempting auto-install...`),!X(l,t)){let a=`${m} could not be auto-installed. ${l.installUrl?`Install manually from ${l.installUrl}`:`Install ${m} and put it on PATH.`}`;t(`Skipping ${i}: ${a}`),g.push({language:i,reason:a});continue}}let f=$??b(l);if(!f){let a=`${m} was not found after installation checks.`;t(`Skipping ${i}: ${a}`),g.push({language:i,reason:a});continue}t(`Indexing ${i} with ${f}...`);let se=H(l,j,f),{binary:ie,args:oe}=l.indexArgs({projectRoot:n,outputPath:c,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:f});try{K(ie,oe,{cwd:n,env:se,stdio:"pipe",maxBuffer:50*1024*1024})}catch(a){let ae=a instanceof Error?a.message:String(a),B=`${f} indexer failed: ${ae.split(`
|
|
4
|
+
`)[0]}`;t(`Skipping ${i}: ${B}`),g.push({language:i,reason:B});continue}qe(l,n,c),p.push({language:i,scipPath:c})}if(p.length===0){let i=g.map(c=>` - ${c.language}: ${c.reason}`).join(`
|
|
5
|
+
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
6
|
+
`+i)}if(g.length>0&&t(`Indexed ${p.length} of ${d.length} languages; skipped ${g.map(i=>i.language).join(", ")}.`),d.length>1&&(p.length>1?(t(`Merging ${p.length} language indexes...`),U(p.map(i=>i.scipPath),o)):p[0].scipPath!==o&&V(p[0].scipPath,o)),t("Converting to SQLite..."),!Q(o))throw new Error(`SCIP index not found at ${o} after indexing`);try{K("scip",["expt-convert","--output",u,o],{env:j,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let c=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${c}`,{cause:i})}finally{for(let{scipPath:i}of P)i!==o&&Ue(i,{force:!0})}let E=Date.now()-x;return t(`Done in ${(E/1e3).toFixed(1)}s`),{languages:p.map(i=>i.language),indexPath:o,dbPath:u,durationMs:E,skipped:g}}function qe(e,n,r){if(!e.defaultOutputPath)return;let t=v(n,e.defaultOutputPath);r!==t&&Q(t)&&V(t,r)}function We(e,n,r){let t=Fe(e)||".scip",s=Oe(e,t);return v(Te(e),`${s}.${r+1}.${n}${t}`)}var ne=process.env.SCIP_REINDEX_PROJECT_ROOT,te=process.env.SCIP_REINDEX_OUTPUT_SCIP,re=process.env.SCIP_REINDEX_OUTPUT_DB,Z=process.env.SCIP_REINDEX_LANGUAGES,Ge=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1";(!ne||!te||!re)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ee=Z?Z.split(",").filter(Boolean):void 0;Y({projectRoot:ne,outputScip:te,outputDb:re,languages:ee?.length?ee:void 0,pnpmWorkspaces:Ge,onStatus:e=>process.stderr.write(`[reindex] ${e}
|
|
7
|
+
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});
|
|
673
8
|
//# sourceMappingURL=reindex-worker.js.map
|