File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
lib/spoom/sorbet/translate
test/spoom/sorbet/translate Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,6 @@ def apply_class_annotations(node)
132132 comments . annotations . reverse_each do |annotation |
133133 from = adjust_to_line_start ( annotation . location . start_offset )
134134 to = adjust_to_line_end ( annotation . location . end_offset )
135- @rewriter << Source ::Delete . new ( from , to )
136135
137136 content = case annotation . string
138137 when "@abstract"
@@ -147,8 +146,12 @@ def apply_class_annotations(node)
147146 srb_type = ::RBS ::Parser . parse_type ( annotation . string . delete_prefix ( "@requires_ancestor: " ) )
148147 rbs_type = RBI ::RBS ::TypeTranslator . translate ( srb_type )
149148 "requires_ancestor { #{ rbs_type } }"
149+ else
150+ next
150151 end
151152
153+ @rewriter << Source ::Delete . new ( from , to )
154+
152155 newline = node . body . nil? ? "" : "\n "
153156 @rewriter << Source ::Insert . new ( insert_pos , "\n #{ indent } #{ content } #{ newline } " )
154157 end
Original file line number Diff line number Diff line change @@ -283,6 +283,31 @@ class << self
283283 RB
284284 end
285285
286+ def test_translate_to_rbi_helpers_with_right_order
287+ contents = <<~RB
288+ # @foo
289+ # @bar
290+ # @requires_ancestor: Kernel
291+ module Baz
292+ #: -> void
293+ def foo; end
294+ end
295+ RB
296+
297+ assert_equal ( <<~RB , rbs_comments_to_sorbet_sigs ( contents ) )
298+ # @foo
299+ # @bar
300+ module Baz
301+ extend T::Helpers
302+
303+ requires_ancestor { Kernel }
304+
305+ sig { void }
306+ def foo; end
307+ end
308+ RB
309+ end
310+
286311 def test_translate_to_rbi_generics
287312 contents = <<~RB
288313 #: [in A, out B]
You can’t perform that action at this time.
0 commit comments