File tree Expand file tree Collapse file tree
test/spoom/sorbet/translate Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,9 +75,19 @@ def node_rbs_comments(node)
7575
7676 continuation_comments = [ ] #: Array[Prism::Comment]
7777
78+ last_line = node . location . start_line
79+
7880 comments . each do |comment |
7981 string = comment . slice
8082
83+ comment_line = comment . location . end_line
84+
85+ if comment_line < last_line - 1
86+ break
87+ end
88+
89+ last_line = comment_line
90+
8191 if string . start_with? ( "# @" )
8292 string = string . delete_prefix ( "#" ) . strip
8393 res . annotations << Annotation . new ( string , comment . location )
Original file line number Diff line number Diff line change @@ -426,6 +426,26 @@ def test_translate_to_rbi_defs_within_send
426426 RBS
427427 end
428428
429+ def test_translate_to_rbi_selects_right_comments
430+ contents = <<~RB
431+ #: -> void
432+
433+ class Foo
434+ #: -> void
435+
436+ #: -> void
437+
438+ class << self
439+ #: -> void
440+
441+ def bar; end
442+ end
443+ end
444+ RB
445+
446+ assert_equal ( contents , rbs_comments_to_sorbet_sigs ( contents ) )
447+ end
448+
429449 private
430450
431451 #: (String, ?max_line_length: Integer?) -> String
You can’t perform that action at this time.
0 commit comments