Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/spoom/rbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@ def node_rbs_comments(node)

continuation_comments = [] #: Array[Prism::Comment]

last_line = node.location.start_line

comments.each do |comment|
string = comment.slice

comment_line = comment.location.end_line

break if comment_line < last_line - 1

last_line = comment_line

if string.start_with?("# @")
string = string.delete_prefix("#").strip
res.annotations << Annotation.new(string, comment.location)
Expand Down
20 changes: 20 additions & 0 deletions test/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,26 @@ def test_translate_to_rbi_defs_within_send
RBS
end

def test_translate_to_rbi_selects_right_comments
contents = <<~RB
#: -> void

class Foo
#: -> void

#: -> void

class << self
#: -> void

def bar; end
end
end
RB

assert_equal(contents, rbs_comments_to_sorbet_sigs(contents))
end

private

#: (String, ?max_line_length: Integer?) -> String
Expand Down