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/bin/veoflow.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
17
17
|
process.env.VEO_CHECKERS_MODULE ??= pathToFileURL(join(here, "../dist/checkers.mjs")).href;
|
|
18
18
|
process.env.VEO_NATIVE_DIR ??= join(here, "../native");
|
|
19
19
|
process.env.VEO_WEB_ROOT ??= join(here, "../web");
|
|
20
|
-
process.env.VEO_VERSION = "0.
|
|
20
|
+
process.env.VEO_VERSION = "0.7.0";
|
|
21
21
|
const { main } = await import("../dist/veo.mjs");
|
|
22
22
|
const code = await main(process.argv.slice(2), {
|
|
23
23
|
out: (line) => process.stdout.write(line + "\n"),
|
package/dist/checkers.mjs
CHANGED
|
@@ -109,6 +109,83 @@ function readIndex(path) {
|
|
|
109
109
|
occurrences: d.occurrences.map((o) => ({ range: [...o.range], symbol: o.symbol, roles: o.symbol_roles }))
|
|
110
110
|
}));
|
|
111
111
|
}
|
|
112
|
+
function decodeIndex(bytes) {
|
|
113
|
+
const fields = (start, end) => {
|
|
114
|
+
const out = [];
|
|
115
|
+
let i = start;
|
|
116
|
+
const varint = () => {
|
|
117
|
+
let x = 0;
|
|
118
|
+
let mul = 1;
|
|
119
|
+
for (; ; ) {
|
|
120
|
+
const c = bytes[i++];
|
|
121
|
+
x += (c & 127) * mul;
|
|
122
|
+
mul *= 128;
|
|
123
|
+
if (!(c & 128)) return x;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
while (i < end) {
|
|
127
|
+
const key = varint();
|
|
128
|
+
const f = Math.floor(key / 8);
|
|
129
|
+
const w = key & 7;
|
|
130
|
+
if (w === 0) out.push({ f, w, v: varint(), s: 0, e: 0 });
|
|
131
|
+
else if (w === 2) {
|
|
132
|
+
const n = varint();
|
|
133
|
+
out.push({ f, w, v: 0, s: i, e: i + n });
|
|
134
|
+
i += n;
|
|
135
|
+
} else if (w === 5) i += 4;
|
|
136
|
+
else if (w === 1) i += 8;
|
|
137
|
+
else throw new Error(`unsupported protobuf wire type ${w}`);
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
};
|
|
141
|
+
const packed = (s, e) => {
|
|
142
|
+
const out = [];
|
|
143
|
+
let i = s;
|
|
144
|
+
while (i < e) {
|
|
145
|
+
let x = 0;
|
|
146
|
+
let mul = 1;
|
|
147
|
+
for (; ; ) {
|
|
148
|
+
const c = bytes[i++];
|
|
149
|
+
x += (c & 127) * mul;
|
|
150
|
+
mul *= 128;
|
|
151
|
+
if (!(c & 128)) break;
|
|
152
|
+
}
|
|
153
|
+
out.push(x);
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
};
|
|
157
|
+
const text = (s, e) => Buffer.from(bytes.subarray(s, e)).toString("utf8");
|
|
158
|
+
const encodings = ["unspecified", "utf8", "utf16", "utf32"];
|
|
159
|
+
const docs = [];
|
|
160
|
+
for (const d of fields(0, bytes.length)) {
|
|
161
|
+
if (d.f !== 2 || d.w !== 2) continue;
|
|
162
|
+
const doc = {
|
|
163
|
+
path: "",
|
|
164
|
+
occurrences: [],
|
|
165
|
+
encoding: "unspecified"
|
|
166
|
+
};
|
|
167
|
+
for (const x of fields(d.s, d.e)) {
|
|
168
|
+
if (x.f === 1 && x.w === 2) doc.path = text(x.s, x.e);
|
|
169
|
+
else if (x.f === 6 && x.w === 0) doc.encoding = encodings[x.v] ?? "unspecified";
|
|
170
|
+
else if (x.f === 2 && x.w === 2) {
|
|
171
|
+
const o = { range: [], symbol: "", roles: 0 };
|
|
172
|
+
for (const y of fields(x.s, x.e)) {
|
|
173
|
+
if (y.f === 1) o.range.push(...y.w === 2 ? packed(y.s, y.e) : [y.v]);
|
|
174
|
+
else if (y.f === 2 && y.w === 2) o.symbol = text(y.s, y.e);
|
|
175
|
+
else if (y.f === 3 && y.w === 0) o.roles = y.v;
|
|
176
|
+
else if ((y.f === 8 || y.f === 9) && y.w === 2) {
|
|
177
|
+
const r = [0, 0, 0, 0];
|
|
178
|
+
for (const z of fields(y.s, y.e)) if (z.w === 0 && z.f >= 1 && z.f <= 4) r[z.f - 1] = z.v;
|
|
179
|
+
o.range = y.f === 8 ? r.slice(0, 3) : r;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
doc.occurrences.push(o);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
docs.push(doc);
|
|
186
|
+
}
|
|
187
|
+
return docs;
|
|
188
|
+
}
|
|
112
189
|
|
|
113
190
|
// packages/checkers/src/translate.ts
|
|
114
191
|
import ts2 from "typescript";
|
|
@@ -797,20 +874,331 @@ function translatePython(docs, adapter, texts) {
|
|
|
797
874
|
}
|
|
798
875
|
return out;
|
|
799
876
|
}
|
|
877
|
+
|
|
878
|
+
// packages/checkers/src/go.ts
|
|
879
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
880
|
+
import { cpSync as cpSync3, existsSync as existsSync4, mkdirSync as mkdirSync3, mkdtempSync as mkdtempSync3, readFileSync as readFileSync3, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
881
|
+
import { homedir, tmpdir as tmpdir3 } from "node:os";
|
|
882
|
+
import { delimiter, dirname as dirname4, join as join4, posix } from "node:path";
|
|
883
|
+
var exe = (name) => process.platform === "win32" ? `${name}.exe` : name;
|
|
884
|
+
function which(name, extra = []) {
|
|
885
|
+
for (const dir of [...(process.env.PATH ?? "").split(delimiter), ...extra]) {
|
|
886
|
+
if (!dir) continue;
|
|
887
|
+
const p = join4(dir, exe(name));
|
|
888
|
+
if (existsSync4(p)) return p;
|
|
889
|
+
}
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
function goTools() {
|
|
893
|
+
const go = which("go");
|
|
894
|
+
if (!go) return { missing: "the Go toolchain (go) is not on the PATH: install Go from https://go.dev/dl/" };
|
|
895
|
+
const scipGo = (process.env.VEOFLOW_SCIP_GO && existsSync4(process.env.VEOFLOW_SCIP_GO) ? process.env.VEOFLOW_SCIP_GO : null) ?? which("scip-go", [join4(process.env.GOPATH ?? join4(homedir(), "go"), "bin")]);
|
|
896
|
+
if (!scipGo)
|
|
897
|
+
return {
|
|
898
|
+
missing: "scip-go is not installed: run `go install github.com/scip-code/scip-go/cmd/scip-go@latest` (or set VEOFLOW_SCIP_GO to it)"
|
|
899
|
+
};
|
|
900
|
+
const r = spawnSync3(go, ["env", "GOROOT"], { encoding: "utf8", timeout: 6e4 });
|
|
901
|
+
const goroot = r.status === 0 ? r.stdout.trim() : "";
|
|
902
|
+
if (!goroot || !existsSync4(join4(goroot, "bin", exe("go"))))
|
|
903
|
+
return { missing: `couldn't find Go's installation (go env GOROOT said "${goroot}")` };
|
|
904
|
+
return { go, scipGo, goroot };
|
|
905
|
+
}
|
|
906
|
+
function moduleFiles(root, files) {
|
|
907
|
+
const out = /* @__PURE__ */ new Set();
|
|
908
|
+
for (const f of files) {
|
|
909
|
+
let dir = posix.dirname(f);
|
|
910
|
+
for (; ; ) {
|
|
911
|
+
for (const name of ["go.mod", "go.sum", "go.work", "go.work.sum"]) {
|
|
912
|
+
const p = dir === "." ? name : `${dir}/${name}`;
|
|
913
|
+
if (existsSync4(join4(root, p))) out.add(p);
|
|
914
|
+
}
|
|
915
|
+
if (dir === "." || dir === "") break;
|
|
916
|
+
dir = posix.dirname(dir);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
return [...out].sort();
|
|
920
|
+
}
|
|
921
|
+
function indexGo(root, files) {
|
|
922
|
+
const tools = goTools();
|
|
923
|
+
if ("missing" in tools) throw new Error(tools.missing);
|
|
924
|
+
const work = mkdtempSync3(join4(tmpdir3(), "veo-scip-go-"));
|
|
925
|
+
try {
|
|
926
|
+
const copy = join4(work, "src");
|
|
927
|
+
const manifests = moduleFiles(root, files);
|
|
928
|
+
for (const f of [...files, ...manifests]) {
|
|
929
|
+
mkdirSync3(dirname4(join4(copy, f)), { recursive: true });
|
|
930
|
+
cpSync3(join4(root, f), join4(copy, f));
|
|
931
|
+
}
|
|
932
|
+
const mods = manifests.filter((m) => posix.basename(m) === "go.mod").map((m) => posix.dirname(m) === "." ? "" : posix.dirname(m));
|
|
933
|
+
const nearest = (f) => mods.filter((m) => m === "" || f.startsWith(`${m}/`)).sort((a, b) => b.length - a.length)[0];
|
|
934
|
+
const used = [...new Set(files.map(nearest).filter((m) => m !== void 0))].sort();
|
|
935
|
+
if (!used.length) throw new Error("no go.mod above the files: scip-go indexes Go modules");
|
|
936
|
+
let workspace = false;
|
|
937
|
+
for (const w of manifests.filter((m) => posix.basename(m) === "go.work")) {
|
|
938
|
+
const dir = posix.dirname(w) === "." ? "" : posix.dirname(w);
|
|
939
|
+
const inside = used.filter((m) => dir === "" || m === dir || m.startsWith(`${dir}/`));
|
|
940
|
+
const goLine = /^\s*go\s+(\S+)/m.exec(readFileSync3(join4(copy, w), "utf8"))?.[1];
|
|
941
|
+
const rel = (m) => `./${posix.relative(dir || ".", m || ".") || "."}`;
|
|
942
|
+
writeFileSync3(
|
|
943
|
+
join4(copy, w),
|
|
944
|
+
`${goLine ? `go ${goLine}
|
|
945
|
+
|
|
946
|
+
` : ""}use (
|
|
947
|
+
${inside.map((m) => ` ${rel(m)}
|
|
948
|
+
`).join("")})
|
|
949
|
+
`
|
|
950
|
+
);
|
|
951
|
+
rmSync3(join4(copy, `${w}.sum`), { force: true });
|
|
952
|
+
if (inside.length) workspace = true;
|
|
953
|
+
}
|
|
954
|
+
const env = {
|
|
955
|
+
// The toolchain's own folder (a version manager's `go` is a shim needing more than a PATH).
|
|
956
|
+
PATH: [join4(tools.goroot, "bin"), dirname4(tools.scipGo)].join(delimiter),
|
|
957
|
+
GOROOT: tools.goroot,
|
|
958
|
+
HOME: work,
|
|
959
|
+
GOPATH: join4(work, "gopath"),
|
|
960
|
+
GOMODCACHE: join4(work, "gomod"),
|
|
961
|
+
GOCACHE: join4(work, "gocache"),
|
|
962
|
+
GOENV: "off",
|
|
963
|
+
GOPROXY: "off",
|
|
964
|
+
GOSUMDB: "off",
|
|
965
|
+
GOTOOLCHAIN: "local",
|
|
966
|
+
// Vendored code isn't copied with its modules.txt: read modules, not vendor/ (not allowed for a workspace).
|
|
967
|
+
GOFLAGS: workspace ? "-buildvcs=false" : "-buildvcs=false -mod=mod",
|
|
968
|
+
GO111MODULE: "on",
|
|
969
|
+
CGO_ENABLED: "0",
|
|
970
|
+
GOOS: "linux",
|
|
971
|
+
GOARCH: "amd64",
|
|
972
|
+
...process.platform === "win32" ? { SYSTEMROOT: process.env.SYSTEMROOT ?? "C:\\Windows", TEMP: work, TMP: work } : { TMPDIR: work }
|
|
973
|
+
};
|
|
974
|
+
const docs = [];
|
|
975
|
+
const wanted = new Set(files);
|
|
976
|
+
used.forEach((mod, i) => {
|
|
977
|
+
const out = join4(work, `index-${i}.scip`);
|
|
978
|
+
const r = spawnSync3(
|
|
979
|
+
tools.scipGo,
|
|
980
|
+
[
|
|
981
|
+
"index",
|
|
982
|
+
"--module-version",
|
|
983
|
+
"0",
|
|
984
|
+
"--repository-remote",
|
|
985
|
+
"veoflow-check",
|
|
986
|
+
"--go-version",
|
|
987
|
+
"go1.22",
|
|
988
|
+
"--skip-implementations",
|
|
989
|
+
"--quiet",
|
|
990
|
+
"--output",
|
|
991
|
+
out,
|
|
992
|
+
"./..."
|
|
993
|
+
],
|
|
994
|
+
{ cwd: join4(copy, mod), env, encoding: "utf8", maxBuffer: 1 << 26, timeout: 30 * 60 * 1e3 }
|
|
995
|
+
);
|
|
996
|
+
if (r.status !== 0 || !existsSync4(out)) {
|
|
997
|
+
const lines = `${r.stderr ?? ""}
|
|
998
|
+
${r.stdout ?? ""}`.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
999
|
+
throw new Error(
|
|
1000
|
+
`scip-go failed on ${mod || "the root module"}${r.error ? ` (${r.error.message})` : ""}: ${lines.at(-1) ?? ""}`
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
for (const d of decodeIndex(readFileSync3(out))) {
|
|
1004
|
+
const path = mod ? posix.join(mod, d.path) : posix.normalize(d.path);
|
|
1005
|
+
if (wanted.has(path)) docs.push({ ...d, path });
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
return docs;
|
|
1009
|
+
} finally {
|
|
1010
|
+
rmSync3(work, { recursive: true, force: true });
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
var ByteLines = class {
|
|
1014
|
+
starts = [0];
|
|
1015
|
+
bytes;
|
|
1016
|
+
constructor(text) {
|
|
1017
|
+
this.bytes = Buffer.from(text, "utf8");
|
|
1018
|
+
for (let i = 0; i < this.bytes.length; i++) if (this.bytes[i] === 10) this.starts.push(i + 1);
|
|
1019
|
+
}
|
|
1020
|
+
/** A UTF-8 byte offset's 0-based line and byte column. */
|
|
1021
|
+
at(offset) {
|
|
1022
|
+
let lo = 0;
|
|
1023
|
+
let hi = this.starts.length - 1;
|
|
1024
|
+
while (lo < hi) {
|
|
1025
|
+
const mid = lo + hi + 1 >> 1;
|
|
1026
|
+
if (this.starts[mid] <= offset) lo = mid;
|
|
1027
|
+
else hi = mid - 1;
|
|
1028
|
+
}
|
|
1029
|
+
return { line: lo, col: offset - this.starts[lo] };
|
|
1030
|
+
}
|
|
1031
|
+
/** A line's byte column as a UTF-16 column. */
|
|
1032
|
+
utf16(line, col) {
|
|
1033
|
+
const start = this.starts[line] ?? this.bytes.length;
|
|
1034
|
+
return this.bytes.subarray(start, start + col).toString("utf8").length;
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
var NAME2 = /([\p{L}_][\p{L}\p{N}_]*)$/u;
|
|
1038
|
+
function goCalleeName(siteText, expression) {
|
|
1039
|
+
let callee;
|
|
1040
|
+
if (expression !== null && siteText.startsWith(expression)) callee = expression;
|
|
1041
|
+
else {
|
|
1042
|
+
let depth = 0;
|
|
1043
|
+
let open = -1;
|
|
1044
|
+
for (let i = 0; i < siteText.length; i++) {
|
|
1045
|
+
const c = siteText[i];
|
|
1046
|
+
if (c === "/" && siteText[i + 1] === "/") {
|
|
1047
|
+
const nl = siteText.indexOf("\n", i);
|
|
1048
|
+
i = nl < 0 ? siteText.length : nl;
|
|
1049
|
+
} else if (c === "/" && siteText[i + 1] === "*") {
|
|
1050
|
+
const end2 = siteText.indexOf("*/", i + 2);
|
|
1051
|
+
i = end2 < 0 ? siteText.length : end2 + 1;
|
|
1052
|
+
} else if (c === '"' || c === "'") {
|
|
1053
|
+
let j = i + 1;
|
|
1054
|
+
while (j < siteText.length && siteText[j] !== c) j += siteText[j] === "\\" ? 2 : 1;
|
|
1055
|
+
i = j;
|
|
1056
|
+
} else if (c === "`") {
|
|
1057
|
+
const end2 = siteText.indexOf("`", i + 1);
|
|
1058
|
+
i = end2 < 0 ? siteText.length : end2;
|
|
1059
|
+
} else if (c === "(" || c === "[" || c === "{") {
|
|
1060
|
+
if (c === "(" && depth === 0) open = i;
|
|
1061
|
+
depth++;
|
|
1062
|
+
} else if (c === ")" || c === "]" || c === "}") depth--;
|
|
1063
|
+
}
|
|
1064
|
+
if (open < 0) return null;
|
|
1065
|
+
callee = siteText.slice(0, open);
|
|
1066
|
+
}
|
|
1067
|
+
let end = callee.trimEnd();
|
|
1068
|
+
if (end.endsWith("]")) {
|
|
1069
|
+
let depth = 0;
|
|
1070
|
+
for (let i = end.length - 1; i >= 0; i--) {
|
|
1071
|
+
if (end[i] === "]") depth++;
|
|
1072
|
+
else if (end[i] === "[" && --depth === 0) {
|
|
1073
|
+
end = end.slice(0, i);
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
const m = NAME2.exec(end);
|
|
1079
|
+
if (!m) return null;
|
|
1080
|
+
return { offset: Buffer.byteLength(end.slice(0, m.index), "utf8"), name: m[1] };
|
|
1081
|
+
}
|
|
1082
|
+
function translateGo(docs, adapter, texts) {
|
|
1083
|
+
const byPath = new Map(docs.map((d) => [d.path, d]));
|
|
1084
|
+
const bytesOf = /* @__PURE__ */ new Map();
|
|
1085
|
+
const linesOf = /* @__PURE__ */ new Map();
|
|
1086
|
+
const byteLines = (path) => {
|
|
1087
|
+
let l = bytesOf.get(path);
|
|
1088
|
+
if (!l) bytesOf.set(path, l = new ByteLines(texts.get(path) ?? ""));
|
|
1089
|
+
return l;
|
|
1090
|
+
};
|
|
1091
|
+
const lines = (path) => {
|
|
1092
|
+
let l = linesOf.get(path);
|
|
1093
|
+
if (!l) linesOf.set(path, l = new Lines(texts.get(path) ?? ""));
|
|
1094
|
+
return l;
|
|
1095
|
+
};
|
|
1096
|
+
const toUtf16 = (path, encoding, line, char) => encoding === "utf8" ? byteLines(path).utf16(line, char) : char;
|
|
1097
|
+
const keyOf = (path, symbol) => symbol.startsWith("local ") ? `${path}\0${symbol}` : symbol.split(" ").filter((_, i) => i !== 3).join(" ");
|
|
1098
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
1099
|
+
for (const d of docs) {
|
|
1100
|
+
if (!texts.has(d.path)) continue;
|
|
1101
|
+
for (const o of d.occurrences) {
|
|
1102
|
+
const key = keyOf(d.path, o.symbol);
|
|
1103
|
+
if (o.roles & DEFINITION && !definitions.has(key) && o.range.length >= 3)
|
|
1104
|
+
definitions.set(key, {
|
|
1105
|
+
file: d.path,
|
|
1106
|
+
line0: o.range[0],
|
|
1107
|
+
char16: toUtf16(d.path, d.encoding, o.range[0], o.range[1])
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const out = [];
|
|
1112
|
+
for (const f of adapter) {
|
|
1113
|
+
if (f.language !== "go") continue;
|
|
1114
|
+
const text = texts.get(f.path);
|
|
1115
|
+
const doc = byPath.get(f.path);
|
|
1116
|
+
if (text === void 0 || !doc) continue;
|
|
1117
|
+
const bl = byteLines(f.path);
|
|
1118
|
+
const at = /* @__PURE__ */ new Map();
|
|
1119
|
+
for (const o of doc.occurrences)
|
|
1120
|
+
if (!(o.roles & DEFINITION) && o.range.length >= 3) at.set(`${o.range[0]}:${o.range[1]}`, o.symbol);
|
|
1121
|
+
const sites = [
|
|
1122
|
+
...f.calls.map((c) => ({
|
|
1123
|
+
site: c.site,
|
|
1124
|
+
expression: null,
|
|
1125
|
+
form: c.form === "iife" ? "iife" : "call",
|
|
1126
|
+
iife: c.form === "iife"
|
|
1127
|
+
})),
|
|
1128
|
+
...f.unresolved.map((u) => ({
|
|
1129
|
+
site: u.site,
|
|
1130
|
+
expression: u.expression,
|
|
1131
|
+
form: "call",
|
|
1132
|
+
iife: false
|
|
1133
|
+
}))
|
|
1134
|
+
];
|
|
1135
|
+
for (const s of sites) {
|
|
1136
|
+
if (s.iife) {
|
|
1137
|
+
out.push({
|
|
1138
|
+
file: f.path,
|
|
1139
|
+
site: s.site,
|
|
1140
|
+
form: "iife",
|
|
1141
|
+
callee: {
|
|
1142
|
+
file: f.path,
|
|
1143
|
+
name: "",
|
|
1144
|
+
at: { line: s.site.start.line, column: s.site.start.column },
|
|
1145
|
+
kind: "function",
|
|
1146
|
+
exact: true
|
|
1147
|
+
},
|
|
1148
|
+
symbol: ""
|
|
1149
|
+
});
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
const siteText = bl.bytes.subarray(s.site.start.offset, s.site.end.offset).toString("utf8");
|
|
1153
|
+
const name = goCalleeName(siteText, s.expression);
|
|
1154
|
+
if (!name) continue;
|
|
1155
|
+
const pos = bl.at(s.site.start.offset + name.offset);
|
|
1156
|
+
const char = doc.encoding === "utf8" ? pos.col : bl.utf16(pos.line, pos.col);
|
|
1157
|
+
const symbol = at.get(`${pos.line}:${char}`);
|
|
1158
|
+
if (symbol === void 0) continue;
|
|
1159
|
+
const def = definitions.get(keyOf(f.path, symbol));
|
|
1160
|
+
const descriptor = lastDescriptor(symbol);
|
|
1161
|
+
const literal = descriptor === null && def !== void 0 && /^[\p{L}_][\p{L}\p{N}_]*[^\n=]*:?=\s*func\b/u.test(
|
|
1162
|
+
(texts.get(def.file) ?? "").slice(lines(def.file).starts[def.line0] + def.char16)
|
|
1163
|
+
);
|
|
1164
|
+
const fn = (descriptor?.kind === "function" || literal) && def;
|
|
1165
|
+
out.push({
|
|
1166
|
+
file: f.path,
|
|
1167
|
+
site: s.site,
|
|
1168
|
+
form: s.form,
|
|
1169
|
+
callee: fn ? {
|
|
1170
|
+
file: def.file,
|
|
1171
|
+
name: descriptor?.name ?? name.name,
|
|
1172
|
+
at: lines(def.file).position(def.line0, def.char16),
|
|
1173
|
+
kind: "function"
|
|
1174
|
+
} : null,
|
|
1175
|
+
symbol
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
return out;
|
|
1180
|
+
}
|
|
800
1181
|
export {
|
|
801
1182
|
DEFINITION,
|
|
802
1183
|
DISAGREEMENTS,
|
|
803
1184
|
IMPORT_DISAGREEMENTS,
|
|
1185
|
+
Lines,
|
|
804
1186
|
adapterDef,
|
|
805
1187
|
callSiteOf,
|
|
806
1188
|
compare,
|
|
807
1189
|
compareImports,
|
|
1190
|
+
decodeIndex,
|
|
808
1191
|
formatReport,
|
|
1192
|
+
goCalleeName,
|
|
1193
|
+
goTools,
|
|
809
1194
|
indexFolder,
|
|
1195
|
+
indexGo,
|
|
810
1196
|
indexPython,
|
|
1197
|
+
lastDescriptor,
|
|
811
1198
|
readIndex,
|
|
812
1199
|
resolveWithCompiler,
|
|
813
1200
|
translate,
|
|
1201
|
+
translateGo,
|
|
814
1202
|
translatePython,
|
|
815
1203
|
workspacePackages
|
|
816
1204
|
};
|