@@ -147,6 +147,66 @@ def bar; end
147147 )
148148 end
149149
150+ def test_translate_to_rbi_skipping_abstract_methods
151+ assert_rewrites_rbs (
152+ from : <<~RUBY ,
153+ # @abstract
154+ class Foo
155+ # @abstract
156+ #: -> String
157+ def bar; end
158+ end
159+
160+ # @abstract
161+ module Baz
162+ # @abstract
163+ #: -> String
164+ def qux; end
165+ end
166+ RUBY
167+
168+ to_pretty_format_for_humans : <<~RUBY ,
169+ class Foo
170+ extend T::Helpers
171+
172+ abstract!
173+
174+ # @abstract
175+ #: -> String
176+ def bar; end
177+ end
178+
179+ module Baz
180+ extend T::Helpers
181+
182+ abstract!
183+
184+ # @abstract
185+ #: -> String
186+ def qux; end
187+ end
188+ RUBY
189+
190+ to_line_matched_format_for_machines : <<~RUBY ,
191+ # RBS_REWRITTEN_ANNOTATION: @abstract
192+ class Foo; extend T::Helpers; abstract!
193+ # @abstract
194+ #: -> String
195+ def bar; end
196+ end
197+
198+ # RBS_REWRITTEN_ANNOTATION: @abstract
199+ module Baz; extend T::Helpers; abstract!
200+ # @abstract
201+ #: -> String
202+ def qux; end
203+ end
204+ RUBY
205+
206+ translate_abstract_methods : false ,
207+ )
208+ end
209+
150210 def test_translate_to_rbi_method_sigs_without_runtime
151211 assert_rewrites_rbs (
152212 from : <<~RUBY ,
@@ -1280,13 +1340,23 @@ def foo; end
12801340
12811341 private
12821342
1283- #: (String, ?max_line_length: Integer?, ?overloads_strategy: Symbol) -> String
1284- def rbs_comments_to_sorbet_sigs ( ruby_contents , max_line_length : nil , overloads_strategy : :translate_all )
1343+ #: (String,
1344+ #| ?max_line_length: Integer?,
1345+ #| ?overloads_strategy: Symbol,
1346+ #| ?translate_abstract_methods: bool
1347+ #| ) -> String
1348+ def rbs_comments_to_sorbet_sigs (
1349+ ruby_contents ,
1350+ max_line_length : nil ,
1351+ overloads_strategy : :translate_all ,
1352+ translate_abstract_methods : true
1353+ )
12851354 RBSCommentsToSorbetSigs ::HumanReadableTranslator . new (
12861355 ruby_contents ,
12871356 file : "test.rb" ,
12881357 options : RBSCommentsToSorbetSigs ::Options . new (
12891358 overloads_strategy :,
1359+ translate_abstract_methods :,
12901360 output_format : RBSCommentsToSorbetSigs ::HumanReadableRBIFormat . new (
12911361 max_line_length :,
12921362 ) ,
@@ -1299,14 +1369,16 @@ def rbs_comments_to_sorbet_sigs(ruby_contents, max_line_length: nil, overloads_s
12991369 #| to_pretty_format_for_humans: String,
13001370 #| to_line_matched_format_for_machines: String | Symbol,
13011371 #| ?max_line_length: Integer?,
1302- #| ?overloads_strategy: Symbol
1372+ #| ?overloads_strategy: Symbol,
1373+ #| ?translate_abstract_methods: bool
13031374 #| ) -> void
13041375 def assert_rewrites_rbs (
13051376 from :,
13061377 to_pretty_format_for_humans :,
13071378 to_line_matched_format_for_machines :,
13081379 max_line_length : nil ,
1309- overloads_strategy : :translate_all
1380+ overloads_strategy : :translate_all ,
1381+ translate_abstract_methods : true
13101382 )
13111383 source_with_rbs = from
13121384 expected_pretty_format = to_pretty_format_for_humans
@@ -1317,6 +1389,7 @@ def assert_rewrites_rbs(
13171389 source_with_rbs ,
13181390 max_line_length :,
13191391 overloads_strategy :,
1392+ translate_abstract_methods :,
13201393 )
13211394
13221395 assert_equal ( expected_pretty_format , rewritten_output )
@@ -1347,6 +1420,7 @@ def assert_rewrites_rbs(
13471420 file : "test.rb" ,
13481421 options : RBSCommentsToSorbetSigs ::Options . new (
13491422 overloads_strategy :,
1423+ translate_abstract_methods :,
13501424 output_format : RBSCommentsToSorbetSigs ::LineMatchedRBIFormat . default ,
13511425 ) ,
13521426 ) . rewrite
0 commit comments