Merge pull request #9242 from reitermarkus/sorbet-delegate

Add Sorbet plugin for `delegate`.
This commit is contained in:
Jonathan Chang 2020-11-22 20:44:20 +11:00 committed by GitHub
commit 6177db7521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View 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

View File

@ -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