Class: SorbetView::SourceMap::Range

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/sorbet_view/source_map/range.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_lsp(lsp_hash) ⇒ Object



18
19
20
21
22
23
# File 'lib/sorbet_view/source_map/range.rb', line 18

def self.from_lsp(lsp_hash)
  new(
    start: Position.from_lsp(lsp_hash['start'] || lsp_hash[:start]),
    end_: Position.from_lsp(lsp_hash['end'] || lsp_hash[:end])
  )
end

Instance Method Details

#contains?(position) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/sorbet_view/source_map/range.rb', line 26

def contains?(position)
  return false if position.line < start.line || position.line > end_.line
  return false if position.line == start.line && position.column < start.column
  return false if position.line == end_.line && position.column > end_.column

  true
end

#to_lspObject



13
14
15
# File 'lib/sorbet_view/source_map/range.rb', line 13

def to_lsp
  { start: start.to_lsp, end: end_.to_lsp }
end