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 class exists
for API compatibility with other TreeHaver backends.
Class Method Summary collapse
-
.from_library(_path = nil, symbol: nil, name: nil) ⇒ Language
(also: from_path)
Load language from library path (API compatibility).
-
.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.
108 109 110 111 112 113 114 115 116 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 108 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 library path (API compatibility)
RBS gem only supports RBS, so path and symbol parameters are ignored.
This method exists for API consistency with tree-sitter backends,
allowing TreeHaver.parser_for(:rbs) to work regardless of backend.
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 140 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)
125 126 127 |
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 125 def rbs( = {}) new(:rbs, options: ) end |