Class: Rucoa::Location

Inherits:
Struct
  • Object
show all
Defined in:
lib/rucoa/location.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#rangeObject

Returns the value of attribute range

Returns:

  • (Object)

    the current value of range



4
5
6
# File 'lib/rucoa/location.rb', line 4

def range
  @range
end

#uriObject

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of uri



4
5
6
# File 'lib/rucoa/location.rb', line 4

def uri
  @uri
end

Class Method Details

.from_rbs_location(location) ⇒ Rucoa::Location

Parameters:

  • location (RBS::Location)

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rucoa/location.rb', line 12

def from_rbs_location(location)
  new(
    range: Range.new(
      Position.new(
        column: location.start_column,
        line: location.start_line
      ),
      Position.new(
        column: location.end_column,
        line: location.end_line
      )
    ),
    uri: "file://#{location.name}"
  )
end

.from_rucoa_node(node) ⇒ Object

Parameters:



29
30
31
32
33
34
# File 'lib/rucoa/location.rb', line 29

def from_rucoa_node(node)
  new(
    range: Range.from_parser_range(node.location.expression),
    uri: node.location.expression.source_buffer.name
  )
end