Add Sorbet plugin for delegate.

This commit is contained in:
Markus Reiter 2020-11-21 13:29:44 +01:00
parent 570edcc0cc
commit 4115086284
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