class SyntaxTree::Location
Represents the location of a node in the tree from the source code.
def self.default
location of a node, but need to create a Location instance to pass to a
A convenience method that is typically used when you don't care about the
def self.default new( start_line: 1, start_char: 0, start_column: 0, end_line: 1, end_char: 0, end_column: 0 ) end
def self.fixed(line:, char:, column:)
def self.fixed(line:, char:, column:) new( start_line: line, start_char: char, start_column: column, end_line: line, end_char: char, end_column: column ) end
def self.token(line:, char:, column:, size:)
def self.token(line:, char:, column:, size:) new( start_line: line, start_char: char, start_column: column, end_line: line, end_char: char + size, end_column: column + size ) end
def ==(other)
def ==(other) other.is_a?(Location) && start_line == other.start_line && start_char == other.start_char && end_line == other.end_line && end_char == other.end_char end
def deconstruct
def deconstruct [start_line, start_char, start_column, end_line, end_char, end_column] end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { start_line: start_line, start_char: start_char, start_column: start_column, end_line: end_line, end_char: end_char, end_column: end_column } end
def initialize(
def initialize( start_line:, start_char:, start_column:, end_line:, end_char:, end_column: ) @start_line = start_line @start_char = start_char @start_column = start_column @end_line = end_line @end_char = end_char @end_column = end_column end
def lines
def lines start_line..end_line end
def to(other)
def to(other) Location.new( start_line: start_line, start_char: start_char, start_column: start_column, end_line: [end_line, other.end_line].max, end_char: other.end_char, end_column: other.end_column ) end