rbs_heuristic_prototype 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7e11861501ff2a314a91b2f337ad4d2eb221ebe592370e45af6e92ea948702
4
- data.tar.gz: 44ffa57df421f66295eca2b851a284aa081261ef54260cb2b504cad251462cf5
3
+ metadata.gz: fbe4430714610920d329586d8fbde2db9dd6f89f7b77731e2c1670d701c93cfe
4
+ data.tar.gz: b3295c9f086521d4d5c38540939a60b7d817f4ed4dc9ba1cafd58fc2755cb768
5
5
  SHA512:
6
- metadata.gz: ab5dec88b9972879a5e138af3b6cec83570fde7dad9b639ce4d8a23b7c8e5f3658d58817b9fb0578bd201a511e5694b377a184842d933e08fdfb6608524ee848
7
- data.tar.gz: 9f889db54fe192e9ec8e2b825fa65181e400f7f7459a1cc8a6a1f04917c6314390bd9c59194b87040e98e20859f345d5fde6f7bde803e2870dc13e4ebe31d44b
6
+ metadata.gz: ffc7778301c51fcb5f137d5ad2c7a83026e810c222cbb5c1f8e8d0a1a0849ca5d7c7c4c5d889758a5ab821c25711170ba714df3b2f831174e835f78efc26cbfc
7
+ data.tar.gz: c76cfe0346985b67cb4098a36a14a31e16a09f5ff5777cbb65dfad2c212b4cff110fcb7da88422a196d9f72448b253a17ba4166a74e5e753043ae40ab8a34cbe
data/.rubocop.yml CHANGED
@@ -15,6 +15,9 @@ Style/StringLiteralsInInterpolation:
15
15
  Layout/LineLength:
16
16
  Max: 120
17
17
 
18
+ Metrics/AbcSize:
19
+ Max: 30
20
+
18
21
  Metrics/BlockLength:
19
22
  Exclude:
20
23
  - "spec/**/*"
data/Gemfile.lock CHANGED
@@ -1,13 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_heuristic_prototype (0.6.0)
4
+ rbs_heuristic_prototype (0.7.0)
5
+ actionmailer
5
6
  activesupport
7
+ parallel
6
8
  rbs
7
9
 
8
10
  GEM
9
11
  remote: https://rubygems.org/
10
12
  specs:
13
+ actionmailer (7.0.7.2)
14
+ actionpack (= 7.0.7.2)
15
+ actionview (= 7.0.7.2)
16
+ activejob (= 7.0.7.2)
17
+ activesupport (= 7.0.7.2)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ net-imap
20
+ net-pop
21
+ net-smtp
22
+ rails-dom-testing (~> 2.0)
11
23
  actionpack (7.0.7.2)
12
24
  actionview (= 7.0.7.2)
13
25
  activesupport (= 7.0.7.2)
@@ -21,6 +33,9 @@ GEM
21
33
  erubi (~> 1.4)
22
34
  rails-dom-testing (~> 2.0)
23
35
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
36
+ activejob (7.0.7.2)
37
+ activesupport (= 7.0.7.2)
38
+ globalid (>= 0.3.6)
24
39
  activemodel (7.0.7.2)
25
40
  activesupport (= 7.0.7.2)
26
41
  activerecord (7.0.7.2)
@@ -38,10 +53,13 @@ GEM
38
53
  concurrent-ruby (1.2.2)
39
54
  crass (1.0.6)
40
55
  csv (3.2.7)
56
+ date (3.3.3)
41
57
  diff-lcs (1.5.0)
42
58
  erubi (1.12.0)
43
59
  ffi (1.15.5)
44
60
  fileutils (1.7.1)
61
+ globalid (1.2.1)
62
+ activesupport (>= 6.1)
45
63
  i18n (1.14.1)
46
64
  concurrent-ruby (~> 1.0)
47
65
  json (2.6.3)
@@ -53,8 +71,23 @@ GEM
53
71
  loofah (2.21.3)
54
72
  crass (~> 1.0.2)
55
73
  nokogiri (>= 1.12.0)
74
+ mail (2.8.1)
75
+ mini_mime (>= 0.1.1)
76
+ net-imap
77
+ net-pop
78
+ net-smtp
56
79
  method_source (1.0.0)
80
+ mini_mime (1.1.5)
57
81
  minitest (5.19.0)
82
+ net-imap (0.4.1)
83
+ date
84
+ net-protocol
85
+ net-pop (0.1.2)
86
+ net-protocol
87
+ net-protocol (0.2.1)
88
+ timeout
89
+ net-smtp (0.4.0)
90
+ net-protocol
58
91
  nokogiri (1.15.4-x86_64-darwin)
59
92
  racc (~> 1.4)
60
93
  nokogiri (1.15.4-x86_64-linux)
@@ -108,7 +141,7 @@ GEM
108
141
  diff-lcs (>= 1.2.0, < 2.0)
109
142
  rspec-support (~> 3.12.0)
110
143
  rspec-support (3.12.0)
111
- rubocop (1.56.2)
144
+ rubocop (1.56.4)
112
145
  base64 (~> 0.1.1)
113
146
  json (~> 2.3)
114
147
  language_server-protocol (>= 3.17.0)
@@ -143,6 +176,7 @@ GEM
143
176
  terminal-table (3.0.2)
144
177
  unicode-display_width (>= 1.1.1, < 3)
145
178
  thor (1.2.2)
179
+ timeout (0.4.0)
146
180
  tzinfo (2.0.6)
147
181
  concurrent-ruby (~> 1.0)
148
182
  unicode-display_width (2.4.2)
data/README.md CHANGED
@@ -40,7 +40,11 @@ by `rbs prototype` according to the heuristic rules.
40
40
  * Rule 5:
41
41
  * Convert a module reference without type arguments (ex. `include Enumerable`) to a module reference with type arguments (ex. `include Enumerable[untyped]`)
42
42
  * Rule 6:
43
- * Convert a module definition of controller concerns to have its module-self-types (ex. `module Loginable` to `module Loginable: ApplicationController`)
43
+ * Convert a module definition of concerns to have its module-self-types (ex. `module Loginable` to `module Loginable: ApplicationController`)
44
+ * Rule 7:
45
+ * Convert a module definition of helpers to have its module-self-types (ex. `module ApplicationHelper` to `module ApplicationHelper: ApplicationController, ActionView::Base`)
46
+ * Rule 8:
47
+ * Convert an instance method of mailer class to a class method (ex. `AccountMailer#welcome_mail` to `AccountMailer.welcome_mail`)
44
48
 
45
49
  ## Development
46
50
 
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_mailer"
4
+ require_relative "base"
5
+
6
+ module RbsHeuristicPrototype
7
+ module Filters
8
+ class ActionMailerFilter < Base
9
+ def process_class(decl)
10
+ klass = const_get(decl)
11
+ if klass&.ancestors&.include?(::ActionMailer::Base)
12
+ process_mailer_class(decl, klass)
13
+ else
14
+ super
15
+ end
16
+ end
17
+
18
+ def process_mailer_class(decl, _klass)
19
+ RBS::AST::Declarations::Class.new(
20
+ name: decl.name,
21
+ type_params: decl.type_params,
22
+ super_class: decl.super_class,
23
+ members: process_mailer_members(decl.members),
24
+ annotations: decl.annotations,
25
+ location: decl.location,
26
+ comment: decl.comment
27
+ )
28
+ end
29
+
30
+ def process_mailer_members(members)
31
+ visible = true
32
+ members.map do |member|
33
+ case member
34
+ when RBS::AST::Members::MethodDefinition
35
+ process_mailer_method(member, visible)
36
+ when RBS::AST::Members::Public
37
+ visible = true
38
+ process_member(member)
39
+ when RBS::AST::Members::Private
40
+ visible = false
41
+ process_member(member)
42
+ when RBS::AST::Members::Base
43
+ process_member(member)
44
+ else
45
+ process(member)
46
+ end
47
+ end
48
+ end
49
+
50
+ def process_mailer_method(member, visible)
51
+ return member if member.visibility == :private || !visible
52
+
53
+ RBS::AST::Members::MethodDefinition.new(
54
+ name: member.name,
55
+ kind: :singleton,
56
+ overloads: member.overloads.map { |overload| process_mailer_method_overload(overload) },
57
+ annotations: member.annotations,
58
+ location: member.location,
59
+ comment: member.comment,
60
+ overloading: member.overloading,
61
+ visibility: member.visibility
62
+ )
63
+ end
64
+
65
+ def process_mailer_method_overload(overload)
66
+ method_type = process_mailer_method_method_type(overload.method_type)
67
+ overload.update(method_type: method_type)
68
+ end
69
+
70
+ def process_mailer_method_method_type(method_type)
71
+ # @type var location: untyped
72
+ name = TypeName("::ActionMailer::MessageDelivery")
73
+ location = method_type.type.return_type.location
74
+ return_type = RBS::Types::Alias.new(name: name, args: [], location: location)
75
+ method_type.update(type: method_type.type.update(return_type: return_type))
76
+ end
77
+ end
78
+ end
79
+ end
@@ -85,8 +85,13 @@ module RbsHeuristicPrototype
85
85
 
86
86
  def const_get(decl)
87
87
  init = Kernel # : singleton(Class)?
88
- decl.name.to_namespace.path.inject(init) do |const, mod|
89
- const&.const_get(mod)
88
+ case decl
89
+ when String
90
+ init&.const_get(decl)
91
+ when RBS::AST::Declarations::Module, RBS::AST::Declarations::Class
92
+ decl.name.to_namespace.path.inject(init) do |const, mod|
93
+ const&.const_get(mod)
94
+ end
90
95
  end
91
96
  rescue StandardError
92
97
  nil
@@ -12,7 +12,7 @@ module RbsHeuristicPrototype
12
12
  @stack = [::Kernel]
13
13
  end
14
14
 
15
- def process_module(decl) # rubocop:disable Metrics/AbcSize
15
+ def process_module(decl)
16
16
  if decl.name.namespace.empty?
17
17
  namespaces = []
18
18
  stack << const_get(decl)
@@ -57,7 +57,7 @@ module RbsHeuristicPrototype
57
57
  namespaces
58
58
  end
59
59
 
60
- def obj_to_decl(obj) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
60
+ def obj_to_decl(obj) # rubocop:disable Metrics/MethodLength
61
61
  if obj.is_a?(Class)
62
62
  if (superclass = obj.superclass)
63
63
  super_class = RBS::AST::Declarations::Class::Super.new(name: TypeName(superclass.name.to_s),
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+ require "active_support/concern"
5
+
6
+ module RbsHeuristicPrototype
7
+ module Filters
8
+ class RailsConcernsFilter < Base
9
+ attr_reader :stack
10
+
11
+ def initialize(env)
12
+ super
13
+ @stack = [::Kernel]
14
+ end
15
+
16
+ def process_module(decl)
17
+ mod = stack.last&.const_get(decl.name.to_s)
18
+ stack << mod
19
+ if mod && concern?(mod) && decl.self_types.empty?
20
+ RBS::AST::Declarations::Module.new(
21
+ name: decl.name,
22
+ type_params: decl.type_params,
23
+ members: decl.members,
24
+ self_types: self_types_for(mod),
25
+ annotations: decl.annotations,
26
+ location: decl.location,
27
+ comment: decl.comment
28
+ )
29
+ else
30
+ super
31
+ end
32
+ ensure
33
+ stack.pop
34
+ end
35
+
36
+ def process_class(decl)
37
+ mod = stack.last&.const_get(decl.name.to_s)
38
+ stack << mod
39
+ super
40
+ ensure
41
+ stack.pop
42
+ end
43
+
44
+ def concern?(mod)
45
+ mod.singleton_class.ancestors.include?(ActiveSupport::Concern)
46
+ end
47
+
48
+ def self_types_for(mod)
49
+ names = case module_type_for(mod)
50
+ when :controller
51
+ self_types_for_controller(mod)
52
+ else
53
+ []
54
+ end
55
+
56
+ names.map do |name|
57
+ RBS::AST::Declarations::Module::Self.new(name: name, args: [], location: nil)
58
+ end
59
+ end
60
+
61
+ def self_types_for_controller(mod)
62
+ if const_get("ApplicationController") && !(mod > ApplicationController)
63
+ [TypeName("::ApplicationController")]
64
+ else
65
+ [TypeName("::ActionController::Base")]
66
+ end
67
+ end
68
+
69
+ def module_type_for(mod)
70
+ source_location = Kernel.const_source_location(mod.name.to_s)
71
+ return :unknown unless source_location
72
+
73
+ filename, = source_location.first
74
+
75
+ case filename
76
+ when %r{app/controllers/concerns}
77
+ :controller
78
+ else
79
+ :unknown
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+ require "active_support/concern"
5
+
6
+ module RbsHeuristicPrototype
7
+ module Filters
8
+ class RailsHelpersFilter < Base
9
+ attr_reader :stack
10
+
11
+ def initialize(env)
12
+ super
13
+ @stack = [::Kernel]
14
+ end
15
+
16
+ def process_module(decl)
17
+ mod = stack.last&.const_get(decl.name.to_s)
18
+ stack << mod
19
+ if mod && helper?(mod) && decl.self_types.empty?
20
+ RBS::AST::Declarations::Module.new(
21
+ name: decl.name,
22
+ type_params: decl.type_params,
23
+ members: decl.members,
24
+ self_types: self_types_for(mod),
25
+ annotations: decl.annotations,
26
+ location: decl.location,
27
+ comment: decl.comment
28
+ )
29
+ else
30
+ super
31
+ end
32
+ ensure
33
+ stack.pop
34
+ end
35
+
36
+ def process_class(decl)
37
+ mod = stack.last&.const_get(decl.name.to_s)
38
+ stack << mod
39
+ super
40
+ ensure
41
+ stack.pop
42
+ end
43
+
44
+ def helper?(mod)
45
+ return false unless mod.name.to_s.end_with?("Helper")
46
+
47
+ source_location = Kernel.const_source_location(mod.name.to_s)
48
+ return false unless source_location
49
+
50
+ filename, = source_location.first
51
+ return false unless filename
52
+
53
+ filename.include?("app/helpers")
54
+ end
55
+
56
+ def self_types_for(mod)
57
+ names = []
58
+ names << if const_get("ApplicationController")
59
+ TypeName("::ApplicationController")
60
+ else
61
+ TypeName("::ActionController::Base")
62
+ end
63
+ names << if mod.name == "ApplicationHelper"
64
+ TypeName("::ActionView::Base")
65
+ else
66
+ TypeName("::ApplicationHelper")
67
+ end
68
+
69
+ names.map do |name|
70
+ RBS::AST::Declarations::Module::Self.new(name: name, args: [], location: nil)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -25,7 +25,7 @@ module RbsHeuristicPrototype
25
25
  if class_decl && decl.args.empty?
26
26
  RBS::AST::Declarations::Class::Super.new(
27
27
  name: decl.name,
28
- args: class_decl.type_params.size.times.map { :untyped },
28
+ args: class_decl.type_params.size.times.map { RBS::Types::Bases::Any.new(location: nil) },
29
29
  location: decl.location
30
30
  )
31
31
  else
@@ -47,7 +47,7 @@ module RbsHeuristicPrototype
47
47
  if class_decl && decl.args.empty?
48
48
  RBS::AST::Members::Include.new(
49
49
  name: decl.name,
50
- args: class_decl.type_params.size.times.map { :untyped },
50
+ args: class_decl.type_params.size.times.map { RBS::Types::Bases::Any.new(location: nil) },
51
51
  annotations: decl.annotations,
52
52
  location: decl.location,
53
53
  comment: decl.comment
@@ -1,16 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "pathname"
4
+ require "parallel"
4
5
  require "rake"
5
6
  require "rake/tasklib"
6
7
 
7
8
  module RbsHeuristicPrototype
8
9
  class RakeTask < Rake::TaskLib
9
10
  FILTERS = {
11
+ action_mailer: "RbsHeuristicPrototype::Filters::ActionMailerFilter",
10
12
  active_model_validations: "RbsHeuristicPrototype::Filters::ActiveModelValidationsFilter",
11
13
  boolean_methods: "RbsHeuristicPrototype::Filters::BooleanMethodsFilter",
12
- controller_concerns: "RbsHeuristicPrototype::Filters::ControllerConcernsFilter",
13
14
  deep_module: "RbsHeuristicPrototype::Filters::DeepModuleFilter",
15
+ rails_concerns: "RbsHeuristicPrototype::Filters::RailsConcernsFilter",
16
+ # rails_helpers: "RbsHeuristicPrototype::Filters::RailsHelpersFilter",
14
17
  symbol_array_constants: "RbsHeuristicPrototype::Filters::SymbolArrayConstantsFilter",
15
18
  type_args: "RbsHeuristicPrototype::Filters::TypeArgsFilter"
16
19
  }.freeze
@@ -39,9 +42,9 @@ module RbsHeuristicPrototype
39
42
  def define_apply_task
40
43
  desc "Apply heuristic filters to prototype signatures"
41
44
  task("#{name}:apply": :environment) do
42
- require "rbs_heuristic_prototype" # load RbsHeuristicPrototype lazily
45
+ require "rbs_heuristic_prototype" # load RbsHeuristicPrototype lazily
43
46
 
44
- path.find do |entry|
47
+ Parallel.each(path.find) do |entry|
45
48
  next unless entry.file?
46
49
 
47
50
  env = FILTERS.inject(load_env(entry)) do |result, (_name, filter)|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsHeuristicPrototype
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "rbs_heuristic_prototype/filters/action_mailer_filter"
3
4
  require_relative "rbs_heuristic_prototype/filters/active_model_validations_filter"
4
5
  require_relative "rbs_heuristic_prototype/filters/boolean_methods_filter"
5
- require_relative "rbs_heuristic_prototype/filters/controller_concerns_filter"
6
6
  require_relative "rbs_heuristic_prototype/filters/deep_module_filter"
7
+ require_relative "rbs_heuristic_prototype/filters/rails_concerns_filter"
8
+ require_relative "rbs_heuristic_prototype/filters/rails_helpers_filter"
7
9
  require_relative "rbs_heuristic_prototype/filters/symbol_array_constants_filter"
8
10
  require_relative "rbs_heuristic_prototype/filters/type_args_filter"
9
11
  require_relative "rbs_heuristic_prototype/rake_task"
@@ -2,7 +2,7 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
5
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
6
6
  remote: https://github.com/ruby/gem_rbs_collection.git
7
7
  repo_dir: gems
8
8
  path: ".gem_rbs_collection"
@@ -11,12 +11,20 @@ gems:
11
11
  version: '0'
12
12
  source:
13
13
  type: stdlib
14
+ - name: actionmailer
15
+ version: '7.0'
16
+ source:
17
+ type: git
18
+ name: ruby/gem_rbs_collection
19
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
20
+ remote: https://github.com/ruby/gem_rbs_collection.git
21
+ repo_dir: gems
14
22
  - name: actionpack
15
23
  version: '6.0'
16
24
  source:
17
25
  type: git
18
26
  name: ruby/gem_rbs_collection
19
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
27
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
20
28
  remote: https://github.com/ruby/gem_rbs_collection.git
21
29
  repo_dir: gems
22
30
  - name: actionview
@@ -24,7 +32,15 @@ gems:
24
32
  source:
25
33
  type: git
26
34
  name: ruby/gem_rbs_collection
27
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
35
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
36
+ remote: https://github.com/ruby/gem_rbs_collection.git
37
+ repo_dir: gems
38
+ - name: activejob
39
+ version: '6.0'
40
+ source:
41
+ type: git
42
+ name: ruby/gem_rbs_collection
43
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
28
44
  remote: https://github.com/ruby/gem_rbs_collection.git
29
45
  repo_dir: gems
30
46
  - name: activemodel
@@ -32,7 +48,7 @@ gems:
32
48
  source:
33
49
  type: git
34
50
  name: ruby/gem_rbs_collection
35
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
51
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
36
52
  remote: https://github.com/ruby/gem_rbs_collection.git
37
53
  repo_dir: gems
38
54
  - name: activerecord
@@ -40,7 +56,7 @@ gems:
40
56
  source:
41
57
  type: git
42
58
  name: ruby/gem_rbs_collection
43
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
59
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
44
60
  remote: https://github.com/ruby/gem_rbs_collection.git
45
61
  repo_dir: gems
46
62
  - name: activesupport
@@ -48,7 +64,7 @@ gems:
48
64
  source:
49
65
  type: git
50
66
  name: ruby/gem_rbs_collection
51
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
67
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
52
68
  remote: https://github.com/ruby/gem_rbs_collection.git
53
69
  repo_dir: gems
54
70
  - name: ast
@@ -56,7 +72,7 @@ gems:
56
72
  source:
57
73
  type: git
58
74
  name: ruby/gem_rbs_collection
59
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
75
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
60
76
  remote: https://github.com/ruby/gem_rbs_collection.git
61
77
  repo_dir: gems
62
78
  - name: base64
@@ -72,19 +88,31 @@ gems:
72
88
  source:
73
89
  type: git
74
90
  name: ruby/gem_rbs_collection
75
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
91
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
76
92
  remote: https://github.com/ruby/gem_rbs_collection.git
77
93
  repo_dir: gems
78
94
  - name: date
79
95
  version: '0'
80
96
  source:
81
97
  type: stdlib
98
+ - name: erb
99
+ version: '0'
100
+ source:
101
+ type: stdlib
102
+ - name: globalid
103
+ version: '1.1'
104
+ source:
105
+ type: git
106
+ name: ruby/gem_rbs_collection
107
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
108
+ remote: https://github.com/ruby/gem_rbs_collection.git
109
+ repo_dir: gems
82
110
  - name: i18n
83
111
  version: '1.10'
84
112
  source:
85
113
  type: git
86
114
  name: ruby/gem_rbs_collection
87
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
115
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
88
116
  remote: https://github.com/ruby/gem_rbs_collection.git
89
117
  repo_dir: gems
90
118
  - name: json
@@ -95,6 +123,14 @@ gems:
95
123
  version: '0'
96
124
  source:
97
125
  type: stdlib
126
+ - name: mail
127
+ version: '2.8'
128
+ source:
129
+ type: git
130
+ name: ruby/gem_rbs_collection
131
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
132
+ remote: https://github.com/ruby/gem_rbs_collection.git
133
+ repo_dir: gems
98
134
  - name: minitest
99
135
  version: '0'
100
136
  source:
@@ -112,7 +148,7 @@ gems:
112
148
  source:
113
149
  type: git
114
150
  name: ruby/gem_rbs_collection
115
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
151
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
116
152
  remote: https://github.com/ruby/gem_rbs_collection.git
117
153
  repo_dir: gems
118
154
  - name: optparse
@@ -124,7 +160,7 @@ gems:
124
160
  source:
125
161
  type: git
126
162
  name: ruby/gem_rbs_collection
127
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
163
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
128
164
  remote: https://github.com/ruby/gem_rbs_collection.git
129
165
  repo_dir: gems
130
166
  - name: pathname
@@ -136,7 +172,7 @@ gems:
136
172
  source:
137
173
  type: git
138
174
  name: ruby/gem_rbs_collection
139
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
175
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
140
176
  remote: https://github.com/ruby/gem_rbs_collection.git
141
177
  repo_dir: gems
142
178
  - name: rails-dom-testing
@@ -144,7 +180,7 @@ gems:
144
180
  source:
145
181
  type: git
146
182
  name: ruby/gem_rbs_collection
147
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
183
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
148
184
  remote: https://github.com/ruby/gem_rbs_collection.git
149
185
  repo_dir: gems
150
186
  - name: railties
@@ -152,7 +188,7 @@ gems:
152
188
  source:
153
189
  type: git
154
190
  name: ruby/gem_rbs_collection
155
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
191
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
156
192
  remote: https://github.com/ruby/gem_rbs_collection.git
157
193
  repo_dir: gems
158
194
  - name: rainbow
@@ -160,7 +196,7 @@ gems:
160
196
  source:
161
197
  type: git
162
198
  name: ruby/gem_rbs_collection
163
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
199
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
164
200
  remote: https://github.com/ruby/gem_rbs_collection.git
165
201
  repo_dir: gems
166
202
  - name: rbs
@@ -183,10 +219,22 @@ gems:
183
219
  version: '0'
184
220
  source:
185
221
  type: stdlib
222
+ - name: thor
223
+ version: '1.2'
224
+ source:
225
+ type: git
226
+ name: ruby/gem_rbs_collection
227
+ revision: 8149bc3fc0f720d935dc0592dc8886e03052f65f
228
+ remote: https://github.com/ruby/gem_rbs_collection.git
229
+ repo_dir: gems
186
230
  - name: time
187
231
  version: '0'
188
232
  source:
189
233
  type: stdlib
234
+ - name: timeout
235
+ version: '0'
236
+ source:
237
+ type: stdlib
190
238
  - name: tsort
191
239
  version: '0'
192
240
  source:
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
+ spec.add_dependency "actionmailer"
30
31
  spec.add_dependency "activesupport"
32
+ spec.add_dependency "parallel"
31
33
  spec.add_dependency "rbs"
32
34
  end
@@ -0,0 +1,12 @@
1
+ module RbsHeuristicPrototype
2
+ module Filters
3
+ class ActionMailerFilter < Base
4
+ def process_class: (RBS::AST::Declarations::Class decl) -> RBS::AST::Declarations::Class
5
+ def process_mailer_class: (RBS::AST::Declarations::Class decl, Class klass) -> RBS::AST::Declarations::Class
6
+ def process_mailer_members: (Array[RBS::AST::Declarations::Class::member] members) -> Array[RBS::AST::Declarations::t | RBS::AST::Members::t]
7
+ def process_mailer_method: (RBS::AST::Members::MethodDefinition member, bool visibility) -> RBS::AST::Members::MethodDefinition
8
+ def process_mailer_method_overload: (RBS::AST::Members::MethodDefinition::Overload overload) -> RBS::AST::Members::MethodDefinition::Overload
9
+ def process_mailer_method_method_type: (RBS::MethodType method_type) -> RBS::MethodType
10
+ end
11
+ end
12
+ end
@@ -10,7 +10,7 @@ module RbsHeuristicPrototype
10
10
  def process_class: (RBS::AST::Declarations::Class decl) -> RBS::AST::Declarations::Class
11
11
  def process_constant: (RBS::AST::Declarations::Constant member) -> RBS::AST::Declarations::Constant
12
12
  def process_member: (RBS::AST::Members::t member) -> RBS::AST::Members::t
13
- def const_get: (RBS::AST::Declarations::Class | RBS::AST::Declarations::Module decl) -> singleton(Class)?
13
+ def const_get: (String | RBS::AST::Declarations::Class | RBS::AST::Declarations::Module decl) -> singleton(Class)?
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,13 @@
1
+ module RbsHeuristicPrototype
2
+ module Filters
3
+ class RailsConcernsFilter < Base
4
+ attr_reader stack: Array[Module]
5
+
6
+ def process_module: (RBS::AST::Declarations::Module decl) -> RBS::AST::Declarations::Module
7
+ def concern?: (Module mod) -> bool
8
+ def self_types_for: (Module mod) -> Array[RBS::AST::Declarations::Module::Self]
9
+ def self_types_for_controller: (Module mod) -> Array[RBS::TypeName]
10
+ def module_type_for: (Module mod) -> (:controller | :unknown)
11
+ end
12
+ end
13
+ end
@@ -1,8 +1,10 @@
1
1
  module RbsHeuristicPrototype
2
2
  module Filters
3
- class BooleanMethodsFilter < Base
3
+ class RailsHelpersFilter < Base
4
+ attr_reader stack: Array[Module]
5
+
4
6
  def process_module: (RBS::AST::Declarations::Module decl) -> RBS::AST::Declarations::Module
5
- def controller_concern?: (Module mod) -> bool
7
+ def helper?: (Module mod) -> bool
6
8
  def self_types_for: (Module mod) -> Array[RBS::AST::Declarations::Module::Self]
7
9
  end
8
10
  end
@@ -0,0 +1,11 @@
1
+ module RbsHeuristicPrototype
2
+ module Filters
3
+ class TypeArgsFilter < Base
4
+ def process_class: (RBS::AST::Declarations::Class decl) -> RBS::AST::Declarations::Class
5
+ def process_super_class: (RBS::AST::Declarations::Class::Super?) -> RBS::AST::Declarations::Class::Super?
6
+ def process_member: (RBS::AST::Members::t member) -> RBS::AST::Members::t
7
+ def process_include: (RBS::AST::Members::Include) -> RBS::AST::Members::Include
8
+ def external_env: () -> RBS::Environment
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_heuristic_prototype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-03 00:00:00.000000000 Z
11
+ date: 2023-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionmailer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: parallel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rbs
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -58,11 +86,13 @@ files:
58
86
  - Steepfile
59
87
  - lib/generators/rbs_heuristic_prototype/install_generator.rb
60
88
  - lib/rbs_heuristic_prototype.rb
89
+ - lib/rbs_heuristic_prototype/filters/action_mailer_filter.rb
61
90
  - lib/rbs_heuristic_prototype/filters/active_model_validations_filter.rb
62
91
  - lib/rbs_heuristic_prototype/filters/base.rb
63
92
  - lib/rbs_heuristic_prototype/filters/boolean_methods_filter.rb
64
- - lib/rbs_heuristic_prototype/filters/controller_concerns_filter.rb
65
93
  - lib/rbs_heuristic_prototype/filters/deep_module_filter.rb
94
+ - lib/rbs_heuristic_prototype/filters/rails_concerns_filter.rb
95
+ - lib/rbs_heuristic_prototype/filters/rails_helpers_filter.rb
66
96
  - lib/rbs_heuristic_prototype/filters/symbol_array_constants_filter.rb
67
97
  - lib/rbs_heuristic_prototype/filters/type_args_filter.rb
68
98
  - lib/rbs_heuristic_prototype/rake_task.rb
@@ -73,15 +103,17 @@ files:
73
103
  - sig/gems/rake.rbs
74
104
  - sig/generators/rbs_heuristic_prototype/install_generator.rbs
75
105
  - sig/rbs_heuristic_prototype.rbs
106
+ - sig/rbs_heuristic_prototype/filters/action_mailer_filter.rbs
76
107
  - sig/rbs_heuristic_prototype/filters/active_model_validations_filter.rbs
77
108
  - sig/rbs_heuristic_prototype/filters/base.rbs
78
109
  - sig/rbs_heuristic_prototype/filters/boolean_methods_filter.rbs
79
- - sig/rbs_heuristic_prototype/filters/controller_concerns_filter.rbs
80
110
  - sig/rbs_heuristic_prototype/filters/deep_module_filter.rbs
111
+ - sig/rbs_heuristic_prototype/filters/rails_concerns_filter.rbs
112
+ - sig/rbs_heuristic_prototype/filters/rails_helpers_filter.rbs
81
113
  - sig/rbs_heuristic_prototype/filters/symbol_array_constants_filter.rbs
114
+ - sig/rbs_heuristic_prototype/filters/type_args_filter.rbs
82
115
  - sig/rbs_heuristic_prototype/rake_task.rbs
83
116
  - sig/shims/active_model.rbs
84
- - sig/shims/thor.rbs
85
117
  homepage: https://github.com/tk0miya/rbs_heuristic_prototype
86
118
  licenses:
87
119
  - MIT
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "base"
4
- require "active_support/concern"
5
-
6
- module RbsHeuristicPrototype
7
- module Filters
8
- class ControllerConcernsFilter < Base
9
- def process_module(decl)
10
- mod = const_get(decl)
11
- if controller_concern?(mod) && decl.self_types.empty?
12
- RBS::AST::Declarations::Module.new(
13
- name: decl.name,
14
- type_params: decl.type_params,
15
- members: decl.members,
16
- self_types: self_types_for(mod),
17
- annotations: decl.annotations,
18
- location: decl.location,
19
- comment: decl.comment
20
- )
21
- else
22
- decl
23
- end
24
- end
25
-
26
- def controller_concern?(mod)
27
- return false unless mod.instance_variable_defined?(:@_dependencies)
28
-
29
- source_location = Kernel.const_source_location(mod.name)
30
- return false unless source_location
31
-
32
- filename, = source_location.first
33
- filename.include?("app/controllers/concerns")
34
- end
35
-
36
- def self_types_for(mod)
37
- name = if Kernel.const_get("ApplicationController") && !(mod > ApplicationController)
38
- TypeName("::ApplicationController")
39
- else
40
- TypeName("::ActionController::Base")
41
- end
42
-
43
- [RBS::AST::Declarations::Module::Self.new(name: name, args: [], location: nil)]
44
- end
45
- end
46
- end
47
- end
data/sig/shims/thor.rbs DELETED
@@ -1,5 +0,0 @@
1
- class Thor
2
- module Actions
3
- def create_file: (String destination, *String? args, ?config: bool) ?{ () -> void } -> untyped
4
- end
5
- end