Class: Rbs::Merge::Backends::RbsBackend::Language
- Inherits:
-
TreeHaver::Base::Language
- Object
- TreeHaver::Base::Language
- Rbs::Merge::Backends::RbsBackend::Language
- Defined in:
- lib/rbs/merge/backends/rbs_backend.rb
Overview
RBS language wrapper
The RBS gem only parses RBS type signature files.
This wrapper satisfies the current TreeHaver language contract.
Class Method Summary collapse
-
.from_library(_path = nil, symbol: nil, name: nil) ⇒ Language
(also: from_path)
Load language from a grammar path.
-
.rbs(options = {}) ⇒ Language
Create an RBS language instance (convenience method).
Instance Method Summary collapse
-
#initialize(name = :rbs, options: {}) ⇒ Language
constructor
A new instance of Language.
Constructor Details
#initialize(name = :rbs, options: {}) ⇒ Language
Returns a new instance of Language.
106 107 108 109 110 111 112 113 114 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 106 def initialize(name = :rbs, options: {}) super(name, backend: :rbs, options: ) unless @name == :rbs raise TreeHaver::NotAvailable, "RBS backend only supports RBS parsing. " \ "Got language: #{name.inspect}" end end |
Class Method Details
.from_library(_path = nil, symbol: nil, name: nil) ⇒ Language Also known as: from_path
Load language from a grammar path.
RBS gem only supports RBS, so path and symbol parameters are ignored.
This keeps the backend aligned with TreeHaver’s language API.
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 137 def from_library(_path = nil, symbol: nil, name: nil) # Derive language name from symbol if provided lang_name = name || symbol&.to_s&.sub(/^tree_sitter_/, "")&.to_sym || :rbs unless lang_name == :rbs raise TreeHaver::NotAvailable, "RBS backend only supports RBS, not #{lang_name}. " \ "Use a tree-sitter backend for #{lang_name} support." end rbs end |
.rbs(options = {}) ⇒ Language
Create an RBS language instance (convenience method)
123 124 125 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 123 def rbs( = {}) new(:rbs, options: ) end |