Module: TreeHaver::Backends::MRI
- Defined in:
- lib/tree_haver/backends/mri.rb
Overview
Note:
This backend only works on MRI Ruby, not JRuby or TruffleRuby
MRI backend using the ruby_tree_sitter gem
This backend wraps the ruby_tree_sitter gem, which is a native C extension for MRI Ruby. It provides the most feature-complete tree-sitter integration on MRI, including support for the Query API.
Defined Under Namespace
Class Method Summary collapse
- .available? ⇒ Boolean
-
.capabilities ⇒ Hash{Symbol => Object}
Get capabilities supported by this backend.
-
.reset! ⇒ void
private
Reset the load state (primarily for testing).
Class Method Details
.available? ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tree_haver/backends/mri.rb', line 27 def available? return @loaded if @load_attempted # rubocop:disable ThreadSafety/ClassInstanceVariable @load_attempted = true # rubocop:disable ThreadSafety/ClassInstanceVariable begin require "tree_sitter" # Note: gem is ruby_tree_sitter but requires tree_sitter @loaded = true # rubocop:disable ThreadSafety/ClassInstanceVariable rescue LoadError @loaded = false # rubocop:disable ThreadSafety/ClassInstanceVariable end @loaded # rubocop:disable ThreadSafety/ClassInstanceVariable end |
.capabilities ⇒ Hash{Symbol => Object}
Get capabilities supported by this backend
55 56 57 58 59 60 61 62 63 |
# File 'lib/tree_haver/backends/mri.rb', line 55 def capabilities return {} unless available? { backend: :mri, query: true, bytes_field: true, incremental: true, } end |
.reset! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Reset the load state (primarily for testing)
44 45 46 47 |
# File 'lib/tree_haver/backends/mri.rb', line 44 def reset! @load_attempted = false # rubocop:disable ThreadSafety/ClassInstanceVariable @loaded = false # rubocop:disable ThreadSafety/ClassInstanceVariable end |