@algosail/lsp 0.1.7 → 0.1.9
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/debug.js +69 -0
- package/index.js +1 -1
- package/package.json +2 -2
package/debug.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createParser } from '@algosail/parser'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
import { resolve } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const filePath = process.argv[2]
|
|
8
|
+
|
|
9
|
+
if (!filePath) {
|
|
10
|
+
console.error('Usage: node debug.js <path-to-file.sail>')
|
|
11
|
+
process.exit(1)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const absPath = resolve(filePath)
|
|
15
|
+
const uri = pathToFileURL(absPath).href
|
|
16
|
+
const text = await readFile(absPath, 'utf8')
|
|
17
|
+
|
|
18
|
+
console.log(`\n=== Parsing: ${absPath} ===\n`)
|
|
19
|
+
|
|
20
|
+
const parser = await createParser()
|
|
21
|
+
const result = await parser.parseSail(uri, text)
|
|
22
|
+
|
|
23
|
+
console.log('--- errors ---')
|
|
24
|
+
if (result.errors.length === 0) {
|
|
25
|
+
console.log('(none)')
|
|
26
|
+
} else {
|
|
27
|
+
for (const err of result.errors) {
|
|
28
|
+
const { row, column } = err.startPosition
|
|
29
|
+
console.log(` [${row}:${column}] ${err.type}: ${JSON.stringify(err.text)}`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log('\n--- groups ---')
|
|
34
|
+
if (Object.keys(result.groups).length === 0) {
|
|
35
|
+
console.log('(none)')
|
|
36
|
+
} else {
|
|
37
|
+
for (const [name, group] of Object.entries(result.groups)) {
|
|
38
|
+
const tags = group.tags.map((t) => t.name).join(', ')
|
|
39
|
+
console.log(` &${name} tags: [${tags}] doc: ${group.doc ?? '—'}`)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log('\n--- maps ---')
|
|
44
|
+
if (Object.keys(result.maps).length === 0) {
|
|
45
|
+
console.log('(none)')
|
|
46
|
+
} else {
|
|
47
|
+
for (const [name, map] of Object.entries(result.maps)) {
|
|
48
|
+
const fields = map.fields.map((f) => `.${f.name}`).join(', ')
|
|
49
|
+
console.log(` $${name} fields: [${fields}] doc: ${map.doc ?? '—'}`)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('\n--- words ---')
|
|
54
|
+
if (result.words.length === 0) {
|
|
55
|
+
console.log('(none)')
|
|
56
|
+
} else {
|
|
57
|
+
for (const word of result.words) {
|
|
58
|
+
console.log(` @${word.name} sig: ${word.sig ?? '—'}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.log('\n--- modules ---')
|
|
63
|
+
if (Object.keys(result.modules).length === 0) {
|
|
64
|
+
console.log('(none)')
|
|
65
|
+
} else {
|
|
66
|
+
for (const [alias, mod] of Object.entries(result.modules)) {
|
|
67
|
+
console.log(` ~${alias} uri: ${mod.uri}`)
|
|
68
|
+
}
|
|
69
|
+
}
|
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ connection.onDidCloseTextDocument(({ textDocument: { uri } }) => {
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
connection.onCompletion(({ textDocument: { uri } }) => {
|
|
40
|
-
return getCompletionItems(parser, uri)
|
|
40
|
+
return getCompletionItems(connection, parser, uri)
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
connection.listen()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algosail/lsp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@algosail/builtins": "^0.0.1",
|
|
11
|
-
"@algosail/parser": "^0.0.
|
|
11
|
+
"@algosail/parser": "^0.0.8",
|
|
12
12
|
"vscode-languageserver": "^9.0.1",
|
|
13
13
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
14
14
|
}
|