@sshadows/tree-sitter-al 3.2.0 → 3.3.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/grammar.js +27 -0
- package/package.json +3 -4
- package/queries/folds.scm +4 -16
- package/queries/highlights.scm +307 -97
- package/queries/indents.scm +5 -5
- package/queries/locals.scm +28 -7
- package/queries/tags.scm +179 -68
- package/queries/textobjects.scm +67 -27
- package/src/grammar.json +16 -0
- package/src/node-types.json +10 -0
- package/src/parser.c +77021 -56029
- package/src/scanner.c +51 -38
- package/src/tree_sitter/array.h +23 -17
- package/tree-sitter-al.wasm +0 -0
- package/queries/bad_delete.scm.v1 +0 -30
package/queries/indents.scm
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
; AL Language (v2) - Tree-sitter Indentation Queries
|
|
2
2
|
; Compatible with Neovim (nvim-treesitter) and Helix editor
|
|
3
|
-
|
|
4
3
|
; =============================================================================
|
|
5
4
|
; Indent Begin - nodes that increase indentation
|
|
6
5
|
; =============================================================================
|
|
7
|
-
|
|
8
6
|
; Object declarations (all use { ... })
|
|
9
7
|
[
|
|
10
8
|
(table_declaration)
|
|
@@ -172,23 +170,25 @@
|
|
|
172
170
|
|
|
173
171
|
; Argument and parameter lists
|
|
174
172
|
(argument_list) @indent.begin
|
|
173
|
+
|
|
175
174
|
(parameter_list) @indent.begin
|
|
176
175
|
|
|
177
176
|
; =============================================================================
|
|
178
177
|
; Indent End - tokens that signal end of indentation
|
|
179
178
|
; =============================================================================
|
|
180
|
-
|
|
181
179
|
"}" @indent.end
|
|
180
|
+
|
|
182
181
|
")" @indent.end
|
|
182
|
+
|
|
183
183
|
"]" @indent.end
|
|
184
184
|
|
|
185
185
|
; Code block begin/end tokens (at depth 0 — named nodes)
|
|
186
|
-
(code_block
|
|
186
|
+
(code_block
|
|
187
|
+
(end_keyword) @indent.end)
|
|
187
188
|
|
|
188
189
|
; =============================================================================
|
|
189
190
|
; Indent Branch - closing tokens that should dedent to match their opener
|
|
190
191
|
; =============================================================================
|
|
191
|
-
|
|
192
192
|
[
|
|
193
193
|
"}"
|
|
194
194
|
")"
|
package/queries/locals.scm
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
; AL Language (v2) - Tree-sitter Scope and Local Variable Tracking
|
|
2
2
|
; See: https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables
|
|
3
|
-
|
|
4
3
|
; =============================================================================
|
|
5
4
|
; Scope Definitions
|
|
6
5
|
; =============================================================================
|
|
7
|
-
|
|
8
6
|
; Object declarations create scopes
|
|
9
7
|
[
|
|
10
8
|
(table_declaration)
|
|
@@ -31,9 +29,13 @@
|
|
|
31
29
|
|
|
32
30
|
; Procedures and triggers create scopes
|
|
33
31
|
(procedure) @local.scope
|
|
32
|
+
|
|
34
33
|
(trigger_declaration) @local.scope
|
|
34
|
+
|
|
35
35
|
(event_declaration) @local.scope
|
|
36
|
+
|
|
36
37
|
(interface_procedure) @local.scope
|
|
38
|
+
|
|
37
39
|
(preproc_split_procedure) @local.scope
|
|
38
40
|
|
|
39
41
|
; Code blocks create scopes
|
|
@@ -41,37 +43,48 @@
|
|
|
41
43
|
|
|
42
44
|
; Control flow statements with bodies create scopes
|
|
43
45
|
(if_statement) @local.scope
|
|
46
|
+
|
|
44
47
|
(case_statement) @local.scope
|
|
48
|
+
|
|
45
49
|
(case_branch) @local.scope
|
|
50
|
+
|
|
46
51
|
(for_statement) @local.scope
|
|
52
|
+
|
|
47
53
|
(foreach_statement) @local.scope
|
|
54
|
+
|
|
48
55
|
(while_statement) @local.scope
|
|
56
|
+
|
|
49
57
|
(repeat_statement) @local.scope
|
|
58
|
+
|
|
50
59
|
(with_statement) @local.scope
|
|
51
60
|
|
|
52
61
|
; =============================================================================
|
|
53
62
|
; Local Definitions
|
|
54
63
|
; =============================================================================
|
|
55
|
-
|
|
56
64
|
; Variable declarations define local variables
|
|
57
65
|
(variable_declaration
|
|
58
66
|
name: (identifier) @local.definition)
|
|
67
|
+
|
|
59
68
|
(variable_declaration
|
|
60
69
|
name: (quoted_identifier) @local.definition)
|
|
61
70
|
|
|
62
71
|
; Parameters define local variables
|
|
63
72
|
(parameter
|
|
64
73
|
name: (identifier) @local.definition)
|
|
74
|
+
|
|
65
75
|
(parameter
|
|
66
76
|
name: (quoted_identifier) @local.definition)
|
|
67
77
|
|
|
68
78
|
; Return values define local variables
|
|
69
79
|
(procedure
|
|
70
80
|
return_value: (identifier) @local.definition)
|
|
81
|
+
|
|
71
82
|
(procedure
|
|
72
83
|
return_value: (quoted_identifier) @local.definition)
|
|
84
|
+
|
|
73
85
|
(trigger_declaration
|
|
74
86
|
return_value: (identifier) @local.definition)
|
|
87
|
+
|
|
75
88
|
(trigger_declaration
|
|
76
89
|
return_value: (quoted_identifier) @local.definition)
|
|
77
90
|
|
|
@@ -81,15 +94,24 @@
|
|
|
81
94
|
|
|
82
95
|
; Field declarations (in tables)
|
|
83
96
|
(field_declaration
|
|
84
|
-
name: [
|
|
97
|
+
name: [
|
|
98
|
+
(identifier)
|
|
99
|
+
(quoted_identifier)
|
|
100
|
+
] @local.definition)
|
|
85
101
|
|
|
86
102
|
; Enum value declarations
|
|
87
103
|
(enum_value_declaration
|
|
88
|
-
value_name: [
|
|
104
|
+
value_name: [
|
|
105
|
+
(identifier)
|
|
106
|
+
(quoted_identifier)
|
|
107
|
+
] @local.definition)
|
|
89
108
|
|
|
90
109
|
; Key declarations
|
|
91
110
|
(key_declaration
|
|
92
|
-
name: [
|
|
111
|
+
name: [
|
|
112
|
+
(identifier)
|
|
113
|
+
(quoted_identifier)
|
|
114
|
+
] @local.definition)
|
|
93
115
|
|
|
94
116
|
; For loop variables
|
|
95
117
|
(for_statement
|
|
@@ -102,7 +124,6 @@
|
|
|
102
124
|
; =============================================================================
|
|
103
125
|
; References
|
|
104
126
|
; =============================================================================
|
|
105
|
-
|
|
106
127
|
; Identifiers are references
|
|
107
128
|
(identifier) @local.reference
|
|
108
129
|
|
package/queries/tags.scm
CHANGED
|
@@ -1,122 +1,192 @@
|
|
|
1
1
|
; AL Language (v2) - Tree-sitter Tags for Code Navigation
|
|
2
2
|
; See: https://tree-sitter.github.io/tree-sitter/4-code-navigation.html
|
|
3
|
-
|
|
4
3
|
; =============================================================================
|
|
5
4
|
; Object Definitions
|
|
6
5
|
; =============================================================================
|
|
7
|
-
|
|
8
6
|
(table_declaration
|
|
9
|
-
object_name: [
|
|
7
|
+
object_name: [
|
|
8
|
+
(identifier)
|
|
9
|
+
(quoted_identifier)
|
|
10
|
+
] @name) @definition.class
|
|
10
11
|
|
|
11
12
|
(page_declaration
|
|
12
|
-
object_name: [
|
|
13
|
+
object_name: [
|
|
14
|
+
(identifier)
|
|
15
|
+
(quoted_identifier)
|
|
16
|
+
] @name) @definition.class
|
|
13
17
|
|
|
14
18
|
(codeunit_declaration
|
|
15
|
-
object_name: [
|
|
19
|
+
object_name: [
|
|
20
|
+
(identifier)
|
|
21
|
+
(quoted_identifier)
|
|
22
|
+
] @name) @definition.class
|
|
16
23
|
|
|
17
24
|
(report_declaration
|
|
18
|
-
object_name: [
|
|
25
|
+
object_name: [
|
|
26
|
+
(identifier)
|
|
27
|
+
(quoted_identifier)
|
|
28
|
+
] @name) @definition.class
|
|
19
29
|
|
|
20
30
|
(query_declaration
|
|
21
|
-
object_name: [
|
|
31
|
+
object_name: [
|
|
32
|
+
(identifier)
|
|
33
|
+
(quoted_identifier)
|
|
34
|
+
] @name) @definition.class
|
|
22
35
|
|
|
23
36
|
(xmlport_declaration
|
|
24
|
-
object_name: [
|
|
37
|
+
object_name: [
|
|
38
|
+
(identifier)
|
|
39
|
+
(quoted_identifier)
|
|
40
|
+
] @name) @definition.class
|
|
25
41
|
|
|
26
42
|
(enum_declaration
|
|
27
|
-
object_name: [
|
|
43
|
+
object_name: [
|
|
44
|
+
(identifier)
|
|
45
|
+
(quoted_identifier)
|
|
46
|
+
] @name) @definition.class
|
|
28
47
|
|
|
29
48
|
(interface_declaration
|
|
30
|
-
object_name: [
|
|
49
|
+
object_name: [
|
|
50
|
+
(identifier)
|
|
51
|
+
(quoted_identifier)
|
|
52
|
+
] @name) @definition.interface
|
|
31
53
|
|
|
32
54
|
(controladdin_declaration
|
|
33
|
-
object_name: [
|
|
55
|
+
object_name: [
|
|
56
|
+
(identifier)
|
|
57
|
+
(quoted_identifier)
|
|
58
|
+
] @name) @definition.class
|
|
34
59
|
|
|
35
60
|
; =============================================================================
|
|
36
61
|
; Extension Definitions
|
|
37
62
|
; =============================================================================
|
|
38
|
-
|
|
39
63
|
(tableextension_declaration
|
|
40
|
-
object_name: [
|
|
64
|
+
object_name: [
|
|
65
|
+
(identifier)
|
|
66
|
+
(quoted_identifier)
|
|
67
|
+
] @name) @definition.class
|
|
41
68
|
|
|
42
69
|
(pageextension_declaration
|
|
43
|
-
object_name: [
|
|
70
|
+
object_name: [
|
|
71
|
+
(identifier)
|
|
72
|
+
(quoted_identifier)
|
|
73
|
+
] @name) @definition.class
|
|
44
74
|
|
|
45
75
|
(enumextension_declaration
|
|
46
|
-
object_name: [
|
|
76
|
+
object_name: [
|
|
77
|
+
(identifier)
|
|
78
|
+
(quoted_identifier)
|
|
79
|
+
] @name) @definition.class
|
|
47
80
|
|
|
48
81
|
(reportextension_declaration
|
|
49
|
-
object_name: [
|
|
82
|
+
object_name: [
|
|
83
|
+
(identifier)
|
|
84
|
+
(quoted_identifier)
|
|
85
|
+
] @name) @definition.class
|
|
50
86
|
|
|
51
87
|
(profileextension_declaration
|
|
52
|
-
object_name: [
|
|
88
|
+
object_name: [
|
|
89
|
+
(identifier)
|
|
90
|
+
(quoted_identifier)
|
|
91
|
+
] @name) @definition.class
|
|
53
92
|
|
|
54
93
|
(permissionsetextension_declaration
|
|
55
|
-
object_name: [
|
|
94
|
+
object_name: [
|
|
95
|
+
(identifier)
|
|
96
|
+
(quoted_identifier)
|
|
97
|
+
] @name) @definition.class
|
|
56
98
|
|
|
57
99
|
; =============================================================================
|
|
58
100
|
; Other Object Types
|
|
59
101
|
; =============================================================================
|
|
60
|
-
|
|
61
102
|
(profile_declaration
|
|
62
|
-
object_name: [
|
|
103
|
+
object_name: [
|
|
104
|
+
(identifier)
|
|
105
|
+
(quoted_identifier)
|
|
106
|
+
] @name) @definition.class
|
|
63
107
|
|
|
64
108
|
(permissionset_declaration
|
|
65
|
-
object_name: [
|
|
109
|
+
object_name: [
|
|
110
|
+
(identifier)
|
|
111
|
+
(quoted_identifier)
|
|
112
|
+
] @name) @definition.class
|
|
66
113
|
|
|
67
114
|
(entitlement_declaration
|
|
68
|
-
object_name: [
|
|
115
|
+
object_name: [
|
|
116
|
+
(identifier)
|
|
117
|
+
(quoted_identifier)
|
|
118
|
+
] @name) @definition.class
|
|
69
119
|
|
|
70
120
|
(pagecustomization_declaration
|
|
71
|
-
object_name: [
|
|
121
|
+
object_name: [
|
|
122
|
+
(identifier)
|
|
123
|
+
(quoted_identifier)
|
|
124
|
+
] @name) @definition.class
|
|
72
125
|
|
|
73
126
|
; =============================================================================
|
|
74
127
|
; Procedure and Trigger Definitions
|
|
75
128
|
; =============================================================================
|
|
76
|
-
|
|
77
129
|
; Procedure definitions
|
|
78
130
|
(procedure
|
|
79
|
-
name: [
|
|
131
|
+
name: [
|
|
132
|
+
(identifier)
|
|
133
|
+
(quoted_identifier)
|
|
134
|
+
] @name) @definition.method
|
|
80
135
|
|
|
81
136
|
; Event declarations
|
|
82
137
|
(event_declaration
|
|
83
|
-
name: [
|
|
138
|
+
name: [
|
|
139
|
+
(identifier)
|
|
140
|
+
(quoted_identifier)
|
|
141
|
+
] @name) @definition.method
|
|
84
142
|
|
|
85
143
|
; Trigger declarations
|
|
86
144
|
(trigger_declaration
|
|
87
|
-
name: [
|
|
145
|
+
name: [
|
|
146
|
+
(identifier)
|
|
147
|
+
(quoted_identifier)
|
|
148
|
+
] @name) @definition.method
|
|
149
|
+
|
|
88
150
|
; Scoped member-trigger name (`Object::Member`) — tag on the member
|
|
89
151
|
(trigger_declaration
|
|
90
152
|
name: (member_trigger_name
|
|
91
|
-
member: [
|
|
153
|
+
member: [
|
|
154
|
+
(identifier)
|
|
155
|
+
(quoted_identifier)
|
|
156
|
+
] @name)) @definition.method
|
|
92
157
|
|
|
93
158
|
; Interface procedures
|
|
94
159
|
(interface_procedure
|
|
95
|
-
name: [
|
|
160
|
+
name: [
|
|
161
|
+
(identifier)
|
|
162
|
+
(quoted_identifier)
|
|
163
|
+
] @name) @definition.method
|
|
96
164
|
|
|
97
165
|
; Split procedures (preprocessor-split)
|
|
98
166
|
(preproc_split_procedure
|
|
99
|
-
name: [
|
|
167
|
+
name: [
|
|
168
|
+
(identifier)
|
|
169
|
+
(quoted_identifier)
|
|
170
|
+
] @name) @definition.method
|
|
100
171
|
|
|
101
172
|
; =============================================================================
|
|
102
173
|
; Test Definitions (for test runners like neotest)
|
|
103
174
|
; =============================================================================
|
|
104
|
-
|
|
105
175
|
; [Test] as first attribute, 0+ trailing attributes before procedure
|
|
106
|
-
(
|
|
107
|
-
(
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
(#match? @_test_attr "^[Tt][Ee][Ss][Tt]$")))
|
|
176
|
+
((attribute_item
|
|
177
|
+
(attribute_content
|
|
178
|
+
name: (identifier) @_test_attr
|
|
179
|
+
(#match? @_test_attr "^[Tt][Ee][Ss][Tt]$")))
|
|
111
180
|
(attribute_item)*
|
|
112
181
|
.
|
|
113
182
|
(procedure
|
|
114
|
-
name: [
|
|
115
|
-
)
|
|
183
|
+
name: [
|
|
184
|
+
(identifier)
|
|
185
|
+
(quoted_identifier)
|
|
186
|
+
] @test.name) @test.definition)
|
|
116
187
|
|
|
117
188
|
; [Test] after 1+ other attributes (e.g. [Obsolete][Test][Scope] procedure)
|
|
118
|
-
(
|
|
119
|
-
(attribute_item)
|
|
189
|
+
((attribute_item)
|
|
120
190
|
.
|
|
121
191
|
(attribute_item
|
|
122
192
|
(attribute_content
|
|
@@ -125,13 +195,14 @@
|
|
|
125
195
|
(attribute_item)*
|
|
126
196
|
.
|
|
127
197
|
(procedure
|
|
128
|
-
name: [
|
|
129
|
-
)
|
|
198
|
+
name: [
|
|
199
|
+
(identifier)
|
|
200
|
+
(quoted_identifier)
|
|
201
|
+
] @test.name) @test.definition)
|
|
130
202
|
|
|
131
203
|
; =============================================================================
|
|
132
204
|
; Parameter Definitions
|
|
133
205
|
; =============================================================================
|
|
134
|
-
|
|
135
206
|
(parameter
|
|
136
207
|
name: (identifier) @name) @definition.parameter
|
|
137
208
|
|
|
@@ -141,27 +212,37 @@
|
|
|
141
212
|
; =============================================================================
|
|
142
213
|
; Field Definitions
|
|
143
214
|
; =============================================================================
|
|
144
|
-
|
|
145
215
|
; Table field definitions
|
|
146
216
|
(field_declaration
|
|
147
|
-
name: [
|
|
217
|
+
name: [
|
|
218
|
+
(identifier)
|
|
219
|
+
(quoted_identifier)
|
|
220
|
+
] @name) @definition.field
|
|
148
221
|
|
|
149
222
|
; Enum value definitions
|
|
150
223
|
(enum_value_declaration
|
|
151
|
-
value_name: [
|
|
224
|
+
value_name: [
|
|
225
|
+
(identifier)
|
|
226
|
+
(quoted_identifier)
|
|
227
|
+
] @name) @definition.constant
|
|
152
228
|
|
|
153
229
|
; Key definitions
|
|
154
230
|
(key_declaration
|
|
155
|
-
name: [
|
|
231
|
+
name: [
|
|
232
|
+
(identifier)
|
|
233
|
+
(quoted_identifier)
|
|
234
|
+
] @name) @definition.field
|
|
156
235
|
|
|
157
236
|
; Fieldgroup definitions
|
|
158
237
|
(fieldgroup_declaration
|
|
159
|
-
name: [
|
|
238
|
+
name: [
|
|
239
|
+
(identifier)
|
|
240
|
+
(quoted_identifier)
|
|
241
|
+
] @name) @definition.field
|
|
160
242
|
|
|
161
243
|
; =============================================================================
|
|
162
244
|
; Variable and Label Definitions
|
|
163
245
|
; =============================================================================
|
|
164
|
-
|
|
165
246
|
; Variable declarations
|
|
166
247
|
(variable_declaration
|
|
167
248
|
name: (identifier) @name) @definition.variable
|
|
@@ -183,40 +264,54 @@
|
|
|
183
264
|
; =============================================================================
|
|
184
265
|
; Action Definitions
|
|
185
266
|
; =============================================================================
|
|
186
|
-
|
|
187
267
|
(action_declaration
|
|
188
|
-
name: [
|
|
268
|
+
name: [
|
|
269
|
+
(identifier)
|
|
270
|
+
(quoted_identifier)
|
|
271
|
+
] @name) @definition.function
|
|
189
272
|
|
|
190
273
|
(customaction_declaration
|
|
191
|
-
name: [
|
|
274
|
+
name: [
|
|
275
|
+
(identifier)
|
|
276
|
+
(quoted_identifier)
|
|
277
|
+
] @name) @definition.function
|
|
192
278
|
|
|
193
279
|
(systemaction_declaration
|
|
194
|
-
name: [
|
|
280
|
+
name: [
|
|
281
|
+
(identifier)
|
|
282
|
+
(quoted_identifier)
|
|
283
|
+
] @name) @definition.function
|
|
195
284
|
|
|
196
285
|
(fileuploadaction_declaration
|
|
197
|
-
name: [
|
|
286
|
+
name: [
|
|
287
|
+
(identifier)
|
|
288
|
+
(quoted_identifier)
|
|
289
|
+
] @name) @definition.function
|
|
198
290
|
|
|
199
291
|
(actionref_declaration
|
|
200
|
-
action_name: [
|
|
292
|
+
action_name: [
|
|
293
|
+
(identifier)
|
|
294
|
+
(quoted_identifier)
|
|
295
|
+
] @name) @definition.function
|
|
201
296
|
|
|
202
297
|
; =============================================================================
|
|
203
298
|
; Module/Namespace Definitions
|
|
204
299
|
; =============================================================================
|
|
205
|
-
|
|
206
300
|
(namespace_declaration
|
|
207
301
|
name: (namespace_name) @name) @definition.module
|
|
208
302
|
|
|
209
303
|
; =============================================================================
|
|
210
304
|
; View Definitions
|
|
211
305
|
; =============================================================================
|
|
212
|
-
|
|
213
306
|
(view_definition
|
|
214
|
-
name: [
|
|
307
|
+
name: [
|
|
308
|
+
(identifier)
|
|
309
|
+
(quoted_identifier)
|
|
310
|
+
] @name) @definition.field
|
|
215
311
|
|
|
216
312
|
; =============================================================================
|
|
217
313
|
; Function/Method References
|
|
218
314
|
; =============================================================================
|
|
219
|
-
|
|
220
315
|
; Direct function calls
|
|
221
316
|
(call_expression
|
|
222
317
|
function: (identifier) @name) @reference.call
|
|
@@ -229,32 +324,48 @@
|
|
|
229
324
|
; =============================================================================
|
|
230
325
|
; Type References
|
|
231
326
|
; =============================================================================
|
|
232
|
-
|
|
233
327
|
; Record type references
|
|
234
328
|
(record_type
|
|
235
|
-
reference: [
|
|
329
|
+
reference: [
|
|
330
|
+
(identifier)
|
|
331
|
+
(quoted_identifier)
|
|
332
|
+
] @name) @reference.type
|
|
236
333
|
|
|
237
334
|
; Object reference type references
|
|
238
335
|
(object_reference_type
|
|
239
|
-
reference: [
|
|
336
|
+
reference: [
|
|
337
|
+
(identifier)
|
|
338
|
+
(quoted_identifier)
|
|
339
|
+
(integer)
|
|
340
|
+
] @name) @reference.type
|
|
240
341
|
|
|
241
342
|
; Database references
|
|
242
343
|
(database_reference
|
|
243
|
-
table_name: [
|
|
344
|
+
table_name: [
|
|
345
|
+
(identifier)
|
|
346
|
+
(quoted_identifier)
|
|
347
|
+
] @name) @reference.class
|
|
244
348
|
|
|
245
349
|
; =============================================================================
|
|
246
350
|
; Interface References
|
|
247
351
|
; =============================================================================
|
|
248
|
-
|
|
249
352
|
(implements_clause
|
|
250
|
-
interface: [
|
|
353
|
+
interface: [
|
|
354
|
+
(identifier)
|
|
355
|
+
(quoted_identifier)
|
|
356
|
+
] @name) @reference.implementation
|
|
251
357
|
|
|
252
358
|
; =============================================================================
|
|
253
359
|
; Enum Value References
|
|
254
360
|
; =============================================================================
|
|
255
|
-
|
|
256
361
|
(qualified_enum_value
|
|
257
|
-
enum_type: [
|
|
362
|
+
enum_type: [
|
|
363
|
+
(identifier)
|
|
364
|
+
(quoted_identifier)
|
|
365
|
+
] @name) @reference.class
|
|
258
366
|
|
|
259
367
|
(qualified_enum_value
|
|
260
|
-
value: [
|
|
368
|
+
value: [
|
|
369
|
+
(identifier)
|
|
370
|
+
(quoted_identifier)
|
|
371
|
+
] @name) @reference.constant
|