@willbooster/tree-sitter-c-sharp 1.0.22 → 1.0.24
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 +45 -15
- package/package.json +1 -1
- package/queries/highlights.scm +1 -0
- package/queries/tags.scm +2 -0
- package/src/node-types.json +127 -4
- package/tree-sitter-c_sharp.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -146,10 +146,11 @@ module.exports = grammar({
|
|
|
146
146
|
// modifier) closed by ')=>'.
|
|
147
147
|
$._lambda_paren_open,
|
|
148
148
|
$._end_of_input,
|
|
149
|
+
$._directive_crlf,
|
|
149
150
|
],
|
|
150
151
|
|
|
151
152
|
extras: ($) => [
|
|
152
|
-
/[\s\u00A0\uFEFF\u3000]+/,
|
|
153
|
+
/[\s\u0085\u00A0\u2028\u2029\uFEFF\u3000]+/,
|
|
153
154
|
$.comment,
|
|
154
155
|
$.preproc_region,
|
|
155
156
|
$.preproc_endregion,
|
|
@@ -480,6 +481,7 @@ module.exports = grammar({
|
|
|
480
481
|
$.delegate_declaration,
|
|
481
482
|
$.field_declaration,
|
|
482
483
|
$.method_declaration,
|
|
484
|
+
$.conditional_method_declaration,
|
|
483
485
|
$.event_declaration,
|
|
484
486
|
$.event_field_declaration,
|
|
485
487
|
$.record_declaration,
|
|
@@ -525,7 +527,8 @@ module.exports = grammar({
|
|
|
525
527
|
|
|
526
528
|
extension_body: ($) => seq('{', repeat($._extension_member_declaration), '}', optional(';')),
|
|
527
529
|
|
|
528
|
-
_extension_member_declaration: ($) =>
|
|
530
|
+
_extension_member_declaration: ($) =>
|
|
531
|
+
choice($.method_declaration, $.conditional_method_declaration, $.property_declaration, $.operator_declaration),
|
|
529
532
|
|
|
530
533
|
field_declaration: ($) => seq(repeat($._attribute_list), repeat($.modifier), $.variable_declaration, ';'),
|
|
531
534
|
|
|
@@ -553,7 +556,13 @@ module.exports = grammar({
|
|
|
553
556
|
$._function_body
|
|
554
557
|
),
|
|
555
558
|
|
|
556
|
-
method_declaration: ($) =>
|
|
559
|
+
method_declaration: ($) => seq($._method_signature, $._function_body),
|
|
560
|
+
|
|
561
|
+
conditional_method_declaration: ($) => seq(alias($.preproc_if_in_method_signature, $.preproc_if), $._function_body),
|
|
562
|
+
|
|
563
|
+
method_signature: ($) => $._method_signature,
|
|
564
|
+
|
|
565
|
+
_method_signature: ($) =>
|
|
557
566
|
seq(
|
|
558
567
|
repeat($._attribute_list),
|
|
559
568
|
repeat($.modifier),
|
|
@@ -562,8 +571,7 @@ module.exports = grammar({
|
|
|
562
571
|
field('name', $.identifier),
|
|
563
572
|
field('type_parameters', optional($.type_parameter_list)),
|
|
564
573
|
field('parameters', $.parameter_list),
|
|
565
|
-
repeat($.type_parameter_constraints_clause)
|
|
566
|
-
$._function_body
|
|
574
|
+
repeat($.type_parameter_constraints_clause)
|
|
567
575
|
),
|
|
568
576
|
|
|
569
577
|
event_declaration: ($) =>
|
|
@@ -1717,13 +1725,25 @@ module.exports = grammar({
|
|
|
1717
1725
|
'yield'
|
|
1718
1726
|
),
|
|
1719
1727
|
|
|
1728
|
+
...preprocIf(
|
|
1729
|
+
'_in_method_signature',
|
|
1730
|
+
($) => choice($.method_signature, alias($.preproc_if_in_method_signature, $.preproc_if)),
|
|
1731
|
+
0,
|
|
1732
|
+
false,
|
|
1733
|
+
true
|
|
1734
|
+
),
|
|
1720
1735
|
...preprocIf('', ($) => $.declaration),
|
|
1721
1736
|
...preprocIf('_in_top_level', ($) => choice($._top_level_item_no_statement, $.statement)),
|
|
1722
1737
|
...preprocIf('_in_expression', ($) => $.expression, -2, false),
|
|
1723
1738
|
...preprocIf('_in_enum_member_declaration', ($) => $.enum_member_declaration, 0, false),
|
|
1724
1739
|
...preprocIf('_in_attribute_list', ($) => $.attribute_list, -1, false),
|
|
1725
1740
|
|
|
1726
|
-
preproc_arg: () =>
|
|
1741
|
+
preproc_arg: ($) =>
|
|
1742
|
+
seq(
|
|
1743
|
+
token(prec(-1, /[^\s\u0085\u2028\u2029]([^/\r\n\u0085\u2028\u2029]|\/[^*\r\n\u0085\u2028\u2029]|\\\r?\n)*/)),
|
|
1744
|
+
optional($._preproc_arg_slash)
|
|
1745
|
+
),
|
|
1746
|
+
_preproc_arg_slash: () => token.immediate(/\//),
|
|
1727
1747
|
preproc_directive: () => /#[ \t]*[a-zA-Z0-9]\w*/,
|
|
1728
1748
|
|
|
1729
1749
|
_preproc_expression: ($) =>
|
|
@@ -1840,9 +1860,9 @@ module.exports = grammar({
|
|
|
1840
1860
|
|
|
1841
1861
|
preproc_undef: ($) => seq(preprocessor('undef'), $.preproc_arg, directiveEnd($)),
|
|
1842
1862
|
|
|
1843
|
-
shebang_directive: () => token(seq('#!',
|
|
1863
|
+
shebang_directive: () => token(seq('#!', /[^\r\n\u0085\u2028\u2029]*/)),
|
|
1844
1864
|
|
|
1845
|
-
comment: () => token(choice(seq('//', /[^\n\
|
|
1865
|
+
comment: () => token(choice(seq('//', /[^\r\n\u0085\u2028\u2029]*/), seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
|
|
1846
1866
|
},
|
|
1847
1867
|
});
|
|
1848
1868
|
|
|
@@ -1855,7 +1875,12 @@ module.exports = grammar({
|
|
|
1855
1875
|
* @returns {ChoiceRule}
|
|
1856
1876
|
*/
|
|
1857
1877
|
function directiveEnd($) {
|
|
1858
|
-
return choice(
|
|
1878
|
+
return choice(directiveNewLine($), $._end_of_input);
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
/** @param {GrammarSymbols<string>} $ */
|
|
1882
|
+
function directiveNewLine($) {
|
|
1883
|
+
return choice($._directive_crlf, /[\r\n\u0085\u2028\u2029]/);
|
|
1859
1884
|
}
|
|
1860
1885
|
|
|
1861
1886
|
/**
|
|
@@ -1877,9 +1902,11 @@ function preprocessor(command) {
|
|
|
1877
1902
|
*
|
|
1878
1903
|
* @param {boolean} rep
|
|
1879
1904
|
*
|
|
1905
|
+
* @param {boolean} required
|
|
1906
|
+
*
|
|
1880
1907
|
* @returns {RuleBuilders<string, string>}
|
|
1881
1908
|
*/
|
|
1882
|
-
function preprocIf(suffix, content, precedence = 0, rep = true) {
|
|
1909
|
+
function preprocIf(suffix, content, precedence = 0, rep = true, required = false) {
|
|
1883
1910
|
/**
|
|
1884
1911
|
*
|
|
1885
1912
|
* @param {GrammarSymbols<string>} $
|
|
@@ -1900,15 +1927,18 @@ function preprocIf(suffix, content, precedence = 0, rep = true) {
|
|
|
1900
1927
|
seq(
|
|
1901
1928
|
preprocessor('if'),
|
|
1902
1929
|
field('condition', $._preproc_expression),
|
|
1903
|
-
|
|
1904
|
-
rep ? repeat(content($)) : optional(content($)),
|
|
1930
|
+
directiveNewLine($),
|
|
1931
|
+
rep ? repeat(content($)) : required ? content($) : optional(content($)),
|
|
1905
1932
|
field('alternative', optional(alternativeBlock($))),
|
|
1906
1933
|
preprocessor('endif')
|
|
1907
1934
|
)
|
|
1908
1935
|
),
|
|
1909
1936
|
|
|
1910
1937
|
['preproc_else' + suffix]: ($) =>
|
|
1911
|
-
prec(
|
|
1938
|
+
prec(
|
|
1939
|
+
precedence,
|
|
1940
|
+
seq(preprocessor('else'), rep ? repeat(content($)) : required ? content($) : optional(content($)))
|
|
1941
|
+
),
|
|
1912
1942
|
|
|
1913
1943
|
['preproc_elif' + suffix]: ($) =>
|
|
1914
1944
|
prec(
|
|
@@ -1916,8 +1946,8 @@ function preprocIf(suffix, content, precedence = 0, rep = true) {
|
|
|
1916
1946
|
seq(
|
|
1917
1947
|
preprocessor('elif'),
|
|
1918
1948
|
field('condition', $._preproc_expression),
|
|
1919
|
-
|
|
1920
|
-
rep ? repeat(content($)) : optional(content($)),
|
|
1949
|
+
directiveNewLine($),
|
|
1950
|
+
rep ? repeat(content($)) : required ? content($) : optional(content($)),
|
|
1921
1951
|
field('alternative', optional(alternativeBlock($)))
|
|
1922
1952
|
)
|
|
1923
1953
|
),
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
package/queries/tags.scm
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
(method_declaration name: (identifier) @name) @definition.method
|
|
10
10
|
|
|
11
|
+
(method_signature name: (identifier) @name) @definition.method
|
|
12
|
+
|
|
11
13
|
(object_creation_expression type: (identifier) @name) @reference.class
|
|
12
14
|
|
|
13
15
|
(type_parameter_constraints_clause (identifier) @name) @reference.class
|
package/src/node-types.json
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
"type": "class_declaration",
|
|
8
8
|
"named": true
|
|
9
9
|
},
|
|
10
|
+
{
|
|
11
|
+
"type": "conditional_method_declaration",
|
|
12
|
+
"named": true
|
|
13
|
+
},
|
|
10
14
|
{
|
|
11
15
|
"type": "constructor_declaration",
|
|
12
16
|
"named": true
|
|
@@ -1856,6 +1860,36 @@
|
|
|
1856
1860
|
}
|
|
1857
1861
|
}
|
|
1858
1862
|
},
|
|
1863
|
+
{
|
|
1864
|
+
"type": "conditional_method_declaration",
|
|
1865
|
+
"named": true,
|
|
1866
|
+
"fields": {
|
|
1867
|
+
"body": {
|
|
1868
|
+
"multiple": false,
|
|
1869
|
+
"required": false,
|
|
1870
|
+
"types": [
|
|
1871
|
+
{
|
|
1872
|
+
"type": "arrow_expression_clause",
|
|
1873
|
+
"named": true
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
"type": "block",
|
|
1877
|
+
"named": true
|
|
1878
|
+
}
|
|
1879
|
+
]
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
"children": {
|
|
1883
|
+
"multiple": false,
|
|
1884
|
+
"required": true,
|
|
1885
|
+
"types": [
|
|
1886
|
+
{
|
|
1887
|
+
"type": "preproc_if",
|
|
1888
|
+
"named": true
|
|
1889
|
+
}
|
|
1890
|
+
]
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1859
1893
|
{
|
|
1860
1894
|
"type": "constant_pattern",
|
|
1861
1895
|
"named": true,
|
|
@@ -2657,6 +2691,10 @@
|
|
|
2657
2691
|
"multiple": true,
|
|
2658
2692
|
"required": false,
|
|
2659
2693
|
"types": [
|
|
2694
|
+
{
|
|
2695
|
+
"type": "conditional_method_declaration",
|
|
2696
|
+
"named": true
|
|
2697
|
+
},
|
|
2660
2698
|
{
|
|
2661
2699
|
"type": "method_declaration",
|
|
2662
2700
|
"named": true
|
|
@@ -4038,6 +4076,78 @@
|
|
|
4038
4076
|
]
|
|
4039
4077
|
}
|
|
4040
4078
|
},
|
|
4079
|
+
{
|
|
4080
|
+
"type": "method_signature",
|
|
4081
|
+
"named": true,
|
|
4082
|
+
"fields": {
|
|
4083
|
+
"name": {
|
|
4084
|
+
"multiple": false,
|
|
4085
|
+
"required": true,
|
|
4086
|
+
"types": [
|
|
4087
|
+
{
|
|
4088
|
+
"type": "identifier",
|
|
4089
|
+
"named": true
|
|
4090
|
+
}
|
|
4091
|
+
]
|
|
4092
|
+
},
|
|
4093
|
+
"parameters": {
|
|
4094
|
+
"multiple": false,
|
|
4095
|
+
"required": true,
|
|
4096
|
+
"types": [
|
|
4097
|
+
{
|
|
4098
|
+
"type": "parameter_list",
|
|
4099
|
+
"named": true
|
|
4100
|
+
}
|
|
4101
|
+
]
|
|
4102
|
+
},
|
|
4103
|
+
"returns": {
|
|
4104
|
+
"multiple": false,
|
|
4105
|
+
"required": true,
|
|
4106
|
+
"types": [
|
|
4107
|
+
{
|
|
4108
|
+
"type": "type",
|
|
4109
|
+
"named": true
|
|
4110
|
+
}
|
|
4111
|
+
]
|
|
4112
|
+
},
|
|
4113
|
+
"type_parameters": {
|
|
4114
|
+
"multiple": false,
|
|
4115
|
+
"required": false,
|
|
4116
|
+
"types": [
|
|
4117
|
+
{
|
|
4118
|
+
"type": "type_parameter_list",
|
|
4119
|
+
"named": true
|
|
4120
|
+
}
|
|
4121
|
+
]
|
|
4122
|
+
}
|
|
4123
|
+
},
|
|
4124
|
+
"children": {
|
|
4125
|
+
"multiple": true,
|
|
4126
|
+
"required": false,
|
|
4127
|
+
"types": [
|
|
4128
|
+
{
|
|
4129
|
+
"type": "attribute_list",
|
|
4130
|
+
"named": true
|
|
4131
|
+
},
|
|
4132
|
+
{
|
|
4133
|
+
"type": "explicit_interface_specifier",
|
|
4134
|
+
"named": true
|
|
4135
|
+
},
|
|
4136
|
+
{
|
|
4137
|
+
"type": "modifier",
|
|
4138
|
+
"named": true
|
|
4139
|
+
},
|
|
4140
|
+
{
|
|
4141
|
+
"type": "preproc_if_in_attribute_list",
|
|
4142
|
+
"named": true
|
|
4143
|
+
},
|
|
4144
|
+
{
|
|
4145
|
+
"type": "type_parameter_constraints_clause",
|
|
4146
|
+
"named": true
|
|
4147
|
+
}
|
|
4148
|
+
]
|
|
4149
|
+
}
|
|
4150
|
+
},
|
|
4041
4151
|
{
|
|
4042
4152
|
"type": "modifier",
|
|
4043
4153
|
"named": true,
|
|
@@ -4700,6 +4810,11 @@
|
|
|
4700
4810
|
]
|
|
4701
4811
|
}
|
|
4702
4812
|
},
|
|
4813
|
+
{
|
|
4814
|
+
"type": "preproc_arg",
|
|
4815
|
+
"named": true,
|
|
4816
|
+
"fields": {}
|
|
4817
|
+
},
|
|
4703
4818
|
{
|
|
4704
4819
|
"type": "preproc_define",
|
|
4705
4820
|
"named": true,
|
|
@@ -4801,6 +4916,10 @@
|
|
|
4801
4916
|
"type": "global_attribute",
|
|
4802
4917
|
"named": true
|
|
4803
4918
|
},
|
|
4919
|
+
{
|
|
4920
|
+
"type": "method_signature",
|
|
4921
|
+
"named": true
|
|
4922
|
+
},
|
|
4804
4923
|
{
|
|
4805
4924
|
"type": "statement",
|
|
4806
4925
|
"named": true
|
|
@@ -4848,6 +4967,10 @@
|
|
|
4848
4967
|
"type": "global_attribute",
|
|
4849
4968
|
"named": true
|
|
4850
4969
|
},
|
|
4970
|
+
{
|
|
4971
|
+
"type": "method_signature",
|
|
4972
|
+
"named": true
|
|
4973
|
+
},
|
|
4851
4974
|
{
|
|
4852
4975
|
"type": "statement",
|
|
4853
4976
|
"named": true
|
|
@@ -4973,6 +5096,10 @@
|
|
|
4973
5096
|
"type": "global_attribute",
|
|
4974
5097
|
"named": true
|
|
4975
5098
|
},
|
|
5099
|
+
{
|
|
5100
|
+
"type": "method_signature",
|
|
5101
|
+
"named": true
|
|
5102
|
+
},
|
|
4976
5103
|
{
|
|
4977
5104
|
"type": "statement",
|
|
4978
5105
|
"named": true
|
|
@@ -7177,10 +7304,6 @@
|
|
|
7177
7304
|
"type": "predefined_type",
|
|
7178
7305
|
"named": true
|
|
7179
7306
|
},
|
|
7180
|
-
{
|
|
7181
|
-
"type": "preproc_arg",
|
|
7182
|
-
"named": true
|
|
7183
|
-
},
|
|
7184
7307
|
{
|
|
7185
7308
|
"type": "private",
|
|
7186
7309
|
"named": false
|
package/tree-sitter-c_sharp.wasm
CHANGED
|
Binary file
|