@sshadows/tree-sitter-al 2.1.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.
@@ -0,0 +1,605 @@
1
+ ; AL Language (v2) - Tree-sitter Syntax Highlighting Queries
2
+ ; See: https://tree-sitter.github.io/tree-sitter/syntax-highlighting
3
+ ;
4
+ ; Keywords are exposed as named nodes (e.g., if_keyword, table_keyword) for
5
+ ; precise highlighting. Note: begin/end use kw() regex tokens and cannot be
6
+ ; matched in queries.
7
+
8
+ ; =============================================================================
9
+ ; Comments
10
+ ; =============================================================================
11
+
12
+ (comment) @comment.line
13
+ (multiline_comment) @comment.block
14
+
15
+ ; =============================================================================
16
+ ; Preprocessor Directives
17
+ ; =============================================================================
18
+
19
+ [
20
+ (preproc_if)
21
+ (preproc_else)
22
+ (preproc_elif)
23
+ (preproc_endif)
24
+ (pragma)
25
+ (preproc_region)
26
+ (preproc_endregion)
27
+ ] @keyword.directive
28
+
29
+ ; =============================================================================
30
+ ; Keywords - Control Flow
31
+ ; =============================================================================
32
+
33
+ [
34
+ (if_keyword)
35
+ (then_keyword)
36
+ (else_keyword)
37
+ (case_keyword)
38
+ (of_keyword)
39
+ (while_keyword)
40
+ (do_keyword)
41
+ (for_keyword)
42
+ (foreach_keyword)
43
+ (in_keyword)
44
+ (repeat_keyword)
45
+ (until_keyword)
46
+ (exit_keyword)
47
+ (break_keyword)
48
+ (continue_keyword)
49
+ (with_keyword)
50
+ (asserterror_keyword)
51
+ (to_keyword)
52
+ (downto_keyword)
53
+ ] @keyword.control
54
+
55
+ ; =============================================================================
56
+ ; Keywords - Declarations
57
+ ; =============================================================================
58
+
59
+ [
60
+ (procedure_keyword)
61
+ (trigger_keyword)
62
+ (var_keyword)
63
+ (event_keyword)
64
+ ] @keyword.declaration
65
+
66
+ ; =============================================================================
67
+ ; Keywords - Object Types
68
+ ; =============================================================================
69
+
70
+ [
71
+ (table_keyword)
72
+ (tableextension_keyword)
73
+ (page_keyword)
74
+ (pageextension_keyword)
75
+ (codeunit_keyword)
76
+ (report_keyword)
77
+ (reportextension_keyword)
78
+ (query_keyword)
79
+ (xmlport_keyword)
80
+ (enum_keyword)
81
+ (enumextension_keyword)
82
+ (interface_keyword)
83
+ (controladdin_keyword)
84
+ (dotnet_keyword)
85
+ (profile_keyword)
86
+ (profileextension_keyword)
87
+ (permissionset_keyword)
88
+ (permissionsetextension_keyword)
89
+ (entitlement_keyword)
90
+ (pagecustomization_keyword)
91
+ ] @keyword.type
92
+
93
+ ; =============================================================================
94
+ ; Keywords - Structure
95
+ ; =============================================================================
96
+
97
+ [
98
+ (namespace_keyword)
99
+ (using_keyword)
100
+ (extends_keyword)
101
+ (implements_keyword)
102
+ (customizes_keyword)
103
+ ] @keyword.import
104
+
105
+ ; =============================================================================
106
+ ; Keywords - Sections
107
+ ; =============================================================================
108
+
109
+ [
110
+ (fields_keyword)
111
+ (keys_keyword)
112
+ (key_keyword)
113
+ (fieldgroups_keyword)
114
+ (fieldgroup_keyword)
115
+ (actions_keyword)
116
+ (layout_keyword)
117
+ (area_keyword)
118
+ (group_keyword)
119
+ (repeater_keyword)
120
+ (cuegroup_keyword)
121
+ (fixed_keyword)
122
+ (grid_keyword)
123
+ (part_keyword)
124
+ (systempart_keyword)
125
+ (usercontrol_keyword)
126
+ (dataset_keyword)
127
+ (elements_keyword)
128
+ (dataitem_keyword)
129
+ (column_keyword)
130
+ (filter_keyword)
131
+ (labels_keyword)
132
+ (rendering_keyword)
133
+ (requestpage_keyword)
134
+ (schema_keyword)
135
+ (views_keyword)
136
+ (view_keyword)
137
+ ] @keyword.structure
138
+
139
+ ; =============================================================================
140
+ ; Keywords - Modifiers
141
+ ; =============================================================================
142
+
143
+ [
144
+ (local_keyword)
145
+ (internal_keyword)
146
+ (protected_keyword)
147
+ (temporary_keyword)
148
+ ] @keyword.modifier
149
+
150
+ ; Procedure modifier (access modifiers on procedures)
151
+ (procedure_modifier) @keyword.modifier
152
+
153
+ ; Object type keyword (used in permission sets, database refs, etc.)
154
+ (object_type_keyword) @keyword
155
+
156
+ ; =============================================================================
157
+ ; Operators
158
+ ; =============================================================================
159
+
160
+ ; Assignment operator
161
+ ":=" @operator
162
+
163
+ ; Arithmetic operators
164
+ [
165
+ "+"
166
+ "-"
167
+ "*"
168
+ "/"
169
+ ] @operator
170
+
171
+ ; Comparison operators (named node wrapping =, <>, <, >, <=, >=)
172
+ (comparison_operator) @operator
173
+
174
+ ; Range operator
175
+ ".." @operator
176
+
177
+ ; Member access
178
+ "." @punctuation.delimiter
179
+
180
+ ; Enum/scope qualifier
181
+ "::" @operator
182
+
183
+ ; Ternary conditional
184
+ "?" @operator
185
+
186
+ ; Keyword operators (string literal alternatives, matchable)
187
+ [
188
+ "and" "AND" "And"
189
+ "or" "OR" "Or"
190
+ "xor" "XOR" "Xor"
191
+ "not" "NOT" "Not"
192
+ "div" "DIV" "Div"
193
+ "mod" "MOD" "Mod"
194
+ "in" "IN" "In"
195
+ ] @keyword.operator
196
+
197
+ ; =============================================================================
198
+ ; Punctuation
199
+ ; =============================================================================
200
+
201
+ ";" @punctuation.delimiter
202
+ ":" @punctuation.delimiter
203
+ "," @punctuation.delimiter
204
+
205
+ "(" @punctuation.bracket
206
+ ")" @punctuation.bracket
207
+ "[" @punctuation.bracket
208
+ "]" @punctuation.bracket
209
+ "{" @punctuation.bracket
210
+ "}" @punctuation.bracket
211
+
212
+ ; =============================================================================
213
+ ; Literals
214
+ ; =============================================================================
215
+
216
+ (string_literal) @string
217
+ (integer) @number
218
+ (decimal) @number.float
219
+ (biginteger_literal) @number
220
+ (boolean) @constant.builtin
221
+ (date_literal) @string.special
222
+ (time_literal) @string.special
223
+ (datetime_literal) @string.special
224
+
225
+ ; =============================================================================
226
+ ; Types
227
+ ; =============================================================================
228
+
229
+ ; Built-in types (Integer, Text, Boolean, Date, etc.)
230
+ (basic_type) @type.builtin
231
+
232
+ ; Parameterized built-in types
233
+ (text_type) @type.builtin
234
+ (code_type) @type.builtin
235
+
236
+ ; Record type references
237
+ (record_type
238
+ reference: [(identifier) (quoted_identifier)] @type)
239
+
240
+ ; Object reference types (Codeunit, Page, Report, etc.)
241
+ (object_reference_type
242
+ reference: [(identifier) (quoted_identifier) (integer)] @type)
243
+
244
+ ; Array, List, Dictionary types
245
+ (array_type) @type
246
+ (list_type) @type
247
+ (dictionary_type) @type
248
+
249
+ ; Option type
250
+ (option_type) @type
251
+
252
+ ; Type specifications
253
+ (type_specification) @type
254
+
255
+ ; DotNet type references
256
+ (dotnet_type
257
+ reference: [(identifier) (quoted_identifier)] @type)
258
+
259
+ ; =============================================================================
260
+ ; Object Declarations
261
+ ; =============================================================================
262
+
263
+ ; Tables
264
+ (table_declaration
265
+ object_id: (integer) @constant)
266
+ (table_declaration
267
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
268
+
269
+ ; Pages
270
+ (page_declaration
271
+ object_id: (integer) @constant)
272
+ (page_declaration
273
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
274
+
275
+ ; Codeunits
276
+ (codeunit_declaration
277
+ object_id: (integer) @constant)
278
+ (codeunit_declaration
279
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
280
+
281
+ ; Reports
282
+ (report_declaration
283
+ object_id: (integer) @constant)
284
+ (report_declaration
285
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
286
+
287
+ ; Queries
288
+ (query_declaration
289
+ object_id: (integer) @constant)
290
+ (query_declaration
291
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
292
+
293
+ ; XMLports
294
+ (xmlport_declaration
295
+ object_id: (integer) @constant)
296
+ (xmlport_declaration
297
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
298
+
299
+ ; Enums
300
+ (enum_declaration
301
+ object_id: (integer) @constant)
302
+ (enum_declaration
303
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
304
+
305
+ ; Interfaces
306
+ (interface_declaration
307
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
308
+
309
+ ; ControlAddins
310
+ (controladdin_declaration
311
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
312
+
313
+ ; Profiles
314
+ (profile_declaration
315
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
316
+
317
+ ; Permission Sets
318
+ (permissionset_declaration
319
+ object_id: (integer) @constant)
320
+ (permissionset_declaration
321
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
322
+
323
+ ; Entitlements
324
+ (entitlement_declaration
325
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
326
+
327
+ ; Page Customizations
328
+ (pagecustomization_declaration
329
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
330
+
331
+ ; DotNet
332
+ (dotnet_declaration) @type
333
+
334
+ ; =============================================================================
335
+ ; Extension Declarations
336
+ ; =============================================================================
337
+
338
+ (tableextension_declaration
339
+ object_id: (integer) @constant)
340
+ (tableextension_declaration
341
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
342
+
343
+ (pageextension_declaration
344
+ object_id: (integer) @constant)
345
+ (pageextension_declaration
346
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
347
+
348
+ (enumextension_declaration
349
+ object_id: (integer) @constant)
350
+ (enumextension_declaration
351
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
352
+
353
+ (reportextension_declaration
354
+ object_id: (integer) @constant)
355
+ (reportextension_declaration
356
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
357
+
358
+ (profileextension_declaration
359
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
360
+
361
+ (permissionsetextension_declaration
362
+ object_id: (integer) @constant)
363
+ (permissionsetextension_declaration
364
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
365
+
366
+ ; Split declarations (preprocessor-split object headers)
367
+ (preproc_split_declaration
368
+ object_id: (integer) @constant)
369
+ (preproc_split_declaration
370
+ object_name: [(identifier) (quoted_identifier)] @type.definition)
371
+
372
+ ; =============================================================================
373
+ ; Procedures and Triggers
374
+ ; =============================================================================
375
+
376
+ ; Procedure names
377
+ (procedure
378
+ name: [(identifier) (quoted_identifier)] @function.definition)
379
+
380
+ ; Event declarations
381
+ (event_declaration
382
+ name: [(identifier) (quoted_identifier)] @function.definition)
383
+
384
+ ; Trigger names
385
+ (trigger_declaration
386
+ name: [(identifier) (quoted_identifier)] @function.definition)
387
+
388
+ ; Interface procedures
389
+ (interface_procedure
390
+ name: [(identifier) (quoted_identifier)] @function.definition)
391
+
392
+ ; Split procedures (preprocessor-split)
393
+ (preproc_split_procedure
394
+ name: [(identifier) (quoted_identifier)] @function.definition)
395
+
396
+ ; =============================================================================
397
+ ; Fields and Variables
398
+ ; =============================================================================
399
+
400
+ ; Table field declarations
401
+ (field_declaration
402
+ id: (integer) @constant)
403
+ (field_declaration
404
+ name: [(identifier) (quoted_identifier)] @property.definition)
405
+
406
+ ; Variable declarations
407
+ (variable_declaration
408
+ name: [(identifier) (quoted_identifier)] @variable.definition)
409
+
410
+ ; Parameters
411
+ (parameter
412
+ name: [(identifier) (quoted_identifier)] @variable.parameter)
413
+
414
+ ; Label declarations
415
+ (label_declaration
416
+ name: (identifier) @constant.definition)
417
+
418
+ ; Enum value declarations
419
+ (enum_value_declaration
420
+ value_id: (integer) @constant)
421
+ (enum_value_declaration
422
+ value_name: [(identifier) (quoted_identifier)] @constant.definition)
423
+
424
+ ; Key declarations
425
+ (key_declaration
426
+ name: [(identifier) (quoted_identifier)] @property.definition)
427
+
428
+ ; Fieldgroup declarations
429
+ (fieldgroup_declaration
430
+ name: [(identifier) (quoted_identifier)] @property.definition)
431
+
432
+ ; Return values
433
+ (procedure
434
+ return_value: [(identifier) (quoted_identifier)] @variable.definition)
435
+ (trigger_declaration
436
+ return_value: [(identifier) (quoted_identifier)] @variable.definition)
437
+
438
+ ; For loop variables
439
+ (for_statement
440
+ variable: (identifier) @variable)
441
+
442
+ ; Foreach loop variables
443
+ (foreach_statement
444
+ variable: (identifier) @variable)
445
+
446
+ ; =============================================================================
447
+ ; Expressions
448
+ ; =============================================================================
449
+
450
+ ; Direct function calls
451
+ (call_expression
452
+ function: (identifier) @function.call)
453
+
454
+ ; Method calls on objects
455
+ (call_expression
456
+ function: (member_expression
457
+ member: (identifier) @function.method.call))
458
+
459
+ ; Member expression components
460
+ (member_expression
461
+ object: (identifier) @variable)
462
+ (member_expression
463
+ member: (identifier) @property)
464
+
465
+ ; Database references
466
+ (database_reference
467
+ table_name: [(identifier) (quoted_identifier)] @type)
468
+
469
+ ; Qualified enum values
470
+ (qualified_enum_value
471
+ enum_type: [(identifier) (quoted_identifier)] @type)
472
+ (qualified_enum_value
473
+ value: [(identifier) (quoted_identifier)] @constant)
474
+
475
+ ; Option members
476
+ (option_member) @constant
477
+
478
+ ; =============================================================================
479
+ ; Actions
480
+ ; =============================================================================
481
+
482
+ (action_declaration
483
+ name: [(identifier) (quoted_identifier)] @function)
484
+
485
+ (actionref_declaration
486
+ action_name: [(identifier) (quoted_identifier)] @function)
487
+
488
+ (customaction_declaration
489
+ name: [(identifier) (quoted_identifier)] @function)
490
+
491
+ (systemaction_declaration
492
+ name: [(identifier) (quoted_identifier)] @function)
493
+
494
+ (fileuploadaction_declaration
495
+ name: [(identifier) (quoted_identifier)] @function)
496
+
497
+ (separator_action
498
+ name: [(identifier) (quoted_identifier)] @punctuation.special)
499
+
500
+ ; =============================================================================
501
+ ; Namespace and Using
502
+ ; =============================================================================
503
+
504
+ (namespace_declaration
505
+ name: (namespace_name) @module)
506
+
507
+ (using_statement
508
+ namespace: (namespace_name) @module)
509
+
510
+ ; =============================================================================
511
+ ; Implements Clause
512
+ ; =============================================================================
513
+
514
+ (implements_clause
515
+ interface: [(identifier) (quoted_identifier)] @type)
516
+
517
+ ; =============================================================================
518
+ ; Attributes
519
+ ; =============================================================================
520
+
521
+ (attribute_item) @attribute
522
+
523
+ (attribute_content
524
+ name: (identifier) @attribute)
525
+
526
+ ; =============================================================================
527
+ ; Properties
528
+ ; =============================================================================
529
+
530
+ ; Property name
531
+ (property
532
+ name: (property_name) @property)
533
+
534
+ ; Keyword identifiers (contextual keywords used as values)
535
+ (keyword_identifier) @keyword
536
+
537
+ ; =============================================================================
538
+ ; Query and Report Elements
539
+ ; =============================================================================
540
+
541
+ ; Query dataitems
542
+ (query_dataitem
543
+ name: [(identifier) (quoted_identifier)] @variable)
544
+ (query_dataitem
545
+ table_name: [(identifier) (quoted_identifier)] @type)
546
+
547
+ ; Query columns
548
+ (query_column
549
+ name: [(identifier) (quoted_identifier)] @property)
550
+
551
+ ; Report dataitems
552
+ (report_dataitem
553
+ name: [(identifier) (quoted_identifier)] @variable)
554
+ (report_dataitem
555
+ table_name: [(identifier) (quoted_identifier)] @type)
556
+
557
+ ; Report columns
558
+ (report_column
559
+ name: [(identifier) (quoted_identifier)] @property)
560
+
561
+ ; =============================================================================
562
+ ; Page Fields
563
+ ; =============================================================================
564
+
565
+ (page_field
566
+ name: [(identifier) (quoted_identifier)] @property)
567
+
568
+ ; =============================================================================
569
+ ; XMLport Elements
570
+ ; =============================================================================
571
+
572
+ (xmlport_element
573
+ name: [(identifier) (quoted_identifier)] @property)
574
+ (xmlport_attribute
575
+ name: [(identifier) (quoted_identifier)] @property)
576
+
577
+ ; =============================================================================
578
+ ; View Definitions
579
+ ; =============================================================================
580
+
581
+ (view_definition
582
+ name: [(identifier) (quoted_identifier)] @property.definition)
583
+
584
+ ; =============================================================================
585
+ ; DotNet
586
+ ; =============================================================================
587
+
588
+ (assembly_declaration
589
+ name: [(string_literal) (quoted_identifier) (dotnet_assembly_name)] @string)
590
+
591
+ (type_declaration) @type
592
+
593
+ ; =============================================================================
594
+ ; Permission Types
595
+ ; =============================================================================
596
+
597
+ (permission_type) @keyword
598
+ (tabledata_permission
599
+ table_name: [(identifier) (quoted_identifier)] @type)
600
+
601
+ ; =============================================================================
602
+ ; Errors
603
+ ; =============================================================================
604
+
605
+ (ERROR) @error