Class: RBS::Location
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/rbs/location.rb |
Class Method Summary
Instance Attribute Summary
- #buffer readonly
- #end_pos readonly
- #start_pos readonly
Instance Method Summary
Constructor Details
.new(buffer:, start_pos:, end_pos:) ⇒ Location
Class Method Details
.to_string(location, default: "*:*:*...*:*")
[ GitHub ]# File 'lib/rbs/location.rb', line 57
def self.to_string(location, default: "*:*:*...*:*") location&.to_s || default end
Instance Attribute Details
#buffer (readonly)
[ GitHub ]# File 'lib/rbs/location.rb', line 3
attr_reader :buffer
#end_pos (readonly)
[ GitHub ]# File 'lib/rbs/location.rb', line 5
attr_reader :end_pos
#start_pos (readonly)
[ GitHub ]# File 'lib/rbs/location.rb', line 4
attr_reader :start_pos
Instance Method Details
#+(other)
[ GitHub ]#<<(other)
[ GitHub ]#==(other)
[ GitHub ]#concat(*others)
[ GitHub ]# File 'lib/rbs/location.rb', line 80
def concat(*others) others.each { |other| self << other } self end
#end_column
[ GitHub ]# File 'lib/rbs/location.rb', line 33
def end_column end_loc[1] end
#end_line
[ GitHub ]# File 'lib/rbs/location.rb', line 29
def end_line end_loc[0] end
#end_loc
[ GitHub ]#inspect
[ GitHub ]# File 'lib/rbs/location.rb', line 13
def inspect "#<#{self.class}:#{self.__id__} @buffer=#{buffer.name}, @pos=#{start_pos}...#{end_pos}, source='#{source.lines.first}', start_line=#{start_line}, start_column=#{start_column}>" end
#name
[ GitHub ]# File 'lib/rbs/location.rb', line 17
def name buffer.name end
#pred?(loc) ⇒ Boolean
#range
[ GitHub ]#source
[ GitHub ]#start_column
[ GitHub ]# File 'lib/rbs/location.rb', line 25
def start_column start_loc[1] end
#start_line
[ GitHub ]# File 'lib/rbs/location.rb', line 21
def start_line start_loc[0] end
#start_loc
[ GitHub ]#to_json(state = _ = nil)
[ GitHub ]# File 'lib/rbs/location.rb', line 101
def to_json(state = _ = nil) { start: { line: start_line, column: start_column }, end: { line: end_line, column: end_column }, buffer: { name: name&.to_s } }.to_json(state) end
#to_s
[ GitHub ]# File 'lib/rbs/location.rb', line 53
def to_s "#{name || "-"}:#{start_line}:#{start_column}...#{end_line}:#{end_column}" end
#with_children(required: {}, optional: {})
[ GitHub ]# File 'lib/rbs/location.rb', line 117
def with_children(required: {}, optional: {}) # @type var required: Hash[Symbol, Range[Integer] | Location] # @type var optional: Hash[Symbol, Range[Integer] | Location | nil] this = WithChildren.new(buffer: buffer, start_pos: start_pos, end_pos: end_pos) req = required.transform_values do |value| case value when Location value.range else value end end opt = optional.transform_values do |value| case value when Location value.range else value end end this.required_children.merge!(req) this.optional_children.merge!(opt) this end