@willbooster/tree-sitter-ruby 6.0.5 → 7.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-ruby/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.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.51.1-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-ruby.svg)](https://crates.io/crates/willbooster-tree-sitter-ruby)
10
10
 
11
11
  Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -20,6 +20,13 @@ The scanner preserves long heredoc identifiers
20
20
  when their state fits the runtime's serialization buffer. If the open heredocs cannot fit, their bodies are parsed as
21
21
  code instead of aborting the process.
22
22
 
23
+ ## Support Scope
24
+
25
+ This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
26
+ nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
27
+ but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
28
+ the trees that error recovery produces may change; such changes are released as new major versions.
29
+
23
30
  ## Usage
24
31
 
25
32
  The npm package ships `tree-sitter-ruby.wasm` for
@@ -64,7 +71,7 @@ const parser = new Parser();
64
71
  parser.setLanguage(await Language.load(ruby));
65
72
  ```
66
73
 
67
- The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
74
+ The package also ships the node types in `src/node-types.json`.
68
75
 
69
76
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-ruby) and on
70
77
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
@@ -108,11 +115,8 @@ Profiles in `.tmp/generation-profiles/` are temporary and must not be committed.
108
115
  `bun run test` runs:
109
116
 
110
117
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
111
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
112
- edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
113
- `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
114
- - included-range comment and incremental-edit checks (`test/unit/includedRanges.test.ts`), which load the Wasm build
115
- produced by `bun run build/ci`;
118
+ - included-range comment checks (`test/unit/includedRanges.test.ts`), which load the Wasm build produced by
119
+ `bun run build/ci`;
116
120
  - a check that the real-world Ruby files of [ruby/spec](https://github.com/ruby/spec) cloned into `examples/` fail to
117
121
  parse exactly as listed in `script/known-failures.txt`. The first run clones the repository, which is pinned to a
118
122
  commit in `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples`
@@ -123,7 +127,7 @@ Profiles in `.tmp/generation-profiles/` are temporary and must not be committed.
123
127
  Node.js compatibility (`test/unit/workerd.test.ts`). Run `bun run test/ci-setup` once to install Chromium.
124
128
 
125
129
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
126
- by every checkout; `script/fuzz-corpus` builds a per-run parser in `.tmp/fuzz` and deletes it afterwards.
130
+ by every checkout.
127
131
 
128
132
  CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
129
133
  parser with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-ruby",
3
- "version": "6.0.5",
3
+ "version": "7.0.0",
4
4
  "description": "Ruby grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -16,7 +16,6 @@
16
16
  },
17
17
  "files": [
18
18
  "grammar.js",
19
- "queries/*.scm",
20
19
  "tree-sitter.json",
21
20
  "src/node-types.json",
22
21
  "*.wasm"
@@ -46,15 +45,15 @@
46
45
  },
47
46
  "devDependencies": {
48
47
  "@tsconfig/bun": "1.0.11",
49
- "@types/bun": "1.4.3",
48
+ "@types/bun": "1.4.4",
50
49
  "@vitest/browser-playwright": "5.0.5",
51
50
  "@willbooster/oxlint-config": "1.4.9",
52
- "@willbooster/wb": "22.29.3",
51
+ "@willbooster/wb": "22.32.3",
53
52
  "@willbooster/web-tree-sitter": "15.0.0",
54
53
  "conventional-changelog-conventionalcommits": "10.4.1",
55
54
  "lefthook": "2.2.2",
56
- "oxlint": "1.88.0",
57
- "oxlint-tsgolint": "7.0.2004",
55
+ "oxlint": "1.89.0",
56
+ "oxlint-tsgolint": "7.0.2005",
58
57
  "playwright": "1.64.1",
59
58
  "semantic-release": "25.0.9",
60
59
  "vite": "8.3.4",
Binary file
package/tree-sitter.json CHANGED
@@ -9,17 +9,11 @@
9
9
  "file-types": [
10
10
  "rb"
11
11
  ],
12
- "highlights": [
13
- "queries/highlights.scm"
14
- ],
15
- "tags": [
16
- "queries/tags.scm"
17
- ],
18
12
  "injection-regex": "ruby"
19
13
  }
20
14
  ],
21
15
  "metadata": {
22
- "version": "6.0.5",
16
+ "version": "7.0.0",
23
17
  "license": "MIT",
24
18
  "description": "Ruby grammar for tree-sitter",
25
19
  "authors": [
@@ -1,151 +0,0 @@
1
- (identifier) @variable
2
-
3
- ((identifier) @function.method
4
- (#is-not? local))
5
-
6
- [
7
- "alias"
8
- "and"
9
- "begin"
10
- "break"
11
- "case"
12
- "class"
13
- "def"
14
- "do"
15
- "else"
16
- "elsif"
17
- "end"
18
- "ensure"
19
- "for"
20
- "if"
21
- "in"
22
- "module"
23
- "next"
24
- "or"
25
- "rescue"
26
- "retry"
27
- "return"
28
- "then"
29
- "unless"
30
- "until"
31
- "when"
32
- "while"
33
- "yield"
34
- ] @keyword
35
-
36
- (constant) @constructor
37
-
38
- ; Function calls
39
-
40
- "defined?" @function.method.builtin
41
-
42
- (call
43
- method: [(identifier) (constant)] @function.method)
44
-
45
- ((identifier) @function.method.builtin
46
- (#eq? @function.method.builtin "require"))
47
-
48
- ; Function definitions
49
-
50
- (alias (identifier) @function.method)
51
- (setter (identifier) @function.method)
52
- (method name: [(identifier) (constant)] @function.method)
53
- (singleton_method name: [(identifier) (constant)] @function.method)
54
-
55
- ; Identifiers
56
-
57
- [
58
- (class_variable)
59
- (instance_variable)
60
- ] @property
61
-
62
- ((identifier) @constant.builtin
63
- (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
64
-
65
- (file) @constant.builtin
66
- (line) @constant.builtin
67
- (encoding) @constant.builtin
68
-
69
- (hash_splat_nil
70
- "**" @operator) @constant.builtin
71
-
72
- ((constant) @constant
73
- (#match? @constant "^[A-Z\\d_]+$"))
74
-
75
- [
76
- (self)
77
- (super)
78
- ] @variable.builtin
79
-
80
- (block_parameter (identifier) @variable.parameter)
81
- (block_parameters (identifier) @variable.parameter)
82
- (destructured_parameter (identifier) @variable.parameter)
83
- (hash_splat_parameter (identifier) @variable.parameter)
84
- (lambda_parameters (identifier) @variable.parameter)
85
- (method_parameters (identifier) @variable.parameter)
86
- (splat_parameter (identifier) @variable.parameter)
87
-
88
- (keyword_parameter name: (identifier) @variable.parameter)
89
- (optional_parameter name: (identifier) @variable.parameter)
90
-
91
- ; Literals
92
-
93
- [
94
- (string)
95
- (bare_string)
96
- (subshell)
97
- (heredoc_body)
98
- (heredoc_beginning)
99
- ] @string
100
-
101
- [
102
- (simple_symbol)
103
- (delimited_symbol)
104
- (hash_key_symbol)
105
- (bare_symbol)
106
- ] @string.special.symbol
107
-
108
- (regex) @string.special.regex
109
- (escape_sequence) @escape
110
-
111
- [
112
- (integer)
113
- (float)
114
- ] @number
115
-
116
- [
117
- (nil)
118
- (true)
119
- (false)
120
- ] @constant.builtin
121
-
122
- (interpolation
123
- "#{" @punctuation.special
124
- "}" @punctuation.special) @embedded
125
-
126
- (comment) @comment
127
-
128
- ; Operators
129
-
130
- [
131
- "="
132
- "=>"
133
- "->"
134
- ] @operator
135
-
136
- [
137
- ","
138
- ";"
139
- "."
140
- ] @punctuation.delimiter
141
-
142
- [
143
- "("
144
- ")"
145
- "["
146
- "]"
147
- "{"
148
- "}"
149
- "%w("
150
- "%i("
151
- ] @punctuation.bracket
@@ -1,27 +0,0 @@
1
- ((method) @local.scope
2
- (#set! local.scope-inherits false))
3
-
4
- [
5
- (lambda)
6
- (block)
7
- (do_block)
8
- ] @local.scope
9
-
10
- (block_parameter (identifier) @local.definition)
11
- (block_parameters (identifier) @local.definition)
12
- (destructured_parameter (identifier) @local.definition)
13
- (hash_splat_parameter (identifier) @local.definition)
14
- (lambda_parameters (identifier) @local.definition)
15
- (method_parameters (identifier) @local.definition)
16
- (splat_parameter (identifier) @local.definition)
17
-
18
- (keyword_parameter name: (identifier) @local.definition)
19
- (optional_parameter name: (identifier) @local.definition)
20
-
21
- (identifier) @local.reference
22
-
23
- (assignment left: (identifier) @local.definition)
24
- (operator_assignment left: (identifier) @local.definition)
25
- (left_assignment_list (identifier) @local.definition)
26
- (rest_assignment (identifier) @local.definition)
27
- (destructured_left_assignment (identifier) @local.definition)
package/queries/tags.scm DELETED
@@ -1,64 +0,0 @@
1
- ; Method definitions
2
-
3
- (
4
- (comment)* @doc
5
- .
6
- [
7
- (method
8
- name: (_) @name) @definition.method
9
- (singleton_method
10
- name: (_) @name) @definition.method
11
- ]
12
- (#strip! @doc "^#\\s*")
13
- (#select-adjacent! @doc @definition.method)
14
- )
15
-
16
- (alias
17
- name: (_) @name) @definition.method
18
-
19
- (setter
20
- (identifier) @ignore)
21
-
22
- ; Class definitions
23
-
24
- (
25
- (comment)* @doc
26
- .
27
- [
28
- (class
29
- name: [
30
- (constant) @name
31
- (scope_resolution
32
- name: (_) @name)
33
- ]) @definition.class
34
- (singleton_class
35
- value: [
36
- (constant) @name
37
- (scope_resolution
38
- name: (_) @name)
39
- ]) @definition.class
40
- ]
41
- (#strip! @doc "^#\\s*")
42
- (#select-adjacent! @doc @definition.class)
43
- )
44
-
45
- ; Module definitions
46
-
47
- (
48
- (module
49
- name: [
50
- (constant) @name
51
- (scope_resolution
52
- name: (_) @name)
53
- ]) @definition.module
54
- )
55
-
56
- ; Calls
57
-
58
- (call method: (identifier) @name) @reference.call
59
-
60
- (
61
- [(identifier) (constant)] @name @reference.call
62
- (#is-not? local)
63
- (#not-match? @name "^(lambda|load|require|require_relative|__FILE__|__LINE__)$")
64
- )