@algosail/lsp 0.1.5 → 0.1.7

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/lib/completion.js CHANGED
@@ -2,7 +2,7 @@ import { CompletionItemKind } from 'vscode-languageserver'
2
2
  import { MarkupKind } from 'vscode-languageserver-types'
3
3
  import { builtinWords } from '@algosail/builtins'
4
4
 
5
- export function getCompletionItems(parser, uri) {
5
+ export function getCompletionItems(connection, parser, uri) {
6
6
  const items = []
7
7
 
8
8
  for (const b of Object.values(builtinWords)) {
@@ -15,10 +15,12 @@ export function getCompletionItems(parser, uri) {
15
15
  }
16
16
 
17
17
  const ast = parser.getAST(uri)
18
+ connection.console.error(`[sail-lsp] Failed to parse ${uri}: ${ast}`)
19
+
18
20
  if (!ast) return items
19
21
 
20
22
  for (const [key, module] of Object.entries(ast.modules)) {
21
- for (const group of module.groups) {
23
+ for (const group of Object.values(module.groups)) {
22
24
  items.push({
23
25
  label: `~${key}&${group.name}`,
24
26
  kind: CompletionItemKind.Enum,
@@ -27,33 +29,33 @@ export function getCompletionItems(parser, uri) {
27
29
  })
28
30
  }
29
31
 
30
- for (const tag of module.tags) {
32
+ for (const tag of Object.values(module.tags)) {
31
33
  items.push({
32
34
  label: `~${key}#${tag.name}`,
33
35
  kind: CompletionItemKind.EnumMember,
34
- detail: `Tag constructor in ~${key}&${tag.group}`,
36
+ detail: `Tag constructor in ~${key}&${tag.group.name}`,
35
37
  documentation: tag.doc ? { kind: MarkupKind.Markdown, value: tag.doc } : undefined,
36
38
  })
37
39
  items.push({
38
40
  label: `~${key}_${tag.name}`,
39
41
  kind: CompletionItemKind.EnumMember,
40
- detail: `Tag pattern in ~${key}&${tag.group}`,
42
+ detail: `Tag pattern in ~${key}&${tag.group.name}`,
41
43
  documentation: tag.doc ? { kind: MarkupKind.Markdown, value: tag.doc } : undefined,
42
44
  })
43
45
  }
44
46
 
45
- for (const map of module.maps) {
47
+ for (const map of Object.values(module.maps)) {
46
48
  items.push({
47
49
  label: `~${key}$${map.name}`,
48
50
  kind: CompletionItemKind.Struct,
49
- detail: `Map %${map.name}`,
51
+ detail: `Map $${map.name}`,
50
52
  documentation: map.doc ? { kind: MarkupKind.Markdown, value: map.doc } : undefined,
51
53
  })
52
54
  for (const field of map.fields) {
53
55
  items.push({
54
56
  label: `~${key}$${map.name}.${field.name}`,
55
57
  kind: CompletionItemKind.Field,
56
- detail: `Field :${field.name}${field.type ? ` (${field.type.kind})` : ''} of ~${key}$${map.name}`,
58
+ detail: `Field .${field.name}${field.type ? ` (${field.type.kind})` : ''} of ~${key}$${map.name}`,
57
59
  documentation: field.doc ? { kind: MarkupKind.Markdown, value: field.doc } : undefined,
58
60
  })
59
61
  }
@@ -69,7 +71,7 @@ export function getCompletionItems(parser, uri) {
69
71
  }
70
72
  }
71
73
 
72
- for (const group of ast.groups) {
74
+ for (const group of Object.values(ast.groups)) {
73
75
  items.push({
74
76
  label: `&${group.name}`,
75
77
  kind: CompletionItemKind.Enum,
@@ -78,33 +80,33 @@ export function getCompletionItems(parser, uri) {
78
80
  })
79
81
  }
80
82
 
81
- for (const tag of ast.tags) {
83
+ for (const tag of Object.values(ast.tags)) {
82
84
  items.push({
83
85
  label: `#${tag.name}`,
84
86
  kind: CompletionItemKind.EnumMember,
85
- detail: `Tag constructor in &${tag.group}`,
87
+ detail: `Tag constructor in &${tag.group.name}`,
86
88
  documentation: tag.doc ? { kind: MarkupKind.Markdown, value: tag.doc } : undefined,
87
89
  })
88
90
  items.push({
89
91
  label: `_${tag.name}`,
90
92
  kind: CompletionItemKind.EnumMember,
91
- detail: `Tag pattern in &${tag.group}`,
93
+ detail: `Tag pattern in &${tag.group.name}`,
92
94
  documentation: tag.doc ? { kind: MarkupKind.Markdown, value: tag.doc } : undefined,
93
95
  })
94
96
  }
95
97
 
96
- for (const map of ast.maps) {
98
+ for (const map of Object.values(ast.maps)) {
97
99
  items.push({
98
100
  label: `$${map.name}`,
99
101
  kind: CompletionItemKind.Struct,
100
- detail: `Map %${map.name}`,
102
+ detail: `Map $${map.name}`,
101
103
  documentation: map.doc ? { kind: MarkupKind.Markdown, value: map.doc } : undefined,
102
104
  })
103
105
  for (const field of map.fields) {
104
106
  items.push({
105
107
  label: `$${map.name}.${field.name}`,
106
108
  kind: CompletionItemKind.Field,
107
- detail: `Field :${field.name}${field.type ? ` (${field.type.kind})` : ''} of $${map.name}`,
109
+ detail: `Field .${field.name}${field.type ? ` (${field.type.kind})` : ''} of $${map.name}`,
108
110
  documentation: field.doc ? { kind: MarkupKind.Markdown, value: field.doc } : undefined,
109
111
  })
110
112
  }
package/lib/validate.js CHANGED
@@ -3,6 +3,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver'
3
3
  export const validateDocument = async (connection, parser, uri, text) => {
4
4
  try {
5
5
  const res = await parser.parseSail(uri, text)
6
+ connection.console.error(`[sail-lsp] Failed to parse ${uri}: ${res}`)
6
7
 
7
8
  const diagnostics = res.errors.map((err) => ({
8
9
  severity: DiagnosticSeverity.Error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algosail/lsp",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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.6",
11
+ "@algosail/parser": "^0.0.7",
12
12
  "vscode-languageserver": "^9.0.1",
13
13
  "vscode-languageserver-textdocument": "^1.0.11"
14
14
  }