Class: Fast::PrismAdapter::Location
- Inherits:
-
Object
- Object
- Fast::PrismAdapter::Location
- Defined in:
- lib/fast/prism_adapter.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(buffer_name, source, start_offset, end_offset, prism_node: nil) ⇒ Location
constructor
A new instance of Location.
- #name ⇒ Object
- #operator ⇒ Object
- #selector ⇒ Object
Constructor Details
#initialize(buffer_name, source, start_offset, end_offset, prism_node: nil) ⇒ Location
Returns a new instance of Location.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fast/prism_adapter.rb', line 14 def initialize(buffer_name, source, start_offset, end_offset, prism_node: nil) @buffer_name = buffer_name @source = source @prism_node = prism_node buffer = Fast::Source.buffer(buffer_name, source: source) @expression = Fast::Source.range( buffer, character_offset(source, start_offset), character_offset(source, end_offset) ) end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
12 13 14 |
# File 'lib/fast/prism_adapter.rb', line 12 def expression @expression end |
#node ⇒ Object
Returns the value of attribute node.
11 12 13 |
# File 'lib/fast/prism_adapter.rb', line 11 def node @node end |
Instance Method Details
#name ⇒ Object
26 27 28 29 30 |
# File 'lib/fast/prism_adapter.rb', line 26 def name return unless @prism_node&.respond_to?(:name_loc) && @prism_node.name_loc range_for(@prism_node.name_loc) end |
#operator ⇒ Object
38 39 40 41 42 |
# File 'lib/fast/prism_adapter.rb', line 38 def operator return unless @prism_node&.respond_to?(:operator_loc) && @prism_node.operator_loc range_for(@prism_node.operator_loc) end |
#selector ⇒ Object
32 33 34 35 36 |
# File 'lib/fast/prism_adapter.rb', line 32 def selector return unless @prism_node&.respond_to?(:message_loc) && @prism_node. range_for(@prism_node.) end |