@@ -408,6 +408,118 @@ class Foo::Bar; end
408408 end
409409 end
410410
411+ def test_go_to_definition_for_send_symbol
412+ source = <<~RUBY
413+ class Foo
414+ def foo; end
415+ end
416+
417+ obj = Foo.new
418+ obj.send(:foo)
419+ RUBY
420+
421+ with_server ( source ) do |server , uri |
422+ server . process_message (
423+ id : 1 ,
424+ method : "textDocument/definition" ,
425+ params : { textDocument : { uri : uri } , position : { character : 11 , line : 5 } }
426+ )
427+ response = server . pop_response . response . first
428+ assert_equal ( 1 , response . target_range . start . line )
429+ assert_equal ( 1 , response . target_range . end . line )
430+ end
431+ end
432+
433+ def test_go_to_definition_for_send_symbol_multiple_objects
434+ source = <<~RUBY
435+ class Foo
436+ def foo; end
437+ end
438+
439+ class Bar
440+ def foo; end
441+ end
442+
443+ f = Foo.new
444+ b = Bar.new
445+
446+ f.send(:foo)
447+ b.send(:foo)
448+ RUBY
449+
450+ with_server ( source ) do |server , uri |
451+ server . process_message (
452+ id : 1 ,
453+ method : "textDocument/definition" ,
454+ params : { textDocument : { uri : uri } , position : { character : 9 , line : 11 } }
455+ )
456+ response = server . pop_response . response
457+ assert_equal ( 2 , response . size )
458+
459+ assert_equal ( 1 , response [ 0 ] . target_range . start . line )
460+ assert_equal ( 1 , response [ 0 ] . target_range . end . line )
461+
462+ assert_equal ( 5 , response [ 1 ] . target_range . start . line )
463+ assert_equal ( 5 , response [ 1 ] . target_range . end . line )
464+ end
465+ end
466+
467+ def test_go_to_definition_for_send_string
468+ source = <<~RUBY
469+ class Foo
470+ def foo; end
471+ end
472+
473+ obj = Foo.new
474+ obj.send("foo")
475+ RUBY
476+
477+ with_server ( source ) do |server , uri |
478+ server . process_message (
479+ id : 2 ,
480+ method : "textDocument/definition" ,
481+ params : { textDocument : { uri : uri } , position : { character : 11 , line : 5 } }
482+ )
483+ response = server . pop_response . response . first
484+ assert_equal ( 1 , response . target_range . start . line )
485+ assert_equal ( 1 , response . target_range . end . line )
486+ end
487+ end
488+
489+ def test_go_to_definition_for_send_string_multiple_objects
490+ source = <<~RUBY
491+ class Foo
492+ def foo; end
493+ end
494+
495+ class Bar
496+ def foo; end
497+ end
498+
499+ f = Foo.new
500+ b = Bar.new
501+
502+ f.send("foo")
503+ b.send("foo")
504+ RUBY
505+
506+ with_server ( source ) do |server , uri |
507+ server . process_message (
508+ id : 1 ,
509+ method : "textDocument/definition" ,
510+ params : { textDocument : { uri : uri } , position : { character : 9 , line : 11 } }
511+ )
512+ response = server . pop_response . response
513+ assert_equal ( 2 , response . size )
514+
515+ assert_equal ( 1 , response [ 0 ] . target_range . start . line )
516+ assert_equal ( 1 , response [ 0 ] . target_range . end . line )
517+
518+ assert_equal ( 5 , response [ 1 ] . target_range . start . line )
519+ assert_equal ( 5 , response [ 1 ] . target_range . end . line )
520+ end
521+ end
522+
411523 def test_does_nothing_when_autoload_declaration_does_not_exist
412524 source = <<~RUBY
413525 # typed: ignore
0 commit comments