veoflow 0.6.0 → 0.7.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/bin/veoflow.mjs +1 -1
- package/dist/checkers.mjs +388 -0
- package/dist/veo.mjs +1268 -194
- package/native/veo-extract.darwin-arm64.node +0 -0
- package/native/veo-extract.darwin-x64.node +0 -0
- package/native/veo-extract.linux-arm64-gnu.node +0 -0
- package/native/veo-extract.linux-x64-gnu.node +0 -0
- package/native/veo-extract.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/web/assets/{index-C934gP-c.js → index-C3_r4kcv.js} +3 -3
- package/web/index.html +1 -1
package/dist/veo.mjs
CHANGED
|
@@ -98,7 +98,7 @@ function withOrdinals(items, groupKey) {
|
|
|
98
98
|
return [item, n2];
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
var SAFE_SOURCE_ID, ids;
|
|
101
|
+
var SAFE_SOURCE_ID, ids, importStatement;
|
|
102
102
|
var init_ids = __esm({
|
|
103
103
|
"packages/core/src/ids.ts"() {
|
|
104
104
|
"use strict";
|
|
@@ -130,6 +130,7 @@ var init_ids = __esm({
|
|
|
130
130
|
/** A function where a path may start (#305). */
|
|
131
131
|
startCandidate: (functionId2) => `start|${functionId2}`
|
|
132
132
|
};
|
|
133
|
+
importStatement = (e) => `${e.from}\0${e.specifier}\0${e.evidence.span.start.offset}`;
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
136
|
|
|
@@ -174,6 +175,7 @@ var init_model = __esm({
|
|
|
174
175
|
metaprogramming: "built at run time",
|
|
175
176
|
"dynamic-sql": "SQL built at run time",
|
|
176
177
|
"imported-symbol": "imported, not linked",
|
|
178
|
+
"package-symbol": "in another file of its package",
|
|
177
179
|
"runtime-global": "built-in",
|
|
178
180
|
"builtin-value": "built-in value",
|
|
179
181
|
"template-binding": "awaiting its component",
|
|
@@ -254,8 +256,8 @@ function foldProgress(p, e) {
|
|
|
254
256
|
case "stage.progress": {
|
|
255
257
|
p = joined(p, e.runId);
|
|
256
258
|
const { done: _d, total: _t, unit: _u, ...rest } = p;
|
|
257
|
-
const { type: _type, projectId: _p, runId: _r, stage, ...
|
|
258
|
-
return { ...rest, stage, ...
|
|
259
|
+
const { type: _type, projectId: _p, runId: _r, stage, ...step2 } = e;
|
|
260
|
+
return { ...rest, stage, ...step2 };
|
|
259
261
|
}
|
|
260
262
|
case "stage.completed":
|
|
261
263
|
if (p?.runId !== e.runId) return p;
|
|
@@ -280,8 +282,8 @@ function progressWords(p) {
|
|
|
280
282
|
if (p.phase === "saving results") return { text: `${name}: saving results${of}`, fraction: 1 };
|
|
281
283
|
if (p.phase) {
|
|
282
284
|
const counted = p.total === void 0 ? "" : p.done === void 0 ? ` (${n(p.total)}${p.unit ? ` ${p.unit}` : ""})` : `: ${n(p.done)} of ${n(p.total)}${p.unit && p.unit !== "files" ? ` ${p.unit}` : ""}`;
|
|
283
|
-
const
|
|
284
|
-
what = p.phase === "reading files" ? counted : `: ${p.phase}${counted}${
|
|
285
|
+
const step2 = p.steps && p.steps > 1 ? `, step ${p.step} of ${p.steps}` : "";
|
|
286
|
+
what = p.phase === "reading files" ? counted : `: ${p.phase}${counted}${step2}`;
|
|
285
287
|
if (p.done !== void 0 && p.total) fraction = p.done / p.total;
|
|
286
288
|
else if (p.steps && p.step) fraction = (p.step - 1) / p.steps;
|
|
287
289
|
}
|
|
@@ -504,8 +506,9 @@ var init_classify = __esm({
|
|
|
504
506
|
"tsx",
|
|
505
507
|
"vue",
|
|
506
508
|
"svelte",
|
|
507
|
-
// Python (#415, R3).
|
|
509
|
+
// Python (#415, R3) and Go (#436).
|
|
508
510
|
"python",
|
|
511
|
+
"go",
|
|
509
512
|
"angular-template"
|
|
510
513
|
]);
|
|
511
514
|
UNSUPPORTED = {
|
|
@@ -865,8 +868,8 @@ function readBlobs(top, shas, sizes, batchBytes = BATCH_BYTES) {
|
|
|
865
868
|
let pos = 0;
|
|
866
869
|
while (pos < out.length) {
|
|
867
870
|
const nl = out.indexOf(10, pos);
|
|
868
|
-
const
|
|
869
|
-
const [sha, type, size] =
|
|
871
|
+
const header2 = out.subarray(pos, nl).toString("utf8");
|
|
872
|
+
const [sha, type, size] = header2.split(" ");
|
|
870
873
|
if (type === "missing" || !size) {
|
|
871
874
|
pos = nl + 1;
|
|
872
875
|
continue;
|
|
@@ -1248,7 +1251,7 @@ function unreadNotice(files) {
|
|
|
1248
1251
|
const parts = [...by].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).map(([name, n2]) => `${n2.toLocaleString("en-US")} ${name} ${n2 === 1 ? "file" : "files"}`);
|
|
1249
1252
|
const list = parts.length === 1 ? parts[0] : `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
|
|
1250
1253
|
const total = [...by.values()].reduce((a, b) => a + b, 0);
|
|
1251
|
-
return `${list} ${total === 1 ? "is" : "are"} listed but not analyzed yet: veoflow analyzes JavaScript and TypeScript (with Vue, Svelte and Angular components) and
|
|
1254
|
+
return `${list} ${total === 1 ? "is" : "are"} listed but not analyzed yet: veoflow analyzes JavaScript and TypeScript (with Vue, Svelte and Angular components), Python and Go today.`;
|
|
1252
1255
|
}
|
|
1253
1256
|
function ignoredSourceFolders(root, unpinned) {
|
|
1254
1257
|
const out = [];
|
|
@@ -1871,7 +1874,7 @@ var init_plan = __esm({
|
|
|
1871
1874
|
};
|
|
1872
1875
|
DEFAULT_MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
1873
1876
|
HARD_MAX_FILE_BYTES = 64 * 1024 * 1024;
|
|
1874
|
-
RESOLVER_MANIFEST = /(^|\/)(package\.json|project\.json|nx\.json|pyproject\.toml|setup\.cfg|requirements[^/]*\.txt|uv\.lock|poetry\.lock|(ts|js)config[^/]*\.json|package-lock\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|yarn\.lock|\.npmrc|\.yarnrc\.yml)$/;
|
|
1877
|
+
RESOLVER_MANIFEST = /(^|\/)(package\.json|project\.json|nx\.json|pyproject\.toml|setup\.cfg|requirements[^/]*\.txt|uv\.lock|poetry\.lock|go\.mod|go\.work|(ts|js)config[^/]*\.json|package-lock\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|yarn\.lock|\.npmrc|\.yarnrc\.yml)$/;
|
|
1875
1878
|
RESOLVER_INPUT = /\.(json|jsonc|lock|ya?ml|toml|mod|sum)$|(^|\/)(\.npmrc|\.nvmrc|\.babelrc)$/i;
|
|
1876
1879
|
MINIFIED_MIN_BYTES = 2e4;
|
|
1877
1880
|
count = (n2, noun) => `${n2.toLocaleString("en-US")} ${noun}${n2 === 1 ? "" : "s"}`;
|
|
@@ -2623,14 +2626,14 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
2623
2626
|
SELECT a.id, a.type, a.file, a.src, 'removed' AS change
|
|
2624
2627
|
FROM a LEFT JOIN b ON b.id = a.id WHERE b.id IS NULL`
|
|
2625
2628
|
).all({ ...pinParams(pa, "a_"), ...pinParams(pb, "b_") });
|
|
2626
|
-
const
|
|
2629
|
+
const cmp12 = (x, y) => x < y ? -1 : x > y ? 1 : 0;
|
|
2627
2630
|
return rows.map((r) => ({
|
|
2628
2631
|
id: r.id,
|
|
2629
2632
|
type: r.type,
|
|
2630
2633
|
change: r.change,
|
|
2631
2634
|
file: r.file,
|
|
2632
2635
|
source: changeSource(r.id, r.file, r.src)
|
|
2633
|
-
})).sort((x, y) =>
|
|
2636
|
+
})).sort((x, y) => cmp12(x.file ?? "", y.file ?? "") || cmp12(x.type, y.type) || cmp12(x.id, y.id));
|
|
2634
2637
|
}
|
|
2635
2638
|
/** How many facts of each type a committed run's graph holds. */
|
|
2636
2639
|
factCounts(run2) {
|
|
@@ -3890,7 +3893,8 @@ var init_src3 = __esm({
|
|
|
3890
3893
|
tsx: "tsx",
|
|
3891
3894
|
vue: "vue",
|
|
3892
3895
|
svelte: "svelte",
|
|
3893
|
-
py: "python"
|
|
3896
|
+
py: "python",
|
|
3897
|
+
go: "go"
|
|
3894
3898
|
};
|
|
3895
3899
|
}
|
|
3896
3900
|
});
|
|
@@ -4595,7 +4599,7 @@ var PROTOCOL_VERSION;
|
|
|
4595
4599
|
var init_protocol = __esm({
|
|
4596
4600
|
"protocol/index.ts"() {
|
|
4597
4601
|
"use strict";
|
|
4598
|
-
PROTOCOL_VERSION = "1.
|
|
4602
|
+
PROTOCOL_VERSION = "1.9.0";
|
|
4599
4603
|
}
|
|
4600
4604
|
});
|
|
4601
4605
|
|
|
@@ -4912,7 +4916,7 @@ var init_stage1 = __esm({
|
|
|
4912
4916
|
byOffset = (a, b) => a.site.start.offset - b.site.start.offset || a.site.end.offset - b.site.end.offset;
|
|
4913
4917
|
BATCH_BYTES2 = 32 << 20;
|
|
4914
4918
|
BATCH_FILES = 200;
|
|
4915
|
-
STAGE1_VERSION =
|
|
4919
|
+
STAGE1_VERSION = 4;
|
|
4916
4920
|
stage1 = {
|
|
4917
4921
|
name: STAGE1,
|
|
4918
4922
|
version: () => `${STAGE1_VERSION}+${adapterVersion()}`,
|
|
@@ -7905,6 +7909,7 @@ function rollUp(out, groupOf, input2, fnFile) {
|
|
|
7905
7909
|
if (!r) roll.set(key, r = { imports: [], calls: [], references: [] });
|
|
7906
7910
|
return r;
|
|
7907
7911
|
};
|
|
7912
|
+
const statements2 = /* @__PURE__ */ new Set();
|
|
7908
7913
|
for (const e of input2.imports) {
|
|
7909
7914
|
const from = groupOf.get(e.from);
|
|
7910
7915
|
if (!from) continue;
|
|
@@ -7914,7 +7919,13 @@ function rollUp(out, groupOf, input2, fnFile) {
|
|
|
7914
7919
|
continue;
|
|
7915
7920
|
}
|
|
7916
7921
|
const to = groupOf.get(e.to);
|
|
7917
|
-
if (to && to !== from)
|
|
7922
|
+
if (to && to !== from) {
|
|
7923
|
+
const statement = `${from}\0${to}\0${e.from}\0${e.specifier}\0${e.evidence.span.start.offset}`;
|
|
7924
|
+
if (!statements2.has(statement)) {
|
|
7925
|
+
statements2.add(statement);
|
|
7926
|
+
rollOf(from, to).imports.push(e);
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7918
7929
|
}
|
|
7919
7930
|
for (const c of input2.calls) {
|
|
7920
7931
|
const fromFile = fnFile.get(c.from);
|
|
@@ -9653,7 +9664,11 @@ function getGroup(engine, args, cwd) {
|
|
|
9653
9664
|
for (const f of files) {
|
|
9654
9665
|
const from = nodeOf.get(f.id);
|
|
9655
9666
|
if (!kept.has(from)) continue;
|
|
9667
|
+
const counted = /* @__PURE__ */ new Set();
|
|
9656
9668
|
for (const e of reader.facts("IMPORTS", f.id)) {
|
|
9669
|
+
const key = `${importStatement(e)}\0${members2.has(e.to) ? nodeOf.get(e.to) : e.to}`;
|
|
9670
|
+
if (counted.has(key)) continue;
|
|
9671
|
+
counted.add(key);
|
|
9657
9672
|
if (members2.has(e.to)) {
|
|
9658
9673
|
const to = nodeOf.get(e.to);
|
|
9659
9674
|
if (to !== from) add2(edges, from, to, e.evidence);
|
|
@@ -10354,7 +10369,9 @@ function explainImport(reader, e) {
|
|
|
10354
10369
|
};
|
|
10355
10370
|
}
|
|
10356
10371
|
function explainUnresolvedImport(u) {
|
|
10357
|
-
const
|
|
10372
|
+
const language = /\.go$/.test(u.file) ? "go" : /\.pyi?$/.test(u.file) ? "python" : null;
|
|
10373
|
+
const own2 = language ? LANGUAGE_IMPORTS[language]?.[u.reason] : void 0;
|
|
10374
|
+
const why = own2?.[0] ?? IMPORT_REASONS[u.reason] ?? u.reason;
|
|
10358
10375
|
const word = { broken: "is broken", "not-analyzed": "leads to a file not analyzed", pending: "is pending" }[u.outcome];
|
|
10359
10376
|
return {
|
|
10360
10377
|
...base(u, u.file),
|
|
@@ -10363,7 +10380,7 @@ function explainUnresolvedImport(u) {
|
|
|
10363
10380
|
outcome: u.outcome,
|
|
10364
10381
|
summary: `'${u.specifier}' ${word}: ${why}.`,
|
|
10365
10382
|
steps: u.steps,
|
|
10366
|
-
...IMPORT_FIXES[u.reason] ? { toResolve: IMPORT_FIXES[u.reason] } : {}
|
|
10383
|
+
...own2?.[1] ?? IMPORT_FIXES[u.reason] ? { toResolve: own2?.[1] ?? IMPORT_FIXES[u.reason] } : {}
|
|
10367
10384
|
};
|
|
10368
10385
|
}
|
|
10369
10386
|
function mayBeBuiltin(reader, expression, reason) {
|
|
@@ -10604,6 +10621,7 @@ function explain(engine, args, cwd) {
|
|
|
10604
10621
|
)
|
|
10605
10622
|
);
|
|
10606
10623
|
const items = [];
|
|
10624
|
+
const explainedImports = /* @__PURE__ */ new Map();
|
|
10607
10625
|
for (const fact of facts) {
|
|
10608
10626
|
if (!("evidence" in fact) || !onLine(fact.evidence)) continue;
|
|
10609
10627
|
if (fact.type === "SiteResolution") continue;
|
|
@@ -10611,9 +10629,24 @@ function explain(engine, args, cwd) {
|
|
|
10611
10629
|
if (fact.type === "CALLS_CROSS_FILE" && fact.id.startsWith("CALLS_CROSS_FILE|site|")) continue;
|
|
10612
10630
|
if (fact.type === "UnresolvedCallSite" && fact.reason === "template-binding" && !fact.component && linkedBindings.has(fact.evidence.span.start.offset))
|
|
10613
10631
|
continue;
|
|
10632
|
+
if (fact.type === "IMPORTS") {
|
|
10633
|
+
const key = importStatement(fact);
|
|
10634
|
+
if (explainedImports.has(key)) {
|
|
10635
|
+
explainedImports.get(key).push(fact);
|
|
10636
|
+
continue;
|
|
10637
|
+
}
|
|
10638
|
+
explainedImports.set(key, [fact]);
|
|
10639
|
+
}
|
|
10614
10640
|
const item = explainFact(reader, fact, stage22);
|
|
10615
10641
|
if (item) items.push(item);
|
|
10616
10642
|
}
|
|
10643
|
+
for (const item of items) {
|
|
10644
|
+
const group = item.kind === "import" ? [...explainedImports.values()].find((g) => g[0].id === item.id) : void 0;
|
|
10645
|
+
if (group && group.length > 1) {
|
|
10646
|
+
const paths = group.map((e) => pathOf3(e.to));
|
|
10647
|
+
item.summary = `'${group[0].specifier}' resolves to ${group.length} files of its package: ${paths.join(", ")}.`;
|
|
10648
|
+
}
|
|
10649
|
+
}
|
|
10617
10650
|
items.sort(
|
|
10618
10651
|
(a, b) => (
|
|
10619
10652
|
// Every item on a line has evidence (it was matched by it).
|
|
@@ -10629,7 +10662,7 @@ function explain(engine, args, cwd) {
|
|
|
10629
10662
|
...file2.status !== "analyzed" ? { file: { status: file2.status, ...file2.reason ? { reason: file2.reason } : {} } } : {}
|
|
10630
10663
|
};
|
|
10631
10664
|
}
|
|
10632
|
-
var EXPLAIN_MAX, pathOf3, cmp5, IMPORT_REASONS, SITE_REASONS, STATUS_WORDS, base, IMPORT_FIXES, CALL_FIXES, RESOLUTION_WORDS;
|
|
10665
|
+
var EXPLAIN_MAX, pathOf3, cmp5, IMPORT_REASONS, SITE_REASONS, STATUS_WORDS, base, LANGUAGE_IMPORTS, IMPORT_FIXES, CALL_FIXES, RESOLUTION_WORDS;
|
|
10633
10666
|
var init_explain = __esm({
|
|
10634
10667
|
"packages/query-imports/src/explain.ts"() {
|
|
10635
10668
|
"use strict";
|
|
@@ -10659,6 +10692,7 @@ var init_explain = __esm({
|
|
|
10659
10692
|
"computed-member": "the function is picked by a computed key, so which one runs depends on the key's value",
|
|
10660
10693
|
"dynamic-sql": "it runs SQL built at run time",
|
|
10661
10694
|
"imported-symbol": "it calls something imported from another file, which Stage 2 links",
|
|
10695
|
+
"package-symbol": "it calls something another file of its package declares (Go), which Stage 2 links",
|
|
10662
10696
|
"runtime-global": "it is part of the language or runtime (a built-in), outside the code analyzed",
|
|
10663
10697
|
"builtin-value": "the value it is called on is built in (a string, a number, a DOM element, a fetch response), so it runs code of the runtime, outside the code analyzed",
|
|
10664
10698
|
"template-binding": "it is a call in a template file, resolved against the components that declare the template",
|
|
@@ -10680,6 +10714,24 @@ var init_explain = __esm({
|
|
|
10680
10714
|
line: fact.evidence.span.start.line,
|
|
10681
10715
|
evidence: fact.evidence
|
|
10682
10716
|
});
|
|
10717
|
+
LANGUAGE_IMPORTS = {
|
|
10718
|
+
go: {
|
|
10719
|
+
"unknown-package": [
|
|
10720
|
+
"no module of the project provides it and go.mod doesn't require it",
|
|
10721
|
+
"Require its module in go.mod, or add the module to the go.work (use) or a local replace."
|
|
10722
|
+
],
|
|
10723
|
+
"file-not-found": [
|
|
10724
|
+
"the module provides no package in that folder",
|
|
10725
|
+
"Fix the import path, or add the package's folder to the module."
|
|
10726
|
+
]
|
|
10727
|
+
},
|
|
10728
|
+
python: {
|
|
10729
|
+
"unknown-package": [
|
|
10730
|
+
"it isn't in the project, the standard library or a distribution the project declares",
|
|
10731
|
+
"Declare its distribution in pyproject.toml or requirements.txt, or add the source that holds it."
|
|
10732
|
+
]
|
|
10733
|
+
}
|
|
10734
|
+
};
|
|
10683
10735
|
IMPORT_FIXES = {
|
|
10684
10736
|
"file-not-found": "Fix the path, or add the file it names.",
|
|
10685
10737
|
"not-exported": "Import a path the package exports, or export it from the package.",
|
|
@@ -11319,12 +11371,22 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11319
11371
|
);
|
|
11320
11372
|
const script = checkable(CHECKED);
|
|
11321
11373
|
const pythonFiles = checkable(CHECKED_PYTHON);
|
|
11322
|
-
const
|
|
11323
|
-
const
|
|
11374
|
+
const goFiles = checkable(CHECKED_GO);
|
|
11375
|
+
const holds = (fs) => fs.some((f) => inScope(f.path));
|
|
11376
|
+
if (!holds(script) && holds(pythonFiles) && holds(goFiles))
|
|
11377
|
+
throw new VeoError(
|
|
11378
|
+
"invalid-arguments",
|
|
11379
|
+
`${args.path} holds Python and Go files: check a Python folder and a Go folder on their own`,
|
|
11380
|
+
{ fields: ["path"] }
|
|
11381
|
+
);
|
|
11382
|
+
const mode = holds(script) ? "typescript" : holds(pythonFiles) ? "python" : holds(goFiles) ? "go" : "typescript";
|
|
11383
|
+
const python = mode === "python";
|
|
11384
|
+
const go = mode === "go";
|
|
11385
|
+
const analyzed = python ? pythonFiles : go ? goFiles : script;
|
|
11324
11386
|
if (!analyzed.some((f) => inScope(f.path)))
|
|
11325
11387
|
throw new VeoError(
|
|
11326
11388
|
"invalid-arguments",
|
|
11327
|
-
`no analyzed JavaScript, TypeScript or
|
|
11389
|
+
`no analyzed JavaScript, TypeScript, Python or Go files under ${args.path} (the checkers read those; analyze the project first)`,
|
|
11328
11390
|
{ fields: ["path"] }
|
|
11329
11391
|
);
|
|
11330
11392
|
const texts = /* @__PURE__ */ new Map();
|
|
@@ -11347,11 +11409,11 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11347
11409
|
const { extract: extract2 } = await Promise.resolve().then(() => (init_src3(), src_exports));
|
|
11348
11410
|
let index;
|
|
11349
11411
|
try {
|
|
11350
|
-
index = python ? checkers.indexPython(source.root, [...texts.keys()]) : checkers.indexFolder(source.root, { files: [...texts.keys()] });
|
|
11412
|
+
index = python ? checkers.indexPython(source.root, [...texts.keys()]) : go ? checkers.indexGo(source.root, [...texts.keys()]) : checkers.indexFolder(source.root, { files: [...texts.keys()] });
|
|
11351
11413
|
} catch (e) {
|
|
11352
11414
|
throw new VeoError(
|
|
11353
11415
|
"checker-failed",
|
|
11354
|
-
`${python ? "scip-python" : "the TypeScript compiler"} couldn't index ${source.root}: ${e.message}`,
|
|
11416
|
+
`${python ? "scip-python" : go ? "scip-go" : "the TypeScript compiler"} couldn't index ${source.root}: ${e.message}`,
|
|
11355
11417
|
{
|
|
11356
11418
|
reason: "index"
|
|
11357
11419
|
}
|
|
@@ -11365,8 +11427,15 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11365
11427
|
manifests: [],
|
|
11366
11428
|
files
|
|
11367
11429
|
}).files;
|
|
11368
|
-
const { calls, candidates, references } = python ? { calls: checkers.translatePython(index, adapter, texts), candidates: [], references: 0 } : checkers.translate(index, texts);
|
|
11369
|
-
const
|
|
11430
|
+
const { calls, candidates, references } = python ? { calls: checkers.translatePython(index, adapter, texts), candidates: [], references: 0 } : go ? { calls: checkers.translateGo(index, adapter, texts), candidates: [], references: 0 } : checkers.translate(index, texts);
|
|
11431
|
+
const indexed = go ? new Set(index.map((d) => d.path)) : null;
|
|
11432
|
+
const report = checkers.compare(
|
|
11433
|
+
adapter,
|
|
11434
|
+
calls,
|
|
11435
|
+
references,
|
|
11436
|
+
candidates.length,
|
|
11437
|
+
(p) => inScope(p) && (!indexed || indexed.has(p))
|
|
11438
|
+
);
|
|
11370
11439
|
const fileId = (path) => ids.file(source.id, path);
|
|
11371
11440
|
const adapterFiles = new Map(adapter.map((f) => [f.path, f]));
|
|
11372
11441
|
const stage22 = reader.writtenStages().includes("stage2");
|
|
@@ -11425,7 +11494,7 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11425
11494
|
if (DISAGREE.has(s.category)) {
|
|
11426
11495
|
const category2 = s.category;
|
|
11427
11496
|
counts.stage1[category2]++;
|
|
11428
|
-
const
|
|
11497
|
+
const narrowed2 = category2 === "checker-only" && stage22 ? candidatesAt(s) : void 0;
|
|
11429
11498
|
sites.push({
|
|
11430
11499
|
stage: "stage1",
|
|
11431
11500
|
category: category2,
|
|
@@ -11436,7 +11505,7 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11436
11505
|
veoflow: s.adapter,
|
|
11437
11506
|
compiler: s.checker,
|
|
11438
11507
|
...changed.has(s.file) ? { changed: true } : {},
|
|
11439
|
-
...
|
|
11508
|
+
...narrowed2 ? { candidates: narrowed2 } : {}
|
|
11440
11509
|
});
|
|
11441
11510
|
continue;
|
|
11442
11511
|
}
|
|
@@ -11467,6 +11536,7 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11467
11536
|
const category = !stage22 ? "not-linked-yet" : got.size === 0 ? "checker-only" : got.size === expected.size && [...expected].every((x) => got.has(x)) ? "agree" : "different-callee";
|
|
11468
11537
|
counts.stage2[category]++;
|
|
11469
11538
|
if (category === "agree") continue;
|
|
11539
|
+
const narrowed = category === "checker-only" ? candidatesAt(s) : void 0;
|
|
11470
11540
|
sites.push({
|
|
11471
11541
|
stage: "stage2",
|
|
11472
11542
|
category,
|
|
@@ -11475,7 +11545,8 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11475
11545
|
line: s.line,
|
|
11476
11546
|
column: s.column,
|
|
11477
11547
|
veoflow: got.size ? [...got].join("; ") : stage2Answer(factsOf(fileId(s.file)), s, stage22, reader),
|
|
11478
|
-
compiler: s.checker
|
|
11548
|
+
compiler: s.checker,
|
|
11549
|
+
...narrowed ? { candidates: narrowed } : {}
|
|
11479
11550
|
});
|
|
11480
11551
|
}
|
|
11481
11552
|
sites.sort(
|
|
@@ -11486,7 +11557,7 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
11486
11557
|
source: source.id,
|
|
11487
11558
|
root: source.root,
|
|
11488
11559
|
path: scope2,
|
|
11489
|
-
checker: python ? "scip-python" : "scip-typescript",
|
|
11560
|
+
checker: python ? "scip-python" : go ? "scip-go" : "scip-typescript",
|
|
11490
11561
|
files: [...texts.keys()].filter(inScope).length,
|
|
11491
11562
|
changed: [...changed].filter(inScope).sort(),
|
|
11492
11563
|
stage2: stage22,
|
|
@@ -11510,7 +11581,7 @@ function stage2Answer(facts, at, stage22, reader) {
|
|
|
11510
11581
|
if (r.importOutcome) return `open: ${reasonWords(r.importOutcome)}`;
|
|
11511
11582
|
return `open: ${reasonWords(r.steps.at(-1)?.kind ?? "unresolved")}`;
|
|
11512
11583
|
}
|
|
11513
|
-
var CHECKED, CHECKED_PYTHON, DISAGREE;
|
|
11584
|
+
var CHECKED, CHECKED_PYTHON, CHECKED_GO, DISAGREE;
|
|
11514
11585
|
var init_check = __esm({
|
|
11515
11586
|
"packages/query-imports/src/check.ts"() {
|
|
11516
11587
|
"use strict";
|
|
@@ -11519,6 +11590,7 @@ var init_check = __esm({
|
|
|
11519
11590
|
init_src2();
|
|
11520
11591
|
CHECKED = /* @__PURE__ */ new Set(["typescript", "tsx", "javascript", "jsx"]);
|
|
11521
11592
|
CHECKED_PYTHON = /* @__PURE__ */ new Set(["python"]);
|
|
11593
|
+
CHECKED_GO = /* @__PURE__ */ new Set(["go"]);
|
|
11522
11594
|
DISAGREE = /* @__PURE__ */ new Set(["different-callee", "adapter-only", "checker-only"]);
|
|
11523
11595
|
}
|
|
11524
11596
|
});
|
|
@@ -11552,9 +11624,13 @@ function fileSummary(engine, args, cwd) {
|
|
|
11552
11624
|
if (!reader.writtenStages().includes("stage2"))
|
|
11553
11625
|
return { ...meta3, file: f.id, path: f.path, alone, acrossFiles: null };
|
|
11554
11626
|
const imports = { files: 0, packages: 0, unresolved: 0 };
|
|
11555
|
-
|
|
11627
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11628
|
+
for (const e of reader.facts("IMPORTS", f.id)) {
|
|
11629
|
+
if (seen.has(importStatement(e))) continue;
|
|
11630
|
+
seen.add(importStatement(e));
|
|
11556
11631
|
if (reader.fact(e.to)?.type === "ExternalPackage") imports.packages++;
|
|
11557
11632
|
else imports.files++;
|
|
11633
|
+
}
|
|
11558
11634
|
imports.unresolved = reader.facts("UnresolvedImport", f.id).filter((u) => u.reason !== "asset").length;
|
|
11559
11635
|
return { ...meta3, file: f.id, path: f.path, alone, acrossFiles: { ...outcomes(reader, f.id), imports } };
|
|
11560
11636
|
}
|
|
@@ -12059,7 +12135,8 @@ function pairOf(reader, end2, from, to, groups2) {
|
|
|
12059
12135
|
callers: new Set(edges.map((e) => e.from)).size,
|
|
12060
12136
|
callees: new Set(edges.map((e) => e.to)).size,
|
|
12061
12137
|
references: references.length,
|
|
12062
|
-
|
|
12138
|
+
// By statement: a Go import is an edge to each file of its package it reaches (#437).
|
|
12139
|
+
imports: new Set(imports.map(importStatement)).size
|
|
12063
12140
|
},
|
|
12064
12141
|
references: references.slice(0, PAIR_LIST_MAX).map((r) => ({
|
|
12065
12142
|
id: r.id,
|
|
@@ -12068,7 +12145,7 @@ function pairOf(reader, end2, from, to, groups2) {
|
|
|
12068
12145
|
context: r.context,
|
|
12069
12146
|
evidence: r.evidence
|
|
12070
12147
|
})),
|
|
12071
|
-
imports: imports.slice(0, PAIR_LIST_MAX).map((e) => ({
|
|
12148
|
+
imports: imports.filter((e, i, all2) => all2.findIndex((x) => importStatement(x) === importStatement(e)) === i).slice(0, PAIR_LIST_MAX).map((e) => ({
|
|
12072
12149
|
id: e.id,
|
|
12073
12150
|
file: e.from,
|
|
12074
12151
|
path: e.from.slice(e.from.indexOf(":") + 1),
|
|
@@ -12918,7 +12995,7 @@ var require_cmp = __commonJS({
|
|
|
12918
12995
|
var gte = require_gte();
|
|
12919
12996
|
var lt = require_lt();
|
|
12920
12997
|
var lte = require_lte();
|
|
12921
|
-
var
|
|
12998
|
+
var cmp12 = (a, op, b, loose) => {
|
|
12922
12999
|
switch (op) {
|
|
12923
13000
|
case "===":
|
|
12924
13001
|
if (typeof a === "object") {
|
|
@@ -12954,7 +13031,7 @@ var require_cmp = __commonJS({
|
|
|
12954
13031
|
throw new TypeError(`Invalid operator: ${op}`);
|
|
12955
13032
|
}
|
|
12956
13033
|
};
|
|
12957
|
-
module.exports =
|
|
13034
|
+
module.exports = cmp12;
|
|
12958
13035
|
}
|
|
12959
13036
|
});
|
|
12960
13037
|
|
|
@@ -13529,7 +13606,7 @@ var require_comparator = __commonJS({
|
|
|
13529
13606
|
return false;
|
|
13530
13607
|
}
|
|
13531
13608
|
}
|
|
13532
|
-
return
|
|
13609
|
+
return cmp12(version3, this.operator, this.semver, this.options);
|
|
13533
13610
|
}
|
|
13534
13611
|
intersects(comp, options2) {
|
|
13535
13612
|
if (!(comp instanceof _Comparator)) {
|
|
@@ -13562,10 +13639,10 @@ var require_comparator = __commonJS({
|
|
|
13562
13639
|
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
13563
13640
|
return true;
|
|
13564
13641
|
}
|
|
13565
|
-
if (
|
|
13642
|
+
if (cmp12(this.semver, "<", comp.semver, options2) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
13566
13643
|
return true;
|
|
13567
13644
|
}
|
|
13568
|
-
if (
|
|
13645
|
+
if (cmp12(this.semver, ">", comp.semver, options2) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
13569
13646
|
return true;
|
|
13570
13647
|
}
|
|
13571
13648
|
return false;
|
|
@@ -13574,7 +13651,7 @@ var require_comparator = __commonJS({
|
|
|
13574
13651
|
module.exports = Comparator;
|
|
13575
13652
|
var parseOptions = require_parse_options();
|
|
13576
13653
|
var { safeRe: re, t } = require_re();
|
|
13577
|
-
var
|
|
13654
|
+
var cmp12 = require_cmp();
|
|
13578
13655
|
var debug = require_debug();
|
|
13579
13656
|
var SemVer = require_semver();
|
|
13580
13657
|
var Range = require_range();
|
|
@@ -14085,7 +14162,7 @@ var require_semver2 = __commonJS({
|
|
|
14085
14162
|
var neq = require_neq();
|
|
14086
14163
|
var gte = require_gte();
|
|
14087
14164
|
var lte = require_lte();
|
|
14088
|
-
var
|
|
14165
|
+
var cmp12 = require_cmp();
|
|
14089
14166
|
var coerce = require_coerce();
|
|
14090
14167
|
var truncate = require_truncate();
|
|
14091
14168
|
var Comparator = require_comparator();
|
|
@@ -14124,7 +14201,7 @@ var require_semver2 = __commonJS({
|
|
|
14124
14201
|
neq,
|
|
14125
14202
|
gte,
|
|
14126
14203
|
lte,
|
|
14127
|
-
cmp:
|
|
14204
|
+
cmp: cmp12,
|
|
14128
14205
|
coerce,
|
|
14129
14206
|
truncate,
|
|
14130
14207
|
Comparator,
|
|
@@ -15805,7 +15882,7 @@ function importFacts(resolved) {
|
|
|
15805
15882
|
if (target2.kind === "package") packages.set(target2.pkg.id, target2.pkg);
|
|
15806
15883
|
edges.push({
|
|
15807
15884
|
type: "IMPORTS",
|
|
15808
|
-
id: ids.importsEdge(s.fileId, s.specifier, s.ordinal),
|
|
15885
|
+
id: ids.importsEdge(s.fileId, s.specifier, s.ordinal) + (target2.kind === "file" && target2.part !== void 0 ? `|${target2.part}` : ""),
|
|
15809
15886
|
from: s.fileId,
|
|
15810
15887
|
to: target2.kind === "file" ? target2.file.id : target2.pkg.id,
|
|
15811
15888
|
specifier: s.specifier,
|
|
@@ -18992,7 +19069,7 @@ function closedWorldResolutions(input2, graph, s, inj = null) {
|
|
|
18992
19069
|
const fns = [...runs.values()];
|
|
18993
19070
|
if (fns.length === 0 || fns.some((f) => f.fn.file === site.file)) continue;
|
|
18994
19071
|
const names = fns.map((f) => `${f.fn.qualifiedName} (${pathOf9(f.fn.file)})`);
|
|
18995
|
-
const
|
|
19072
|
+
const step2 = {
|
|
18996
19073
|
kind: "closed-world",
|
|
18997
19074
|
detail: `the project is analyzed as a closed world (analysis.closedWorld): the values of ${typeName} it makes run ${fns.length === 1 ? names[0] : `one of ${names.join(", ")}`}, and nothing else`
|
|
18998
19075
|
};
|
|
@@ -19008,7 +19085,7 @@ function closedWorldResolutions(input2, graph, s, inj = null) {
|
|
|
19008
19085
|
externalPackage: null,
|
|
19009
19086
|
via: "closed-world",
|
|
19010
19087
|
importOutcome: null,
|
|
19011
|
-
steps: [...r.steps,
|
|
19088
|
+
steps: [...r.steps, step2],
|
|
19012
19089
|
evidence: r.evidence
|
|
19013
19090
|
});
|
|
19014
19091
|
out.edges.push({
|
|
@@ -19028,7 +19105,7 @@ function closedWorldResolutions(input2, graph, s, inj = null) {
|
|
|
19028
19105
|
if (candidates.length !== fns.length) continue;
|
|
19029
19106
|
const { exhaustive: _open, ...rest } = r;
|
|
19030
19107
|
void _open;
|
|
19031
|
-
out.resolutions.push({ ...rest, steps: [...r.steps,
|
|
19108
|
+
out.resolutions.push({ ...rest, steps: [...r.steps, step2], candidates });
|
|
19032
19109
|
continue;
|
|
19033
19110
|
}
|
|
19034
19111
|
return out;
|
|
@@ -20499,8 +20576,976 @@ var init_exits2 = __esm({
|
|
|
20499
20576
|
}
|
|
20500
20577
|
});
|
|
20501
20578
|
|
|
20502
|
-
// packages/stage2/src/
|
|
20579
|
+
// packages/stage2/src/go.ts
|
|
20503
20580
|
import { posix as posix9 } from "node:path";
|
|
20581
|
+
function parseGoMod(text, dir) {
|
|
20582
|
+
const path = /^\s*module\s+("?)([^\s"]+)\1/m.exec(text)?.[2];
|
|
20583
|
+
if (!path) return null;
|
|
20584
|
+
const requires = /* @__PURE__ */ new Map();
|
|
20585
|
+
const replaces = /* @__PURE__ */ new Map();
|
|
20586
|
+
let block = null;
|
|
20587
|
+
for (const raw of text.split("\n")) {
|
|
20588
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
20589
|
+
if (!line) continue;
|
|
20590
|
+
if (block) {
|
|
20591
|
+
if (line === ")") {
|
|
20592
|
+
block = null;
|
|
20593
|
+
continue;
|
|
20594
|
+
}
|
|
20595
|
+
}
|
|
20596
|
+
const open3 = /^(require|replace)\s*\($/.exec(line);
|
|
20597
|
+
if (open3) {
|
|
20598
|
+
block = open3[1];
|
|
20599
|
+
continue;
|
|
20600
|
+
}
|
|
20601
|
+
const m = /^(require|replace)\s+(.*)$/.exec(line);
|
|
20602
|
+
const [kind, rest] = m ? [m[1], m[2]] : block ? [block, line] : [null, ""];
|
|
20603
|
+
if (kind === "require") {
|
|
20604
|
+
const r = /^("?)([^\s"]+)\1\s+(\S+)/.exec(rest);
|
|
20605
|
+
if (r) requires.set(r[2], r[3]);
|
|
20606
|
+
} else if (kind === "replace") {
|
|
20607
|
+
const r = /^("?)([^\s"]+)\1(?:\s+\S+)?\s*=>\s*("?)([^\s"]+)\3/.exec(rest);
|
|
20608
|
+
if (r && /^\.\.?(\/|$)/.test(r[4])) {
|
|
20609
|
+
const target2 = posix9.normalize(posix9.join(dir, r[4])).replace(/^\.$/, "").replace(/\/$/, "");
|
|
20610
|
+
if (!target2.startsWith("..")) replaces.set(r[2], target2);
|
|
20611
|
+
}
|
|
20612
|
+
}
|
|
20613
|
+
}
|
|
20614
|
+
return { dir, path, requires, replaces };
|
|
20615
|
+
}
|
|
20616
|
+
function parseGoWork(text, dir) {
|
|
20617
|
+
const out = [];
|
|
20618
|
+
let inUse2 = false;
|
|
20619
|
+
for (const raw of text.split("\n")) {
|
|
20620
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
20621
|
+
if (!line) continue;
|
|
20622
|
+
if (inUse2) {
|
|
20623
|
+
if (line === ")") inUse2 = false;
|
|
20624
|
+
else out.push(line.replace(/^"|"$/g, ""));
|
|
20625
|
+
continue;
|
|
20626
|
+
}
|
|
20627
|
+
if (/^use\s*\($/.test(line)) inUse2 = true;
|
|
20628
|
+
else {
|
|
20629
|
+
const m = /^use\s+("?)([^\s"]+)\1/.exec(line);
|
|
20630
|
+
if (m) out.push(m[2]);
|
|
20631
|
+
}
|
|
20632
|
+
}
|
|
20633
|
+
return out.map((u) => posix9.normalize(posix9.join(dir, u)).replace(/^\.$/, "").replace(/\/$/, ""));
|
|
20634
|
+
}
|
|
20635
|
+
function goModules(plans) {
|
|
20636
|
+
const out = [];
|
|
20637
|
+
for (const plan of plans) {
|
|
20638
|
+
const mods = [];
|
|
20639
|
+
const works = [];
|
|
20640
|
+
for (const m of plan.manifests) {
|
|
20641
|
+
const base2 = posix9.basename(m.path);
|
|
20642
|
+
const dir = posix9.dirname(m.path) === "." ? "" : posix9.dirname(m.path);
|
|
20643
|
+
if (goSkipsDir(m.path)) continue;
|
|
20644
|
+
if (base2 === "go.mod") {
|
|
20645
|
+
const g = parseGoMod(m.content, dir);
|
|
20646
|
+
if (g) mods.push({ ...g, source: plan.sourceId, workspace: [] });
|
|
20647
|
+
} else if (base2 === "go.work") works.push({ dir, uses: parseGoWork(m.content, dir) });
|
|
20648
|
+
}
|
|
20649
|
+
for (const mod of mods) {
|
|
20650
|
+
const work = works.filter(
|
|
20651
|
+
(w) => (w.dir === "" || mod.dir === w.dir || mod.dir.startsWith(`${w.dir}/`)) && w.uses.includes(mod.dir)
|
|
20652
|
+
).sort((a, b) => b.dir.length - a.dir.length)[0];
|
|
20653
|
+
if (work) mod.workspace = work.uses;
|
|
20654
|
+
}
|
|
20655
|
+
out.push(...mods);
|
|
20656
|
+
}
|
|
20657
|
+
return out;
|
|
20658
|
+
}
|
|
20659
|
+
function goResults(plans) {
|
|
20660
|
+
const out = /* @__PURE__ */ new Map();
|
|
20661
|
+
for (const plan of plans) {
|
|
20662
|
+
const files = plan.files.filter((f) => f.language === "go" && f.content !== void 0 && !f.skip);
|
|
20663
|
+
if (!files.length) continue;
|
|
20664
|
+
const response = extract({
|
|
20665
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
20666
|
+
root: plan.root,
|
|
20667
|
+
manifests: [],
|
|
20668
|
+
files: files.map((f) => ({ path: f.path, language: f.language, content: f.content }))
|
|
20669
|
+
});
|
|
20670
|
+
for (const r of response.files) out.set(`${plan.sourceId}\0${r.path}`, r);
|
|
20671
|
+
}
|
|
20672
|
+
return out;
|
|
20673
|
+
}
|
|
20674
|
+
function suffixed(path) {
|
|
20675
|
+
const parts = posix9.basename(path, ".go").replace(/_test$/, "").split("_");
|
|
20676
|
+
const last = parts.at(-1);
|
|
20677
|
+
const prev = parts.at(-2);
|
|
20678
|
+
return parts.length > 1 && (GOOS.includes(last) || GOARCH.includes(last) && (parts.length === 2 || GOOS.includes(prev ?? "") || parts.length > 2));
|
|
20679
|
+
}
|
|
20680
|
+
function header(text) {
|
|
20681
|
+
let build = null;
|
|
20682
|
+
let legacyIgnore = false;
|
|
20683
|
+
const ignored = () => build ? /^\/\/go:build\s+ignore\s*$/.test(build.text) : legacyIgnore;
|
|
20684
|
+
let offset = 0;
|
|
20685
|
+
let line = 1;
|
|
20686
|
+
let inBlock = false;
|
|
20687
|
+
for (const raw of text.split("\n")) {
|
|
20688
|
+
const l = raw.replace(/\r$/, "");
|
|
20689
|
+
const t = l.trim();
|
|
20690
|
+
if (inBlock) {
|
|
20691
|
+
if (t.includes("*/")) inBlock = false;
|
|
20692
|
+
} else if (t.startsWith("/*")) {
|
|
20693
|
+
if (!t.includes("*/")) inBlock = true;
|
|
20694
|
+
} else if (t.startsWith("//go:build")) {
|
|
20695
|
+
build = { text: t, line, col: l.indexOf("//") + 1, offset: offset + l.indexOf("//") };
|
|
20696
|
+
} else if (/^\/\/\s*\+build\b.*\bignore\b/.test(t)) {
|
|
20697
|
+
legacyIgnore = true;
|
|
20698
|
+
} else if (t && !t.startsWith("//")) {
|
|
20699
|
+
const m = /^\uFEFF?package\s+([A-Za-z_]\w*)/.exec(t);
|
|
20700
|
+
return { pkg: m ? m[1] : null, build, ignore: ignored() };
|
|
20701
|
+
}
|
|
20702
|
+
offset += Buffer.byteLength(raw, "utf8") + 1;
|
|
20703
|
+
line++;
|
|
20704
|
+
}
|
|
20705
|
+
return { pkg: null, build, ignore: ignored() };
|
|
20706
|
+
}
|
|
20707
|
+
function goSkipsDir(path) {
|
|
20708
|
+
return posix9.dirname(path).split("/").some((p) => p === "testdata" || p.length > 1 && (p.startsWith("_") || p.startsWith(".")));
|
|
20709
|
+
}
|
|
20710
|
+
function assumedName(path) {
|
|
20711
|
+
const parts = path.split("/");
|
|
20712
|
+
let base2 = parts.pop() ?? path;
|
|
20713
|
+
if (/^v\d+$/.test(base2) && parts.length) base2 = parts.pop();
|
|
20714
|
+
base2 = base2.replace(/^go-/, "");
|
|
20715
|
+
const m = /^[\p{L}\p{N}_]*/u.exec(base2);
|
|
20716
|
+
return m ? m[0] : base2;
|
|
20717
|
+
}
|
|
20718
|
+
function packageVars(text) {
|
|
20719
|
+
const out = /* @__PURE__ */ new Map();
|
|
20720
|
+
let depth = 0;
|
|
20721
|
+
let inBlock = false;
|
|
20722
|
+
let inRaw = false;
|
|
20723
|
+
let inComment = false;
|
|
20724
|
+
let varBlock = false;
|
|
20725
|
+
const entry = (s) => {
|
|
20726
|
+
const m = /^([A-Za-z_]\w*)\s*(.*)$/.exec(s.trim());
|
|
20727
|
+
if (!m || m[1] === "_") return;
|
|
20728
|
+
const rest = m[2].replace(/\/\/.*$/, "").trim();
|
|
20729
|
+
const v = {};
|
|
20730
|
+
const value = /^=\s*([A-Za-z_]\w*)\s*$/.exec(rest);
|
|
20731
|
+
const lit = /^=\s*&?([A-Za-z_][\w.]*)\s*\{/.exec(rest);
|
|
20732
|
+
const typed = /^\*?([A-Za-z_][\w.]*)\s*(?:=|$)/.exec(rest);
|
|
20733
|
+
if (value) v.value = value[1];
|
|
20734
|
+
else if (lit) v.written = lit[1];
|
|
20735
|
+
else if (typed && !rest.startsWith("=")) v.written = typed[1];
|
|
20736
|
+
if (!out.has(m[1])) out.set(m[1], v);
|
|
20737
|
+
};
|
|
20738
|
+
for (const raw of text.split("\n")) {
|
|
20739
|
+
const atStart = depth;
|
|
20740
|
+
const line = raw.replace(/\r$/, "");
|
|
20741
|
+
if (!inBlock && !inRaw && !inComment) {
|
|
20742
|
+
if (atStart === 0 && /^var\s*\($/.test(line.trim())) varBlock = true;
|
|
20743
|
+
else if (atStart === 0 && /^var\s+/.test(line)) entry(line.replace(/^var\s+/, ""));
|
|
20744
|
+
else if (varBlock && atStart === 1 && line.trim() !== ")") entry(line);
|
|
20745
|
+
}
|
|
20746
|
+
for (let i = 0; i < line.length; i++) {
|
|
20747
|
+
const c = line[i];
|
|
20748
|
+
if (inComment) {
|
|
20749
|
+
if (c === "*" && line[i + 1] === "/") {
|
|
20750
|
+
inComment = false;
|
|
20751
|
+
i++;
|
|
20752
|
+
}
|
|
20753
|
+
continue;
|
|
20754
|
+
}
|
|
20755
|
+
if (inRaw) {
|
|
20756
|
+
if (c === "`") inRaw = false;
|
|
20757
|
+
continue;
|
|
20758
|
+
}
|
|
20759
|
+
if (c === "/" && line[i + 1] === "/") break;
|
|
20760
|
+
if (c === "/" && line[i + 1] === "*") {
|
|
20761
|
+
inComment = true;
|
|
20762
|
+
i++;
|
|
20763
|
+
} else if (c === "`") inRaw = true;
|
|
20764
|
+
else if (c === '"' || c === "'") {
|
|
20765
|
+
let j = i + 1;
|
|
20766
|
+
while (j < line.length && line[j] !== c) j += line[j] === "\\" ? 2 : 1;
|
|
20767
|
+
i = j;
|
|
20768
|
+
} else if (c === "(" || c === "[" || c === "{") depth++;
|
|
20769
|
+
else if (c === ")" || c === "]" || c === "}") depth = Math.max(0, depth - 1);
|
|
20770
|
+
}
|
|
20771
|
+
if (varBlock && depth === 0 && atStart >= 1) varBlock = false;
|
|
20772
|
+
inBlock = inComment;
|
|
20773
|
+
}
|
|
20774
|
+
return out;
|
|
20775
|
+
}
|
|
20776
|
+
function linkGo(input2) {
|
|
20777
|
+
const modules = goModules(input2.plans);
|
|
20778
|
+
const text = new Map(
|
|
20779
|
+
input2.plans.flatMap(
|
|
20780
|
+
(p) => p.files.filter((f) => f.language === "go" && f.content !== void 0).map((f) => [ids.file(p.sourceId, f.path), f.content])
|
|
20781
|
+
)
|
|
20782
|
+
);
|
|
20783
|
+
const moduleOf = (source, path) => modules.filter((m) => m.source === source && (m.dir === "" || path.startsWith(`${m.dir}/`))).sort((a, b) => b.dir.length - a.dir.length)[0] ?? null;
|
|
20784
|
+
const goFiles = /* @__PURE__ */ new Map();
|
|
20785
|
+
for (const node2 of input2.files) {
|
|
20786
|
+
if (node2.language !== "go") continue;
|
|
20787
|
+
const result2 = input2.results.get(`${node2.source}\0${node2.path}`);
|
|
20788
|
+
const t = text.get(node2.id);
|
|
20789
|
+
if (!result2 || t === void 0) continue;
|
|
20790
|
+
const h = header(t);
|
|
20791
|
+
const dir = posix9.dirname(node2.path) === "." ? "" : posix9.dirname(node2.path);
|
|
20792
|
+
goFiles.set(node2.id, {
|
|
20793
|
+
node: node2,
|
|
20794
|
+
// Never built, or skipped by the go command: its own imports and calls still resolve, but no
|
|
20795
|
+
// other file sees it (a file without a package clause, unreadable, is on its own too).
|
|
20796
|
+
excluded: h.ignore || goSkipsDir(node2.path) || !h.pkg,
|
|
20797
|
+
dir,
|
|
20798
|
+
pkg: h.pkg ?? "",
|
|
20799
|
+
test: node2.path.endsWith("_test.go"),
|
|
20800
|
+
build: h.build ? {
|
|
20801
|
+
text: h.build.text,
|
|
20802
|
+
span: {
|
|
20803
|
+
start: { line: h.build.line, column: h.build.col, offset: h.build.offset },
|
|
20804
|
+
end: {
|
|
20805
|
+
line: h.build.line,
|
|
20806
|
+
column: h.build.col + [...h.build.text].length,
|
|
20807
|
+
offset: h.build.offset + Buffer.byteLength(h.build.text, "utf8")
|
|
20808
|
+
}
|
|
20809
|
+
}
|
|
20810
|
+
} : null,
|
|
20811
|
+
suffixed: suffixed(node2.path),
|
|
20812
|
+
module: moduleOf(node2.source, node2.path),
|
|
20813
|
+
result: result2
|
|
20814
|
+
});
|
|
20815
|
+
}
|
|
20816
|
+
const keyOf2 = (f) => `${f.node.source}\0${f.dir}\0${f.pkg}`;
|
|
20817
|
+
const packages = /* @__PURE__ */ new Map();
|
|
20818
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
20819
|
+
for (const f of goFiles.values()) {
|
|
20820
|
+
if (f.excluded) continue;
|
|
20821
|
+
const d = `${f.node.source}\0${f.dir}`;
|
|
20822
|
+
byDir.set(d, [...byDir.get(d) ?? [], f]);
|
|
20823
|
+
const k = keyOf2(f);
|
|
20824
|
+
const list = packages.get(k) ?? [];
|
|
20825
|
+
list.push(f);
|
|
20826
|
+
packages.set(k, list);
|
|
20827
|
+
}
|
|
20828
|
+
for (const list of packages.values()) list.sort((a, b) => cmp10(a.node.path, b.node.path));
|
|
20829
|
+
const visible = (f) => {
|
|
20830
|
+
const own2 = (packages.get(keyOf2(f)) ?? []).filter((g) => f.test || !g.test);
|
|
20831
|
+
return f.excluded ? [...own2, f] : own2;
|
|
20832
|
+
};
|
|
20833
|
+
const importable = (source, dir, mod) => {
|
|
20834
|
+
const inDir = (byDir.get(`${source}\0${dir}`) ?? []).filter(
|
|
20835
|
+
(f) => !f.test && !f.pkg.endsWith("_test") && f.module === mod
|
|
20836
|
+
);
|
|
20837
|
+
if (!inDir.length) return [];
|
|
20838
|
+
const counts = /* @__PURE__ */ new Map();
|
|
20839
|
+
for (const f of inDir) counts.set(f.pkg, (counts.get(f.pkg) ?? 0) + 1);
|
|
20840
|
+
const name = [...counts].sort((a, b) => b[1] - a[1] || cmp10(a[0], b[0]))[0][0];
|
|
20841
|
+
return inDir.filter((f) => f.pkg === name).sort((a, b) => cmp10(a.node.path, b.node.path));
|
|
20842
|
+
};
|
|
20843
|
+
const packagesOut = /* @__PURE__ */ new Map();
|
|
20844
|
+
const external = (source, ecosystem, name, version3) => {
|
|
20845
|
+
const id = ids.externalPackage(source, ecosystem, name);
|
|
20846
|
+
let pkg = packagesOut.get(id);
|
|
20847
|
+
if (!pkg) packagesOut.set(id, pkg = { type: "ExternalPackage", id, source, ecosystem, name, version: version3 });
|
|
20848
|
+
return pkg;
|
|
20849
|
+
};
|
|
20850
|
+
const resolveCache = /* @__PURE__ */ new Map();
|
|
20851
|
+
const resolvePath2 = (from, path) => {
|
|
20852
|
+
const cacheKey = `${from.node.source}\0${from.module?.dir ?? "\0"}\0${path}`;
|
|
20853
|
+
const hit = resolveCache.get(cacheKey);
|
|
20854
|
+
if (hit) return hit;
|
|
20855
|
+
const t = resolveUncached(from, path);
|
|
20856
|
+
resolveCache.set(cacheKey, t);
|
|
20857
|
+
return t;
|
|
20858
|
+
};
|
|
20859
|
+
const resolveUncached = (from, path) => {
|
|
20860
|
+
const source = from.node.source;
|
|
20861
|
+
const mod = from.module;
|
|
20862
|
+
const providers = [];
|
|
20863
|
+
const sourceModules = modules.filter((m) => m.source === source);
|
|
20864
|
+
if (mod) {
|
|
20865
|
+
providers.push({ path: mod.path, local: mod, via: "module" });
|
|
20866
|
+
for (const dir of mod.workspace) {
|
|
20867
|
+
const w = sourceModules.find((m) => m.dir === dir);
|
|
20868
|
+
if (w && w !== mod) providers.push({ path: w.path, local: w, via: "workspace" });
|
|
20869
|
+
}
|
|
20870
|
+
for (const [p, dir] of mod.replaces) {
|
|
20871
|
+
const r = sourceModules.find((m) => m.dir === dir);
|
|
20872
|
+
if (r) providers.push({ path: p, local: r, via: "replace" });
|
|
20873
|
+
}
|
|
20874
|
+
for (const [p, v] of mod.requires)
|
|
20875
|
+
providers.push({ path: p, local: null, via: "dependency", version: v });
|
|
20876
|
+
}
|
|
20877
|
+
const covers2 = (p) => path === p || path.startsWith(`${p}/`);
|
|
20878
|
+
const best = providers.filter((p) => covers2(p.path)).sort((a, b) => b.path.length - a.path.length)[0];
|
|
20879
|
+
if (best?.local) {
|
|
20880
|
+
const rest = path.slice(best.path.length).replace(/^\//, "");
|
|
20881
|
+
const dir = [best.local.dir, rest].filter(Boolean).join("/");
|
|
20882
|
+
const files = importable(source, dir, best.local);
|
|
20883
|
+
const said = best.via === "module" ? `${path} is in this file's module ${best.path} (${best.local.dir || "the source root"})` : best.via === "workspace" ? `${path} is in ${best.path}, a module the go.work uses (${best.local.dir})` : `${path} is in ${best.path}, which go.mod replaces with ${best.local.dir}`;
|
|
20884
|
+
if (!files.length)
|
|
20885
|
+
return {
|
|
20886
|
+
kind: "broken",
|
|
20887
|
+
reason: "file-not-found",
|
|
20888
|
+
steps: [step(best.via, said), step("not-found", `no Go package in ${dir || "the source root"}`)]
|
|
20889
|
+
};
|
|
20890
|
+
return {
|
|
20891
|
+
kind: "package",
|
|
20892
|
+
key: keyOf2(files[0]),
|
|
20893
|
+
files,
|
|
20894
|
+
name: files[0].pkg,
|
|
20895
|
+
via: best.via,
|
|
20896
|
+
steps: [
|
|
20897
|
+
step(best.via, said),
|
|
20898
|
+
step("package", `the package ${files[0].pkg} in ${dir || "the source root"}`)
|
|
20899
|
+
]
|
|
20900
|
+
};
|
|
20901
|
+
}
|
|
20902
|
+
if (best)
|
|
20903
|
+
return {
|
|
20904
|
+
kind: "external",
|
|
20905
|
+
pkg: external(source, "golang", best.path, best.version ?? null),
|
|
20906
|
+
via: "dependency",
|
|
20907
|
+
steps: [
|
|
20908
|
+
step(
|
|
20909
|
+
"dependency",
|
|
20910
|
+
`${path} is in ${best.path} ${best.version ?? ""}, which go.mod requires`.trim()
|
|
20911
|
+
)
|
|
20912
|
+
]
|
|
20913
|
+
};
|
|
20914
|
+
if (!path.split("/")[0].includes("."))
|
|
20915
|
+
return {
|
|
20916
|
+
kind: "external",
|
|
20917
|
+
pkg: external(source, "go", path, null),
|
|
20918
|
+
via: "stdlib",
|
|
20919
|
+
steps: [step("stdlib", `${path} is in Go's standard library`)]
|
|
20920
|
+
};
|
|
20921
|
+
return {
|
|
20922
|
+
kind: "broken",
|
|
20923
|
+
reason: "unknown-package",
|
|
20924
|
+
steps: [step("not-found", `no module of the project provides ${path}, and go.mod doesn't require it`)]
|
|
20925
|
+
};
|
|
20926
|
+
};
|
|
20927
|
+
const resolved = [];
|
|
20928
|
+
const packageImports = [];
|
|
20929
|
+
const importsOf = /* @__PURE__ */ new Map();
|
|
20930
|
+
for (const f of goFiles.values()) {
|
|
20931
|
+
const list = [];
|
|
20932
|
+
for (const s of statements(f.node.source, f.node.path, f.result)) {
|
|
20933
|
+
const target2 = resolvePath2(f, s.specifier);
|
|
20934
|
+
const local = s.bindings[0]?.[1] ?? null;
|
|
20935
|
+
list.push({ path: s.specifier, target: target2, local });
|
|
20936
|
+
if (target2.kind === "package") packageImports.push({ statement: s, target: target2, importer: f.node.id });
|
|
20937
|
+
else if (target2.kind === "external")
|
|
20938
|
+
resolved.push({
|
|
20939
|
+
statement: s,
|
|
20940
|
+
target: { kind: "package", pkg: target2.pkg, via: target2.via, steps: target2.steps }
|
|
20941
|
+
});
|
|
20942
|
+
else
|
|
20943
|
+
resolved.push({
|
|
20944
|
+
statement: s,
|
|
20945
|
+
target: { kind: "unresolved", outcome: "broken", reason: target2.reason, steps: target2.steps }
|
|
20946
|
+
});
|
|
20947
|
+
}
|
|
20948
|
+
importsOf.set(f.node.id, list);
|
|
20949
|
+
}
|
|
20950
|
+
const importByPath = (f, path) => importsOf.get(f.node.id)?.find((i) => i.path === path);
|
|
20951
|
+
const importByName = (f, name) => {
|
|
20952
|
+
for (const i of importsOf.get(f.node.id) ?? []) {
|
|
20953
|
+
if (i.local === null || i.local === ".") continue;
|
|
20954
|
+
const unaliased = i.local === assumedName(i.path);
|
|
20955
|
+
const bound = unaliased && i.target.kind === "package" ? i.target.name : i.local;
|
|
20956
|
+
if (bound === name) return i;
|
|
20957
|
+
}
|
|
20958
|
+
return void 0;
|
|
20959
|
+
};
|
|
20960
|
+
const fnsOf = /* @__PURE__ */ new Map();
|
|
20961
|
+
for (const fn of input2.functions) {
|
|
20962
|
+
if (!goFiles.has(fn.file)) continue;
|
|
20963
|
+
const ok = fn.qualifiedName.includes(".") ? fn.kind === "method" : fn.kind === "function" || fn.kind === "arrow";
|
|
20964
|
+
if (!ok) continue;
|
|
20965
|
+
let byName = fnsOf.get(fn.file);
|
|
20966
|
+
if (!byName) fnsOf.set(fn.file, byName = /* @__PURE__ */ new Map());
|
|
20967
|
+
byName.set(fn.qualifiedName, [...byName.get(fn.qualifiedName) ?? [], fn]);
|
|
20968
|
+
}
|
|
20969
|
+
const declared2 = (files, name) => files.flatMap((g) => fnsOf.get(g.node.id)?.get(name) ?? []);
|
|
20970
|
+
const filesKey = (files) => `${files[0]?.node.id ?? ""}\0${files.length}\0${files.at(-1)?.node.id ?? ""}`;
|
|
20971
|
+
const typeDecl = (files, name) => {
|
|
20972
|
+
for (const g of files) {
|
|
20973
|
+
const decl = g.result.types.find((t) => t.name === name);
|
|
20974
|
+
if (decl) return { decl, file: g };
|
|
20975
|
+
}
|
|
20976
|
+
return null;
|
|
20977
|
+
};
|
|
20978
|
+
const varsCache = /* @__PURE__ */ new Map();
|
|
20979
|
+
const varsOf = (g) => {
|
|
20980
|
+
let v = varsCache.get(g.node.id);
|
|
20981
|
+
if (!v) varsCache.set(g.node.id, v = packageVars(text.get(g.node.id) ?? ""));
|
|
20982
|
+
return v;
|
|
20983
|
+
};
|
|
20984
|
+
const packageVar = (files, name) => {
|
|
20985
|
+
for (const g of files) {
|
|
20986
|
+
const v = varsOf(g).get(name);
|
|
20987
|
+
if (v) return { ...v, file: g };
|
|
20988
|
+
}
|
|
20989
|
+
return null;
|
|
20990
|
+
};
|
|
20991
|
+
const varFunction = (files, name) => packageVar(files, name)?.value ?? null;
|
|
20992
|
+
const typeIn = (f, written2) => {
|
|
20993
|
+
const w = written2.replace(/^\*+/, "").replace(/\[.*\]$/, "").trim();
|
|
20994
|
+
const q = /^([A-Za-z_]\w*)\.([A-Za-z_]\w*)$/.exec(w);
|
|
20995
|
+
if (q) {
|
|
20996
|
+
const imp = importByName(f, q[1]);
|
|
20997
|
+
if (!imp) return { kind: "none" };
|
|
20998
|
+
if (imp.target.kind === "package")
|
|
20999
|
+
return { kind: "local", files: imp.target.files, key: imp.target.key, name: q[2] };
|
|
21000
|
+
if (imp.target.kind === "external") return { kind: "external", pkg: imp.target.pkg };
|
|
21001
|
+
return { kind: "broken", reason: imp.target.reason };
|
|
21002
|
+
}
|
|
21003
|
+
if (GO_BUILTIN_TYPES.has(w)) return { kind: "builtin", name: w };
|
|
21004
|
+
if (/^[A-Za-z_]\w*$/.test(w)) return { kind: "local", files: packageOf(f), key: keyOf2(f), name: w };
|
|
21005
|
+
return { kind: "none" };
|
|
21006
|
+
};
|
|
21007
|
+
const packageOf = (f) => visible(f);
|
|
21008
|
+
const methodCache = /* @__PURE__ */ new Map();
|
|
21009
|
+
const methodOf = (t, m) => {
|
|
21010
|
+
const key = `${filesKey(t.files)}\0${t.name}\0${m}`;
|
|
21011
|
+
let hit = methodCache.get(key);
|
|
21012
|
+
if (!hit) methodCache.set(key, hit = methodUncached(t, m));
|
|
21013
|
+
return hit;
|
|
21014
|
+
};
|
|
21015
|
+
const methodUncached = (t, m) => {
|
|
21016
|
+
const own2 = declared2(t.files, `${t.name}.${m}`);
|
|
21017
|
+
if (own2.length) return { kind: "fns", fns: own2, promoted: false };
|
|
21018
|
+
const d = typeDecl(t.files, t.name);
|
|
21019
|
+
if (!d) return { kind: "none", why: `${t.name} is not a type of its package` };
|
|
21020
|
+
if (d.decl.kind === "interface") return { kind: "interface", files: t.files, name: t.name };
|
|
21021
|
+
if (d.decl.members.some((x) => x.name === m && x.kind === "other"))
|
|
21022
|
+
return {
|
|
21023
|
+
kind: "none",
|
|
21024
|
+
why: `${m} is a field of ${t.name} holding a function: its value isn't followed`,
|
|
21025
|
+
field: true
|
|
21026
|
+
};
|
|
21027
|
+
let level = d.decl.bases.map((b) => ({ ref: typeIn(d.file, b.name) }));
|
|
21028
|
+
const seen = /* @__PURE__ */ new Set([`${d.file.dir}\0${t.name}`]);
|
|
21029
|
+
let externalAbove = null;
|
|
21030
|
+
for (let depth = 0; depth < 8 && level.length; depth++) {
|
|
21031
|
+
const found = [];
|
|
21032
|
+
const next = [];
|
|
21033
|
+
let external2 = null;
|
|
21034
|
+
for (const { ref } of level) {
|
|
21035
|
+
if (ref.kind === "external") {
|
|
21036
|
+
external2 ??= ref.pkg;
|
|
21037
|
+
continue;
|
|
21038
|
+
}
|
|
21039
|
+
if (ref.kind !== "local") continue;
|
|
21040
|
+
const k = `${ref.key}\0${ref.name}`;
|
|
21041
|
+
if (seen.has(k)) continue;
|
|
21042
|
+
seen.add(k);
|
|
21043
|
+
const fns = declared2(ref.files, `${ref.name}.${m}`);
|
|
21044
|
+
if (fns.length) {
|
|
21045
|
+
found.push({ kind: "fns", fns, promoted: true });
|
|
21046
|
+
continue;
|
|
21047
|
+
}
|
|
21048
|
+
const e = typeDecl(ref.files, ref.name);
|
|
21049
|
+
if (!e) continue;
|
|
21050
|
+
if (e.decl.kind === "interface") {
|
|
21051
|
+
if (interfaceMethods(ref.files, ref.name).has(m))
|
|
21052
|
+
found.push({ kind: "interface", files: ref.files, name: ref.name });
|
|
21053
|
+
continue;
|
|
21054
|
+
}
|
|
21055
|
+
next.push(...e.decl.bases.map((b) => ({ ref: typeIn(e.file, b.name) })));
|
|
21056
|
+
}
|
|
21057
|
+
if (found.length === 1)
|
|
21058
|
+
return externalAbove ? {
|
|
21059
|
+
kind: "none",
|
|
21060
|
+
why: `${m} may be ${externalAbove.name}'s, embedded above, or an embedded type's of the project`
|
|
21061
|
+
} : found[0];
|
|
21062
|
+
if (found.length > 1)
|
|
21063
|
+
return { kind: "none", why: `${m} is promoted from several embedded types at the same depth` };
|
|
21064
|
+
externalAbove ??= external2;
|
|
21065
|
+
level = next;
|
|
21066
|
+
}
|
|
21067
|
+
if (externalAbove) return { kind: "external", pkg: externalAbove };
|
|
21068
|
+
return { kind: "none", why: `${t.name} has no method ${m}` };
|
|
21069
|
+
};
|
|
21070
|
+
const ifaceCache = /* @__PURE__ */ new Map();
|
|
21071
|
+
const interfaceMethods = (files, name, depth = 0) => {
|
|
21072
|
+
const key = `${files[0]?.node.id ?? ""}\0${name}`;
|
|
21073
|
+
const hit = ifaceCache.get(key);
|
|
21074
|
+
if (hit) return hit;
|
|
21075
|
+
const out = /* @__PURE__ */ new Set();
|
|
21076
|
+
const d = typeDecl(files, name);
|
|
21077
|
+
if (d && d.decl.kind === "interface" && depth < 8) {
|
|
21078
|
+
for (const mem of d.decl.members) out.add(mem.name);
|
|
21079
|
+
for (const b of d.decl.bases) {
|
|
21080
|
+
const ref = typeIn(d.file, b.name);
|
|
21081
|
+
if (ref.kind === "local")
|
|
21082
|
+
for (const x of interfaceMethods(ref.files, ref.name, depth + 1)) out.add(x);
|
|
21083
|
+
}
|
|
21084
|
+
}
|
|
21085
|
+
ifaceCache.set(key, out);
|
|
21086
|
+
return out;
|
|
21087
|
+
};
|
|
21088
|
+
const allTypes = [];
|
|
21089
|
+
for (const list of packages.values()) {
|
|
21090
|
+
const names = /* @__PURE__ */ new Set();
|
|
21091
|
+
for (const g of list) for (const t of g.result.types) if (t.kind === "class") names.add(t.name);
|
|
21092
|
+
const nonTest = list.filter((g) => !g.test);
|
|
21093
|
+
for (const name of [...names].sort()) allTypes.push({ files: nonTest.length ? nonTest : list, name });
|
|
21094
|
+
}
|
|
21095
|
+
const satisfyCache = /* @__PURE__ */ new Map();
|
|
21096
|
+
const satisfying = (files, iface, m) => {
|
|
21097
|
+
const key = `${filesKey(files)}\0${iface}\0${m}`;
|
|
21098
|
+
let hit = satisfyCache.get(key);
|
|
21099
|
+
if (!hit) satisfyCache.set(key, hit = satisfyingUncached(files, iface, m));
|
|
21100
|
+
return hit;
|
|
21101
|
+
};
|
|
21102
|
+
const satisfyingUncached = (files, iface, m) => {
|
|
21103
|
+
const need = interfaceMethods(files, iface);
|
|
21104
|
+
if (!need.size || !need.has(m)) return [];
|
|
21105
|
+
const out = [];
|
|
21106
|
+
for (const t of allTypes) {
|
|
21107
|
+
let ok = true;
|
|
21108
|
+
let target2 = [];
|
|
21109
|
+
for (const n2 of need) {
|
|
21110
|
+
const found = methodOf(t, n2);
|
|
21111
|
+
if (found.kind !== "fns") {
|
|
21112
|
+
ok = false;
|
|
21113
|
+
break;
|
|
21114
|
+
}
|
|
21115
|
+
if (n2 === m) target2 = found.fns;
|
|
21116
|
+
}
|
|
21117
|
+
if (ok) out.push(...target2);
|
|
21118
|
+
}
|
|
21119
|
+
const uniq = [...new Map(out.map((f) => [f.id, f])).values()];
|
|
21120
|
+
return uniq.sort(
|
|
21121
|
+
(a, b) => cmp10(fileOf(a.file), fileOf(b.file)) || a.evidence.span.start.offset - b.evidence.span.start.offset
|
|
21122
|
+
);
|
|
21123
|
+
};
|
|
21124
|
+
const fileOf = (id) => id.slice(id.indexOf(":") + 1);
|
|
21125
|
+
const rawByFile = /* @__PURE__ */ new Map();
|
|
21126
|
+
const resultsSite = (site) => {
|
|
21127
|
+
let m = rawByFile.get(site.file);
|
|
21128
|
+
if (!m) {
|
|
21129
|
+
m = new Map(
|
|
21130
|
+
(goFiles.get(site.file)?.result.unresolved ?? []).map((u) => [
|
|
21131
|
+
`${u.site.start.offset}\0${u.expression}`,
|
|
21132
|
+
u
|
|
21133
|
+
])
|
|
21134
|
+
);
|
|
21135
|
+
rawByFile.set(site.file, m);
|
|
21136
|
+
}
|
|
21137
|
+
return m.get(`${site.evidence.span.start.offset}\0${site.expression}`);
|
|
21138
|
+
};
|
|
21139
|
+
const evidence = (file2, span) => ({
|
|
21140
|
+
file: file2,
|
|
21141
|
+
span,
|
|
21142
|
+
commit: input2.revisions.get(file2.slice(0, file2.indexOf(":"))) ?? ""
|
|
21143
|
+
});
|
|
21144
|
+
const variantBasis = (fn) => {
|
|
21145
|
+
const g = goFiles.get(fn.file);
|
|
21146
|
+
return g?.build && !g.suffixed ? evidence(fn.file, g.build.span) : fn.evidence;
|
|
21147
|
+
};
|
|
21148
|
+
const onType = (t, m, via, said) => {
|
|
21149
|
+
if (t.kind === "external")
|
|
21150
|
+
return { kind: "external", pkg: t.pkg, steps: [step("external", `${said}, a type of ${t.pkg.name}`)] };
|
|
21151
|
+
if (t.kind === "broken")
|
|
21152
|
+
return {
|
|
21153
|
+
kind: "broken",
|
|
21154
|
+
reason: t.reason,
|
|
21155
|
+
steps: [step("not-found", `${said}: its import is broken`)]
|
|
21156
|
+
};
|
|
21157
|
+
if (t.kind === "builtin")
|
|
21158
|
+
return { kind: "runtime", steps: [step("runtime", `${said}: a method of Go's built-in ${t.name}`)] };
|
|
21159
|
+
if (t.kind === "none")
|
|
21160
|
+
return { kind: "open", steps: [step("untyped", `${said}: not a named type Stage 2 follows`)] };
|
|
21161
|
+
const found = methodOf(t, m);
|
|
21162
|
+
switch (found.kind) {
|
|
21163
|
+
case "fns":
|
|
21164
|
+
return found.fns.length > 1 ? {
|
|
21165
|
+
kind: "fns",
|
|
21166
|
+
fns: found.fns,
|
|
21167
|
+
via,
|
|
21168
|
+
steps: [step("variants", `${t.name}.${m} has a body per build variant`)],
|
|
21169
|
+
variants: true
|
|
21170
|
+
} : {
|
|
21171
|
+
kind: "fns",
|
|
21172
|
+
fns: found.fns,
|
|
21173
|
+
via: found.promoted ? "inherited" : via,
|
|
21174
|
+
steps: [
|
|
21175
|
+
step(
|
|
21176
|
+
found.promoted ? "promoted" : "method",
|
|
21177
|
+
found.promoted ? `${m} is promoted to ${t.name} from an embedded field` : `${said}: ${t.name}.${m}`
|
|
21178
|
+
)
|
|
21179
|
+
]
|
|
21180
|
+
};
|
|
21181
|
+
case "interface": {
|
|
21182
|
+
const fns = satisfying(found.files, found.name, m);
|
|
21183
|
+
return fns.length ? {
|
|
21184
|
+
kind: "candidates",
|
|
21185
|
+
fns,
|
|
21186
|
+
steps: [
|
|
21187
|
+
step(
|
|
21188
|
+
"interface",
|
|
21189
|
+
`${found.name} is an interface: every type of the project that satisfies it`
|
|
21190
|
+
)
|
|
21191
|
+
]
|
|
21192
|
+
} : { kind: "open", steps: [step("interface", `no type of the project satisfies ${found.name}`)] };
|
|
21193
|
+
}
|
|
21194
|
+
case "external":
|
|
21195
|
+
return {
|
|
21196
|
+
kind: "external",
|
|
21197
|
+
pkg: found.pkg,
|
|
21198
|
+
steps: [step("external", `${m} is promoted from ${found.pkg.name}`)]
|
|
21199
|
+
};
|
|
21200
|
+
default:
|
|
21201
|
+
return { kind: "open", steps: [step(found.field ? "field" : "not-found", found.why)] };
|
|
21202
|
+
}
|
|
21203
|
+
};
|
|
21204
|
+
const fieldOf = (t, field) => {
|
|
21205
|
+
let level = [t];
|
|
21206
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21207
|
+
for (let depth = 0; depth < 8 && level.length; depth++) {
|
|
21208
|
+
const found = [];
|
|
21209
|
+
const next = [];
|
|
21210
|
+
for (const ref of level) {
|
|
21211
|
+
if (ref.kind !== "local") continue;
|
|
21212
|
+
const k = `${ref.key}\0${ref.name}`;
|
|
21213
|
+
if (seen.has(k)) continue;
|
|
21214
|
+
seen.add(k);
|
|
21215
|
+
const d = typeDecl(ref.files, ref.name);
|
|
21216
|
+
if (!d) continue;
|
|
21217
|
+
const mem = d.decl.members.find((x) => x.name === field && x.valueType);
|
|
21218
|
+
const base2 = d.decl.bases.find((b) => b.name.replace(/^.*\./, "") === field);
|
|
21219
|
+
if (mem?.valueType) found.push(typeIn(d.file, mem.valueType));
|
|
21220
|
+
else if (base2) found.push(typeIn(d.file, base2.name));
|
|
21221
|
+
else next.push(...d.decl.bases.map((b) => typeIn(d.file, b.name)));
|
|
21222
|
+
}
|
|
21223
|
+
if (found.length === 1) return found[0];
|
|
21224
|
+
if (found.length > 1) return { kind: "none" };
|
|
21225
|
+
level = next;
|
|
21226
|
+
}
|
|
21227
|
+
return { kind: "none" };
|
|
21228
|
+
};
|
|
21229
|
+
const throughFields = (t, fields) => {
|
|
21230
|
+
let cur = t;
|
|
21231
|
+
for (const field of fields) {
|
|
21232
|
+
if (cur.kind !== "local") return cur;
|
|
21233
|
+
cur = fieldOf(cur, field);
|
|
21234
|
+
}
|
|
21235
|
+
return cur;
|
|
21236
|
+
};
|
|
21237
|
+
const resultOf2 = (fn) => {
|
|
21238
|
+
const g = goFiles.get(fn.file);
|
|
21239
|
+
const def = g?.result.definitions.find((d) => d.qualifiedName === fn.qualifiedName);
|
|
21240
|
+
return g && def?.returns ? typeIn(g, def.returns) : { kind: "none" };
|
|
21241
|
+
};
|
|
21242
|
+
const named = (files, name, via, said) => {
|
|
21243
|
+
const fns = declared2(files, name);
|
|
21244
|
+
if (fns.length > 1)
|
|
21245
|
+
return {
|
|
21246
|
+
kind: "fns",
|
|
21247
|
+
fns,
|
|
21248
|
+
via,
|
|
21249
|
+
variants: true,
|
|
21250
|
+
steps: [step("variants", `${name} has a body per build variant`)]
|
|
21251
|
+
};
|
|
21252
|
+
if (fns.length === 1) return { kind: "fns", fns, via, steps: [step(via ?? "package", said)] };
|
|
21253
|
+
const value = varFunction(files, name);
|
|
21254
|
+
if (value) {
|
|
21255
|
+
const target2 = declared2(files, value);
|
|
21256
|
+
if (target2.length === 1)
|
|
21257
|
+
return {
|
|
21258
|
+
kind: "fns",
|
|
21259
|
+
fns: target2,
|
|
21260
|
+
via: "flow",
|
|
21261
|
+
steps: [step("flow", `${name} is a variable holding ${value}`)]
|
|
21262
|
+
};
|
|
21263
|
+
}
|
|
21264
|
+
if (typeDecl(files, name))
|
|
21265
|
+
return {
|
|
21266
|
+
kind: "open",
|
|
21267
|
+
steps: [step("not-a-function", `${name} is a type: ${name}(\u2026) converts to it, calling nothing`)]
|
|
21268
|
+
};
|
|
21269
|
+
return null;
|
|
21270
|
+
};
|
|
21271
|
+
const outcome = (site, raw, f) => {
|
|
21272
|
+
if (site.reason === "dynamic-dispatch") {
|
|
21273
|
+
if (raw.table) {
|
|
21274
|
+
const t = f.result.tables.find((x) => x.name === raw.table);
|
|
21275
|
+
const entries = (t?.entries ?? []).flatMap((e) => {
|
|
21276
|
+
const fn = e.function ? declared2([f], e.function)[0] : void 0;
|
|
21277
|
+
return fn ? [{ fn, basis: evidence(f.node.id, e.span) }] : [];
|
|
21278
|
+
});
|
|
21279
|
+
return entries.length ? {
|
|
21280
|
+
kind: "candidates",
|
|
21281
|
+
fns: entries.map((e) => e.fn),
|
|
21282
|
+
basis: entries.map((e) => e.basis),
|
|
21283
|
+
steps: [step("table", `${raw.table} is a map of functions; the call runs one of its values`)]
|
|
21284
|
+
} : null;
|
|
21285
|
+
}
|
|
21286
|
+
if (raw.receiverType && raw.member)
|
|
21287
|
+
return onType(
|
|
21288
|
+
typeIn(f, raw.receiverType),
|
|
21289
|
+
raw.member,
|
|
21290
|
+
// Another package's type (`helpers.Store`) is reached through its import.
|
|
21291
|
+
raw.receiverType.includes(".") ? "import" : "package",
|
|
21292
|
+
`${site.expression}'s receiver is a ${raw.receiverType}`
|
|
21293
|
+
);
|
|
21294
|
+
return null;
|
|
21295
|
+
}
|
|
21296
|
+
if (site.reason === "package-symbol") {
|
|
21297
|
+
const pkg = packageOf(f);
|
|
21298
|
+
if (raw.receiverType && raw.member) {
|
|
21299
|
+
const t = throughFields(typeIn(f, raw.receiverType), raw.through ?? []);
|
|
21300
|
+
return onType(
|
|
21301
|
+
t,
|
|
21302
|
+
raw.member,
|
|
21303
|
+
"package",
|
|
21304
|
+
`${site.expression} is on a ${raw.receiverType}${raw.through?.length ? `, through ${raw.through.join(".")}` : ""}`
|
|
21305
|
+
);
|
|
21306
|
+
}
|
|
21307
|
+
const name = raw.importedName;
|
|
21308
|
+
if (!name) return null;
|
|
21309
|
+
if (raw.member && raw.receiver === "returned") {
|
|
21310
|
+
const fns = declared2(pkg, name);
|
|
21311
|
+
if (fns.length !== 1)
|
|
21312
|
+
return { kind: "open", steps: [step("not-found", `${name} is not one function of the package`)] };
|
|
21313
|
+
return withVia(
|
|
21314
|
+
onType(
|
|
21315
|
+
throughFields(resultOf2(fns[0]), raw.through ?? []),
|
|
21316
|
+
raw.member,
|
|
21317
|
+
"returned",
|
|
21318
|
+
`${name} returns it`
|
|
21319
|
+
),
|
|
21320
|
+
"returned"
|
|
21321
|
+
);
|
|
21322
|
+
}
|
|
21323
|
+
if (raw.member) {
|
|
21324
|
+
const imp = importByName(f, name);
|
|
21325
|
+
if (imp) return throughImport(imp, raw.member, null, site);
|
|
21326
|
+
const v = packageVar(pkg, name);
|
|
21327
|
+
if (v?.written)
|
|
21328
|
+
return onType(typeIn(v.file, v.written), raw.member, "package", `${name} is a ${v.written}`);
|
|
21329
|
+
if (v)
|
|
21330
|
+
return {
|
|
21331
|
+
kind: "open",
|
|
21332
|
+
steps: [
|
|
21333
|
+
step(
|
|
21334
|
+
"untyped",
|
|
21335
|
+
`${name} is a package variable whose type isn't written: Stage 2 doesn't follow its value`
|
|
21336
|
+
)
|
|
21337
|
+
]
|
|
21338
|
+
};
|
|
21339
|
+
return { kind: "open", steps: [step("not-found", `${name} is not declared by the package`)] };
|
|
21340
|
+
}
|
|
21341
|
+
const own2 = named(pkg, name, "package", `${name} is declared by another file of the package`);
|
|
21342
|
+
if (own2) return own2;
|
|
21343
|
+
for (const imp of importsOf.get(f.node.id) ?? []) {
|
|
21344
|
+
if (imp.local !== "." || imp.target.kind !== "package") continue;
|
|
21345
|
+
const found = named(
|
|
21346
|
+
imp.target.files,
|
|
21347
|
+
name,
|
|
21348
|
+
"import",
|
|
21349
|
+
`${name} comes in with the dot import of ${imp.path}`
|
|
21350
|
+
);
|
|
21351
|
+
if (found) return found;
|
|
21352
|
+
}
|
|
21353
|
+
return { kind: "open", steps: [step("not-found", `no file of the package declares ${name}`)] };
|
|
21354
|
+
}
|
|
21355
|
+
if (site.reason === "imported-symbol" && raw.importSpecifier) {
|
|
21356
|
+
const imp = importByPath(f, raw.importSpecifier);
|
|
21357
|
+
if (!imp) return null;
|
|
21358
|
+
return throughImport(imp, raw.member ?? null, raw, site);
|
|
21359
|
+
}
|
|
21360
|
+
return null;
|
|
21361
|
+
};
|
|
21362
|
+
const withVia = (o, via) => o.kind === "fns" && !o.variants && o.via !== "inherited" ? { ...o, via } : o;
|
|
21363
|
+
const throughImport = (imp, member, raw, site) => {
|
|
21364
|
+
const head = step("import", `${site.expression} goes through the import of ${imp.path}`);
|
|
21365
|
+
const prefix = (o) => ({ ...o, steps: [head, ...o.steps] });
|
|
21366
|
+
if (imp.target.kind === "external")
|
|
21367
|
+
return prefix({ kind: "external", pkg: imp.target.pkg, steps: imp.target.steps });
|
|
21368
|
+
if (imp.target.kind === "broken")
|
|
21369
|
+
return prefix({ kind: "broken", reason: imp.target.reason, steps: imp.target.steps });
|
|
21370
|
+
const importer = goFiles.get(site.file);
|
|
21371
|
+
const files = importer?.test && importer.pkg.endsWith("_test") && imp.target.files[0]?.dir === importer.dir ? [...imp.target.files, ...(packages.get(imp.target.key) ?? []).filter((g) => g.test)] : imp.target.files;
|
|
21372
|
+
const key = imp.target.key;
|
|
21373
|
+
const name = raw?.importedName ?? null;
|
|
21374
|
+
if (!raw || !member || !raw.receiver) {
|
|
21375
|
+
const target2 = raw ? name : member;
|
|
21376
|
+
if (!target2) return prefix({ kind: "open", steps: [] });
|
|
21377
|
+
return prefix(
|
|
21378
|
+
named(files, target2, "import", `${target2} is declared by ${imp.path}`) ?? {
|
|
21379
|
+
kind: "open",
|
|
21380
|
+
steps: [step("not-found", `${imp.path} declares no function ${target2}`)]
|
|
21381
|
+
}
|
|
21382
|
+
);
|
|
21383
|
+
}
|
|
21384
|
+
if (raw.receiver === "returned") {
|
|
21385
|
+
const fns = declared2(files, name ?? "");
|
|
21386
|
+
if (fns.length !== 1)
|
|
21387
|
+
return prefix({
|
|
21388
|
+
kind: "open",
|
|
21389
|
+
steps: [step("not-found", `${imp.path} declares no function ${name}`)]
|
|
21390
|
+
});
|
|
21391
|
+
return prefix(
|
|
21392
|
+
withVia(
|
|
21393
|
+
onType(
|
|
21394
|
+
throughFields(resultOf2(fns[0]), raw.through ?? []),
|
|
21395
|
+
member,
|
|
21396
|
+
"returned",
|
|
21397
|
+
`${name} returns it`
|
|
21398
|
+
),
|
|
21399
|
+
"returned"
|
|
21400
|
+
)
|
|
21401
|
+
);
|
|
21402
|
+
}
|
|
21403
|
+
const t = throughFields({ kind: "local", files, key, name: name ?? "" }, raw.through ?? []);
|
|
21404
|
+
return prefix(onType(t, member, "import", `${site.expression} is on a ${name} of ${imp.path}`));
|
|
21405
|
+
};
|
|
21406
|
+
const resolutions = [];
|
|
21407
|
+
const edges = [];
|
|
21408
|
+
for (const site of input2.sites) {
|
|
21409
|
+
const f = goFiles.get(site.file);
|
|
21410
|
+
const raw = f ? resultsSite(site) : void 0;
|
|
21411
|
+
if (!f || !raw) continue;
|
|
21412
|
+
const o = outcome(site, raw, f);
|
|
21413
|
+
if (!o) continue;
|
|
21414
|
+
const base2 = {
|
|
21415
|
+
type: "SiteResolution",
|
|
21416
|
+
id: ids.resolution(site.id),
|
|
21417
|
+
site: site.id,
|
|
21418
|
+
file: site.file,
|
|
21419
|
+
evidence: site.evidence
|
|
21420
|
+
};
|
|
21421
|
+
if (o.kind === "fns" && o.fns.length === 1 && !o.variants) {
|
|
21422
|
+
const fn = o.fns[0];
|
|
21423
|
+
const via = o.via ?? "package";
|
|
21424
|
+
resolutions.push({
|
|
21425
|
+
...base2,
|
|
21426
|
+
status: "linked",
|
|
21427
|
+
target: fn.id,
|
|
21428
|
+
externalPackage: null,
|
|
21429
|
+
via,
|
|
21430
|
+
importOutcome: null,
|
|
21431
|
+
steps: o.steps
|
|
21432
|
+
});
|
|
21433
|
+
edges.push({
|
|
21434
|
+
type: "CALLS_CROSS_FILE",
|
|
21435
|
+
id: ids.linkedCall(site.id),
|
|
21436
|
+
from: site.enclosingFn,
|
|
21437
|
+
to: fn.id,
|
|
21438
|
+
form: "plain",
|
|
21439
|
+
resolution: "static-exact",
|
|
21440
|
+
confidence: 1,
|
|
21441
|
+
evidence: site.evidence,
|
|
21442
|
+
via: via === "returned" || via === "flow" ? via : via === "package" || via === "inherited" && site.reason === "package-symbol" ? "package" : "import"
|
|
21443
|
+
});
|
|
21444
|
+
} else if (o.kind === "fns" || o.kind === "candidates") {
|
|
21445
|
+
const variants = o.kind === "fns";
|
|
21446
|
+
resolutions.push({
|
|
21447
|
+
...base2,
|
|
21448
|
+
status: "unresolved",
|
|
21449
|
+
target: null,
|
|
21450
|
+
externalPackage: null,
|
|
21451
|
+
importOutcome: null,
|
|
21452
|
+
steps: o.steps,
|
|
21453
|
+
candidates: o.fns.map((fn, i) => ({
|
|
21454
|
+
function: fn.id,
|
|
21455
|
+
basis: variants ? variantBasis(fn) : (o.kind === "candidates" ? o.basis?.[i] : void 0) ?? fn.evidence
|
|
21456
|
+
})),
|
|
21457
|
+
...variants ? {} : { exhaustive: false }
|
|
21458
|
+
});
|
|
21459
|
+
} else if (o.kind === "runtime") {
|
|
21460
|
+
resolutions.push({
|
|
21461
|
+
...base2,
|
|
21462
|
+
status: "external",
|
|
21463
|
+
target: null,
|
|
21464
|
+
externalPackage: null,
|
|
21465
|
+
importOutcome: null,
|
|
21466
|
+
steps: o.steps
|
|
21467
|
+
});
|
|
21468
|
+
} else if (o.kind === "external") {
|
|
21469
|
+
resolutions.push({
|
|
21470
|
+
...base2,
|
|
21471
|
+
status: "external",
|
|
21472
|
+
target: null,
|
|
21473
|
+
externalPackage: o.pkg.id,
|
|
21474
|
+
importOutcome: null,
|
|
21475
|
+
steps: o.steps
|
|
21476
|
+
});
|
|
21477
|
+
} else if (o.kind === "broken") {
|
|
21478
|
+
resolutions.push({
|
|
21479
|
+
...base2,
|
|
21480
|
+
status: "unresolved",
|
|
21481
|
+
target: null,
|
|
21482
|
+
externalPackage: null,
|
|
21483
|
+
importOutcome: "broken",
|
|
21484
|
+
steps: o.steps
|
|
21485
|
+
});
|
|
21486
|
+
} else if (site.reason !== "dynamic-dispatch") {
|
|
21487
|
+
resolutions.push({
|
|
21488
|
+
...base2,
|
|
21489
|
+
status: "unresolved",
|
|
21490
|
+
target: null,
|
|
21491
|
+
externalPackage: null,
|
|
21492
|
+
importOutcome: null,
|
|
21493
|
+
steps: o.steps
|
|
21494
|
+
});
|
|
21495
|
+
}
|
|
21496
|
+
}
|
|
21497
|
+
const fnFile = new Map(input2.functions.map((fn) => [fn.id, fn.file]));
|
|
21498
|
+
const reached = /* @__PURE__ */ new Map();
|
|
21499
|
+
for (const r of resolutions) {
|
|
21500
|
+
const to = [r.target, ...(r.candidates ?? []).map((c) => c.function)].flatMap((id) => {
|
|
21501
|
+
const file2 = id ? fnFile.get(id) : void 0;
|
|
21502
|
+
return file2 ? [file2] : [];
|
|
21503
|
+
});
|
|
21504
|
+
if (!to.length) continue;
|
|
21505
|
+
let set2 = reached.get(r.file);
|
|
21506
|
+
if (!set2) reached.set(r.file, set2 = /* @__PURE__ */ new Set());
|
|
21507
|
+
for (const t of to) set2.add(t);
|
|
21508
|
+
}
|
|
21509
|
+
for (const { statement, target: target2, importer } of packageImports) {
|
|
21510
|
+
const from = goFiles.get(importer);
|
|
21511
|
+
const reachable = from?.test && from.pkg.endsWith("_test") && target2.files[0]?.dir === from.dir ? [...target2.files, ...(packages.get(target2.key) ?? []).filter((g) => g.test)] : target2.files;
|
|
21512
|
+
const used = reachable.filter((t) => reached.get(importer)?.has(t.node.id));
|
|
21513
|
+
for (const t of used.length ? used : target2.files)
|
|
21514
|
+
resolved.push({
|
|
21515
|
+
statement,
|
|
21516
|
+
target: { kind: "file", file: t.node, via: target2.via, steps: target2.steps, part: t.node.path }
|
|
21517
|
+
});
|
|
21518
|
+
}
|
|
21519
|
+
return { resolved, resolutions, edges };
|
|
21520
|
+
}
|
|
21521
|
+
function cmp10(a, b) {
|
|
21522
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
21523
|
+
}
|
|
21524
|
+
var step, GO_BUILTIN_TYPES, GOOS, GOARCH;
|
|
21525
|
+
var init_go = __esm({
|
|
21526
|
+
"packages/stage2/src/go.ts"() {
|
|
21527
|
+
"use strict";
|
|
21528
|
+
init_src();
|
|
21529
|
+
init_src3();
|
|
21530
|
+
init_protocol();
|
|
21531
|
+
init_imports();
|
|
21532
|
+
step = (kind, detail) => ({ kind, detail });
|
|
21533
|
+
GO_BUILTIN_TYPES = new Set(
|
|
21534
|
+
"any bool byte comparable complex64 complex128 error float32 float64 int int8 int16 int32 int64 rune string uint uint8 uint16 uint32 uint64 uintptr".split(
|
|
21535
|
+
" "
|
|
21536
|
+
)
|
|
21537
|
+
);
|
|
21538
|
+
GOOS = "aix android darwin dragonfly freebsd hurd illumos ios js linux nacl netbsd openbsd plan9 solaris wasip1 windows zos".split(
|
|
21539
|
+
" "
|
|
21540
|
+
);
|
|
21541
|
+
GOARCH = "386 amd64 arm arm64 loong64 mips mips64 mips64le mipsle ppc64 ppc64le riscv64 s390x sparc64 wasm".split(
|
|
21542
|
+
" "
|
|
21543
|
+
);
|
|
21544
|
+
}
|
|
21545
|
+
});
|
|
21546
|
+
|
|
21547
|
+
// packages/stage2/src/groups.ts
|
|
21548
|
+
import { posix as posix10 } from "node:path";
|
|
20504
21549
|
function groups(input2) {
|
|
20505
21550
|
const threshold = input2.clusterThreshold ?? DEFAULT_CLUSTER_THRESHOLD;
|
|
20506
21551
|
const fnFile = new Map(input2.functions.map((f) => [f.id, f.file]));
|
|
@@ -20512,25 +21557,34 @@ function groups(input2) {
|
|
|
20512
21557
|
const rootName = manifests.get("package.json")?.name;
|
|
20513
21558
|
const packages = [];
|
|
20514
21559
|
for (const [path, json2] of manifests) {
|
|
20515
|
-
if (
|
|
20516
|
-
const dir =
|
|
21560
|
+
if (posix10.basename(path) !== "package.json" || path === "package.json") continue;
|
|
21561
|
+
const dir = posix10.dirname(path);
|
|
20517
21562
|
const name = json2?.name;
|
|
20518
21563
|
if (typeof name === "string" && name && members2(dir)) packages.push({ dir, name });
|
|
20519
21564
|
}
|
|
20520
21565
|
const holds = (dir) => input2.files.some((f) => f.source === plan.sourceId && f.path.startsWith(`${dir}/`));
|
|
20521
21566
|
if (manifests.has("nx.json"))
|
|
20522
21567
|
for (const [path, json2] of manifests) {
|
|
20523
|
-
if (
|
|
20524
|
-
const dir =
|
|
21568
|
+
if (posix10.basename(path) !== "project.json" || path === "project.json") continue;
|
|
21569
|
+
const dir = posix10.dirname(path);
|
|
20525
21570
|
if (packages.some((p) => p.dir === dir) || !holds(dir)) continue;
|
|
20526
21571
|
const name = json2?.name;
|
|
20527
|
-
packages.push({ dir, name: typeof name === "string" && name ? name :
|
|
21572
|
+
packages.push({ dir, name: typeof name === "string" && name ? name : posix10.basename(dir) });
|
|
20528
21573
|
}
|
|
20529
|
-
|
|
21574
|
+
let goRoot = null;
|
|
21575
|
+
for (const m of plan.manifests) {
|
|
21576
|
+
if (posix10.basename(m.path) !== "go.mod" || goSkipsDir(m.path)) continue;
|
|
21577
|
+
const dir = posix10.dirname(m.path) === "." ? "" : posix10.dirname(m.path);
|
|
21578
|
+
const mod = parseGoMod(m.content, dir);
|
|
21579
|
+
if (!mod) continue;
|
|
21580
|
+
if (dir === "") goRoot = mod.path;
|
|
21581
|
+
else if (!packages.some((p) => p.dir === dir) && holds(dir)) packages.push({ dir, name: mod.path });
|
|
21582
|
+
}
|
|
21583
|
+
packages.sort((a, b) => b.dir.length - a.dir.length || cmp11(a.dir, b.dir));
|
|
20530
21584
|
const named = /* @__PURE__ */ new Map();
|
|
20531
21585
|
for (const p of packages) named.set(p.name, (named.get(p.name) ?? 0) + 1);
|
|
20532
21586
|
for (const p of packages) if (named.get(p.name) > 1) p.name = `${p.name} (${p.dir})`;
|
|
20533
|
-
const files = input2.files.filter((f) => f.source === plan.sourceId).sort((a, b) =>
|
|
21587
|
+
const files = input2.files.filter((f) => f.source === plan.sourceId).sort((a, b) => cmp11(a.path, b.path));
|
|
20534
21588
|
const boundaries = /* @__PURE__ */ new Map();
|
|
20535
21589
|
for (const f of files) {
|
|
20536
21590
|
const pkg = packages.find((p) => f.path.startsWith(`${p.dir}/`));
|
|
@@ -20539,7 +21593,7 @@ function groups(input2) {
|
|
|
20539
21593
|
if (!b) {
|
|
20540
21594
|
b = pkg ? { kind: "workspace-package", name: pkg.name, root: pkg.dir, files: [] } : {
|
|
20541
21595
|
kind: "repository",
|
|
20542
|
-
name: typeof rootName === "string" && rootName ? rootName : plan.sourceId,
|
|
21596
|
+
name: typeof rootName === "string" && rootName ? rootName : goRoot ?? plan.sourceId,
|
|
20543
21597
|
root: "",
|
|
20544
21598
|
files: []
|
|
20545
21599
|
};
|
|
@@ -20584,7 +21638,7 @@ function groups(input2) {
|
|
|
20584
21638
|
});
|
|
20585
21639
|
}
|
|
20586
21640
|
};
|
|
20587
|
-
for (const b of [...boundaries.values()].sort((x, y) =>
|
|
21641
|
+
for (const b of [...boundaries.values()].sort((x, y) => cmp11(x.root, y.root))) {
|
|
20588
21642
|
const units = b.kind === "repository" && packages.length === 0 ? folderUnits(b.files) : null;
|
|
20589
21643
|
const repo = { kind: "repository", name: b.name, root: b.root };
|
|
20590
21644
|
if (units) {
|
|
@@ -20657,7 +21711,7 @@ function folderUnits(files) {
|
|
|
20657
21711
|
list.push(f);
|
|
20658
21712
|
units.set(root, list);
|
|
20659
21713
|
}
|
|
20660
|
-
return [...units].map(([root, list]) => ({ root, files: list })).sort((a, b) =>
|
|
21714
|
+
return [...units].map(([root, list]) => ({ root, files: list })).sort((a, b) => cmp11(a.root, b.root));
|
|
20661
21715
|
}
|
|
20662
21716
|
function folderParts(files, root, threshold) {
|
|
20663
21717
|
if (files.length <= threshold) return [{ root, files }];
|
|
@@ -20674,7 +21728,7 @@ function folderParts(files, root, threshold) {
|
|
|
20674
21728
|
children.set(child, [...children.get(child) ?? [], f]);
|
|
20675
21729
|
}
|
|
20676
21730
|
}
|
|
20677
|
-
const large = [...children].filter(([, list]) => list.length >= min).sort(([a], [b]) =>
|
|
21731
|
+
const large = [...children].filter(([, list]) => list.length >= min).sort(([a], [b]) => cmp11(a, b));
|
|
20678
21732
|
if (large.length === 0) return [{ root, files, connect: true }];
|
|
20679
21733
|
const out = large.flatMap(([child, list]) => folderParts(list, child, threshold));
|
|
20680
21734
|
const big = new Set(large.map(([child]) => child));
|
|
@@ -20707,7 +21761,7 @@ function clusters(files, imports, calls, fnFile) {
|
|
|
20707
21761
|
});
|
|
20708
21762
|
let community = louvain(n2, edges);
|
|
20709
21763
|
const touched = new Set(edges.flatMap((e) => [e.a, e.b]));
|
|
20710
|
-
const dir = (i) =>
|
|
21764
|
+
const dir = (i) => posix10.dirname(files[i].path);
|
|
20711
21765
|
const folderCommunity = /* @__PURE__ */ new Map();
|
|
20712
21766
|
for (let i = 0; i < n2; i++)
|
|
20713
21767
|
if (touched.has(i) && !folderCommunity.has(dir(i))) folderCommunity.set(dir(i), community[i]);
|
|
@@ -20728,16 +21782,17 @@ function clusters(files, imports, calls, fnFile) {
|
|
|
20728
21782
|
});
|
|
20729
21783
|
return [...members2.values()].map(nameCluster).sort(byKey).map(disambiguate());
|
|
20730
21784
|
}
|
|
20731
|
-
var DEFAULT_CLUSTER_THRESHOLD,
|
|
21785
|
+
var DEFAULT_CLUSTER_THRESHOLD, cmp11;
|
|
20732
21786
|
var init_groups = __esm({
|
|
20733
21787
|
"packages/stage2/src/groups.ts"() {
|
|
20734
21788
|
"use strict";
|
|
20735
21789
|
init_src();
|
|
20736
21790
|
init_cluster();
|
|
21791
|
+
init_go();
|
|
20737
21792
|
init_imports();
|
|
20738
21793
|
init_cluster();
|
|
20739
21794
|
DEFAULT_CLUSTER_THRESHOLD = 200;
|
|
20740
|
-
|
|
21795
|
+
cmp11 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
20741
21796
|
}
|
|
20742
21797
|
});
|
|
20743
21798
|
|
|
@@ -21174,7 +22229,7 @@ function makeLinker(input2, graph = typeGraph(input2)) {
|
|
|
21174
22229
|
kind: "no-import",
|
|
21175
22230
|
steps: [{ kind: "not-found", detail: `no import of ${u.importSpecifier} in this file` }]
|
|
21176
22231
|
};
|
|
21177
|
-
if (u.receiver && u.member) {
|
|
22232
|
+
if (u.receiver && u.receiver !== "returned" && u.member) {
|
|
21178
22233
|
const cls = u.importedName ?? "default";
|
|
21179
22234
|
const found2 = classMember(statement, cls, u.member, u.receiver);
|
|
21180
22235
|
return {
|
|
@@ -22558,7 +23613,7 @@ var init_together = __esm({
|
|
|
22558
23613
|
});
|
|
22559
23614
|
|
|
22560
23615
|
// packages/stage2/src/python.ts
|
|
22561
|
-
import { posix as
|
|
23616
|
+
import { posix as posix11 } from "node:path";
|
|
22562
23617
|
function pythonProject(plan, forPath) {
|
|
22563
23618
|
const roots = /* @__PURE__ */ new Set();
|
|
22564
23619
|
const dependencies = /* @__PURE__ */ new Set();
|
|
@@ -22568,10 +23623,10 @@ function pythonProject(plan, forPath) {
|
|
|
22568
23623
|
if (name) dependencies.add(normalize(name));
|
|
22569
23624
|
};
|
|
22570
23625
|
for (const m of plan.manifests) {
|
|
22571
|
-
const base2 =
|
|
22572
|
-
const dir =
|
|
23626
|
+
const base2 = posix11.basename(m.path);
|
|
23627
|
+
const dir = posix11.dirname(m.path) === "." ? "" : posix11.dirname(m.path);
|
|
22573
23628
|
if (forPath !== void 0 && dir && !forPath.startsWith(`${dir}/`)) continue;
|
|
22574
|
-
const at = (p) =>
|
|
23629
|
+
const at = (p) => posix11.normalize(posix11.join(dir, p)).replace(/^\.\/?$/, "").replace(/\/$/, "");
|
|
22575
23630
|
if (base2 === "pyproject.toml") {
|
|
22576
23631
|
roots.add(dir);
|
|
22577
23632
|
let section = "";
|
|
@@ -22581,14 +23636,14 @@ function pythonProject(plan, forPath) {
|
|
|
22581
23636
|
else if (kind === "roots") for (const s of quoted(value)) roots.add(at(s));
|
|
22582
23637
|
else if (kind === "poetry")
|
|
22583
23638
|
for (const from of value.matchAll(/from\s*=\s*["']([^"']+)["']/g)) roots.add(at(from[1]));
|
|
22584
|
-
else if (kind === "hatch") for (const s of quoted(value)) roots.add(at(
|
|
23639
|
+
else if (kind === "hatch") for (const s of quoted(value)) roots.add(at(posix11.dirname(s)));
|
|
22585
23640
|
};
|
|
22586
23641
|
for (const raw of m.content.split("\n")) {
|
|
22587
23642
|
const line = raw.replace(/\s+#.*$/, "").trim();
|
|
22588
23643
|
if (!line) continue;
|
|
22589
|
-
const
|
|
22590
|
-
if (
|
|
22591
|
-
section =
|
|
23644
|
+
const header2 = /^\[\[?([^\]]+)\]\]?$/.exec(line);
|
|
23645
|
+
if (header2) {
|
|
23646
|
+
section = header2[1].trim();
|
|
22592
23647
|
inArray = null;
|
|
22593
23648
|
continue;
|
|
22594
23649
|
}
|
|
@@ -22620,9 +23675,9 @@ function pythonProject(plan, forPath) {
|
|
|
22620
23675
|
let section = "";
|
|
22621
23676
|
let key = "";
|
|
22622
23677
|
for (const raw of m.content.split("\n")) {
|
|
22623
|
-
const
|
|
22624
|
-
if (
|
|
22625
|
-
section =
|
|
23678
|
+
const header2 = /^\s*\[([^\]]+)\]/.exec(raw);
|
|
23679
|
+
if (header2) {
|
|
23680
|
+
section = header2[1].trim();
|
|
22626
23681
|
key = "";
|
|
22627
23682
|
continue;
|
|
22628
23683
|
}
|
|
@@ -22688,7 +23743,7 @@ function moduleIndex(paths) {
|
|
|
22688
23743
|
const files = new Set(paths.filter(isPython));
|
|
22689
23744
|
const dirs = /* @__PURE__ */ new Set();
|
|
22690
23745
|
for (const p of files)
|
|
22691
|
-
for (let d =
|
|
23746
|
+
for (let d = posix11.dirname(p); d !== "." && d !== ""; d = posix11.dirname(d)) dirs.add(d);
|
|
22692
23747
|
return { files, dirs };
|
|
22693
23748
|
}
|
|
22694
23749
|
function moduleFile(index, path) {
|
|
@@ -22786,7 +23841,7 @@ function resolvePythonImports(plans, files, results) {
|
|
|
22786
23841
|
const index = moduleIndex(fileNodes.map((f) => f.path));
|
|
22787
23842
|
const projects = /* @__PURE__ */ new Map();
|
|
22788
23843
|
const manifestDirs = [
|
|
22789
|
-
...new Set(plan.manifests.map((m) =>
|
|
23844
|
+
...new Set(plan.manifests.map((m) => posix11.dirname(m.path) === "." ? "" : posix11.dirname(m.path)))
|
|
22790
23845
|
];
|
|
22791
23846
|
const projectFor = (path) => {
|
|
22792
23847
|
const key = manifestDirs.filter((d) => !d || path.startsWith(`${d}/`)).join("\0");
|
|
@@ -22797,7 +23852,7 @@ function resolvePythonImports(plans, files, results) {
|
|
|
22797
23852
|
let project2 = projectFor("");
|
|
22798
23853
|
const text = new Map(plan.files.filter((f) => f.content !== void 0).map((f) => [f.path, f.content]));
|
|
22799
23854
|
const pathIn = (root, dotted) => {
|
|
22800
|
-
const p =
|
|
23855
|
+
const p = posix11.join(root, ...dotted.split("."));
|
|
22801
23856
|
return p === "." ? "" : p;
|
|
22802
23857
|
};
|
|
22803
23858
|
const absoluteFile = (dotted) => {
|
|
@@ -22825,7 +23880,7 @@ function resolvePythonImports(plans, files, results) {
|
|
|
22825
23880
|
if (!isFrom) {
|
|
22826
23881
|
const local = s.bindings[0]?.[1];
|
|
22827
23882
|
if (local) folders.set(`${fileId}\0${local}`, dir);
|
|
22828
|
-
const first = [...index.files].filter((p) =>
|
|
23883
|
+
const first = [...index.files].filter((p) => posix11.dirname(p) === dir).sort()[0];
|
|
22829
23884
|
return first ? toFile(first, "absolute") : {
|
|
22830
23885
|
kind: "unresolved",
|
|
22831
23886
|
outcome: "broken",
|
|
@@ -22920,9 +23975,9 @@ function resolvePythonImports(plans, files, results) {
|
|
|
22920
23975
|
if (s.specifier.startsWith(".")) {
|
|
22921
23976
|
const level = /^\.+/.exec(s.specifier)[0].length;
|
|
22922
23977
|
const rest = s.specifier.slice(level);
|
|
22923
|
-
let dir =
|
|
22924
|
-
for (let i = 1; i < level; i++) dir =
|
|
22925
|
-
const path = rest ?
|
|
23978
|
+
let dir = posix11.dirname(f.path) === "." ? "" : posix11.dirname(f.path);
|
|
23979
|
+
for (let i = 1; i < level; i++) dir = posix11.dirname(dir) === "." ? "" : posix11.dirname(dir);
|
|
23980
|
+
const path = rest ? posix11.join(dir, ...rest.split(".")) : dir;
|
|
22926
23981
|
steps.push({ kind: "relative", detail: `${s.specifier} from ${f.path} is ${path || "the root"}` });
|
|
22927
23982
|
const file2 = moduleFile(index, path);
|
|
22928
23983
|
if (file2)
|
|
@@ -23025,12 +24080,12 @@ function linkPython(input2) {
|
|
|
23025
24080
|
allOf.set(fileId, names);
|
|
23026
24081
|
return names;
|
|
23027
24082
|
};
|
|
23028
|
-
const
|
|
24083
|
+
const step2 = (kind, detail) => ({ kind, detail });
|
|
23029
24084
|
const missing = (stop, detail, hops = [], steps = []) => ({
|
|
23030
24085
|
kind: "missing",
|
|
23031
24086
|
stop,
|
|
23032
24087
|
hops,
|
|
23033
|
-
steps: [...steps,
|
|
24088
|
+
steps: [...steps, step2(stop, detail)]
|
|
23034
24089
|
});
|
|
23035
24090
|
const variables = /* @__PURE__ */ new Map();
|
|
23036
24091
|
const variable = (fileId, name) => {
|
|
@@ -23049,7 +24104,7 @@ function linkPython(input2) {
|
|
|
23049
24104
|
kind: "module",
|
|
23050
24105
|
file: pkg.id,
|
|
23051
24106
|
hops,
|
|
23052
|
-
steps: [
|
|
24107
|
+
steps: [step2("package", `${name} is the package ${pkg.path}`)]
|
|
23053
24108
|
};
|
|
23054
24109
|
const dir = input2.imports.folders.get(key);
|
|
23055
24110
|
if (dir !== void 0)
|
|
@@ -23058,7 +24113,7 @@ function linkPython(input2) {
|
|
|
23058
24113
|
source: sourceOf7(fileId),
|
|
23059
24114
|
dir,
|
|
23060
24115
|
hops,
|
|
23061
|
-
steps: [
|
|
24116
|
+
steps: [step2("namespace", `${name} is the namespace package ${dir || "at the root"}`)]
|
|
23062
24117
|
};
|
|
23063
24118
|
return null;
|
|
23064
24119
|
};
|
|
@@ -23070,7 +24125,7 @@ function linkPython(input2) {
|
|
|
23070
24125
|
kind: "module",
|
|
23071
24126
|
file: `${source}:${candidate}`,
|
|
23072
24127
|
hops,
|
|
23073
|
-
steps: [
|
|
24128
|
+
steps: [step2("submodule", `${name} is the submodule ${candidate}`)]
|
|
23074
24129
|
};
|
|
23075
24130
|
}
|
|
23076
24131
|
return missing("not-exported", `${dir || "the root"} has no module ${name}`, hops);
|
|
@@ -23091,14 +24146,14 @@ function linkPython(input2) {
|
|
|
23091
24146
|
}
|
|
23092
24147
|
const fn = fnByName.get(`${fileId}\0${name}`);
|
|
23093
24148
|
if (fn)
|
|
23094
|
-
return { kind: "function", fn: fn.id, hops, steps: [
|
|
24149
|
+
return { kind: "function", fn: fn.id, hops, steps: [step2("definition", `${path} defines ${name}`)] };
|
|
23095
24150
|
if (result2.types.some((t) => t.name === name))
|
|
23096
24151
|
return {
|
|
23097
24152
|
kind: "class",
|
|
23098
24153
|
file: fileId,
|
|
23099
24154
|
name,
|
|
23100
24155
|
hops,
|
|
23101
|
-
steps: [
|
|
24156
|
+
steps: [step2("definition", `${path} defines the class ${name}`)]
|
|
23102
24157
|
};
|
|
23103
24158
|
const value = variable(fileId, name);
|
|
23104
24159
|
if (value !== null)
|
|
@@ -23108,7 +24163,7 @@ function linkPython(input2) {
|
|
|
23108
24163
|
name,
|
|
23109
24164
|
cls: value,
|
|
23110
24165
|
hops,
|
|
23111
|
-
steps: [
|
|
24166
|
+
steps: [step2("value", `${path} assigns ${name}${value ? ` (${value})` : ""}`)]
|
|
23112
24167
|
};
|
|
23113
24168
|
if (hops.includes(fileId)) return missing("cycle", `${path} imports ${name} in a cycle`, hops);
|
|
23114
24169
|
const statements2 = statementsOf.get(fileId) ?? [];
|
|
@@ -23116,7 +24171,7 @@ function linkPython(input2) {
|
|
|
23116
24171
|
const binding2 = r.statement.bindings.find(([, local]) => local === name);
|
|
23117
24172
|
if (!binding2) continue;
|
|
23118
24173
|
const imported = binding2[0];
|
|
23119
|
-
const via =
|
|
24174
|
+
const via = step2("re-export", `${path} imports ${name} from ${r.statement.specifier}`);
|
|
23120
24175
|
if (imported === "*") {
|
|
23121
24176
|
const ns = bindingAsModule(r);
|
|
23122
24177
|
if (ns.kind === "folder") return { ...ns, hops };
|
|
@@ -23136,13 +24191,13 @@ function linkPython(input2) {
|
|
|
23136
24191
|
if (e.kind !== "missing")
|
|
23137
24192
|
return {
|
|
23138
24193
|
...e,
|
|
23139
|
-
steps: [
|
|
24194
|
+
steps: [step2("re-export", `${path} imports everything from ${r.statement.specifier}`), ...e.steps]
|
|
23140
24195
|
};
|
|
23141
24196
|
}
|
|
23142
24197
|
const bound = boundName(fileId, name, hops);
|
|
23143
24198
|
if (bound) return bound;
|
|
23144
24199
|
if (path.endsWith("__init__.py")) {
|
|
23145
|
-
const dir =
|
|
24200
|
+
const dir = posix11.dirname(path);
|
|
23146
24201
|
const base2 = dir === "." ? "" : `${dir}/`;
|
|
23147
24202
|
for (const candidate of [`${base2}${name}.py`, `${base2}${name}/__init__.py`]) {
|
|
23148
24203
|
const id = `${sourceOf7(fileId)}:${candidate}`;
|
|
@@ -23151,7 +24206,7 @@ function linkPython(input2) {
|
|
|
23151
24206
|
kind: "module",
|
|
23152
24207
|
file: id,
|
|
23153
24208
|
hops,
|
|
23154
|
-
steps: [
|
|
24209
|
+
steps: [step2("submodule", `${name} is the submodule ${candidate}`)]
|
|
23155
24210
|
};
|
|
23156
24211
|
}
|
|
23157
24212
|
}
|
|
@@ -23204,7 +24259,7 @@ function linkPython(input2) {
|
|
|
23204
24259
|
source: sourceOf7(r.statement.fileId),
|
|
23205
24260
|
dir: ns,
|
|
23206
24261
|
hops: [],
|
|
23207
|
-
steps: [
|
|
24262
|
+
steps: [step2("namespace", `${local} is the namespace package ${ns || "at the root"}`)]
|
|
23208
24263
|
};
|
|
23209
24264
|
const t = r.target;
|
|
23210
24265
|
if (t.kind === "package") return { kind: "external", pkg: t.pkg.id, hops: [], steps: [...t.steps] };
|
|
@@ -23331,7 +24386,7 @@ function linkPython(input2) {
|
|
|
23331
24386
|
kind: "function",
|
|
23332
24387
|
fn: found.fn.id,
|
|
23333
24388
|
hops: e.hops,
|
|
23334
|
-
steps: [...e.steps,
|
|
24389
|
+
steps: [...e.steps, step2("instance", `${e.name}'s ${m} is ${found.fn.qualifiedName}`)]
|
|
23335
24390
|
} : found && "pkg" in found ? { kind: "external", pkg: found.pkg, hops: e.hops, steps: e.steps } : missing("member", `no class up ${e.name}'s chain declares ${m}`, e.hops, e.steps);
|
|
23336
24391
|
};
|
|
23337
24392
|
const classNamed = (fileId, name) => {
|
|
@@ -23369,7 +24424,7 @@ function linkPython(input2) {
|
|
|
23369
24424
|
target: null,
|
|
23370
24425
|
externalPackage: null,
|
|
23371
24426
|
importOutcome: null,
|
|
23372
|
-
steps: [
|
|
24427
|
+
steps: [step2("table", `${table} is a dict of functions; the call runs one of its values`)],
|
|
23373
24428
|
candidates,
|
|
23374
24429
|
...t.exhaustive ? {} : { exhaustive: false }
|
|
23375
24430
|
});
|
|
@@ -23390,7 +24445,7 @@ function linkPython(input2) {
|
|
|
23390
24445
|
target: null,
|
|
23391
24446
|
externalPackage: null,
|
|
23392
24447
|
importOutcome: null,
|
|
23393
|
-
steps: [
|
|
24448
|
+
steps: [step2("typed", `${site.expression}'s receiver is annotated ${raw.receiverType}`)],
|
|
23394
24449
|
candidates: found.map((x) => ({ function: x.fn.id, basis: x.basis })),
|
|
23395
24450
|
exhaustive: false
|
|
23396
24451
|
});
|
|
@@ -23470,7 +24525,7 @@ function linkPython(input2) {
|
|
|
23470
24525
|
kind: "function",
|
|
23471
24526
|
fn: ctor.id,
|
|
23472
24527
|
hops: e.hops,
|
|
23473
|
-
steps: [...e.steps,
|
|
24528
|
+
steps: [...e.steps, step2("constructor", `calling ${e.name} runs ${ctor.qualifiedName}`)]
|
|
23474
24529
|
} : missing("not-a-function", `${e.name} has no constructor Stage 2 can follow`, e.hops, e.steps);
|
|
23475
24530
|
} else if (e.kind === "module" || e.kind === "folder")
|
|
23476
24531
|
e = missing("not-a-function", `${site.expression} is a module`, e.hops, e.steps);
|
|
@@ -23484,7 +24539,7 @@ function linkPython(input2) {
|
|
|
23484
24539
|
}
|
|
23485
24540
|
const via = inherited ? "inherited" : "import";
|
|
23486
24541
|
e = withSteps(e, [
|
|
23487
|
-
|
|
24542
|
+
step2(
|
|
23488
24543
|
"import",
|
|
23489
24544
|
inherited ? `${site.expression} reaches ${site.importedName}, a base imported from ${site.importSpecifier}` : `${site.expression} goes through the import of ${site.importSpecifier}`
|
|
23490
24545
|
)
|
|
@@ -23669,7 +24724,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23669
24724
|
if (scope2) scopes.add(scope2);
|
|
23670
24725
|
}
|
|
23671
24726
|
const files = view.facts("File");
|
|
23672
|
-
const
|
|
24727
|
+
const step2 = async (n2, phase, count2, unit) => {
|
|
23673
24728
|
if (!ctx.progress) return;
|
|
23674
24729
|
ctx.progress({ phase, step: n2, steps: STEPS, ...count2 ? { total: count2(), unit } : {} });
|
|
23675
24730
|
await breathe();
|
|
@@ -23683,18 +24738,31 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23683
24738
|
scopes.add(linksScope(f.id));
|
|
23684
24739
|
scopes.add(symbolsScope(f.id));
|
|
23685
24740
|
}
|
|
23686
|
-
await
|
|
24741
|
+
await step2(1, "resolving imports", () => files.length, "files");
|
|
23687
24742
|
const { resolved, results } = resolveImports2(ctx.plans, files);
|
|
23688
24743
|
const pyResults = pythonResults(ctx.plans);
|
|
23689
24744
|
const pyImports = resolvePythonImports(ctx.plans, files, pyResults);
|
|
23690
|
-
const { edges, unresolved, packages } = importFacts([...resolved, ...pyImports.resolved]);
|
|
23691
24745
|
const pyFiles = new Set(files.filter((f) => f.language === "python").map((f) => f.id));
|
|
24746
|
+
const goFiles = new Set(files.filter((f) => f.language === "go").map((f) => f.id));
|
|
23692
24747
|
const allSites = view.facts("UnresolvedCallSite");
|
|
24748
|
+
const goLinked = linkGo({
|
|
24749
|
+
plans: ctx.plans,
|
|
24750
|
+
files,
|
|
24751
|
+
results: goResults(ctx.plans),
|
|
24752
|
+
functions: view.facts("Function"),
|
|
24753
|
+
sites: allSites.filter((s) => goFiles.has(s.file)),
|
|
24754
|
+
revisions: new Map(ctx.plans.map((p) => [p.sourceId, p.revision]))
|
|
24755
|
+
});
|
|
24756
|
+
const { edges, unresolved, packages } = importFacts([
|
|
24757
|
+
...resolved,
|
|
24758
|
+
...pyImports.resolved,
|
|
24759
|
+
...goLinked.resolved
|
|
24760
|
+
]);
|
|
23693
24761
|
const linkInput = {
|
|
23694
24762
|
resolved,
|
|
23695
24763
|
results,
|
|
23696
24764
|
functions: view.facts("Function"),
|
|
23697
|
-
sites: allSites.filter((s) => !pyFiles.has(s.file)),
|
|
24765
|
+
sites: allSites.filter((s) => !pyFiles.has(s.file) && !goFiles.has(s.file)),
|
|
23698
24766
|
revisions: new Map(ctx.plans.map((p) => [p.sourceId, p.revision]))
|
|
23699
24767
|
};
|
|
23700
24768
|
const pyText = new Map(
|
|
@@ -23710,7 +24778,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23710
24778
|
revisions: linkInput.revisions,
|
|
23711
24779
|
text: (id) => pyText.get(id)
|
|
23712
24780
|
});
|
|
23713
|
-
await
|
|
24781
|
+
await step2(2, "linking calls", () => linkInput.sites.length, "call sites");
|
|
23714
24782
|
const graph = typeGraph(linkInput);
|
|
23715
24783
|
const linked = link(linkInput, graph);
|
|
23716
24784
|
const linker = makeLinker(linkInput, graph);
|
|
@@ -23728,7 +24796,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23728
24796
|
templates: view.facts("DeclaredTemplate"),
|
|
23729
24797
|
revisions: new Map(ctx.plans.map((p) => [p.sourceId, p.revision]))
|
|
23730
24798
|
});
|
|
23731
|
-
await
|
|
24799
|
+
await step2(3, "typing calls with the TypeScript checker");
|
|
23732
24800
|
const program = scripts({
|
|
23733
24801
|
files,
|
|
23734
24802
|
text: (f) => ctx.evidence.get(f.contentHash),
|
|
@@ -23808,7 +24876,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23808
24876
|
const closedById = new Map(closedOut.resolutions.map((r) => [r.id, r]));
|
|
23809
24877
|
settledNarrowed = settledNarrowed.map((r) => closedById.get(r.id) ?? r);
|
|
23810
24878
|
typed.resolutions = typed.resolutions.map((r) => closedById.get(r.id) ?? r);
|
|
23811
|
-
await
|
|
24879
|
+
await step2(4, "naming where paths leave the project");
|
|
23812
24880
|
const fnIds = new Set(linkInput.functions.map((f) => f.id));
|
|
23813
24881
|
const named = exits(
|
|
23814
24882
|
{
|
|
@@ -23828,7 +24896,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23828
24896
|
},
|
|
23829
24897
|
program
|
|
23830
24898
|
);
|
|
23831
|
-
await
|
|
24899
|
+
await step2(5, "grouping files");
|
|
23832
24900
|
const map2 = groups({
|
|
23833
24901
|
plans: ctx.plans,
|
|
23834
24902
|
files,
|
|
@@ -23838,6 +24906,7 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23838
24906
|
calls: [
|
|
23839
24907
|
...linked.edges,
|
|
23840
24908
|
...pyLinked.edges,
|
|
24909
|
+
...goLinked.edges,
|
|
23841
24910
|
...typed.edges,
|
|
23842
24911
|
...injected.edges,
|
|
23843
24912
|
...returned.edges,
|
|
@@ -23867,6 +24936,8 @@ async function runStage2(ctx, options2 = {}) {
|
|
|
23867
24936
|
...named.resolutions,
|
|
23868
24937
|
...pyLinked.resolutions,
|
|
23869
24938
|
...pyLinked.edges,
|
|
24939
|
+
...goLinked.resolutions,
|
|
24940
|
+
...goLinked.edges,
|
|
23870
24941
|
...typed.edges,
|
|
23871
24942
|
...injected.edges,
|
|
23872
24943
|
...returned.edges,
|
|
@@ -23912,6 +24983,7 @@ var init_src8 = __esm({
|
|
|
23912
24983
|
init_types();
|
|
23913
24984
|
init_typegraph();
|
|
23914
24985
|
init_together();
|
|
24986
|
+
init_go();
|
|
23915
24987
|
init_python();
|
|
23916
24988
|
init_imports();
|
|
23917
24989
|
init_link();
|
|
@@ -23926,7 +24998,7 @@ var init_src8 = __esm({
|
|
|
23926
24998
|
symbolsScope = (fileId) => `${STAGE23}:symbols:${fileId}`;
|
|
23927
24999
|
groupSource = (groupId) => groupId.split("|")[1];
|
|
23928
25000
|
STEPS = 5;
|
|
23929
|
-
STAGE2_VERSION =
|
|
25001
|
+
STAGE2_VERSION = 12;
|
|
23930
25002
|
stage2 = createStage2();
|
|
23931
25003
|
}
|
|
23932
25004
|
});
|
|
@@ -24517,10 +25589,10 @@ function isValidJWT(jwt2, alg) {
|
|
|
24517
25589
|
if (!jwtRegex.test(jwt2))
|
|
24518
25590
|
return false;
|
|
24519
25591
|
try {
|
|
24520
|
-
const [
|
|
24521
|
-
if (!
|
|
25592
|
+
const [header2] = jwt2.split(".");
|
|
25593
|
+
if (!header2)
|
|
24522
25594
|
return false;
|
|
24523
|
-
const base643 =
|
|
25595
|
+
const base643 = header2.replace(/-/g, "+").replace(/_/g, "/").padEnd(header2.length + (4 - header2.length % 4) % 4, "=");
|
|
24524
25596
|
const decoded = JSON.parse(atob(base643));
|
|
24525
25597
|
if (typeof decoded !== "object" || decoded === null)
|
|
24526
25598
|
return false;
|
|
@@ -24544,12 +25616,12 @@ function isValidCidr(ip, version3) {
|
|
|
24544
25616
|
}
|
|
24545
25617
|
return false;
|
|
24546
25618
|
}
|
|
24547
|
-
function floatSafeRemainder(val,
|
|
25619
|
+
function floatSafeRemainder(val, step2) {
|
|
24548
25620
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
24549
|
-
const stepDecCount = (
|
|
25621
|
+
const stepDecCount = (step2.toString().split(".")[1] || "").length;
|
|
24550
25622
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
24551
25623
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
24552
|
-
const stepInt = Number.parseInt(
|
|
25624
|
+
const stepInt = Number.parseInt(step2.toFixed(decCount).replace(".", ""));
|
|
24553
25625
|
return valInt % stepInt / 10 ** decCount;
|
|
24554
25626
|
}
|
|
24555
25627
|
function deepPartialify(schema) {
|
|
@@ -28011,8 +29083,8 @@ function cleanRegex(source) {
|
|
|
28011
29083
|
const end2 = source.endsWith("$") ? source.length - 1 : source.length;
|
|
28012
29084
|
return source.slice(start, end2);
|
|
28013
29085
|
}
|
|
28014
|
-
function floatSafeRemainder2(val,
|
|
28015
|
-
const ratio = val /
|
|
29086
|
+
function floatSafeRemainder2(val, step2) {
|
|
29087
|
+
const ratio = val / step2;
|
|
28016
29088
|
const roundedRatio = Math.round(ratio);
|
|
28017
29089
|
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
28018
29090
|
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
@@ -30096,10 +31168,10 @@ function isValidJWT2(token, algorithm = null) {
|
|
|
30096
31168
|
const tokensParts = token.split(".");
|
|
30097
31169
|
if (tokensParts.length !== 3)
|
|
30098
31170
|
return false;
|
|
30099
|
-
const [
|
|
30100
|
-
if (!
|
|
31171
|
+
const [header2] = tokensParts;
|
|
31172
|
+
if (!header2)
|
|
30101
31173
|
return false;
|
|
30102
|
-
const parsedHeader = JSON.parse(atob(
|
|
31174
|
+
const parsedHeader = JSON.parse(atob(header2));
|
|
30103
31175
|
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
30104
31176
|
return false;
|
|
30105
31177
|
if (!parsedHeader.alg)
|
|
@@ -67319,23 +68391,23 @@ var require_accept_negotiator = __commonJS({
|
|
|
67319
68391
|
this.supportedValues = supportedValues;
|
|
67320
68392
|
this.cache = cache;
|
|
67321
68393
|
}
|
|
67322
|
-
Negotiator.prototype.negotiate = function(
|
|
67323
|
-
if (typeof
|
|
68394
|
+
Negotiator.prototype.negotiate = function(header2) {
|
|
68395
|
+
if (typeof header2 !== "string") {
|
|
67324
68396
|
return null;
|
|
67325
68397
|
}
|
|
67326
68398
|
if (!this.cache) {
|
|
67327
|
-
return negotiate(
|
|
68399
|
+
return negotiate(header2, this.supportedValues);
|
|
67328
68400
|
}
|
|
67329
|
-
if (!this.cache.has(
|
|
67330
|
-
this.cache.set(
|
|
68401
|
+
if (!this.cache.has(header2)) {
|
|
68402
|
+
this.cache.set(header2, negotiate(header2, this.supportedValues));
|
|
67331
68403
|
}
|
|
67332
|
-
return this.cache.get(
|
|
68404
|
+
return this.cache.get(header2);
|
|
67333
68405
|
};
|
|
67334
|
-
function negotiate(
|
|
67335
|
-
if (!
|
|
68406
|
+
function negotiate(header2, supportedValues) {
|
|
68407
|
+
if (!header2 || !Array.isArray(supportedValues) || supportedValues.length === 0) {
|
|
67336
68408
|
return null;
|
|
67337
68409
|
}
|
|
67338
|
-
if (
|
|
68410
|
+
if (header2 === "*") {
|
|
67339
68411
|
return supportedValues[0];
|
|
67340
68412
|
}
|
|
67341
68413
|
let preferredEncoding = null;
|
|
@@ -67364,19 +68436,19 @@ var require_accept_negotiator = __commonJS({
|
|
|
67364
68436
|
}
|
|
67365
68437
|
return false;
|
|
67366
68438
|
}
|
|
67367
|
-
parse5(
|
|
68439
|
+
parse5(header2, processMatch);
|
|
67368
68440
|
return preferredEncoding;
|
|
67369
68441
|
}
|
|
67370
68442
|
var BEGIN = 0;
|
|
67371
68443
|
var TOKEN = 1;
|
|
67372
68444
|
var QUALITY = 2;
|
|
67373
68445
|
var END = 3;
|
|
67374
|
-
function parse5(
|
|
68446
|
+
function parse5(header2, processMatch) {
|
|
67375
68447
|
let str3 = "";
|
|
67376
68448
|
let quality;
|
|
67377
68449
|
let state = BEGIN;
|
|
67378
|
-
for (let i = 0, il =
|
|
67379
|
-
const char =
|
|
68450
|
+
for (let i = 0, il = header2.length; i < il; ++i) {
|
|
68451
|
+
const char = header2[i];
|
|
67380
68452
|
if (char === " " || char === " ") {
|
|
67381
68453
|
continue;
|
|
67382
68454
|
} else if (char === ";") {
|
|
@@ -67416,7 +68488,7 @@ var require_accept_negotiator = __commonJS({
|
|
|
67416
68488
|
continue;
|
|
67417
68489
|
}
|
|
67418
68490
|
if (state === TOKEN) {
|
|
67419
|
-
const prevChar =
|
|
68491
|
+
const prevChar = header2[i - 1];
|
|
67420
68492
|
if (prevChar === " " || prevChar === " ") {
|
|
67421
68493
|
str3 = "";
|
|
67422
68494
|
}
|
|
@@ -67458,43 +68530,43 @@ function create(filename, options2) {
|
|
|
67458
68530
|
const parameters = createParameters(filename, options2?.fallback);
|
|
67459
68531
|
return format({ type, parameters }, { extended: false });
|
|
67460
68532
|
}
|
|
67461
|
-
function parse4(
|
|
67462
|
-
const len =
|
|
68533
|
+
function parse4(header2, options2) {
|
|
68534
|
+
const len = header2.length;
|
|
67463
68535
|
const multipart = options2?.multipart === true;
|
|
67464
68536
|
const extended2 = options2?.extended !== false;
|
|
67465
|
-
let index = skipOWS(
|
|
68537
|
+
let index = skipOWS(header2, 0, header2.length);
|
|
67466
68538
|
const typeStart = index;
|
|
67467
|
-
index = parseToken(
|
|
67468
|
-
const typeEnd = trailingOWS(
|
|
67469
|
-
const type =
|
|
68539
|
+
index = parseToken(header2, index, len);
|
|
68540
|
+
const typeEnd = trailingOWS(header2, typeStart, index);
|
|
68541
|
+
const type = header2.slice(typeStart, typeEnd).toLowerCase();
|
|
67470
68542
|
const parameters = new NullObject();
|
|
67471
68543
|
parameter: while (index < len) {
|
|
67472
|
-
index = skipOWS(
|
|
68544
|
+
index = skipOWS(header2, index + 1, len);
|
|
67473
68545
|
const keyStart = index;
|
|
67474
68546
|
while (index < len) {
|
|
67475
|
-
const char =
|
|
68547
|
+
const char = header2.charCodeAt(index);
|
|
67476
68548
|
if (char === SEMI)
|
|
67477
68549
|
continue parameter;
|
|
67478
68550
|
if (char === EQ) {
|
|
67479
|
-
const keyEnd = trailingOWS(
|
|
67480
|
-
const key =
|
|
67481
|
-
index = skipOWS(
|
|
67482
|
-
if (index < len &&
|
|
68551
|
+
const keyEnd = trailingOWS(header2, keyStart, index);
|
|
68552
|
+
const key = header2.slice(keyStart, keyEnd).toLowerCase();
|
|
68553
|
+
index = skipOWS(header2, index + 1, len);
|
|
68554
|
+
if (index < len && header2.charCodeAt(index) === DQUOTE) {
|
|
67483
68555
|
index++;
|
|
67484
68556
|
let value2 = "";
|
|
67485
68557
|
if (multipart) {
|
|
67486
68558
|
while (index < len) {
|
|
67487
|
-
const code =
|
|
68559
|
+
const code = header2.charCodeAt(index++);
|
|
67488
68560
|
if (code === DQUOTE) {
|
|
67489
|
-
index = parseToken(
|
|
68561
|
+
index = parseToken(header2, index, len);
|
|
67490
68562
|
if (parameters[key] === void 0)
|
|
67491
68563
|
parameters[key] = value2;
|
|
67492
68564
|
break;
|
|
67493
68565
|
}
|
|
67494
68566
|
if (code === /* % */
|
|
67495
68567
|
37 && index + 1 < len) {
|
|
67496
|
-
const code2 =
|
|
67497
|
-
const code3 =
|
|
68568
|
+
const code2 = header2.charCodeAt(index);
|
|
68569
|
+
const code3 = header2.charCodeAt(index + 1);
|
|
67498
68570
|
if (code2 === 50 && code3 === 50) {
|
|
67499
68571
|
value2 += '"';
|
|
67500
68572
|
index += 2;
|
|
@@ -67517,15 +68589,15 @@ function parse4(header, options2) {
|
|
|
67517
68589
|
}
|
|
67518
68590
|
} else {
|
|
67519
68591
|
while (index < len) {
|
|
67520
|
-
const code =
|
|
68592
|
+
const code = header2.charCodeAt(index++);
|
|
67521
68593
|
if (code === DQUOTE) {
|
|
67522
|
-
index = parseToken(
|
|
68594
|
+
index = parseToken(header2, index, len);
|
|
67523
68595
|
if (parameters[key] === void 0)
|
|
67524
68596
|
parameters[key] = value2;
|
|
67525
68597
|
break;
|
|
67526
68598
|
}
|
|
67527
68599
|
if (code === BSLASH && index < len) {
|
|
67528
|
-
value2 +=
|
|
68600
|
+
value2 += header2[index++];
|
|
67529
68601
|
continue;
|
|
67530
68602
|
}
|
|
67531
68603
|
value2 += String.fromCharCode(code);
|
|
@@ -67534,9 +68606,9 @@ function parse4(header, options2) {
|
|
|
67534
68606
|
continue parameter;
|
|
67535
68607
|
}
|
|
67536
68608
|
const valueStart = index;
|
|
67537
|
-
index = parseToken(
|
|
67538
|
-
const valueEnd = trailingOWS(
|
|
67539
|
-
const value =
|
|
68609
|
+
index = parseToken(header2, index, len);
|
|
68610
|
+
const valueEnd = trailingOWS(header2, valueStart, index);
|
|
68611
|
+
const value = header2.slice(valueStart, valueEnd);
|
|
67540
68612
|
if (parameters[key] === void 0) {
|
|
67541
68613
|
parameters[key] = value;
|
|
67542
68614
|
if (extended2 && key.charCodeAt(key.length - 1) === ASTERISK) {
|
|
@@ -68942,9 +70014,9 @@ var require_static = __commonJS({
|
|
|
68942
70014
|
}
|
|
68943
70015
|
function getEncodingHeader(headers, checked) {
|
|
68944
70016
|
if (!("accept-encoding" in headers)) return;
|
|
68945
|
-
const
|
|
70017
|
+
const header2 = headers["accept-encoding"].toLowerCase().replace(asteriskRegex, "gzip");
|
|
68946
70018
|
return encodingNegotiator.negotiate(
|
|
68947
|
-
|
|
70019
|
+
header2,
|
|
68948
70020
|
supportedEncodings.filter((enc) => !checked.has(enc))
|
|
68949
70021
|
);
|
|
68950
70022
|
}
|
|
@@ -71161,7 +72233,7 @@ var require_extension = __commonJS({
|
|
|
71161
72233
|
if (dest[name] === void 0) dest[name] = [elem];
|
|
71162
72234
|
else dest[name].push(elem);
|
|
71163
72235
|
}
|
|
71164
|
-
function parse5(
|
|
72236
|
+
function parse5(header2) {
|
|
71165
72237
|
const offers = /* @__PURE__ */ Object.create(null);
|
|
71166
72238
|
let params = /* @__PURE__ */ Object.create(null);
|
|
71167
72239
|
let mustUnescape = false;
|
|
@@ -71173,8 +72245,8 @@ var require_extension = __commonJS({
|
|
|
71173
72245
|
let code = -1;
|
|
71174
72246
|
let end2 = -1;
|
|
71175
72247
|
let i = 0;
|
|
71176
|
-
for (; i <
|
|
71177
|
-
code =
|
|
72248
|
+
for (; i < header2.length; i++) {
|
|
72249
|
+
code = header2.charCodeAt(i);
|
|
71178
72250
|
if (extensionName === void 0) {
|
|
71179
72251
|
if (end2 === -1 && tokenChars[code] === 1) {
|
|
71180
72252
|
if (start === -1) start = i;
|
|
@@ -71185,7 +72257,7 @@ var require_extension = __commonJS({
|
|
|
71185
72257
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
71186
72258
|
}
|
|
71187
72259
|
if (end2 === -1) end2 = i;
|
|
71188
|
-
const name =
|
|
72260
|
+
const name = header2.slice(start, end2);
|
|
71189
72261
|
if (code === 44) {
|
|
71190
72262
|
push(offers, name, params);
|
|
71191
72263
|
params = /* @__PURE__ */ Object.create(null);
|
|
@@ -71206,7 +72278,7 @@ var require_extension = __commonJS({
|
|
|
71206
72278
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
71207
72279
|
}
|
|
71208
72280
|
if (end2 === -1) end2 = i;
|
|
71209
|
-
push(params,
|
|
72281
|
+
push(params, header2.slice(start, end2), true);
|
|
71210
72282
|
if (code === 44) {
|
|
71211
72283
|
push(offers, extensionName, params);
|
|
71212
72284
|
params = /* @__PURE__ */ Object.create(null);
|
|
@@ -71214,7 +72286,7 @@ var require_extension = __commonJS({
|
|
|
71214
72286
|
}
|
|
71215
72287
|
start = end2 = -1;
|
|
71216
72288
|
} else if (code === 61 && start !== -1 && end2 === -1) {
|
|
71217
|
-
paramName =
|
|
72289
|
+
paramName = header2.slice(start, i);
|
|
71218
72290
|
start = end2 = -1;
|
|
71219
72291
|
} else {
|
|
71220
72292
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
@@ -71238,7 +72310,7 @@ var require_extension = __commonJS({
|
|
|
71238
72310
|
} else {
|
|
71239
72311
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
71240
72312
|
}
|
|
71241
|
-
} else if (code === 34 &&
|
|
72313
|
+
} else if (code === 34 && header2.charCodeAt(i - 1) === 61) {
|
|
71242
72314
|
inQuotes = true;
|
|
71243
72315
|
} else if (end2 === -1 && tokenChars[code] === 1) {
|
|
71244
72316
|
if (start === -1) start = i;
|
|
@@ -71249,7 +72321,7 @@ var require_extension = __commonJS({
|
|
|
71249
72321
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
71250
72322
|
}
|
|
71251
72323
|
if (end2 === -1) end2 = i;
|
|
71252
|
-
let value =
|
|
72324
|
+
let value = header2.slice(start, end2);
|
|
71253
72325
|
if (mustUnescape) {
|
|
71254
72326
|
value = value.replace(/\\/g, "");
|
|
71255
72327
|
mustUnescape = false;
|
|
@@ -71271,7 +72343,7 @@ var require_extension = __commonJS({
|
|
|
71271
72343
|
throw new SyntaxError("Unexpected end of input");
|
|
71272
72344
|
}
|
|
71273
72345
|
if (end2 === -1) end2 = i;
|
|
71274
|
-
const token =
|
|
72346
|
+
const token = header2.slice(start, end2);
|
|
71275
72347
|
if (extensionName === void 0) {
|
|
71276
72348
|
push(offers, token, params);
|
|
71277
72349
|
} else {
|
|
@@ -72317,13 +73389,13 @@ var require_subprotocol = __commonJS({
|
|
|
72317
73389
|
"node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
72318
73390
|
"use strict";
|
|
72319
73391
|
var { tokenChars } = require_validation2();
|
|
72320
|
-
function parse5(
|
|
73392
|
+
function parse5(header2) {
|
|
72321
73393
|
const protocols = /* @__PURE__ */ new Set();
|
|
72322
73394
|
let start = -1;
|
|
72323
73395
|
let end2 = -1;
|
|
72324
73396
|
let i = 0;
|
|
72325
|
-
for (i; i <
|
|
72326
|
-
const code =
|
|
73397
|
+
for (i; i < header2.length; i++) {
|
|
73398
|
+
const code = header2.charCodeAt(i);
|
|
72327
73399
|
if (end2 === -1 && tokenChars[code] === 1) {
|
|
72328
73400
|
if (start === -1) start = i;
|
|
72329
73401
|
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
@@ -72333,7 +73405,7 @@ var require_subprotocol = __commonJS({
|
|
|
72333
73405
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
72334
73406
|
}
|
|
72335
73407
|
if (end2 === -1) end2 = i;
|
|
72336
|
-
const protocol2 =
|
|
73408
|
+
const protocol2 = header2.slice(start, end2);
|
|
72337
73409
|
if (protocols.has(protocol2)) {
|
|
72338
73410
|
throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
|
|
72339
73411
|
}
|
|
@@ -72346,7 +73418,7 @@ var require_subprotocol = __commonJS({
|
|
|
72346
73418
|
if (start === -1 || end2 !== -1) {
|
|
72347
73419
|
throw new SyntaxError("Unexpected end of input");
|
|
72348
73420
|
}
|
|
72349
|
-
const protocol =
|
|
73421
|
+
const protocol = header2.slice(start, i);
|
|
72350
73422
|
if (protocols.has(protocol)) {
|
|
72351
73423
|
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
72352
73424
|
}
|
|
@@ -87402,17 +88474,17 @@ var require_reply = __commonJS({
|
|
|
87402
88474
|
const req = reply.request;
|
|
87403
88475
|
if (reply[kReplyTrailers] !== null) {
|
|
87404
88476
|
const trailerHeaders = Object.keys(reply[kReplyTrailers]);
|
|
87405
|
-
let
|
|
88477
|
+
let header2 = "";
|
|
87406
88478
|
for (const trailerName of trailerHeaders) {
|
|
87407
88479
|
if (typeof reply[kReplyTrailers][trailerName] !== "function") continue;
|
|
87408
|
-
|
|
87409
|
-
|
|
88480
|
+
header2 += " ";
|
|
88481
|
+
header2 += trailerName;
|
|
87410
88482
|
}
|
|
87411
|
-
if (
|
|
88483
|
+
if (header2 !== "") {
|
|
87412
88484
|
if (!isHttp2Reply(reply)) {
|
|
87413
88485
|
reply.header("Transfer-Encoding", "chunked");
|
|
87414
88486
|
}
|
|
87415
|
-
reply.header("Trailer",
|
|
88487
|
+
reply.header("Trailer", header2.trim());
|
|
87416
88488
|
} else {
|
|
87417
88489
|
reply[kReplyTrailers] = null;
|
|
87418
88490
|
}
|
|
@@ -87780,35 +88852,35 @@ var require_forwarded = __commonJS({
|
|
|
87780
88852
|
if (!req) {
|
|
87781
88853
|
throw new TypeError("argument req is required");
|
|
87782
88854
|
}
|
|
87783
|
-
const
|
|
88855
|
+
const header2 = req.headers["x-forwarded-for"];
|
|
87784
88856
|
const socketAddr = req.socket.remoteAddress;
|
|
87785
|
-
if (!
|
|
88857
|
+
if (!header2 || typeof header2 !== "string") {
|
|
87786
88858
|
return [socketAddr];
|
|
87787
|
-
} else if (
|
|
87788
|
-
const remote =
|
|
88859
|
+
} else if (header2.indexOf(",") === -1) {
|
|
88860
|
+
const remote = header2.trim();
|
|
87789
88861
|
return remote.length ? [socketAddr, remote] : [socketAddr];
|
|
87790
88862
|
} else {
|
|
87791
|
-
return parse5(
|
|
88863
|
+
return parse5(header2, socketAddr);
|
|
87792
88864
|
}
|
|
87793
88865
|
}
|
|
87794
|
-
function parse5(
|
|
88866
|
+
function parse5(header2, socketAddr) {
|
|
87795
88867
|
const result2 = [socketAddr];
|
|
87796
|
-
let end2 =
|
|
88868
|
+
let end2 = header2.length;
|
|
87797
88869
|
let start = end2;
|
|
87798
88870
|
let char;
|
|
87799
88871
|
let i;
|
|
87800
88872
|
for (i = end2 - 1; i >= 0; --i) {
|
|
87801
|
-
char =
|
|
88873
|
+
char = header2[i];
|
|
87802
88874
|
if (char === " " || char === " ") {
|
|
87803
88875
|
start === end2 && (start = end2 = i);
|
|
87804
88876
|
} else if (char === ",") {
|
|
87805
|
-
start !== end2 && result2.push(
|
|
88877
|
+
start !== end2 && result2.push(header2.slice(start, end2));
|
|
87806
88878
|
start = end2 = i;
|
|
87807
88879
|
} else {
|
|
87808
88880
|
start = i;
|
|
87809
88881
|
}
|
|
87810
88882
|
}
|
|
87811
|
-
start !== end2 && result2.push(
|
|
88883
|
+
start !== end2 && result2.push(header2.substring(start, end2));
|
|
87812
88884
|
return result2;
|
|
87813
88885
|
}
|
|
87814
88886
|
module.exports = forwarded;
|
|
@@ -100518,13 +101590,13 @@ Content-Disposition: form-data`;
|
|
|
100518
101590
|
yield textEncoder.encode(`${normalizeLinefeeds(value)}\r
|
|
100519
101591
|
`);
|
|
100520
101592
|
} else {
|
|
100521
|
-
let
|
|
100522
|
-
value.name && (
|
|
100523
|
-
|
|
101593
|
+
let header2 = `${prefix}; name="${escape2(normalizeLinefeeds(name))}"`;
|
|
101594
|
+
value.name && (header2 += `; filename="${escape2(value.name)}"`);
|
|
101595
|
+
header2 += `\r
|
|
100524
101596
|
Content-Type: ${value.type || "application/octet-stream"}\r
|
|
100525
101597
|
\r
|
|
100526
101598
|
`;
|
|
100527
|
-
yield textEncoder.encode(
|
|
101599
|
+
yield textEncoder.encode(header2);
|
|
100528
101600
|
if (value.stream) {
|
|
100529
101601
|
yield* value.stream();
|
|
100530
101602
|
} else {
|
|
@@ -100649,8 +101721,8 @@ var require_request2 = __commonJS({
|
|
|
100649
101721
|
if (payload && !payloadResume && !Object.hasOwn(this.headers, "content-length")) {
|
|
100650
101722
|
this.headers["content-length"] = (Buffer.isBuffer(payload) ? payload.length : Buffer.byteLength(payload)).toString();
|
|
100651
101723
|
}
|
|
100652
|
-
for (const
|
|
100653
|
-
this.rawHeaders.push(
|
|
101724
|
+
for (const header2 of Object.keys(this.headers)) {
|
|
101725
|
+
this.rawHeaders.push(header2, this.headers[header2]);
|
|
100654
101726
|
}
|
|
100655
101727
|
this._lightMyRequest = {
|
|
100656
101728
|
payload,
|
|
@@ -103789,6 +104861,7 @@ var init_grammar = __esm({
|
|
|
103789
104861
|
"dynamic-dispatch": "type unknown",
|
|
103790
104862
|
reflection: "reflection",
|
|
103791
104863
|
"imported-symbol": "imported",
|
|
104864
|
+
"package-symbol": "in its package",
|
|
103792
104865
|
"runtime-global": "built-in",
|
|
103793
104866
|
"builtin-value": "on a built-in value",
|
|
103794
104867
|
"template-binding": "awaiting its component",
|
|
@@ -105668,7 +106741,8 @@ Usage:
|
|
|
105668
106741
|
or "-" for stdin); check the installed one again (offline)
|
|
105669
106742
|
veoflow check [<file|folder>] [--json] [--project <id>]
|
|
105670
106743
|
a reference checker's second opinion (the TypeScript compiler;
|
|
105671
|
-
Pyright for Python
|
|
106744
|
+
Pyright for Python; go/types for Go, with scip-go installed):
|
|
106745
|
+
each call site where it and veoflow
|
|
105672
106746
|
disagree, with both answers
|
|
105673
106747
|
veoflow report <file>:<line> [--include-code] [--out <file>] [--force] [--project <id>]
|
|
105674
106748
|
a bundle to reproduce an analysis bug there (no source code
|
|
@@ -105740,7 +106814,7 @@ function describeCheck(r, cwd, projectFlag) {
|
|
|
105740
106814
|
const disagree1 = s1["different-callee"] + s1["adapter-only"] + s1["checker-only"];
|
|
105741
106815
|
const disagree2 = s2["different-callee"] + s2["checker-only"];
|
|
105742
106816
|
out.push(
|
|
105743
|
-
`checked ${r.source}${r.path ? `:${r.path}` : ""} (${r.files} files) with ${r.checker === "scip-python" ? "Pyright (scip-python)" : "the TypeScript compiler (scip-typescript)"}`
|
|
106817
|
+
`checked ${r.source}${r.path ? `:${r.path}` : ""} (${r.files} files) with ${r.checker === "scip-python" ? "Pyright (scip-python)" : r.checker === "scip-go" ? "go/types (scip-go)" : "the TypeScript compiler (scip-typescript)"}`
|
|
105744
106818
|
);
|
|
105745
106819
|
out.push(
|
|
105746
106820
|
` calls within files (Stage 1): ${s1.agree} agree, ${disagree1} disagree; ${s1.outside} resolve outside the source (not compared)`
|
|
@@ -106517,7 +107591,7 @@ try: ${answer.suggestions.join(" \xB7 ")}`);
|
|
|
106517
107591
|
);
|
|
106518
107592
|
io.out(` ${flat(item.summary)}`);
|
|
106519
107593
|
const steps = item.steps[0]?.detail === item.summary ? item.steps.slice(1) : item.steps;
|
|
106520
|
-
for (const [i,
|
|
107594
|
+
for (const [i, step2] of steps.entries()) io.out(` ${i + 1}. ${flat(step2.detail)}`);
|
|
106521
107595
|
for (const c of item.candidates ?? []) io.out(` could be ${c.name} (${c.path})`);
|
|
106522
107596
|
if (item.toResolve) io.out(` to resolve it: ${flat(item.toResolve, 400)}`);
|
|
106523
107597
|
}
|