@algosail/lsp 0.1.12 → 0.2.1
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 +12 -1
- package/lib/completion.js +2 -2
- package/lib/validate.js +20 -0
- package/package.json +3 -2
package/debug.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createParser } from '../parser/index.js'
|
|
3
|
+
import { typecheck } from '../typecheck/index.js'
|
|
3
4
|
import { readFile } from 'node:fs/promises'
|
|
4
5
|
import { pathToFileURL } from 'node:url'
|
|
5
6
|
import { resolve } from 'node:path'
|
|
@@ -19,6 +20,16 @@ console.log(`\n=== Parsing: ${absPath} ===\n`)
|
|
|
19
20
|
|
|
20
21
|
const parser = await createParser()
|
|
21
22
|
const result = await parser.parseSail(uri, text)
|
|
23
|
+
const checkResults = typecheck(result)
|
|
24
|
+
|
|
25
|
+
console.log('--- check results ---')
|
|
26
|
+
if (checkResults.length === 0) {
|
|
27
|
+
console.log('(none)')
|
|
28
|
+
} else {
|
|
29
|
+
for (const err of checkResults) {
|
|
30
|
+
console.log(err.message)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
|
|
23
34
|
console.log('--- errors ---')
|
|
24
35
|
if (result.errors.length === 0) {
|
|
@@ -54,7 +65,7 @@ console.log('\n--- words ---')
|
|
|
54
65
|
if (result.words.length === 0) {
|
|
55
66
|
console.log('(none)')
|
|
56
67
|
} else {
|
|
57
|
-
for (const word of result.words) {
|
|
68
|
+
for (const word of Object.values(result.words)) {
|
|
58
69
|
console.log(` @${word.name} sig: ${word.sig ?? '—'}`)
|
|
59
70
|
}
|
|
60
71
|
}
|
package/lib/completion.js
CHANGED
|
@@ -75,7 +75,7 @@ export function getCompletionItems(parser, uri) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
for (const word of module.words) {
|
|
78
|
+
for (const word of Object.values(module.words)) {
|
|
79
79
|
items.push(item(`~${key}/${word.name}`, CompletionItemKind.Function, word.sig, word.doc))
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -124,7 +124,7 @@ export function getCompletionItems(parser, uri) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
for (const word of ast.words) {
|
|
127
|
+
for (const word of Object.values(ast.words)) {
|
|
128
128
|
items.push(item(`/${word.name}`, CompletionItemKind.Function, word.sig, word.doc))
|
|
129
129
|
}
|
|
130
130
|
|
package/lib/validate.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DiagnosticSeverity } from 'vscode-languageserver'
|
|
2
|
+
import { typecheck } from '@algosail/typecheck'
|
|
2
3
|
|
|
3
4
|
export const validateDocument = async (connection, parser, uri, text) => {
|
|
4
5
|
try {
|
|
@@ -20,6 +21,25 @@ export const validateDocument = async (connection, parser, uri, text) => {
|
|
|
20
21
|
source: 'sail',
|
|
21
22
|
}))
|
|
22
23
|
|
|
24
|
+
const checkResults = typecheck(res)
|
|
25
|
+
diagnostics.push(
|
|
26
|
+
...checkResults.map((error) => ({
|
|
27
|
+
severity: DiagnosticSeverity.Error,
|
|
28
|
+
range: {
|
|
29
|
+
start: {
|
|
30
|
+
line: err.startPosition.row,
|
|
31
|
+
character: err.startPosition.column,
|
|
32
|
+
},
|
|
33
|
+
end: {
|
|
34
|
+
line: err.endPosition.row,
|
|
35
|
+
character: err.endPosition.column,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
message: error.message,
|
|
39
|
+
source: 'sail-typecheck',
|
|
40
|
+
})),
|
|
41
|
+
)
|
|
42
|
+
|
|
23
43
|
connection.sendDiagnostics({ uri, diagnostics })
|
|
24
44
|
} catch (err) {
|
|
25
45
|
connection.console.error(`[sail-lsp] Failed to parse ${uri}: ${err.message}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algosail/lsp",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@algosail/builtins": "^0.0.1",
|
|
11
|
-
"@algosail/parser": "^0.0.
|
|
11
|
+
"@algosail/parser": "^0.0.10",
|
|
12
|
+
"@algosail/typecheck": "^0.0.2",
|
|
12
13
|
"vscode-languageserver": "^9.0.1",
|
|
13
14
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
14
15
|
}
|