Add Sorbet plugin for delegate.
This commit is contained in:
parent
570edcc0cc
commit
4115086284
21
Library/Homebrew/sorbet/plugins/delegate.rb
Normal file
21
Library/Homebrew/sorbet/plugins/delegate.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
source = ARGV[5]
|
||||
|
||||
methods = if (single = source[/delegate\s+([^:]+):\s+/, 1])
|
||||
[single]
|
||||
else
|
||||
multiple = source[/delegate\s+\[(.*?)\]\s+=>\s+/m, 1]
|
||||
non_comments = multiple.gsub(/\#.*$/, "")
|
||||
non_comments.scan(/:([^:,\s]+)/).flatten
|
||||
end
|
||||
|
||||
methods.each do |method|
|
||||
puts <<~RUBY
|
||||
# typed: strict
|
||||
|
||||
sig {params(arg0: T.untyped).returns(T.untyped)}
|
||||
def #{method}(*arg0); end
|
||||
RUBY
|
||||
end
|
||||
@ -4,3 +4,4 @@ ruby_extra_args:
|
||||
triggers:
|
||||
using: sorbet/plugins/unpack_strategy_magic.rb
|
||||
attr_predicate: sorbet/plugins/attr_predicate.rb
|
||||
delegate: sorbet/plugins/delegate.rb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user