class TypeProf::CodeRange

Attributes

first[R]
last[R]

Public Class Methods

from_lsp(lsp_range) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 63
def self.from_lsp(lsp_range)
  CodeRange.new(CodeLocation.from_lsp(lsp[:start]), CodeLocation.from_lsp(lsp[:end]))
end
from_rbs(rbs_loc) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 67
def self.from_rbs(rbs_loc)
  CodeRange.new(
    CodeLocation.new(rbs_loc.start_line, rbs_loc.start_column),
    CodeLocation.new(rbs_loc.end_line, rbs_loc.end_column),
  )
end
new(first, last) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 52
def initialize(first, last)
  @first, @last = first, last
end

Public Instance Methods

contain?(other) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 82
def contain?(other)
  @first <= other.first && other.last <= @last
end
contain_loc?(loc) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 78
def contain_loc?(loc)
  @first <= loc && loc < @last
end
inspect() click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 56
def inspect
  "%p-%p" % [@first, @last]
end
overlap?(other) click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 86
def overlap?(other)
  if @first <= other.first
    return @last > other.first
  else
    return @first < other.last
  end
end
to_lsp() click to toggle source
# File typeprof-0.21.8/lib/typeprof/code-range.rb, line 74
def to_lsp
  { start: @first.to_lsp, end: @last.to_lsp }
end