@willbooster/tree-sitter-c-sharp 14.1.4 → 15.0.1

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-c-sharp/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.43.2-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-c-sharp.svg)](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
@@ -41,13 +41,14 @@ The contextual type names `nint` and `nuint` use `identifier` nodes.
41
41
 
42
42
  The npm package ships `tree-sitter-c_sharp.wasm` for
43
43
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
44
- browsers, and Cloudflare Workers. The parser uses WillBooster ABI 7 and loads only with that runtime. Use version 10.0.2 or later within major version 10; upstream's runtime rejects it. Install the runtime alongside the grammar when using
44
+ browsers, and Cloudflare Workers. The parser uses WillBooster ABI 9 and loads only with that runtime. Use version 13.0.0 or later within major version 13; upstream's runtime rejects it. Install the runtime alongside the grammar when using
45
45
  the Wasm parser; it remains an optional peer for consumers that only use the grammar source or queries.
46
46
 
47
47
  In Node.js and Bun, load it from the package:
48
48
 
49
49
  ```js
50
50
  import { fileURLToPath } from 'node:url';
51
+
51
52
  import { Language, Parser } from '@willbooster/web-tree-sitter';
52
53
 
53
54
  await Parser.init();
@@ -60,9 +61,9 @@ const tree = parser.parse('class Program {}\n');
60
61
  In browsers, serve both `.wasm` files and load them by URL. With Vite:
61
62
 
62
63
  ```js
64
+ import cSharpUrl from '@willbooster/tree-sitter-c-sharp/tree-sitter-c_sharp.wasm?url';
63
65
  import { Language, Parser } from '@willbooster/web-tree-sitter';
64
66
  import runtimeUrl from '@willbooster/web-tree-sitter/web-tree-sitter.wasm?url';
65
- import cSharpUrl from '@willbooster/tree-sitter-c-sharp/tree-sitter-c_sharp.wasm?url';
66
67
 
67
68
  await Parser.init({ locateFile: () => runtimeUrl });
68
69
  const parser = new Parser();
@@ -74,9 +75,9 @@ compiles them at build time) and pass them to `Parser.init` and `Language.load`.
74
75
  `nodejs_compat` flag:
75
76
 
76
77
  ```js
78
+ import cSharp from '@willbooster/tree-sitter-c-sharp/tree-sitter-c_sharp.wasm';
77
79
  import { Language, Parser } from '@willbooster/web-tree-sitter';
78
80
  import runtime from '@willbooster/web-tree-sitter/web-tree-sitter.wasm';
79
- import cSharp from '@willbooster/tree-sitter-c-sharp/tree-sitter-c_sharp.wasm';
80
81
 
81
82
  await Parser.init({ wasmModule: runtime });
82
83
  const parser = new Parser();
@@ -89,12 +90,12 @@ Their external tokens and serialized scanner state must match.
89
90
 
90
91
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-c-sharp) and on
91
92
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
92
- fuzzed with. Use runtime 10.0.2 or later within major version 10:
93
+ fuzzed with. Use runtime 13.0.0 or later within major version 13:
93
94
 
94
95
  ```toml
95
96
  [dependencies]
96
- tree-sitter = { package = "willbooster-tree-sitter", version = "10.0.2" }
97
- tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "11" }
97
+ tree-sitter = { package = "willbooster-tree-sitter", version = "13.0.0" }
98
+ tree-sitter-c-sharp = { package = "willbooster-tree-sitter-c-sharp", version = "15" }
98
99
  ```
99
100
 
100
101
  ```rust
package/grammar.js CHANGED
@@ -1412,17 +1412,19 @@ module.exports = grammar({
1412
1412
  field('body', $.switch_body)
1413
1413
  ),
1414
1414
 
1415
- switch_body: ($) => seq('{', repeat($.switch_section), blockEnd()),
1415
+ switch_body: ($) => seq('{', optional(conditionalSectionRun($)), repeat($.switch_section), blockEnd()),
1416
1416
 
1417
1417
  switch_section: ($) =>
1418
1418
  prec.left(
1419
1419
  seq(
1420
1420
  choice(seq('case', choice($.expression, seq($.pattern, optional($.when_clause)))), 'default'),
1421
1421
  alias(sym('_case_label_colon'), ':'),
1422
- repeat($.statement)
1422
+ repeat(choice($.statement, $._preproc_if_in_switch_body))
1423
1423
  )
1424
1424
  ),
1425
1425
 
1426
+ _preproc_if_in_switch_body: () => alias(sym('preproc_if_in_switch_body'), sym('preproc_if')),
1427
+
1426
1428
  throw_statement: ($) => seq('throw', optional($.expression), statementEnd()),
1427
1429
 
1428
1430
  try_statement: ($) => seq('try', field('body', $.block), repeat($.catch_clause), optional($.finally_clause)),
@@ -2723,6 +2725,32 @@ module.exports = grammar({
2723
2725
  ...preprocIf('_in_top_level', ($) => conditionalStatements($), 0, false, true),
2724
2726
  ...preprocIf('_in_if_alternative', ($) => seq(optional('else'), conditionalStatements($)), 0, false),
2725
2727
 
2728
+ // Alternatives start with any statements that continue the enclosing section. Nested directives precede the
2729
+ // sections because a directive after a section belongs to that section's statements.
2730
+ preproc_if_in_switch_body: ($) =>
2731
+ conditionalDirective(
2732
+ 'if',
2733
+ $,
2734
+ choice(seq(conditionalSectionRun($), repeat($.switch_section)), repeat1($.switch_section)),
2735
+ field('alternative', optional($._preproc_switch_body_alternative)),
2736
+ preprocessor('endif')
2737
+ ),
2738
+ preproc_elif_in_switch_body: ($) =>
2739
+ conditionalDirective(
2740
+ 'elif',
2741
+ $,
2742
+ repeat($.statement),
2743
+ optional(conditionalSectionRun($)),
2744
+ repeat($.switch_section),
2745
+ field('alternative', optional($._preproc_switch_body_alternative))
2746
+ ),
2747
+ preproc_else_in_switch_body: ($) =>
2748
+ seq(preprocessor('else'), repeat($.statement), optional(conditionalSectionRun($)), repeat($.switch_section)),
2749
+ _preproc_switch_body_alternative: () =>
2750
+ choice(
2751
+ alias(sym('preproc_else_in_switch_body'), sym('preproc_else')),
2752
+ alias(sym('preproc_elif_in_switch_body'), sym('preproc_elif'))
2753
+ ),
2726
2754
  ...preprocIf('_in_expression', ($) => $.expression, -2, false),
2727
2755
  ...conditionalListDirective('_in_initializer', ($) => $.expression),
2728
2756
  ...conditionalListDirective(
@@ -3161,6 +3189,15 @@ function argumentValue($) {
3161
3189
  return choice(seq(optional(choice('ref', 'out', 'in')), $.expression), seq('out', $.declaration_expression));
3162
3190
  }
3163
3191
 
3192
+ /**
3193
+ * Conditional switch sections followed by more of them or by the statements their conditional labels share.
3194
+ *
3195
+ * @param {import('@willbooster/web-tree-sitter/dsl').GrammarSymbols<'_preproc_if_in_switch_body' | 'statement'>} $
3196
+ */
3197
+ function conditionalSectionRun($) {
3198
+ return seq($._preproc_if_in_switch_body, repeat(choice($._preproc_if_in_switch_body, $.statement)));
3199
+ }
3200
+
3164
3201
  /**
3165
3202
  * Statements of a conditional branch, where the last may be an if statement whose `else` body follows the directive.
3166
3203
  *
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-c-sharp",
3
- "version": "14.1.4",
3
+ "version": "15.0.1",
4
4
  "description": "C# grammar for tree-sitter",
5
5
  "keywords": [
6
+ "c-sharp",
6
7
  "incremental",
7
8
  "parsing",
8
- "tree-sitter",
9
- "c-sharp"
9
+ "tree-sitter"
10
10
  ],
11
+ "license": "MIT",
12
+ "author": "WillBooster Inc.",
11
13
  "repository": {
12
14
  "type": "git",
13
15
  "url": "git+https://github.com/WillBooster/tree-sitter-c-sharp.git"
14
16
  },
15
- "license": "MIT",
16
- "author": "WillBooster Inc.",
17
17
  "files": [
18
18
  "grammar.js",
19
19
  "queries/*.scm",
@@ -21,6 +21,10 @@
21
21
  "src/node-types.json",
22
22
  "*.wasm"
23
23
  ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
24
28
  "scripts": {
25
29
  "build-wasm": "script/generate --build-wasm",
26
30
  "build/ci": "bun run build-wasm",
@@ -44,33 +48,26 @@
44
48
  "devDependencies": {
45
49
  "@tsconfig/bun": "1.0.11",
46
50
  "@types/bun": "1.4.3",
47
- "@vitest/browser-playwright": "5.0.3",
48
- "@willbooster/oxfmt-config": "1.2.2",
49
- "@willbooster/oxlint-config": "1.4.8",
50
- "@willbooster/wb": "22.26.2",
51
- "@willbooster/web-tree-sitter": "10.0.2",
51
+ "@vitest/browser-playwright": "5.0.5",
52
+ "@willbooster/oxlint-config": "1.4.9",
53
+ "@willbooster/wb": "22.29.3",
54
+ "@willbooster/web-tree-sitter": "13.0.0",
52
55
  "conventional-changelog-conventionalcommits": "10.4.1",
53
56
  "lefthook": "2.2.2",
54
- "oxfmt": "0.73.0",
55
57
  "oxlint": "1.88.0",
56
58
  "oxlint-tsgolint": "7.0.2004",
57
- "playwright": "1.64.0",
59
+ "playwright": "1.64.1",
58
60
  "semantic-release": "25.0.9",
59
- "sort-package-json": "4.0.0",
60
61
  "vite": "8.3.4",
61
- "vitest": "5.0.3",
62
- "wrangler": "4.149.0"
62
+ "vitest": "5.0.5",
63
+ "wrangler": "4.151.1"
63
64
  },
64
65
  "peerDependencies": {
65
- "@willbooster/web-tree-sitter": "^10.0.2"
66
+ "@willbooster/web-tree-sitter": "^13.0.0"
66
67
  },
67
68
  "peerDependenciesMeta": {
68
69
  "@willbooster/web-tree-sitter": {
69
70
  "optional": true
70
71
  }
71
- },
72
- "publishConfig": {
73
- "access": "public",
74
- "registry": "https://registry.npmjs.org/"
75
72
  }
76
73
  }
@@ -6368,6 +6368,10 @@
6368
6368
  "type": "switch_expression_arm",
6369
6369
  "named": true
6370
6370
  },
6371
+ {
6372
+ "type": "switch_section",
6373
+ "named": true
6374
+ },
6371
6375
  {
6372
6376
  "type": "type_declaration",
6373
6377
  "named": true
@@ -6460,6 +6464,10 @@
6460
6464
  "type": "switch_expression_arm",
6461
6465
  "named": true
6462
6466
  },
6467
+ {
6468
+ "type": "switch_section",
6469
+ "named": true
6470
+ },
6463
6471
  {
6464
6472
  "type": "type_declaration",
6465
6473
  "named": true
@@ -6629,6 +6637,10 @@
6629
6637
  "type": "switch_expression_arm",
6630
6638
  "named": true
6631
6639
  },
6640
+ {
6641
+ "type": "switch_section",
6642
+ "named": true
6643
+ },
6632
6644
  {
6633
6645
  "type": "type_declaration",
6634
6646
  "named": true
@@ -7572,6 +7584,10 @@
7572
7584
  "multiple": true,
7573
7585
  "required": false,
7574
7586
  "types": [
7587
+ {
7588
+ "type": "statement",
7589
+ "named": true
7590
+ },
7575
7591
  {
7576
7592
  "type": "switch_section",
7577
7593
  "named": true
Binary file
package/tree-sitter.json CHANGED
@@ -31,7 +31,7 @@
31
31
  }
32
32
  ],
33
33
  "metadata": {
34
- "version": "14.1.4",
34
+ "version": "15.0.1",
35
35
  "license": "MIT",
36
36
  "description": "C# grammar for tree-sitter",
37
37
  "authors": [