Class: Rucoa::Handlers::TextDocumentSelectionRangeHandler::SelectionRangeProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/rucoa/handlers/text_document_selection_range_handler.rb

Defined Under Namespace

Classes: NodeToRangesMapper

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position:, source:) ⇒ SelectionRangeProvider

Returns a new instance of SelectionRangeProvider.

Parameters:



54
55
56
57
58
59
60
# File 'lib/rucoa/handlers/text_document_selection_range_handler.rb', line 54

def initialize(
  position:,
  source:
)
  @position = position
  @source = source
end

Class Method Details

.call(position:, source:) ⇒ Hash?

Parameters:

Returns:

  • (Hash, nil)


41
42
43
44
45
46
47
48
49
# File 'lib/rucoa/handlers/text_document_selection_range_handler.rb', line 41

def call(
  position:,
  source:
)
  new(
    position: position,
    source: source
  ).call
end

Instance Method Details

#callHash?

Returns:

  • (Hash, nil)


63
64
65
66
67
68
69
70
# File 'lib/rucoa/handlers/text_document_selection_range_handler.rb', line 63

def call
  ranges.reverse.reduce(nil) do |result, range|
    {
      parent: result,
      range: range.to_vscode_range
    }
  end
end