tapioca 0.17.3 → 0.17.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/exe/tapioca +6 -1
  3. data/lib/ruby_lsp/tapioca/addon.rb +1 -1
  4. data/lib/ruby_lsp/tapioca/server_addon.rb +10 -7
  5. data/lib/tapioca/bundler_ext/auto_require_hook.rb +1 -4
  6. data/lib/tapioca/cli.rb +3 -3
  7. data/lib/tapioca/commands/abstract_dsl.rb +3 -4
  8. data/lib/tapioca/commands/abstract_gem.rb +2 -3
  9. data/lib/tapioca/commands/annotations.rb +2 -2
  10. data/lib/tapioca/commands/check_shims.rb +2 -2
  11. data/lib/tapioca/commands/command.rb +4 -6
  12. data/lib/tapioca/commands/command_without_tracker.rb +1 -4
  13. data/lib/tapioca/commands/gem_generate.rb +1 -1
  14. data/lib/tapioca/dsl/compiler.rb +8 -10
  15. data/lib/tapioca/dsl/compilers/aasm.rb +1 -2
  16. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -2
  17. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -2
  18. data/lib/tapioca/dsl/compilers/action_text.rb +1 -2
  19. data/lib/tapioca/dsl/compilers/active_job.rb +1 -2
  20. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -4
  21. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -4
  22. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -10
  23. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -2
  24. data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -2
  25. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +2 -3
  26. data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -2
  27. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
  28. data/lib/tapioca/dsl/compilers/active_record_relations.rb +63 -91
  29. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -2
  30. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -2
  31. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -2
  32. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -2
  33. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -2
  34. data/lib/tapioca/dsl/compilers/active_storage.rb +1 -9
  35. data/lib/tapioca/dsl/compilers/active_support_concern.rb +1 -2
  36. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -2
  37. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -2
  38. data/lib/tapioca/dsl/compilers/config.rb +1 -2
  39. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -2
  40. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -2
  41. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -2
  42. data/lib/tapioca/dsl/compilers/identity_cache.rb +1 -2
  43. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -2
  44. data/lib/tapioca/dsl/compilers/kredis.rb +1 -4
  45. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +1 -2
  46. data/lib/tapioca/dsl/compilers/protobuf.rb +1 -2
  47. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -2
  48. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -2
  49. data/lib/tapioca/dsl/compilers/smart_properties.rb +21 -18
  50. data/lib/tapioca/dsl/compilers/state_machines.rb +1 -2
  51. data/lib/tapioca/dsl/compilers/url_helpers.rb +1 -2
  52. data/lib/tapioca/dsl/pipeline.rb +2 -2
  53. data/lib/tapioca/gem/events.rb +2 -6
  54. data/lib/tapioca/gem/listeners/base.rb +1 -4
  55. data/lib/tapioca/helpers/cli_helper.rb +1 -4
  56. data/lib/tapioca/helpers/config_helper.rb +2 -5
  57. data/lib/tapioca/helpers/env_helper.rb +1 -4
  58. data/lib/tapioca/helpers/rbi_files_helper.rb +3 -6
  59. data/lib/tapioca/helpers/test/content.rb +1 -4
  60. data/lib/tapioca/helpers/test/dsl_compiler.rb +1 -4
  61. data/lib/tapioca/helpers/test/isolation.rb +2 -7
  62. data/lib/tapioca/helpers/test/template.rb +1 -4
  63. data/lib/tapioca/loaders/loader.rb +4 -6
  64. data/lib/tapioca/rbs/rewriter.rb +1 -1
  65. data/lib/tapioca/repo_index.rb +0 -2
  66. data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -4
  67. data/lib/tapioca/runtime/trackers/method_definition.rb +2 -2
  68. data/lib/tapioca/runtime/trackers/tracker.rb +1 -4
  69. data/lib/tapioca/sorbet_ext/name_patch.rb +1 -1
  70. data/lib/tapioca/version.rb +1 -1
  71. metadata +1 -1
@@ -148,13 +148,12 @@ module Tapioca
148
148
  # end
149
149
  # end
150
150
  # ~~~
151
+ #: [ConstantType = singleton(::ActiveRecord::Base)]
151
152
  class ActiveRecordRelations < Compiler
152
153
  extend T::Sig
153
154
  include Helpers::ActiveRecordConstantsHelper
154
155
  include SorbetHelper
155
156
 
156
- ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
157
-
158
157
  # From ActiveRecord::ConnectionAdapter::Quoting#quote, minus nil
159
158
  ID_TYPES = [
160
159
  "String",
@@ -217,6 +216,17 @@ module Tapioca
217
216
  []
218
217
  end #: Array[Symbol]
219
218
  BATCHES_METHODS = ActiveRecord::Batches.instance_methods(false) #: Array[Symbol]
219
+ BATCHES_METHODS_PARAMETERS = {
220
+ start: ["T.untyped", "nil"],
221
+ finish: ["T.untyped", "nil"],
222
+ load: ["T.untyped", "false"],
223
+ batch_size: ["Integer", "1000"],
224
+ of: ["Integer", "1000"],
225
+ error_on_ignore: ["T.untyped", "nil"],
226
+ order: ["Symbol", ":asc"],
227
+ cursor: ["T.untyped", "primary_key"],
228
+ use_ranges: ["T.untyped", "nil"],
229
+ } #: Hash[Symbol, [String, String]]
220
230
  CALCULATION_METHODS = ActiveRecord::Calculations.instance_methods(false) #: Array[Symbol]
221
231
  ENUMERABLE_QUERY_METHODS = [:any?, :many?, :none?, :one?] #: Array[Symbol]
222
232
  FIND_OR_CREATE_METHODS = [
@@ -826,7 +836,15 @@ module Tapioca
826
836
  end
827
837
  end
828
838
  when :ids
829
- create_common_method("ids", return_type: "Array")
839
+ if constant.table_exists?
840
+ primary_key_type = constant.type_for_attribute(constant.primary_key)
841
+ type = Tapioca::Dsl::Helpers::ActiveModelTypeHelper.type_for(primary_key_type)
842
+ type = RBIHelper.as_non_nilable_type(type)
843
+ create_common_method("ids", return_type: "T::Array[#{type}]")
844
+ else
845
+ create_common_method("ids", return_type: "Array")
846
+ end
847
+
830
848
  when :pick, :pluck
831
849
  create_common_method(
832
850
  method_name,
@@ -855,102 +873,31 @@ module Tapioca
855
873
  end
856
874
 
857
875
  BATCHES_METHODS.each do |method_name|
858
- case method_name
859
- when :find_each
860
- order = ActiveRecord::Batches.instance_method(:find_each).parameters.include?([:key, :order])
861
-
862
- common_relation_methods_module.create_method("find_each") do |method|
863
- method.add_kw_opt_param("start", "nil")
864
- method.add_kw_opt_param("finish", "nil")
865
- method.add_kw_opt_param("batch_size", "1000")
866
- method.add_kw_opt_param("error_on_ignore", "nil")
867
- method.add_kw_opt_param("order", ":asc") if order
868
- method.add_block_param("block")
876
+ block_param, return_type, parameters = batch_method_configs(method_name)
877
+ next if block_param.nil? || return_type.nil? || parameters.nil?
869
878
 
870
- method.add_sig do |sig|
871
- sig.add_param("start", "T.untyped")
872
- sig.add_param("finish", "T.untyped")
873
- sig.add_param("batch_size", "Integer")
874
- sig.add_param("error_on_ignore", "T.untyped")
875
- sig.add_param("order", "Symbol") if order
876
- sig.add_param("block", "T.proc.params(object: #{constant_name}).void")
877
- sig.return_type = "void"
878
- end
879
+ common_relation_methods_module.create_method(method_name.to_s) do |method|
880
+ parameters.each do |name, (style, _type, default)|
881
+ # The style is always "key", but this is a safeguard to prevent confusing errors in the future.
882
+ raise "Unexpected style #{style} for #{name}" unless style == :key
879
883
 
880
- method.add_sig do |sig|
881
- sig.add_param("start", "T.untyped")
882
- sig.add_param("finish", "T.untyped")
883
- sig.add_param("batch_size", "Integer")
884
- sig.add_param("error_on_ignore", "T.untyped")
885
- sig.add_param("order", "Symbol") if order
886
- sig.return_type = "T::Enumerator[#{constant_name}]"
887
- end
884
+ method.add_kw_opt_param(name, T.must(default))
888
885
  end
889
- when :find_in_batches
890
- order = ActiveRecord::Batches.instance_method(:find_in_batches).parameters.include?([:key, :order])
891
- common_relation_methods_module.create_method("find_in_batches") do |method|
892
- method.add_kw_opt_param("start", "nil")
893
- method.add_kw_opt_param("finish", "nil")
894
- method.add_kw_opt_param("batch_size", "1000")
895
- method.add_kw_opt_param("error_on_ignore", "nil")
896
- method.add_kw_opt_param("order", ":asc") if order
897
- method.add_block_param("block")
898
-
899
- method.add_sig do |sig|
900
- sig.add_param("start", "T.untyped")
901
- sig.add_param("finish", "T.untyped")
902
- sig.add_param("batch_size", "Integer")
903
- sig.add_param("error_on_ignore", "T.untyped")
904
- sig.add_param("order", "Symbol") if order
905
- sig.add_param("block", "T.proc.params(object: T::Array[#{constant_name}]).void")
906
- sig.return_type = "void"
907
- end
886
+ method.add_block_param("block")
908
887
 
909
- method.add_sig do |sig|
910
- sig.add_param("start", "T.untyped")
911
- sig.add_param("finish", "T.untyped")
912
- sig.add_param("batch_size", "Integer")
913
- sig.add_param("error_on_ignore", "T.untyped")
914
- sig.add_param("order", "Symbol") if order
915
- sig.return_type = "T::Enumerator[T::Enumerator[#{constant_name}]]"
888
+ method.add_sig do |sig|
889
+ parameters.each do |name, (_style, type, _default)|
890
+ sig.add_param(name, type)
916
891
  end
892
+ sig.add_param("block", "T.proc.params(object: #{block_param}).void")
893
+ sig.return_type = "void"
917
894
  end
918
- when :in_batches
919
- order = ActiveRecord::Batches.instance_method(:in_batches).parameters.include?([:key, :order])
920
- use_ranges = ActiveRecord::Batches.instance_method(:in_batches).parameters.include?([:key, :use_ranges])
921
-
922
- common_relation_methods_module.create_method("in_batches") do |method|
923
- method.add_kw_opt_param("of", "1000")
924
- method.add_kw_opt_param("start", "nil")
925
- method.add_kw_opt_param("finish", "nil")
926
- method.add_kw_opt_param("load", "false")
927
- method.add_kw_opt_param("error_on_ignore", "nil")
928
- method.add_kw_opt_param("order", ":asc") if order
929
- method.add_kw_opt_param("use_ranges", "nil") if use_ranges
930
- method.add_block_param("block")
931
895
 
932
- method.add_sig do |sig|
933
- sig.add_param("of", "Integer")
934
- sig.add_param("start", "T.untyped")
935
- sig.add_param("finish", "T.untyped")
936
- sig.add_param("load", "T.untyped")
937
- sig.add_param("error_on_ignore", "T.untyped")
938
- sig.add_param("order", "Symbol") if order
939
- sig.add_param("use_ranges", "T.untyped") if use_ranges
940
- sig.add_param("block", "T.proc.params(object: #{RelationClassName}).void")
941
- sig.return_type = "void"
942
- end
943
-
944
- method.add_sig do |sig|
945
- sig.add_param("of", "Integer")
946
- sig.add_param("start", "T.untyped")
947
- sig.add_param("finish", "T.untyped")
948
- sig.add_param("load", "T.untyped")
949
- sig.add_param("error_on_ignore", "T.untyped")
950
- sig.add_param("order", "Symbol") if order
951
- sig.add_param("use_ranges", "T.untyped") if use_ranges
952
- sig.return_type = "::ActiveRecord::Batches::BatchEnumerator"
896
+ method.add_sig do |sig|
897
+ parameters.each do |name, (_style, type, _default)|
898
+ sig.add_param(name, type)
953
899
  end
900
+ sig.return_type = return_type
954
901
  end
955
902
  end
956
903
  end
@@ -1029,6 +976,31 @@ module Tapioca
1029
976
  end
1030
977
  end
1031
978
 
979
+ #: (Symbol) -> [String, String, Hash[String, [Symbol, String, String?]]]?
980
+ def batch_method_configs(method_name)
981
+ block_param, return_type = case method_name
982
+ when :find_each
983
+ [constant_name, "T::Enumerator[#{constant_name}]"]
984
+ when :find_in_batches
985
+ ["T::Array[#{constant_name}]", "T::Enumerator[T::Enumerator[#{constant_name}]]"]
986
+ when :in_batches
987
+ [RelationClassName, "::ActiveRecord::Batches::BatchEnumerator"]
988
+ else
989
+ return
990
+ end
991
+
992
+ parameters = {}
993
+
994
+ ActiveRecord::Batches.instance_method(method_name).parameters.each do |style, name|
995
+ type, default = BATCHES_METHODS_PARAMETERS[name]
996
+ next if type.nil?
997
+
998
+ parameters[name.to_s] = [style, type, default]
999
+ end
1000
+
1001
+ [block_param, return_type, parameters]
1002
+ end
1003
+
1032
1004
  #: ((Symbol | String) name, ?parameters: Array[RBI::TypedParam], ?return_type: String?) -> void
1033
1005
  def create_common_method(name, parameters: [], return_type: nil)
1034
1006
  common_relation_methods_module.create_method(
@@ -38,12 +38,11 @@ module Tapioca
38
38
  # end
39
39
  # end
40
40
  # ~~~
41
+ #: [ConstantType = singleton(::ActiveRecord::Base)]
41
42
  class ActiveRecordScope < Compiler
42
43
  extend T::Sig
43
44
  include Helpers::ActiveRecordConstantsHelper
44
45
 
45
- ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
46
-
47
46
  # @override
48
47
  #: -> void
49
48
  def decorate
@@ -32,12 +32,11 @@ module Tapioca
32
32
  # def regenerate_auth_token; end
33
33
  # end
34
34
  # ~~~
35
+ #: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
35
36
  class ActiveRecordSecureToken < Compiler
36
37
  extend T::Sig
37
38
  include Helpers::ActiveRecordConstantsHelper
38
39
 
39
- ConstantType = type_member { { fixed: T.all(T.class_of(ActiveRecord::Base), Extensions::ActiveRecord) } }
40
-
41
40
  # @override
42
41
  #: -> void
43
42
  def decorate
@@ -78,12 +78,11 @@ module Tapioca
78
78
  # end
79
79
  # end
80
80
  # ~~~
81
+ #: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
81
82
  class ActiveRecordStore < Compiler
82
83
  extend T::Sig
83
84
  include Helpers::ActiveRecordConstantsHelper
84
85
 
85
- ConstantType = type_member { { fixed: T.all(T.class_of(ActiveRecord::Base), Extensions::ActiveRecord) } }
86
-
87
86
  # @override
88
87
  #: -> void
89
88
  def decorate
@@ -81,11 +81,10 @@ module Tapioca
81
81
  # end
82
82
  # end
83
83
  # ~~~
84
+ #: [ConstantType = singleton(::ActiveRecord::Base)]
84
85
  class ActiveRecordTypedStore < Compiler
85
86
  extend T::Sig
86
87
 
87
- ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
88
-
89
88
  # @override
90
89
  #: -> void
91
90
  def decorate
@@ -54,11 +54,10 @@ module Tapioca
54
54
  # def year?; end
55
55
  # end
56
56
  # ~~~
57
+ #: [ConstantType = singleton(::ActiveResource::Base)]
57
58
  class ActiveResource < Compiler
58
59
  extend T::Sig
59
60
 
60
- ConstantType = type_member { { fixed: T.class_of(::ActiveResource::Base) } }
61
-
62
61
  # @override
63
62
  #: -> void
64
63
  def decorate
@@ -38,18 +38,10 @@ module Tapioca
38
38
  # def photo=(attachable); end
39
39
  # end
40
40
  # ~~~
41
+ #: [ConstantType = (Module & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
41
42
  class ActiveStorage < Compiler
42
43
  extend T::Sig
43
44
 
44
- ConstantType = type_member do
45
- {
46
- fixed: T.all(
47
- Module,
48
- ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods,
49
- ),
50
- }
51
- end
52
-
53
45
  # @override
54
46
  #: -> void
55
47
  def decorate
@@ -37,11 +37,10 @@ module Tapioca
37
37
  # mixes_in_class_methods(::Foo::ClassMethods)
38
38
  # end
39
39
  # ~~~
40
+ #: [ConstantType = Module]
40
41
  class ActiveSupportConcern < Compiler
41
42
  extend T::Sig
42
43
 
43
- ConstantType = type_member { { fixed: Module } }
44
-
45
44
  # @override
46
45
  #: -> void
47
46
  def decorate
@@ -59,11 +59,10 @@ module Tapioca
59
59
  # end
60
60
  # end
61
61
  # ~~~
62
+ #: [ConstantType = singleton(::ActiveSupport::CurrentAttributes)]
62
63
  class ActiveSupportCurrentAttributes < Compiler
63
64
  extend T::Sig
64
65
 
65
- ConstantType = type_member { { fixed: T.class_of(::ActiveSupport::CurrentAttributes) } }
66
-
67
66
  # @override
68
67
  #: -> void
69
68
  def decorate
@@ -34,11 +34,10 @@ module Tapioca
34
34
  # end
35
35
  # end
36
36
  # ```
37
+ #: [ConstantType = singleton(::Time)]
37
38
  class ActiveSupportTimeExt < Compiler
38
39
  extend T::Sig
39
40
 
40
- ConstantType = type_member { { fixed: T.class_of(::Time) } }
41
-
42
41
  # @override
43
42
  #: -> void
44
43
  def decorate
@@ -40,13 +40,12 @@ module Tapioca
40
40
  # def github=(value); end
41
41
  # end
42
42
  # ```
43
+ #: [ConstantType = Module]
43
44
  class Config < Compiler
44
45
  extend T::Sig
45
46
 
46
47
  CONFIG_OPTIONS_SUFFIX = "ConfigOptions"
47
48
 
48
- ConstantType = type_member { { fixed: Module } }
49
-
50
49
  # @override
51
50
  #: -> void
52
51
  def decorate
@@ -58,11 +58,10 @@ module Tapioca
58
58
  # end
59
59
  # end
60
60
  # ~~~
61
+ #: [ConstantType = (singleton(::FrozenRecord::Base) & Extensions::FrozenRecord)]
61
62
  class FrozenRecord < Compiler
62
63
  extend T::Sig
63
64
 
64
- ConstantType = type_member { { fixed: T.all(T.class_of(::FrozenRecord::Base), Extensions::FrozenRecord) } }
65
-
66
65
  # @override
67
66
  #: -> void
68
67
  def decorate
@@ -34,11 +34,10 @@ module Tapioca
34
34
  # def post_id; end
35
35
  # end
36
36
  # ~~~
37
+ #: [ConstantType = singleton(GraphQL::Schema::InputObject)]
37
38
  class GraphqlInputObject < Compiler
38
39
  extend T::Sig
39
40
 
40
- ConstantType = type_member { { fixed: T.class_of(GraphQL::Schema::InputObject) } }
41
-
42
41
  # @override
43
42
  #: -> void
44
43
  def decorate
@@ -35,11 +35,10 @@ module Tapioca
35
35
  # def resolve(body:, post_id:); end
36
36
  # end
37
37
  # ~~~
38
+ #: [ConstantType = singleton(GraphQL::Schema::Mutation)]
38
39
  class GraphqlMutation < Compiler
39
40
  extend T::Sig
40
41
 
41
- ConstantType = type_member { { fixed: T.class_of(GraphQL::Schema::Mutation) } }
42
-
43
42
  # @override
44
43
  #: -> void
45
44
  def decorate
@@ -55,13 +55,12 @@ module Tapioca
55
55
  # def fetch_by_title_and_review_date(title, review_date, includes: nil); end
56
56
  # end
57
57
  # ~~~
58
+ #: [ConstantType = singleton(::ActiveRecord::Base)]
58
59
  class IdentityCache < Compiler
59
60
  extend T::Sig
60
61
 
61
62
  COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((Module | String) type) -> String
62
63
 
63
- ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
64
-
65
64
  # @override
66
65
  #: -> void
67
66
  def decorate
@@ -79,11 +79,10 @@ module Tapioca
79
79
  # end
80
80
  # end
81
81
  # ~~~
82
+ #: [ConstantType = singleton(::JsonApiClient::Resource)]
82
83
  class JsonApiClientResource < Compiler
83
84
  extend T::Sig
84
85
 
85
- ConstantType = type_member { { fixed: T.class_of(::JsonApiClient::Resource) } }
86
-
87
86
  # @override
88
87
  #: -> void
89
88
  def decorate
@@ -63,13 +63,10 @@ module Tapioca
63
63
  # end
64
64
  # end
65
65
  # ~~~
66
+ #: [ConstantType = (Class[::Kredis::Attributes] & ::Kredis::Attributes::ClassMethods & Extensions::Kredis)]
66
67
  class Kredis < Compiler
67
68
  extend T::Sig
68
69
 
69
- ConstantType = type_member do
70
- { fixed: T.all(T::Class[::Kredis::Attributes], ::Kredis::Attributes::ClassMethods, Extensions::Kredis) }
71
- end
72
-
73
70
  # @override
74
71
  #: -> void
75
72
  def decorate
@@ -44,11 +44,10 @@ module Tapioca
44
44
  # end
45
45
  # end
46
46
  # ~~~
47
+ #: [ConstantType = Module]
47
48
  class MixedInClassAttributes < Compiler
48
49
  extend T::Sig
49
50
 
50
- ConstantType = type_member { { fixed: Module } }
51
-
52
51
  # @override
53
52
  #: -> void
54
53
  def decorate
@@ -64,6 +64,7 @@ module Tapioca
64
64
  # ~~~
65
65
  # --ignore=/path/to/proto/cart_pb.rb
66
66
  # ~~~
67
+ #: [ConstantType = Class[top]]
67
68
  class Protobuf < Compiler
68
69
  class Field < T::Struct
69
70
  prop :name, String
@@ -74,8 +75,6 @@ module Tapioca
74
75
 
75
76
  extend T::Sig
76
77
 
77
- ConstantType = type_member { { fixed: T::Class[T.anything] } }
78
-
79
78
  FIELD_RE = /^[a-z_][a-zA-Z0-9_]*$/
80
79
 
81
80
  # @override
@@ -33,13 +33,12 @@ module Tapioca
33
33
  # def skip_comments; end
34
34
  # end
35
35
  # ~~~
36
+ #: [ConstantType = singleton(::Rails::Generators::Base)]
36
37
  class RailsGenerators < Compiler
37
38
  extend T::Sig
38
39
 
39
40
  BUILT_IN_MATCHER = /::(ActionMailbox|ActionText|ActiveRecord|Rails)::Generators/
40
41
 
41
- ConstantType = type_member { { fixed: T.class_of(::Rails::Generators::Base) } }
42
-
43
42
  # @override
44
43
  #: -> void
45
44
  def decorate
@@ -41,11 +41,10 @@ module Tapioca
41
41
  # as accepted values for the `interval` parameter:
42
42
  # * `self.perform_at` will also accept a `ActiveSupport::TimeWithZone` value
43
43
  # * `self.perform_in` will also accept a `ActiveSupport::Duration` value
44
+ #: [ConstantType = singleton(::Sidekiq::Worker)]
44
45
  class SidekiqWorker < Compiler
45
46
  extend T::Sig
46
47
 
47
- ConstantType = type_member { { fixed: T.class_of(::Sidekiq::Worker) } }
48
-
49
48
  # @override
50
49
  #: -> void
51
50
  def decorate
@@ -29,36 +29,39 @@ module Tapioca
29
29
  # # post.rbi
30
30
  # # typed: true
31
31
  # class Post
32
- # sig { returns(T.nilable(::String)) }
33
- # def title; end
32
+ # include SmartPropertiesGeneratedMethods
34
33
  #
35
- # sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
36
- # def title=(title); end
34
+ # module SmartPropertiesGeneratedMethods
35
+ # sig { returns(T.nilable(::String)) }
36
+ # def title; end
37
37
  #
38
- # sig { returns(::String) }
39
- # def description; end
38
+ # sig { params(title: T.nilable(::String)).returns(T.nilable(::String)) }
39
+ # def title=(title); end
40
40
  #
41
- # sig { params(description: ::String).returns(::String) }
42
- # def description=(description); end
41
+ # sig { returns(::String) }
42
+ # def description; end
43
43
  #
44
- # sig { returns(T.nilable(T::Boolean)) }
45
- # def published?; end
44
+ # sig { params(description: ::String).returns(::String) }
45
+ # def description=(description); end
46
46
  #
47
- # sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
48
- # def published=(published); end
47
+ # sig { returns(T.nilable(T::Boolean)) }
48
+ # def published?; end
49
49
  #
50
- # sig { returns(T.nilable(T::Boolean)) }
51
- # def enabled; end
50
+ # sig { params(published: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
51
+ # def published=(published); end
52
52
  #
53
- # sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
54
- # def enabled=(enabled); end
53
+ # sig { returns(T.nilable(T::Boolean)) }
54
+ # def enabled; end
55
+ #
56
+ # sig { params(enabled: T.nilable(T::Boolean)).returns(T.nilable(T::Boolean)) }
57
+ # def enabled=(enabled); end
58
+ # end
55
59
  # end
56
60
  # ~~~
61
+ #: [ConstantType = singleton(::SmartProperties)]
57
62
  class SmartProperties < Compiler
58
63
  extend T::Sig
59
64
 
60
- ConstantType = type_member { { fixed: T.class_of(::SmartProperties) } }
61
-
62
65
  # @override
63
66
  #: -> void
64
67
  def decorate
@@ -109,11 +109,10 @@ module Tapioca
109
109
  # end
110
110
  # end
111
111
  # ~~~
112
+ #: [ConstantType = (Module & ::StateMachines::ClassMethods)]
112
113
  class StateMachines < Compiler
113
114
  extend T::Sig
114
115
 
115
- ConstantType = type_member { { fixed: T.all(Module, ::StateMachines::ClassMethods) } }
116
-
117
116
  # @override
118
117
  #: -> void
119
118
  def decorate
@@ -78,11 +78,10 @@ module Tapioca
78
78
  # include GeneratedUrlHelpersModule
79
79
  # end
80
80
  # ~~~
81
+ #: [ConstantType = Module]
81
82
  class UrlHelpers < Compiler
82
83
  extend T::Sig
83
84
 
84
- ConstantType = type_member { { fixed: Module } }
85
-
86
85
  # @override
87
86
  #: -> void
88
87
  def decorate
@@ -60,7 +60,7 @@ module Tapioca
60
60
  No classes/modules can be matched for RBI generation.
61
61
  Please check that the requested classes/modules include processable DSL methods.
62
62
  ERROR
63
- raise Thor::Error, ""
63
+ raise Tapioca::Error, ""
64
64
  end
65
65
 
66
66
  if defined?(::ActiveRecord::Base) && constants_to_process.any? { |c| ::ActiveRecord::Base > c }
@@ -82,7 +82,7 @@ module Tapioca
82
82
  report_error(msg)
83
83
  end
84
84
 
85
- raise Thor::Error, ""
85
+ raise Tapioca::Error, ""
86
86
  end
87
87
 
88
88
  result.compact
@@ -3,11 +3,9 @@
3
3
 
4
4
  module Tapioca
5
5
  module Gem
6
+ # @abstract
6
7
  class Event
7
8
  extend T::Sig
8
- extend T::Helpers
9
-
10
- abstract!
11
9
  end
12
10
 
13
11
  class SymbolFound < Event
@@ -57,12 +55,10 @@ module Tapioca
57
55
  end
58
56
  end
59
57
 
58
+ # @abstract
60
59
  class NodeAdded < Event
61
- extend T::Helpers
62
60
  extend T::Sig
63
61
 
64
- abstract!
65
-
66
62
  #: String
67
63
  attr_reader :symbol
68
64
 
@@ -4,12 +4,9 @@
4
4
  module Tapioca
5
5
  module Gem
6
6
  module Listeners
7
+ # @abstract
7
8
  class Base
8
9
  extend T::Sig
9
- extend T::Helpers
10
-
11
- abstract!
12
-
13
10
  #: (Pipeline pipeline) -> void
14
11
  def initialize(pipeline)
15
12
  @pipeline = pipeline
@@ -2,12 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
+ # @requires_ancestor: Thor::Shell
5
6
  module CliHelper
6
7
  extend T::Sig
7
- extend T::Helpers
8
-
9
- requires_ancestor { Thor::Shell }
10
-
11
8
  #: (?String message, *(Symbol | Array[Symbol]) color) -> void
12
9
  def say_error(message = "", *color)
13
10
  # Thor has its own `say_error` now, but it has two problems: