-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-spans.ts
More file actions
34 lines (29 loc) · 908 Bytes
/
debug-spans.ts
File metadata and controls
34 lines (29 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { compileForLSP, type SourceFile } from "./src/compile.ts";
import { readFileSync } from "fs";
const preludePath = "./lib/prelude.alg";
const preludeContent = readFileSync(preludePath, "utf-8");
const userPath = "./integration/http/main.alg";
const userContent = readFileSync(userPath, "utf-8");
const sources: SourceFile[] = [
{ path: preludePath, content: preludeContent },
{ path: userPath, content: userContent },
];
const result = compileForLSP(sources);
// Find definitions in user file (fileId = 1)
console.log("User file definitions (fileId=1):");
if (result.symbolTable) {
for (const [_id, def] of result.symbolTable.definitions) {
if (def.location.fileId === 1) {
console.log(
" " +
def.name +
" (" +
def.kind +
"): span " +
def.location.start +
"-" +
def.location.end,
);
}
}
}