tree_haver 3.1.1 → 3.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 141cf04a77bd50b8802a20eb098ddb03352b08fa6b1592b95180dcf336cc25e1
4
- data.tar.gz: 134418492ecd86ef348221dfb7cef3f7c459acee00318c2669bdd666dc37d4ba
3
+ metadata.gz: 4086bd0349e2cfd205314110a7af3b8548530cc8d5f4328d84ecc38f840744f9
4
+ data.tar.gz: 01c27844a370a8235518002d6947226061931a127de6473b495d99ac4549cefd
5
5
  SHA512:
6
- metadata.gz: bafe3a43549cecf6e38a3c8f68c4f072348050d2a3807c4ad8fa9ec2f1d073892abaf5b4300e750a2282849c1bdd081c9ef122b1f2dcb0c5044bddedb451c7b2
7
- data.tar.gz: 62e7cd0947fdda50ea54f9e9a1b07a05c142388ef56a7a25a9ebb177f12804883cc3fc59dbfbbd3d5f08d062f59f89e850bb5d71733521344c53b5eec19ada78
6
+ metadata.gz: 1a77445cd016d4cf0d5cb0cf28aee79e6a664578ac2da92babc663e3df483f024f1c17c434ef19d4941cf25dd6674aea68177d71c096b75e3d83315d4d0e222a
7
+ data.tar.gz: a53b817c9a24181d7b2b17810977f0978085c0603ca07b41f9189a221d1e3a7cd0b2e7751e53f4440883ea02e22c262de6b965ca9dedb4bf7bc6282ff29d57c3
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,167 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [3.2.0] - 2025-12-30
34
+
35
+ - TAG: [v3.2.0][3.2.0t]
36
+ - COVERAGE: 86.82% -- 2167/2496 lines in 22 files
37
+ - BRANCH COVERAGE: 66.79% -- 734/1099 branches in 22 files
38
+ - 90.03% documented
39
+
40
+ ### Added
41
+
42
+ - `TreeHaver::CITRUS_DEFAULTS` constant with default Citrus configurations for known languages
43
+ - Enables automatic Citrus fallback for TOML without explicit `citrus_config` parameter
44
+ - Currently includes configuration for `:toml` (gem: `toml-rb`, const: `TomlRB::Document`)
45
+ - Regression test suite for Citrus fallback (`spec/integration/citrus_fallback_spec.rb`)
46
+ - Tests `parser_for` with all tree-sitter backends stubbed as unavailable (simulating TruffleRuby)
47
+ - Tests `CitrusGrammarFinder` with nil `gem_name` and `require_path`
48
+ - Tests explicit Citrus backend usage on MRI via `with_backend(:citrus)`
49
+ - Shared examples for TOML parsing tests (`spec/support/shared_examples/toml_parsing_examples.rb`)
50
+ - `"toml parsing basics"` - tests basic parsing, positions, children, text extraction
51
+ - `"toml node navigation"` - tests first_child, named_children navigation
52
+ - Multi-backend TOML test suite (`spec/integration/multi_backend_toml_spec.rb`)
53
+ - Runs shared examples against both tree-sitter-toml and Citrus/toml-rb backends
54
+ - Tests backend equivalence for parsing results and positions
55
+ - Tagged appropriately so tests run on whichever backends are available
56
+ - Backend Platform Compatibility section to README
57
+ - Complete compatibility matrix showing which backends work on MRI, JRuby, TruffleRuby
58
+ - Detailed explanations for TruffleRuby and JRuby limitations
59
+ - `FFI.available?` method at module level for API consistency with other backends
60
+ - `TreeHaver.resolve_native_backend_module` method for resolving only tree-sitter backends
61
+ - `TreeHaver::NATIVE_BACKENDS` constant listing backends that support shared libraries
62
+ - TruffleRuby short-circuit in `resolve_native_backend_module` for efficiency
63
+ - Avoids trying 3 backends that are all known to fail on TruffleRuby
64
+ - `citrus_available?` method to check if Citrus backend is available
65
+
66
+ ### Fixed
67
+
68
+ - **`TreeHaver::Node#child` now returns `nil` for out-of-bounds indices on all backends**
69
+ - MRI backend (ruby_tree_sitter) raises `IndexError` for invalid indices
70
+ - Other backends return `nil` for invalid indices
71
+ - Now consistently returns `nil` across all backends for API compatibility
72
+ - **Citrus backend `calculate_point` returns negative column values**
73
+ - When `offset` was 0, `@source.rindex("\n", -1)` searched from end of string
74
+ - This caused `column = 0 - (position_of_last_newline) - 1` to be negative (e.g., -34)
75
+ - Fix: Early return `{row: 0, column: 0}` for `offset <= 0`
76
+ - This bug affected both MRI and TruffleRuby when using Citrus backend
77
+ - **Citrus fallback fails on TruffleRuby when no explicit `citrus_config` provided**
78
+ - `parser_for(:toml)` would fail with `TypeError: no implicit conversion of nil into String`
79
+ - Root cause: `citrus_config` defaulted to `{}`, so `citrus_config[:gem_name]` was `nil`
80
+ - `CitrusGrammarFinder` was instantiated with `gem_name: nil`, causing `require nil`
81
+ - On TruffleRuby, this triggered a bug in `bundled_gems.rb` calling `File.path` on nil
82
+ - Fix: Added `CITRUS_DEFAULTS` with known Citrus configurations (TOML currently)
83
+ - Fix: `parser_for` now uses `CITRUS_DEFAULTS[name]` when no explicit config provided
84
+ - Fix: Added guard in `CitrusGrammarFinder#available?` to return false when `require_path` is nil
85
+ - Fix: Added `TypeError` to rescue clause for TruffleRuby-specific edge cases
86
+ - **`from_library` no longer falls back to pure-Ruby backends**
87
+ - Previously, calling `Language.from_library(path)` on TruffleRuby would fall back to Citrus
88
+ backend which then raised a confusing error about not supporting shared libraries
89
+ - Now `from_library` only considers native tree-sitter backends (MRI, Rust, FFI, Java)
90
+ - Clear error message when no native backend is available explaining the situation
91
+ - **Integration specs now use `parser_for` instead of explicit paths**
92
+ - `tree_edge_cases_spec.rb` and `node_edge_cases_spec.rb` now use `TreeHaver.parser_for(:toml)`
93
+ which auto-discovers the best available backend (tree-sitter or Citrus fallback)
94
+ - Tests now work correctly on all platforms (MRI, JRuby, TruffleRuby)
95
+ - Tagged with `:toml_parsing` which passes if ANY toml parser is available
96
+ - **Core specs now use `parser_for` instead of explicit paths**
97
+ - `tree_spec.rb`, `node_spec.rb`, `parser_spec.rb` converted to use `TreeHaver.parser_for(:toml)`
98
+ - All `:toml_grammar` tags changed to `:toml_parsing` for cross-platform compatibility
99
+ - Tests now run on JRuby and TruffleRuby via Citrus/toml-rb fallback
100
+ - FFI backend now properly reports as unavailable on TruffleRuby
101
+ - `ffi_gem_available?` returns `false` on TruffleRuby since tree-sitter uses STRUCT_BY_VALUE return types
102
+ - `FFI.available?` added at module level (was only in Native submodule)
103
+ - Prevents confusing runtime errors (Polyglot::ForeignException) by detecting incompatibility upfront
104
+ - Dependency tags now check `truffleruby?` before attempting FFI backend tests
105
+ - MRI backend now properly reports as unavailable on JRuby and TruffleRuby
106
+ - `available?` returns `false` on non-MRI platforms (C extension only works on MRI)
107
+ - Rust backend now properly reports as unavailable on JRuby and TruffleRuby
108
+ - `available?` returns `false` on non-MRI platforms (magnus requires MRI's C API)
109
+ - Backend compatibility matrix spec now properly skips tests for platform-incompatible backends
110
+ - MRI and Rust backends skip on JRuby/TruffleRuby with clear skip messages
111
+ - FFI backend skips on TruffleRuby with clear skip message
112
+
113
+ ### Changed
114
+
115
+ - **BREAKING: RSpec Dependency Tag Naming Convention Overhaul**
116
+ - All dependency tags now follow consistent naming conventions with suffixes
117
+ - Backend tags now use `*_backend` suffix (e.g., `:commonmarker_backend`, `:markly_backend`)
118
+ - Engine tags now use `*_engine` suffix (e.g., `:mri_engine`, `:jruby_engine`, `:truffleruby_engine`)
119
+ - Grammar tags now use `*_grammar` suffix (e.g., `:bash_grammar`, `:toml_grammar`, `:json_grammar`)
120
+ - Parsing capability tags now use `*_parsing` suffix (e.g., `:toml_parsing`, `:markdown_parsing`)
121
+ - **Migration required**: Update specs using legacy tags:
122
+ - `:commonmarker` → `:commonmarker_backend`
123
+ - `:markly` → `:markly_backend`
124
+ - `:mri` → `:mri_engine`
125
+ - `:jruby` → `:jruby_engine`
126
+ - `:truffleruby` → `:truffleruby_engine`
127
+ - `:tree_sitter_bash` → `:bash_grammar`
128
+ - `:tree_sitter_toml` → `:toml_grammar`
129
+ - `:tree_sitter_json` → `:json_grammar`
130
+ - `:tree_sitter_jsonc` → `:jsonc_grammar`
131
+ - `:toml_backend` → `:toml_parsing`
132
+ - `:markdown_backend` → `:markdown_parsing`
133
+ - **Removed inner-merge dependency tags from tree_haver**
134
+ - Tags `:toml_merge`, `:json_merge`, `:prism_merge`, `:psych_merge` removed
135
+ - These belong in ast-merge gem, not tree_haver
136
+ - Use `require "ast/merge/rspec/dependency_tags"` for merge gem tags
137
+ - **API Consistency**: All backends now have uniform `available?` API at module level:
138
+ - `TreeHaver::Backends::FFI.available?` - checks ffi gem + not TruffleRuby + MRI not loaded
139
+ - `TreeHaver::Backends::MRI.available?` - checks MRI platform + ruby_tree_sitter gem
140
+ - `TreeHaver::Backends::Rust.available?` - checks MRI platform + tree_stump gem
141
+ - `TreeHaver::Backends::Java.available?` - checks JRuby platform + jtreesitter JAR
142
+ - `TreeHaver::Backends::Prism.available?` - checks prism gem (all platforms)
143
+ - `TreeHaver::Backends::Psych.available?` - checks psych stdlib (all platforms)
144
+ - `TreeHaver::Backends::Commonmarker.available?` - checks commonmarker gem (all platforms)
145
+ - `TreeHaver::Backends::Markly.available?` - checks markly gem (all platforms)
146
+ - `TreeHaver::Backends::Citrus.available?` - checks citrus gem (all platforms)
147
+ - README now accurately documents TruffleRuby backend support
148
+ - FFI backend doesn't work on TruffleRuby due to `STRUCT_BY_VALUE` limitation in TruffleRuby's FFI
149
+ - Rust backend (tree_stump) doesn't work due to magnus/rb-sys incompatibility with TruffleRuby's C API
150
+ - TruffleRuby users should use Prism, Psych, Commonmarker, Markly, or Citrus backends
151
+ - Documented confirmed tree-sitter backend limitations:
152
+ - **TruffleRuby**: No tree-sitter backend works (FFI, MRI, Rust all fail)
153
+ - **JRuby**: Only Java and FFI backends work; Rust/MRI don't
154
+ - Updated Rust Backend section with platform compatibility notes
155
+ - Updated FFI Backend section with TruffleRuby limitation details
156
+ - Use kettle-rb/ts-grammar-setup GHA in CI workflows
157
+
158
+ ### Fixed
159
+
160
+ - Rakefile now properly overrides `test` task after `require "kettle/dev"`
161
+ - Works around a bug in kettle-dev where test task runs minitest loader in CI
162
+ - Ensures `rake test` runs RSpec specs instead of empty minitest suite
163
+ - `TreeHaver::RSpec::DependencyTags` now catches TruffleRuby FFI exceptions
164
+ - TruffleRuby's FFI raises `Polyglot::ForeignException` for unsupported types like `STRUCT_BY_VALUE`
165
+ - `ffi_available?` and `libtree_sitter_available?` now return `false` instead of crashing
166
+ - Fixes spec loading errors on TruffleRuby
167
+ - `TreeHaver::Backends::FFI::Language.from_library` now catches `RuntimeError` from TruffleRuby
168
+ - TruffleRuby raises `RuntimeError` instead of `LoadError` when a shared library cannot be opened
169
+ - Now properly converts to `TreeHaver::NotAvailable` with descriptive message
170
+ - `TreeHaver::Backends::FFI::Native.try_load!` now only sets `@loaded = true` after all `attach_function` calls succeed
171
+ - Previously, `loaded?` returned `true` even when `attach_function` failed (e.g., on TruffleRuby)
172
+ - Now `loaded?` correctly returns `false` when FFI functions couldn't be attached
173
+ - Ensures FFI tests are properly skipped on TruffleRuby
174
+
175
+ ## [3.1.2] - 2025-12-29
176
+
177
+ - TAG: [v3.1.2][3.1.2t]
178
+ - COVERAGE: 87.40% -- 2171/2484 lines in 22 files
179
+ - BRANCH COVERAGE: 67.04% -- 726/1083 branches in 22 files
180
+ - 90.03% documented
181
+
182
+ ### Added
183
+
184
+ - Enhanced `TreeHaver::RSpec::DependencyTags` debugging
185
+ - `env_summary` method returns relevant environment variables for diagnosis
186
+ - `grammar_works?` now logs detailed trace when `TREE_HAVER_DEBUG=1`
187
+ - `before(:suite)` prints both env vars and dependency status when debugging
188
+ - Helps diagnose differences between local and CI environments
189
+ - Many new specs for:
190
+ - TreeHaver::GrammarFinder
191
+ - TreeHaver::Node
192
+ - TreeHaver::Tree
193
+
33
194
  ## [3.1.1] - 2025-12-28
34
195
 
35
196
  - TAG: [v3.1.1][3.1.1t]
@@ -321,7 +482,7 @@ Please file a bug if you notice a violation of semantic versioning.
321
482
  - Shows when TREE_SITTER_*_PATH is set but points to nonexistent file
322
483
  - Provides helpful guidance for setting environment variables correctly
323
484
  - Fixed registry conflicts when registering multiple backend types for the same language
324
- - Fixed `CitrusGrammarFinder` to properly handle gems with non-standard require paths (e.g., `toml-rb.rb` vs `toml/rb.rb`)
485
+ - Fixed `CitrusGrammarFinder` to use gem name as-is for require path (e.g., `require "toml-rb"` not `require "toml/rb"`)
325
486
  - Fixed Citrus backend infinite recursion in `Node#extract_type_from_event`
326
487
  - Added cycle detection to prevent stack overflow when traversing recursive grammar structures
327
488
 
@@ -419,7 +580,11 @@ Despite the major version bump to 3.0.0 (following semver due to the breaking `L
419
580
 
420
581
  - Initial release
421
582
 
422
- [Unreleased]: https://github.com/kettle-rb/tree_haver/compare/v3.1.1...HEAD
583
+ [Unreleased]: https://github.com/kettle-rb/tree_haver/compare/v3.2.0...HEAD
584
+ [3.2.0]: https://github.com/kettle-rb/tree_haver/compare/v3.1.2...v3.2.0
585
+ [3.2.0t]: https://github.com/kettle-rb/tree_haver/releases/tag/v3.2.0
586
+ [3.1.2]: https://github.com/kettle-rb/tree_haver/compare/v3.1.1...v3.1.2
587
+ [3.1.2t]: https://github.com/kettle-rb/tree_haver/releases/tag/v3.1.2
423
588
  [3.1.1]: https://github.com/kettle-rb/tree_haver/compare/v3.1.0...v3.1.1
424
589
  [3.1.1t]: https://github.com/kettle-rb/tree_haver/releases/tag/v3.1.1
425
590
  [3.1.0]: https://github.com/kettle-rb/tree_haver/compare/v3.0.0...v3.1.0