- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 162
Open
Description
Hi,
I'm coming from lekemula/solargraph-rspec#28.
It looks like we have some inconsistency on what the location range for BlockNode  should be:
Currently
 some_method_with_block do
 #^ - block start
 end
 #^ - block endExpected
 some_method_with_block do
 #                      ^ - block start
 end
 #^ - block endReproduction
irb:
# frozen_string_literal: true
require 'solargraph'
code = <<~RUBY
some_method do
  puts 'hello'
end
RUBY
ast = Solargraph::Parser.parse(code)
puts Solargraph::Parser.node_range(ast).inspect
# includes the `some_method` line
# #<Solargraph::Range #<Solargraph::Position 0, 0> to #<Solargraph::Position 2, 3>>
source_map = Solargraph::SourceMap.load_string(code)
puts source_map.source.node_at(0, 0)
# does not include the block:
# (send nil :some_method)
puts source_map.source.node_at(0, 12)
# (block
#   (send nil :some_method)
#   (args)
#   (send nil :puts
#     (str "hello")))This leads the Solargraph::SourceMap#locate_closure_pin to return the wrong closure when Go-to-definition/Hover.
Would it make sense to fix this here upstream instead?
Metadata
Metadata
Assignees
Labels
No labels