@willbooster/tree-sitter-c-sharp 8.0.4 → 10.0.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/README.md +1 -1
- package/grammar.js +257 -29
- package/package.json +6 -6
- package/queries/highlights.scm +6 -4
- package/queries/tags.scm +1 -3
- package/src/node-types.json +220 -46
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-c-sharp)
|
|
10
10
|
|
|
11
11
|
C# grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
package/grammar.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const { alias, choice, field, grammar, optional, prec, repeat, repeat1, seq, sym, token } =
|
|
12
12
|
/** @type {typeof globalThis & import('@willbooster/web-tree-sitter/dsl').DSL} */ (globalThis);
|
|
13
13
|
|
|
14
|
-
/** @typedef {'_preproc_expression' | '_top_level_item_no_statement' | 'attribute_list' | 'declaration' | 'enum_member_declaration' | 'expression' | 'method_signature' | 'statement'} PreprocContentRule */
|
|
14
|
+
/** @typedef {'_preproc_expression' | '_top_level_item_no_statement' | '_base_list_mixed_type' | '_base_list_mixed_suffix' | '_base_list_trivia' | '_base_list' | '_base_list_type' | '_base_list_suffix' | '_base_list_prefix' | '_base_list_separator' | '_base_list_separator_path' | '_enum_base_clause' | '_enum_base_type' | 'attribute_list' | 'declaration' | 'enum_member_declaration' | 'expression' | 'method_signature' | 'statement'} PreprocContentRule */
|
|
15
15
|
|
|
16
16
|
const PREC = {
|
|
17
17
|
GENERIC: 19,
|
|
@@ -226,11 +226,36 @@ module.exports = grammar({
|
|
|
226
226
|
[$.parameter, $.declaration_expression],
|
|
227
227
|
[$.parameter, $.tuple_element],
|
|
228
228
|
[$.event_declaration, $.variable_declarator],
|
|
229
|
-
[$.base_list],
|
|
230
229
|
[$.using_directive, $.modifier],
|
|
231
230
|
[$.using_directive],
|
|
232
231
|
[$._constructor_declaration_initializer, $._simple_name],
|
|
233
232
|
[$.receiver_parameter, $.scoped_type, $._reserved_identifier],
|
|
233
|
+
[$._base_list_type, $._conditional_base_list_head, $._base_list_prefix],
|
|
234
|
+
[$._base_list_type, $._base_list_prefix],
|
|
235
|
+
[$._base_list_separator_path, $._base_list_suffix],
|
|
236
|
+
[sym('preproc_if_in_base_list'), sym('preproc_if_in_base_list_suffix')],
|
|
237
|
+
[sym('preproc_elif_in_base_list'), sym('preproc_elif_in_base_list_suffix')],
|
|
238
|
+
[sym('preproc_else_in_base_list'), sym('preproc_else_in_base_list_suffix')],
|
|
239
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_prefix'), sym('preproc_if_in_base_list_suffix')],
|
|
240
|
+
[
|
|
241
|
+
sym('preproc_elif_in_empty_base'),
|
|
242
|
+
sym('preproc_elif_in_base_list_prefix'),
|
|
243
|
+
sym('preproc_elif_in_base_list_suffix'),
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
sym('preproc_else_in_empty_base'),
|
|
247
|
+
sym('preproc_else_in_base_list_prefix'),
|
|
248
|
+
sym('preproc_else_in_base_list_suffix'),
|
|
249
|
+
],
|
|
250
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_prefix')],
|
|
251
|
+
[sym('preproc_elif_in_empty_base'), sym('preproc_elif_in_base_list_prefix')],
|
|
252
|
+
[sym('preproc_else_in_empty_base'), sym('preproc_else_in_base_list_prefix')],
|
|
253
|
+
[sym('preproc_if_in_empty_base'), sym('preproc_if_in_base_list_suffix')],
|
|
254
|
+
[sym('preproc_elif_in_empty_base'), sym('preproc_elif_in_base_list_suffix')],
|
|
255
|
+
[sym('preproc_else_in_empty_base'), sym('preproc_else_in_base_list_suffix')],
|
|
256
|
+
[sym('preproc_if_in_base_list_prefix'), sym('preproc_if_in_base_list_suffix')],
|
|
257
|
+
[sym('preproc_elif_in_base_list_prefix'), sym('preproc_elif_in_base_list_suffix')],
|
|
258
|
+
[sym('preproc_else_in_base_list_prefix'), sym('preproc_else_in_base_list_suffix')],
|
|
234
259
|
],
|
|
235
260
|
|
|
236
261
|
externals: () => [
|
|
@@ -307,6 +332,11 @@ module.exports = grammar({
|
|
|
307
332
|
],
|
|
308
333
|
|
|
309
334
|
inline: ($) => [
|
|
335
|
+
$._base_list,
|
|
336
|
+
$._base_list_head,
|
|
337
|
+
$._base_list_separator,
|
|
338
|
+
$._enum_base_clause,
|
|
339
|
+
$._enum_base_type,
|
|
310
340
|
$._postfix_receiver,
|
|
311
341
|
$._namespace_member_declaration,
|
|
312
342
|
$._object_creation_type,
|
|
@@ -393,7 +423,8 @@ module.exports = grammar({
|
|
|
393
423
|
namespace_declaration: ($) =>
|
|
394
424
|
seq('namespace', field('name', $._name), field('body', $.declaration_list), sym('_optional_semi')),
|
|
395
425
|
|
|
396
|
-
file_scoped_namespace_declaration: ($) =>
|
|
426
|
+
file_scoped_namespace_declaration: ($) =>
|
|
427
|
+
prec.right(seq('namespace', field('name', $._name), statementEnd(), repeat($._top_level_item_no_statement))),
|
|
397
428
|
|
|
398
429
|
type_declaration: ($) =>
|
|
399
430
|
choice(
|
|
@@ -413,7 +444,9 @@ module.exports = grammar({
|
|
|
413
444
|
repeat($.modifier),
|
|
414
445
|
'class',
|
|
415
446
|
field('name', $.identifier),
|
|
416
|
-
|
|
447
|
+
optional($.type_parameter_list),
|
|
448
|
+
optional($.parameter_list),
|
|
449
|
+
optional($._base_list),
|
|
417
450
|
repeat($.type_parameter_constraints_clause)
|
|
418
451
|
),
|
|
419
452
|
|
|
@@ -426,7 +459,9 @@ module.exports = grammar({
|
|
|
426
459
|
optional(seq('ref', optional(alias('partial', $.modifier)))),
|
|
427
460
|
'struct',
|
|
428
461
|
field('name', $.identifier),
|
|
429
|
-
|
|
462
|
+
optional($.type_parameter_list),
|
|
463
|
+
optional($.parameter_list),
|
|
464
|
+
optional($._base_list),
|
|
430
465
|
repeat($.type_parameter_constraints_clause)
|
|
431
466
|
),
|
|
432
467
|
|
|
@@ -437,7 +472,13 @@ module.exports = grammar({
|
|
|
437
472
|
),
|
|
438
473
|
|
|
439
474
|
_enum_declaration_initializer: ($) =>
|
|
440
|
-
seq(
|
|
475
|
+
seq(
|
|
476
|
+
repeat($._attribute_list),
|
|
477
|
+
repeat($.modifier),
|
|
478
|
+
'enum',
|
|
479
|
+
field('name', $.identifier),
|
|
480
|
+
optional($._enum_base_clause)
|
|
481
|
+
),
|
|
441
482
|
|
|
442
483
|
enum_member_declaration_list: ($) =>
|
|
443
484
|
seq(
|
|
@@ -461,7 +502,7 @@ module.exports = grammar({
|
|
|
461
502
|
'interface',
|
|
462
503
|
field('name', $.identifier),
|
|
463
504
|
field('type_parameters', optional($.type_parameter_list)),
|
|
464
|
-
optional($.
|
|
505
|
+
optional($._base_list),
|
|
465
506
|
repeat($.type_parameter_constraints_clause)
|
|
466
507
|
),
|
|
467
508
|
|
|
@@ -488,22 +529,15 @@ module.exports = grammar({
|
|
|
488
529
|
'record',
|
|
489
530
|
optional(choice('class', 'struct')),
|
|
490
531
|
field('name', $.identifier),
|
|
491
|
-
|
|
492
|
-
optional(
|
|
532
|
+
optional($.type_parameter_list),
|
|
533
|
+
optional($.parameter_list),
|
|
534
|
+
optional($._base_list),
|
|
493
535
|
repeat($.type_parameter_constraints_clause)
|
|
494
536
|
),
|
|
495
537
|
|
|
496
|
-
record_base: ($) =>
|
|
497
|
-
choice(
|
|
498
|
-
seq(':', commaSep1($._name)),
|
|
499
|
-
seq(':', $.primary_constructor_base_type, optional(seq(',', commaSep1($._name))))
|
|
500
|
-
),
|
|
501
|
-
|
|
502
538
|
_declaration_list_body: ($) =>
|
|
503
539
|
choice(seq(field('body', $.declaration_list), sym('_optional_semi')), statementEnd()),
|
|
504
540
|
|
|
505
|
-
primary_constructor_base_type: ($) => seq(field('type', $._name), $.argument_list),
|
|
506
|
-
|
|
507
541
|
modifier: () =>
|
|
508
542
|
prec.right(
|
|
509
543
|
choice(
|
|
@@ -536,7 +570,88 @@ module.exports = grammar({
|
|
|
536
570
|
|
|
537
571
|
type_parameter: ($) => seq(repeat($._attribute_list), optional(choice('in', 'out')), field('name', $.identifier)),
|
|
538
572
|
|
|
539
|
-
|
|
573
|
+
_enum_base_clause: ($) => choice(alias($._enum_base_list, $.base_list), $._conditional_enum_base_clause),
|
|
574
|
+
|
|
575
|
+
_conditional_enum_base_clause: ($) =>
|
|
576
|
+
seq(alias(sym('preproc_if_in_enum_base_clause'), sym('preproc_if')), optional($._enum_base_clause)),
|
|
577
|
+
|
|
578
|
+
_enum_base_list: ($) => seq(':', $._enum_base_type),
|
|
579
|
+
|
|
580
|
+
_enum_base_type: ($) =>
|
|
581
|
+
seq(
|
|
582
|
+
repeat($._base_list_trivia),
|
|
583
|
+
choice(field('underlying_type', $.type), $._conditional_enum_base_type),
|
|
584
|
+
repeat($._base_list_trivia)
|
|
585
|
+
),
|
|
586
|
+
|
|
587
|
+
_conditional_enum_base_type: ($) =>
|
|
588
|
+
choice(
|
|
589
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if')),
|
|
590
|
+
seq(
|
|
591
|
+
$._conditional_enum_base_type,
|
|
592
|
+
repeat($._base_list_trivia),
|
|
593
|
+
alias(sym('preproc_if_in_enum_base_type'), sym('preproc_if'))
|
|
594
|
+
)
|
|
595
|
+
),
|
|
596
|
+
|
|
597
|
+
_base_list_trivia: () => alias(sym('preproc_if_in_empty_base'), sym('preproc_if')),
|
|
598
|
+
|
|
599
|
+
_base_list: ($) => choice($.base_list, $._conditional_base_list),
|
|
600
|
+
|
|
601
|
+
_conditional_base_list: ($) =>
|
|
602
|
+
seq(
|
|
603
|
+
alias(sym('preproc_if_in_base_list'), sym('preproc_if')),
|
|
604
|
+
optional(choice($._base_list_suffix, $._base_list))
|
|
605
|
+
),
|
|
606
|
+
|
|
607
|
+
base_list: ($) => seq(':', $._base_list_type),
|
|
608
|
+
|
|
609
|
+
_base_list_type: ($) =>
|
|
610
|
+
choice(
|
|
611
|
+
seq($._base_list_mixed_type, choice($._base_list_type, $._base_list_suffix)),
|
|
612
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), $._base_list_type),
|
|
613
|
+
seq($._base_list_head, optional($._base_list_suffix))
|
|
614
|
+
),
|
|
615
|
+
|
|
616
|
+
_base_list_head: ($) =>
|
|
617
|
+
choice(seq(field('base', $.type), optional($.argument_list)), $._conditional_base_list_head),
|
|
618
|
+
|
|
619
|
+
_conditional_base_list_head: ($) =>
|
|
620
|
+
choice(
|
|
621
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if')),
|
|
622
|
+
seq(
|
|
623
|
+
$._conditional_base_list_head,
|
|
624
|
+
repeat($._base_list_trivia),
|
|
625
|
+
alias(sym('preproc_if_in_base_list_type'), sym('preproc_if'))
|
|
626
|
+
)
|
|
627
|
+
),
|
|
628
|
+
|
|
629
|
+
_base_list_mixed_type: () => alias(sym('preproc_if_in_mixed_base_type'), sym('preproc_if')),
|
|
630
|
+
|
|
631
|
+
_base_list_mixed_suffix: () => alias(sym('preproc_if_in_mixed_base_suffix'), sym('preproc_if')),
|
|
632
|
+
|
|
633
|
+
_base_list_prefix: ($) =>
|
|
634
|
+
choice(
|
|
635
|
+
seq($._base_list_mixed_type, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
636
|
+
seq(alias(sym('preproc_if_in_base_list_prefix'), sym('preproc_if')), optional($._base_list_prefix)),
|
|
637
|
+
seq($._base_list_head, $._base_list_separator_path)
|
|
638
|
+
),
|
|
639
|
+
|
|
640
|
+
_base_list_separator: () => choice(',', alias(sym('preproc_if_in_base_list_separator'), sym('preproc_if'))),
|
|
641
|
+
|
|
642
|
+
_base_list_separator_path: ($) =>
|
|
643
|
+
choice(
|
|
644
|
+
seq($._base_list_mixed_suffix, choice($._base_list_prefix, $._base_list_separator_path)),
|
|
645
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), $._base_list_separator_path),
|
|
646
|
+
seq($._base_list_separator, optional($._base_list_prefix))
|
|
647
|
+
),
|
|
648
|
+
|
|
649
|
+
_base_list_suffix: ($) =>
|
|
650
|
+
choice(
|
|
651
|
+
seq($._base_list_mixed_suffix, choice($._base_list_type, $._base_list_suffix)),
|
|
652
|
+
seq(alias(sym('preproc_if_in_base_list_suffix'), sym('preproc_if')), optional($._base_list_suffix)),
|
|
653
|
+
seq($._base_list_separator, $._base_list_type)
|
|
654
|
+
),
|
|
540
655
|
|
|
541
656
|
type_parameter_constraints_clause: ($) => seq('where', $.identifier, ':', commaSep1($.type_parameter_constraint)),
|
|
542
657
|
|
|
@@ -2335,6 +2450,36 @@ module.exports = grammar({
|
|
|
2335
2450
|
false,
|
|
2336
2451
|
true
|
|
2337
2452
|
),
|
|
2453
|
+
...preprocIfWithMixedContent(
|
|
2454
|
+
'_in_mixed_base_type',
|
|
2455
|
+
($) => $._base_list_type,
|
|
2456
|
+
($) => $._base_list_prefix,
|
|
2457
|
+
($) =>
|
|
2458
|
+
choice(
|
|
2459
|
+
$._base_list_mixed_type,
|
|
2460
|
+
seq($._base_list_prefix, $._base_list_mixed_type),
|
|
2461
|
+
seq($._base_list_type, $._base_list_mixed_suffix)
|
|
2462
|
+
)
|
|
2463
|
+
),
|
|
2464
|
+
...preprocIfWithMixedContent(
|
|
2465
|
+
'_in_mixed_base_suffix',
|
|
2466
|
+
($) => $._base_list_suffix,
|
|
2467
|
+
($) => $._base_list_separator_path,
|
|
2468
|
+
($) =>
|
|
2469
|
+
choice(
|
|
2470
|
+
$._base_list_mixed_suffix,
|
|
2471
|
+
seq($._base_list_suffix, $._base_list_mixed_suffix),
|
|
2472
|
+
seq($._base_list_separator_path, $._base_list_mixed_type)
|
|
2473
|
+
)
|
|
2474
|
+
),
|
|
2475
|
+
...preprocIf('_in_empty_base', ($) => $._base_list_trivia),
|
|
2476
|
+
...preprocIf('_in_enum_base_clause', ($) => $._enum_base_clause, 0, false),
|
|
2477
|
+
...preprocIfWithContent('_in_enum_base_type', ($) => $._enum_base_type),
|
|
2478
|
+
...preprocIf('_in_base_list', ($) => $._base_list, 0, false),
|
|
2479
|
+
...preprocIfWithContent('_in_base_list_type', ($) => $._base_list_type),
|
|
2480
|
+
...preprocIf('_in_base_list_prefix', ($) => $._base_list_prefix, 0, false),
|
|
2481
|
+
...preprocIf('_in_base_list_separator', ($) => $._base_list_separator_path, 0, false, true),
|
|
2482
|
+
...preprocIf('_in_base_list_suffix', ($) => $._base_list_suffix, 0, false),
|
|
2338
2483
|
...preprocIf('', ($) => $.declaration),
|
|
2339
2484
|
...preprocIf('_in_top_level', ($) => choice($._top_level_item_no_statement, $.statement)),
|
|
2340
2485
|
...preprocIf('_in_expression', ($) => $.expression, -2, false),
|
|
@@ -2611,6 +2756,87 @@ function preprocessor(command) {
|
|
|
2611
2756
|
return alias(new RegExp('#[ \t]*' + command), '#' + command);
|
|
2612
2757
|
}
|
|
2613
2758
|
|
|
2759
|
+
/**
|
|
2760
|
+
* @param {string} suffix
|
|
2761
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} complete
|
|
2762
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} prefix
|
|
2763
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} mixed
|
|
2764
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2765
|
+
*/
|
|
2766
|
+
function preprocIfWithMixedContent(suffix, complete, prefix, mixed) {
|
|
2767
|
+
const contents = [undefined, complete, prefix, mixed];
|
|
2768
|
+
/** @param {number} mask */
|
|
2769
|
+
function alternativeBlock(mask) {
|
|
2770
|
+
return choice(
|
|
2771
|
+
alias(sym('preproc_else' + suffix + mask), sym('preproc_else')),
|
|
2772
|
+
alias(sym('preproc_elif' + suffix + mask), sym('preproc_elif'))
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2777
|
+
* @param {number} mask
|
|
2778
|
+
*/
|
|
2779
|
+
function contentOrAlternative($, mask) {
|
|
2780
|
+
return choice(
|
|
2781
|
+
...contents.map((content, provided) => {
|
|
2782
|
+
const remaining = mask & ~provided;
|
|
2783
|
+
const alternative = field(
|
|
2784
|
+
'alternative',
|
|
2785
|
+
remaining ? alternativeBlock(remaining) : optional(alternativeBlock(0))
|
|
2786
|
+
);
|
|
2787
|
+
return content ? seq(content($), alternative) : alternative;
|
|
2788
|
+
})
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
/** @type {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>} */
|
|
2792
|
+
const rules = {
|
|
2793
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($, 3), preprocessor('endif')),
|
|
2794
|
+
};
|
|
2795
|
+
for (const mask of [0, 1, 2, 3]) {
|
|
2796
|
+
rules['preproc_elif' + suffix + mask] = ($) => conditionalDirective('elif', $, contentOrAlternative($, mask));
|
|
2797
|
+
rules['preproc_else' + suffix + mask] = ($) =>
|
|
2798
|
+
seq(
|
|
2799
|
+
preprocessor('else'),
|
|
2800
|
+
choice(
|
|
2801
|
+
...contents.flatMap((content, provided) => (content && (provided & mask) === mask ? [content($)] : [])),
|
|
2802
|
+
...(mask === 0 ? [optional($._base_list_trivia)] : [])
|
|
2803
|
+
)
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
return rules;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
/**
|
|
2810
|
+
* @param {string} suffix
|
|
2811
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>} content
|
|
2812
|
+
* @returns {Record<string, import('@willbooster/web-tree-sitter/dsl').RuleBuilder<PreprocContentRule>>}
|
|
2813
|
+
*/
|
|
2814
|
+
function preprocIfWithContent(suffix, content) {
|
|
2815
|
+
/** @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $ */
|
|
2816
|
+
function contentOrAlternative($) {
|
|
2817
|
+
return choice(
|
|
2818
|
+
seq(content($), field('alternative', optional(alternativeBlock(false)))),
|
|
2819
|
+
seq(repeat($._base_list_trivia), field('alternative', alternativeBlock(true)))
|
|
2820
|
+
);
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
/** @param {boolean} required */
|
|
2824
|
+
function alternativeBlock(required) {
|
|
2825
|
+
const alternativeSuffix = suffix + (required ? '_with_content' : '');
|
|
2826
|
+
return choice(
|
|
2827
|
+
alias(sym('preproc_else' + alternativeSuffix), sym('preproc_else')),
|
|
2828
|
+
alias(sym('preproc_elif' + alternativeSuffix), sym('preproc_elif'))
|
|
2829
|
+
);
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
return {
|
|
2833
|
+
...preprocIf(suffix, ($) => choice(content($), repeat1($._base_list_trivia)), 0, false),
|
|
2834
|
+
['preproc_if' + suffix]: ($) => conditionalDirective('if', $, contentOrAlternative($), preprocessor('endif')),
|
|
2835
|
+
['preproc_else' + suffix + '_with_content']: ($) => seq(preprocessor('else'), content($)),
|
|
2836
|
+
['preproc_elif' + suffix + '_with_content']: ($) => conditionalDirective('elif', $, contentOrAlternative($)),
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2614
2840
|
/**
|
|
2615
2841
|
*
|
|
2616
2842
|
* @param {string} suffix
|
|
@@ -2647,10 +2873,9 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2647
2873
|
['preproc_if' + suffix]: ($) =>
|
|
2648
2874
|
prec(
|
|
2649
2875
|
precedence,
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
directiveNewLine(),
|
|
2876
|
+
conditionalDirective(
|
|
2877
|
+
'if',
|
|
2878
|
+
$,
|
|
2654
2879
|
contentRule($),
|
|
2655
2880
|
field('alternative', optional(alternativeBlock())),
|
|
2656
2881
|
preprocessor('endif')
|
|
@@ -2662,17 +2887,20 @@ function preprocIf(suffix, content, precedence = 0, rep = true, required = false
|
|
|
2662
2887
|
['preproc_elif' + suffix]: ($) =>
|
|
2663
2888
|
prec(
|
|
2664
2889
|
precedence,
|
|
2665
|
-
|
|
2666
|
-
preprocessor('elif'),
|
|
2667
|
-
field('condition', $._preproc_expression),
|
|
2668
|
-
directiveNewLine(),
|
|
2669
|
-
contentRule($),
|
|
2670
|
-
field('alternative', optional(alternativeBlock()))
|
|
2671
|
-
)
|
|
2890
|
+
conditionalDirective('elif', $, contentRule($), field('alternative', optional(alternativeBlock())))
|
|
2672
2891
|
),
|
|
2673
2892
|
};
|
|
2674
2893
|
}
|
|
2675
2894
|
|
|
2895
|
+
/**
|
|
2896
|
+
* @param {'if' | 'elif'} command
|
|
2897
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<PreprocContentRule>} $
|
|
2898
|
+
* @param {...import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
|
|
2899
|
+
*/
|
|
2900
|
+
function conditionalDirective(command, $, ...content) {
|
|
2901
|
+
return seq(preprocessor(command), field('condition', $._preproc_expression), directiveNewLine(), ...content);
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2676
2904
|
/**
|
|
2677
2905
|
* @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'_simple_name'>} $
|
|
2678
2906
|
* @param {import('@willbooster/web-tree-sitter/dsl').Rule} receiver
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-c-sharp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "C# grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@tsconfig/bun": "1.0.11",
|
|
46
|
-
"@types/bun": "1.4.
|
|
46
|
+
"@types/bun": "1.4.3",
|
|
47
47
|
"@vitest/browser-playwright": "5.0.3",
|
|
48
48
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
49
49
|
"@willbooster/oxlint-config": "1.4.8",
|
|
50
|
-
"@willbooster/wb": "22.26.
|
|
50
|
+
"@willbooster/wb": "22.26.2",
|
|
51
51
|
"@willbooster/web-tree-sitter": "7.0.20",
|
|
52
52
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
53
|
-
"lefthook": "2.2.
|
|
54
|
-
"oxfmt": "0.
|
|
55
|
-
"oxlint": "1.
|
|
53
|
+
"lefthook": "2.2.2",
|
|
54
|
+
"oxfmt": "0.73.0",
|
|
55
|
+
"oxlint": "1.88.0",
|
|
56
56
|
"oxlint-tsgolint": "7.0.2004",
|
|
57
57
|
"playwright": "1.64.0",
|
|
58
58
|
"semantic-release": "25.0.9",
|
package/queries/highlights.scm
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
(interface_declaration name: (identifier) @type)
|
|
12
12
|
(class_declaration name: (identifier) @type)
|
|
13
13
|
(enum_declaration name: (identifier) @type)
|
|
14
|
-
(struct_declaration (identifier) @type)
|
|
15
|
-
(record_declaration (identifier) @type)
|
|
14
|
+
(struct_declaration name: (identifier) @type)
|
|
15
|
+
(record_declaration name: (identifier) @type)
|
|
16
16
|
(namespace_declaration name: (identifier) @module)
|
|
17
17
|
|
|
18
18
|
(generic_name (identifier) @type)
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
(_ type: (identifier) @type)
|
|
29
29
|
|
|
30
|
-
(base_list (identifier) @type)
|
|
31
|
-
|
|
32
30
|
(predefined_type) @type.builtin
|
|
33
31
|
|
|
34
32
|
;; Enum
|
|
@@ -219,3 +217,7 @@
|
|
|
219
217
|
(file_directive_value) @string
|
|
220
218
|
|
|
221
219
|
(file_directive_kind) @keyword.directive
|
|
220
|
+
|
|
221
|
+
(_ base: (identifier) @type)
|
|
222
|
+
|
|
223
|
+
(_ underlying_type: (identifier) @type)
|
package/queries/tags.scm
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
(class_declaration name: (identifier) @name) @definition.class
|
|
2
2
|
|
|
3
|
-
(
|
|
3
|
+
(_ base: (_) @name @reference.class)
|
|
4
4
|
|
|
5
5
|
(interface_declaration name: (identifier) @name) @definition.interface
|
|
6
6
|
|
|
7
|
-
(interface_declaration (base_list (_) @name)) @reference.interface
|
|
8
|
-
|
|
9
7
|
(method_declaration name: (identifier) @name) @definition.method
|
|
10
8
|
|
|
11
9
|
(method_signature name: (identifier) @name) @definition.method
|
package/src/node-types.json
CHANGED
|
@@ -1427,21 +1427,38 @@
|
|
|
1427
1427
|
{
|
|
1428
1428
|
"type": "base_list",
|
|
1429
1429
|
"named": true,
|
|
1430
|
-
"fields": {
|
|
1430
|
+
"fields": {
|
|
1431
|
+
"base": {
|
|
1432
|
+
"multiple": true,
|
|
1433
|
+
"required": false,
|
|
1434
|
+
"types": [
|
|
1435
|
+
{
|
|
1436
|
+
"type": "type",
|
|
1437
|
+
"named": true
|
|
1438
|
+
}
|
|
1439
|
+
]
|
|
1440
|
+
},
|
|
1441
|
+
"underlying_type": {
|
|
1442
|
+
"multiple": false,
|
|
1443
|
+
"required": false,
|
|
1444
|
+
"types": [
|
|
1445
|
+
{
|
|
1446
|
+
"type": "type",
|
|
1447
|
+
"named": true
|
|
1448
|
+
}
|
|
1449
|
+
]
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1431
1452
|
"children": {
|
|
1432
1453
|
"multiple": true,
|
|
1433
|
-
"required":
|
|
1454
|
+
"required": false,
|
|
1434
1455
|
"types": [
|
|
1435
1456
|
{
|
|
1436
1457
|
"type": "argument_list",
|
|
1437
1458
|
"named": true
|
|
1438
1459
|
},
|
|
1439
1460
|
{
|
|
1440
|
-
"type": "
|
|
1441
|
-
"named": true
|
|
1442
|
-
},
|
|
1443
|
-
{
|
|
1444
|
-
"type": "type",
|
|
1461
|
+
"type": "preproc_if",
|
|
1445
1462
|
"named": true
|
|
1446
1463
|
}
|
|
1447
1464
|
]
|
|
@@ -1952,6 +1969,16 @@
|
|
|
1952
1969
|
"type": "class_declaration",
|
|
1953
1970
|
"named": true,
|
|
1954
1971
|
"fields": {
|
|
1972
|
+
"base": {
|
|
1973
|
+
"multiple": true,
|
|
1974
|
+
"required": false,
|
|
1975
|
+
"types": [
|
|
1976
|
+
{
|
|
1977
|
+
"type": "type",
|
|
1978
|
+
"named": true
|
|
1979
|
+
}
|
|
1980
|
+
]
|
|
1981
|
+
},
|
|
1955
1982
|
"body": {
|
|
1956
1983
|
"multiple": false,
|
|
1957
1984
|
"required": false,
|
|
@@ -1977,6 +2004,10 @@
|
|
|
1977
2004
|
"multiple": true,
|
|
1978
2005
|
"required": false,
|
|
1979
2006
|
"types": [
|
|
2007
|
+
{
|
|
2008
|
+
"type": "argument_list",
|
|
2009
|
+
"named": true
|
|
2010
|
+
},
|
|
1980
2011
|
{
|
|
1981
2012
|
"type": "attribute_list",
|
|
1982
2013
|
"named": true
|
|
@@ -1993,6 +2024,10 @@
|
|
|
1993
2024
|
"type": "parameter_list",
|
|
1994
2025
|
"named": true
|
|
1995
2026
|
},
|
|
2027
|
+
{
|
|
2028
|
+
"type": "preproc_if",
|
|
2029
|
+
"named": true
|
|
2030
|
+
},
|
|
1996
2031
|
{
|
|
1997
2032
|
"type": "preproc_if_in_attribute_list",
|
|
1998
2033
|
"named": true
|
|
@@ -3123,6 +3158,10 @@
|
|
|
3123
3158
|
"type": "modifier",
|
|
3124
3159
|
"named": true
|
|
3125
3160
|
},
|
|
3161
|
+
{
|
|
3162
|
+
"type": "preproc_if",
|
|
3163
|
+
"named": true
|
|
3164
|
+
},
|
|
3126
3165
|
{
|
|
3127
3166
|
"type": "preproc_if_in_attribute_list",
|
|
3128
3167
|
"named": true
|
|
@@ -3633,6 +3672,40 @@
|
|
|
3633
3672
|
}
|
|
3634
3673
|
]
|
|
3635
3674
|
}
|
|
3675
|
+
},
|
|
3676
|
+
"children": {
|
|
3677
|
+
"multiple": true,
|
|
3678
|
+
"required": false,
|
|
3679
|
+
"types": [
|
|
3680
|
+
{
|
|
3681
|
+
"type": "extern_alias_directive",
|
|
3682
|
+
"named": true
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
"type": "file_scoped_namespace_declaration",
|
|
3686
|
+
"named": true
|
|
3687
|
+
},
|
|
3688
|
+
{
|
|
3689
|
+
"type": "global_attribute",
|
|
3690
|
+
"named": true
|
|
3691
|
+
},
|
|
3692
|
+
{
|
|
3693
|
+
"type": "namespace_declaration",
|
|
3694
|
+
"named": true
|
|
3695
|
+
},
|
|
3696
|
+
{
|
|
3697
|
+
"type": "preproc_if",
|
|
3698
|
+
"named": true
|
|
3699
|
+
},
|
|
3700
|
+
{
|
|
3701
|
+
"type": "type_declaration",
|
|
3702
|
+
"named": true
|
|
3703
|
+
},
|
|
3704
|
+
{
|
|
3705
|
+
"type": "using_directive",
|
|
3706
|
+
"named": true
|
|
3707
|
+
}
|
|
3708
|
+
]
|
|
3636
3709
|
}
|
|
3637
3710
|
},
|
|
3638
3711
|
{
|
|
@@ -4165,6 +4238,16 @@
|
|
|
4165
4238
|
"type": "interface_declaration",
|
|
4166
4239
|
"named": true,
|
|
4167
4240
|
"fields": {
|
|
4241
|
+
"base": {
|
|
4242
|
+
"multiple": true,
|
|
4243
|
+
"required": false,
|
|
4244
|
+
"types": [
|
|
4245
|
+
{
|
|
4246
|
+
"type": "type",
|
|
4247
|
+
"named": true
|
|
4248
|
+
}
|
|
4249
|
+
]
|
|
4250
|
+
},
|
|
4168
4251
|
"body": {
|
|
4169
4252
|
"multiple": false,
|
|
4170
4253
|
"required": false,
|
|
@@ -4200,6 +4283,10 @@
|
|
|
4200
4283
|
"multiple": true,
|
|
4201
4284
|
"required": false,
|
|
4202
4285
|
"types": [
|
|
4286
|
+
{
|
|
4287
|
+
"type": "argument_list",
|
|
4288
|
+
"named": true
|
|
4289
|
+
},
|
|
4203
4290
|
{
|
|
4204
4291
|
"type": "attribute_list",
|
|
4205
4292
|
"named": true
|
|
@@ -4212,6 +4299,10 @@
|
|
|
4212
4299
|
"type": "modifier",
|
|
4213
4300
|
"named": true
|
|
4214
4301
|
},
|
|
4302
|
+
{
|
|
4303
|
+
"type": "preproc_if",
|
|
4304
|
+
"named": true
|
|
4305
|
+
},
|
|
4215
4306
|
{
|
|
4216
4307
|
"type": "preproc_if_in_attribute_list",
|
|
4217
4308
|
"named": true
|
|
@@ -6104,6 +6195,16 @@
|
|
|
6104
6195
|
}
|
|
6105
6196
|
]
|
|
6106
6197
|
},
|
|
6198
|
+
"base": {
|
|
6199
|
+
"multiple": true,
|
|
6200
|
+
"required": false,
|
|
6201
|
+
"types": [
|
|
6202
|
+
{
|
|
6203
|
+
"type": "type",
|
|
6204
|
+
"named": true
|
|
6205
|
+
}
|
|
6206
|
+
]
|
|
6207
|
+
},
|
|
6107
6208
|
"condition": {
|
|
6108
6209
|
"multiple": false,
|
|
6109
6210
|
"required": true,
|
|
@@ -6137,16 +6238,34 @@
|
|
|
6137
6238
|
"named": true
|
|
6138
6239
|
}
|
|
6139
6240
|
]
|
|
6241
|
+
},
|
|
6242
|
+
"underlying_type": {
|
|
6243
|
+
"multiple": false,
|
|
6244
|
+
"required": false,
|
|
6245
|
+
"types": [
|
|
6246
|
+
{
|
|
6247
|
+
"type": "type",
|
|
6248
|
+
"named": true
|
|
6249
|
+
}
|
|
6250
|
+
]
|
|
6140
6251
|
}
|
|
6141
6252
|
},
|
|
6142
6253
|
"children": {
|
|
6143
6254
|
"multiple": true,
|
|
6144
6255
|
"required": false,
|
|
6145
6256
|
"types": [
|
|
6257
|
+
{
|
|
6258
|
+
"type": "argument_list",
|
|
6259
|
+
"named": true
|
|
6260
|
+
},
|
|
6146
6261
|
{
|
|
6147
6262
|
"type": "attribute_list",
|
|
6148
6263
|
"named": true
|
|
6149
6264
|
},
|
|
6265
|
+
{
|
|
6266
|
+
"type": "base_list",
|
|
6267
|
+
"named": true
|
|
6268
|
+
},
|
|
6150
6269
|
{
|
|
6151
6270
|
"type": "declaration",
|
|
6152
6271
|
"named": true
|
|
@@ -6189,15 +6308,44 @@
|
|
|
6189
6308
|
{
|
|
6190
6309
|
"type": "preproc_else",
|
|
6191
6310
|
"named": true,
|
|
6192
|
-
"fields": {
|
|
6311
|
+
"fields": {
|
|
6312
|
+
"base": {
|
|
6313
|
+
"multiple": true,
|
|
6314
|
+
"required": false,
|
|
6315
|
+
"types": [
|
|
6316
|
+
{
|
|
6317
|
+
"type": "type",
|
|
6318
|
+
"named": true
|
|
6319
|
+
}
|
|
6320
|
+
]
|
|
6321
|
+
},
|
|
6322
|
+
"underlying_type": {
|
|
6323
|
+
"multiple": false,
|
|
6324
|
+
"required": false,
|
|
6325
|
+
"types": [
|
|
6326
|
+
{
|
|
6327
|
+
"type": "type",
|
|
6328
|
+
"named": true
|
|
6329
|
+
}
|
|
6330
|
+
]
|
|
6331
|
+
}
|
|
6332
|
+
},
|
|
6193
6333
|
"children": {
|
|
6194
6334
|
"multiple": true,
|
|
6195
6335
|
"required": false,
|
|
6196
6336
|
"types": [
|
|
6337
|
+
{
|
|
6338
|
+
"type": "argument_list",
|
|
6339
|
+
"named": true
|
|
6340
|
+
},
|
|
6197
6341
|
{
|
|
6198
6342
|
"type": "attribute_list",
|
|
6199
6343
|
"named": true
|
|
6200
6344
|
},
|
|
6345
|
+
{
|
|
6346
|
+
"type": "base_list",
|
|
6347
|
+
"named": true
|
|
6348
|
+
},
|
|
6201
6349
|
{
|
|
6202
6350
|
"type": "declaration",
|
|
6203
6351
|
"named": true
|
|
@@ -6288,6 +6436,16 @@
|
|
|
6288
6436
|
}
|
|
6289
6437
|
]
|
|
6290
6438
|
},
|
|
6439
|
+
"base": {
|
|
6440
|
+
"multiple": true,
|
|
6441
|
+
"required": false,
|
|
6442
|
+
"types": [
|
|
6443
|
+
{
|
|
6444
|
+
"type": "type",
|
|
6445
|
+
"named": true
|
|
6446
|
+
}
|
|
6447
|
+
]
|
|
6448
|
+
},
|
|
6291
6449
|
"condition": {
|
|
6292
6450
|
"multiple": false,
|
|
6293
6451
|
"required": true,
|
|
@@ -6321,12 +6479,30 @@
|
|
|
6321
6479
|
"named": true
|
|
6322
6480
|
}
|
|
6323
6481
|
]
|
|
6482
|
+
},
|
|
6483
|
+
"underlying_type": {
|
|
6484
|
+
"multiple": false,
|
|
6485
|
+
"required": false,
|
|
6486
|
+
"types": [
|
|
6487
|
+
{
|
|
6488
|
+
"type": "type",
|
|
6489
|
+
"named": true
|
|
6490
|
+
}
|
|
6491
|
+
]
|
|
6324
6492
|
}
|
|
6325
6493
|
},
|
|
6326
6494
|
"children": {
|
|
6327
6495
|
"multiple": true,
|
|
6328
6496
|
"required": false,
|
|
6329
6497
|
"types": [
|
|
6498
|
+
{
|
|
6499
|
+
"type": "argument_list",
|
|
6500
|
+
"named": true
|
|
6501
|
+
},
|
|
6502
|
+
{
|
|
6503
|
+
"type": "base_list",
|
|
6504
|
+
"named": true
|
|
6505
|
+
},
|
|
6330
6506
|
{
|
|
6331
6507
|
"type": "declaration",
|
|
6332
6508
|
"named": true
|
|
@@ -6533,44 +6709,6 @@
|
|
|
6533
6709
|
]
|
|
6534
6710
|
}
|
|
6535
6711
|
},
|
|
6536
|
-
{
|
|
6537
|
-
"type": "primary_constructor_base_type",
|
|
6538
|
-
"named": true,
|
|
6539
|
-
"fields": {
|
|
6540
|
-
"type": {
|
|
6541
|
-
"multiple": false,
|
|
6542
|
-
"required": true,
|
|
6543
|
-
"types": [
|
|
6544
|
-
{
|
|
6545
|
-
"type": "alias_qualified_name",
|
|
6546
|
-
"named": true
|
|
6547
|
-
},
|
|
6548
|
-
{
|
|
6549
|
-
"type": "generic_name",
|
|
6550
|
-
"named": true
|
|
6551
|
-
},
|
|
6552
|
-
{
|
|
6553
|
-
"type": "identifier",
|
|
6554
|
-
"named": true
|
|
6555
|
-
},
|
|
6556
|
-
{
|
|
6557
|
-
"type": "qualified_name",
|
|
6558
|
-
"named": true
|
|
6559
|
-
}
|
|
6560
|
-
]
|
|
6561
|
-
}
|
|
6562
|
-
},
|
|
6563
|
-
"children": {
|
|
6564
|
-
"multiple": false,
|
|
6565
|
-
"required": true,
|
|
6566
|
-
"types": [
|
|
6567
|
-
{
|
|
6568
|
-
"type": "argument_list",
|
|
6569
|
-
"named": true
|
|
6570
|
-
}
|
|
6571
|
-
]
|
|
6572
|
-
}
|
|
6573
|
-
},
|
|
6574
6712
|
{
|
|
6575
6713
|
"type": "property_declaration",
|
|
6576
6714
|
"named": true,
|
|
@@ -6829,6 +6967,16 @@
|
|
|
6829
6967
|
"type": "record_declaration",
|
|
6830
6968
|
"named": true,
|
|
6831
6969
|
"fields": {
|
|
6970
|
+
"base": {
|
|
6971
|
+
"multiple": true,
|
|
6972
|
+
"required": false,
|
|
6973
|
+
"types": [
|
|
6974
|
+
{
|
|
6975
|
+
"type": "type",
|
|
6976
|
+
"named": true
|
|
6977
|
+
}
|
|
6978
|
+
]
|
|
6979
|
+
},
|
|
6832
6980
|
"body": {
|
|
6833
6981
|
"multiple": false,
|
|
6834
6982
|
"required": false,
|
|
@@ -6854,6 +7002,10 @@
|
|
|
6854
7002
|
"multiple": true,
|
|
6855
7003
|
"required": false,
|
|
6856
7004
|
"types": [
|
|
7005
|
+
{
|
|
7006
|
+
"type": "argument_list",
|
|
7007
|
+
"named": true
|
|
7008
|
+
},
|
|
6857
7009
|
{
|
|
6858
7010
|
"type": "attribute_list",
|
|
6859
7011
|
"named": true
|
|
@@ -6870,6 +7022,10 @@
|
|
|
6870
7022
|
"type": "parameter_list",
|
|
6871
7023
|
"named": true
|
|
6872
7024
|
},
|
|
7025
|
+
{
|
|
7026
|
+
"type": "preproc_if",
|
|
7027
|
+
"named": true
|
|
7028
|
+
},
|
|
6873
7029
|
{
|
|
6874
7030
|
"type": "preproc_if_in_attribute_list",
|
|
6875
7031
|
"named": true
|
|
@@ -7221,6 +7377,16 @@
|
|
|
7221
7377
|
"type": "struct_declaration",
|
|
7222
7378
|
"named": true,
|
|
7223
7379
|
"fields": {
|
|
7380
|
+
"base": {
|
|
7381
|
+
"multiple": true,
|
|
7382
|
+
"required": false,
|
|
7383
|
+
"types": [
|
|
7384
|
+
{
|
|
7385
|
+
"type": "type",
|
|
7386
|
+
"named": true
|
|
7387
|
+
}
|
|
7388
|
+
]
|
|
7389
|
+
},
|
|
7224
7390
|
"body": {
|
|
7225
7391
|
"multiple": false,
|
|
7226
7392
|
"required": false,
|
|
@@ -7246,6 +7412,10 @@
|
|
|
7246
7412
|
"multiple": true,
|
|
7247
7413
|
"required": false,
|
|
7248
7414
|
"types": [
|
|
7415
|
+
{
|
|
7416
|
+
"type": "argument_list",
|
|
7417
|
+
"named": true
|
|
7418
|
+
},
|
|
7249
7419
|
{
|
|
7250
7420
|
"type": "attribute_list",
|
|
7251
7421
|
"named": true
|
|
@@ -7262,6 +7432,10 @@
|
|
|
7262
7432
|
"type": "parameter_list",
|
|
7263
7433
|
"named": true
|
|
7264
7434
|
},
|
|
7435
|
+
{
|
|
7436
|
+
"type": "preproc_if",
|
|
7437
|
+
"named": true
|
|
7438
|
+
},
|
|
7265
7439
|
{
|
|
7266
7440
|
"type": "preproc_if_in_attribute_list",
|
|
7267
7441
|
"named": true
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|