class Solargraph::Range


A pair of positions that compose a section of text.

def self.from_expr expr

Returns:
  • (Range) -

Parameters:
  • expr (Parser::Source::Range) --
def self.from_expr expr
  from_to(expr.line, expr.column, expr.last_line, expr.last_column)
end

def self.from_node node

Returns:
  • (Range) -

Parameters:
  • node (RubyVM::AbstractSyntaxTree::Node, Parser::AST::Node) --
def self.from_node node
  if defined?(RubyVM::AbstractSyntaxTree::Node)
    if node.is_a?(RubyVM::AbstractSyntaxTree::Node)
      Solargraph::Range.from_to(node.first_lineno - 1, node.first_column, node.last_lineno - 1, node.last_column)
    end
  elsif node.loc && node.loc.expression
    from_expr(node.loc.expression)
  end
end

def self.from_to l1, c1, l2, c2

Returns:
  • (Range) -

Parameters:
  • c2 (Integer) -- Ending character
  • l2 (Integer) -- Ending line
  • c1 (Integer) -- Starting character
  • l1 (Integer) -- Starting line
def self.from_to l1, c1, l2, c2
  Range.new(Position.new(l1, c1), Position.new(l2, c2))
end

def == other

def == other
  return false unless other.is_a?(Range)
  start == other.start && ending == other.ending
end

def contain? position

Returns:
  • (Boolean) -

Parameters:
  • position (Position, Array(Integer, Integer)) --
def contain? position
  position = Position.normalize(position)
  return false if position.line < start.line || position.line > ending.line
  return false if position.line == start.line && position.character < start.character
  return false if position.line == ending.line && position.character > ending.character
  true
end

def include? position

Returns:
  • (Boolean) -

Parameters:
  • position (Position, Array(Integer, Integer)) --
def include? position
  position = Position.normalize(position)
  contain?(position) && !(position.line == start.line && position.character == start.character)
end

def initialize start, ending

Parameters:
  • ending (Position) --
  • start (Position) --
def initialize start, ending
  @start = start
  @ending = ending
end

def inspect

def inspect
  "#<#{self.class} #{start.inspect} to #{ending.inspect}>"
end

def to_hash

Returns:
  • (Hash) -
def to_hash
  {
    start: start.to_hash,
    end: ending.to_hash
  }
end