tapioca 0.6.4 → 0.7.2
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.
- checksums.yaml +4 -4
- data/Gemfile +8 -2
- data/README.md +27 -15
- data/Rakefile +10 -14
- data/lib/tapioca/cli.rb +65 -80
- data/lib/tapioca/{generators/base.rb → commands/command.rb} +16 -9
- data/lib/tapioca/{generators → commands}/dsl.rb +59 -45
- data/lib/tapioca/{generators → commands}/gem.rb +93 -30
- data/lib/tapioca/{generators → commands}/init.rb +9 -13
- data/lib/tapioca/{generators → commands}/require.rb +8 -10
- data/lib/tapioca/commands/todo.rb +86 -0
- data/lib/tapioca/commands.rb +13 -0
- data/lib/tapioca/dsl/compiler.rb +185 -0
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/aasm.rb +12 -9
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/action_controller_helpers.rb +13 -20
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/action_mailer.rb +10 -8
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_job.rb +11 -9
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_model_attributes.rb +13 -11
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_model_secure_password.rb +10 -12
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_associations.rb +28 -34
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_columns.rb +18 -16
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_enum.rb +14 -12
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_fixtures.rb +12 -8
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +712 -0
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_scope.rb +21 -20
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_record_typed_store.rb +11 -16
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_resource.rb +10 -8
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_storage.rb +14 -10
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_support_concern.rb +19 -14
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/active_support_current_attributes.rb +16 -21
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/config.rb +11 -9
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/frozen_record.rb +13 -11
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/identity_cache.rb +23 -22
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/mixed_in_class_attributes.rb +12 -10
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/protobuf.rb +22 -10
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/rails_generators.rb +12 -13
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/sidekiq_worker.rb +14 -13
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/smart_properties.rb +11 -9
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/state_machines.rb +12 -10
- data/lib/tapioca/{compilers/dsl → dsl/compilers}/url_helpers.rb +20 -15
- data/lib/tapioca/dsl/compilers.rb +31 -0
- data/lib/tapioca/{compilers/dsl → dsl}/extensions/frozen_record.rb +2 -2
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +114 -0
- data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +29 -0
- data/lib/tapioca/{compilers/dsl → dsl/helpers}/param_helper.rb +6 -3
- data/lib/tapioca/dsl/pipeline.rb +169 -0
- data/lib/tapioca/gem/events.rb +120 -0
- data/lib/tapioca/gem/listeners/base.rb +48 -0
- data/lib/tapioca/gem/listeners/dynamic_mixins.rb +32 -0
- data/lib/tapioca/gem/listeners/methods.rb +183 -0
- data/lib/tapioca/gem/listeners/mixins.rb +101 -0
- data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +21 -0
- data/lib/tapioca/gem/listeners/sorbet_enums.rb +26 -0
- data/lib/tapioca/gem/listeners/sorbet_helpers.rb +29 -0
- data/lib/tapioca/gem/listeners/sorbet_props.rb +33 -0
- data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +23 -0
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +79 -0
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +51 -0
- data/lib/tapioca/gem/listeners/subconstants.rb +37 -0
- data/lib/tapioca/gem/listeners/yard_doc.rb +96 -0
- data/lib/tapioca/gem/listeners.rb +16 -0
- data/lib/tapioca/gem/pipeline.rb +365 -0
- data/lib/tapioca/helpers/cli_helper.rb +7 -0
- data/lib/tapioca/helpers/config_helper.rb +5 -8
- data/lib/tapioca/helpers/shims_helper.rb +87 -0
- data/lib/tapioca/helpers/signatures_helper.rb +17 -0
- data/lib/tapioca/helpers/sorbet_helper.rb +57 -0
- data/lib/tapioca/helpers/test/dsl_compiler.rb +118 -0
- data/lib/tapioca/helpers/test/isolation.rb +1 -1
- data/lib/tapioca/helpers/test/template.rb +13 -2
- data/lib/tapioca/helpers/type_variable_helper.rb +43 -0
- data/lib/tapioca/internal.rb +18 -10
- data/lib/tapioca/rbi_ext/model.rb +14 -50
- data/lib/tapioca/rbi_formatter.rb +37 -0
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +227 -0
- data/lib/tapioca/runtime/generic_type_registry.rb +168 -0
- data/lib/tapioca/runtime/loader.rb +123 -0
- data/lib/tapioca/runtime/reflection.rb +157 -0
- data/lib/tapioca/runtime/trackers/autoload.rb +72 -0
- data/lib/tapioca/runtime/trackers/constant_definition.rb +44 -0
- data/lib/tapioca/runtime/trackers/mixin.rb +80 -0
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +50 -0
- data/lib/tapioca/{trackers.rb → runtime/trackers.rb} +4 -3
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +69 -34
- data/lib/tapioca/sorbet_ext/name_patch.rb +7 -1
- data/lib/tapioca/{compilers → static}/requires_compiler.rb +2 -2
- data/lib/tapioca/static/symbol_loader.rb +83 -0
- data/lib/tapioca/static/symbol_table_parser.rb +63 -0
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +2 -7
- metadata +83 -62
- data/lib/tapioca/compilers/dsl/active_record_relations.rb +0 -720
- data/lib/tapioca/compilers/dsl/base.rb +0 -195
- data/lib/tapioca/compilers/dsl/helper/active_record_constants.rb +0 -27
- data/lib/tapioca/compilers/dsl_compiler.rb +0 -134
- data/lib/tapioca/compilers/dynamic_mixin_compiler.rb +0 -223
- data/lib/tapioca/compilers/sorbet.rb +0 -59
- data/lib/tapioca/compilers/symbol_table/symbol_generator.rb +0 -780
- data/lib/tapioca/compilers/symbol_table/symbol_loader.rb +0 -90
- data/lib/tapioca/compilers/symbol_table_compiler.rb +0 -17
- data/lib/tapioca/compilers/todos_compiler.rb +0 -32
- data/lib/tapioca/generators/todo.rb +0 -76
- data/lib/tapioca/generators.rb +0 -9
- data/lib/tapioca/generic_type_registry.rb +0 -164
- data/lib/tapioca/helpers/active_record_column_type_helper.rb +0 -108
- data/lib/tapioca/loader.rb +0 -119
- data/lib/tapioca/reflection.rb +0 -151
- data/lib/tapioca/trackers/autoload.rb +0 -70
- data/lib/tapioca/trackers/constant_definition.rb +0 -42
- data/lib/tapioca/trackers/mixin.rb +0 -78
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "tapioca/sorbet_ext/name_patch"
|
|
5
|
+
require "tapioca/helpers/sorbet_helper"
|
|
5
6
|
|
|
6
7
|
module T
|
|
7
8
|
module Generic
|
|
@@ -17,36 +18,52 @@ module T
|
|
|
17
18
|
constant = super
|
|
18
19
|
# `register_type` method builds and returns an instantiated clone of the generic type
|
|
19
20
|
# so, we just return that from this method as well.
|
|
20
|
-
Tapioca::GenericTypeRegistry.register_type(constant, types)
|
|
21
|
+
Tapioca::Runtime::GenericTypeRegistry.register_type(constant, types)
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
def type_member(variance = :invariant, fixed: nil, lower:
|
|
24
|
+
def type_member(variance = :invariant, fixed: nil, lower: nil, upper: nil, &blk)
|
|
24
25
|
# `T::Generic#type_member` just instantiates a `T::Type::TypeMember` instance and returns it.
|
|
25
26
|
# We use that when registering the type member and then later return it from this method.
|
|
27
|
+
hash = if blk
|
|
28
|
+
blk.call
|
|
29
|
+
else
|
|
30
|
+
{
|
|
31
|
+
fixed: fixed,
|
|
32
|
+
lower: lower,
|
|
33
|
+
upper: upper,
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
26
37
|
Tapioca::TypeVariableModule.new(
|
|
27
38
|
T.cast(self, Module),
|
|
28
39
|
Tapioca::TypeVariableModule::Type::Member,
|
|
29
40
|
variance,
|
|
30
|
-
|
|
31
|
-
lower,
|
|
32
|
-
upper
|
|
41
|
+
**hash,
|
|
33
42
|
).tap do |type_variable|
|
|
34
|
-
Tapioca::GenericTypeRegistry.register_type_variable(self, type_variable)
|
|
43
|
+
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
|
35
44
|
end
|
|
36
45
|
end
|
|
37
46
|
|
|
38
|
-
def type_template(variance = :invariant, fixed: nil, lower:
|
|
47
|
+
def type_template(variance = :invariant, fixed: nil, lower: nil, upper: nil, &blk)
|
|
39
48
|
# `T::Generic#type_template` just instantiates a `T::Type::TypeTemplate` instance and returns it.
|
|
40
49
|
# We use that when registering the type template and then later return it from this method.
|
|
50
|
+
hash = if blk
|
|
51
|
+
blk.call
|
|
52
|
+
else
|
|
53
|
+
{
|
|
54
|
+
fixed: fixed,
|
|
55
|
+
lower: lower,
|
|
56
|
+
upper: upper,
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
|
|
41
60
|
Tapioca::TypeVariableModule.new(
|
|
42
61
|
T.cast(self, Module),
|
|
43
62
|
Tapioca::TypeVariableModule::Type::Template,
|
|
44
63
|
variance,
|
|
45
|
-
|
|
46
|
-
lower,
|
|
47
|
-
upper
|
|
64
|
+
**hash,
|
|
48
65
|
).tap do |type_variable|
|
|
49
|
-
Tapioca::GenericTypeRegistry.register_type_variable(self, type_variable)
|
|
66
|
+
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
|
50
67
|
end
|
|
51
68
|
end
|
|
52
69
|
end
|
|
@@ -57,18 +74,6 @@ module T
|
|
|
57
74
|
module Types
|
|
58
75
|
class Simple
|
|
59
76
|
module GenericPatch
|
|
60
|
-
def valid?(obj)
|
|
61
|
-
# Since `Tapioca::TypeVariable` is a `Module`, it will be wrapped by a
|
|
62
|
-
# `Simple` type. We want to always make type variable types valid, so we
|
|
63
|
-
# need to explicitly check that `raw_type` is a `Tapioca::TypeVariable`
|
|
64
|
-
# and return `true`
|
|
65
|
-
if defined?(Tapioca::TypeVariableModule) && Tapioca::TypeVariableModule === @raw_type
|
|
66
|
-
return true
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
obj.is_a?(@raw_type)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
77
|
# This method intercepts calls to the `name` method for simple types, so that
|
|
73
78
|
# it can ask the name to the type if the type is generic, since, by this point,
|
|
74
79
|
# we've created a clone of that type with the `name` method returning the
|
|
@@ -88,9 +93,34 @@ module T
|
|
|
88
93
|
prepend GenericPatch
|
|
89
94
|
end
|
|
90
95
|
end
|
|
96
|
+
|
|
97
|
+
module Utils
|
|
98
|
+
module CoercePatch
|
|
99
|
+
def coerce(val)
|
|
100
|
+
if val.is_a?(Tapioca::TypeVariableModule)
|
|
101
|
+
val.coerce_to_type_variable
|
|
102
|
+
else
|
|
103
|
+
super
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class << self
|
|
109
|
+
prepend(CoercePatch)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
91
112
|
end
|
|
92
113
|
|
|
93
114
|
module Tapioca
|
|
115
|
+
class TypeVariable < ::T::Types::TypeVariable
|
|
116
|
+
def initialize(name, variance)
|
|
117
|
+
@name = name
|
|
118
|
+
super(variance)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
attr_reader :name
|
|
122
|
+
end
|
|
123
|
+
|
|
94
124
|
# This is subclassing from `Module` so that instances of this type will be modules.
|
|
95
125
|
# The reason why we want that is because that means those instances will automatically
|
|
96
126
|
# get bound to the constant names they are assigned to by Ruby. As a result, we don't
|
|
@@ -109,7 +139,7 @@ module Tapioca
|
|
|
109
139
|
sig do
|
|
110
140
|
params(context: Module, type: Type, variance: Symbol, fixed: T.untyped, lower: T.untyped, upper: T.untyped).void
|
|
111
141
|
end
|
|
112
|
-
def initialize(context, type, variance, fixed, lower, upper
|
|
142
|
+
def initialize(context, type, variance, fixed: nil, lower: nil, upper: nil)
|
|
113
143
|
@context = context
|
|
114
144
|
@type = type
|
|
115
145
|
@variance = variance
|
|
@@ -140,17 +170,22 @@ module Tapioca
|
|
|
140
170
|
|
|
141
171
|
sig { returns(String) }
|
|
142
172
|
def serialize
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
173
|
+
fixed = @fixed.to_s if @fixed
|
|
174
|
+
upper = @upper.to_s if @upper
|
|
175
|
+
lower = @lower.to_s if @lower
|
|
176
|
+
|
|
177
|
+
TypeVariableHelper.serialize_type_variable(
|
|
178
|
+
@type.serialize,
|
|
179
|
+
@variance,
|
|
180
|
+
fixed,
|
|
181
|
+
upper,
|
|
182
|
+
lower
|
|
183
|
+
)
|
|
184
|
+
end
|
|
150
185
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
186
|
+
sig { returns(Tapioca::TypeVariable) }
|
|
187
|
+
def coerce_to_type_variable
|
|
188
|
+
TypeVariable.new(name, @variance)
|
|
154
189
|
end
|
|
155
190
|
|
|
156
191
|
private
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# typed: true
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
# We need sorbet to compile the signature for `qualified_name_of` before applying
|
|
5
|
+
# the patch to avoid an infinite loop.
|
|
6
|
+
T::Utils.signature_for_method(::Tapioca::Runtime::Reflection.method(:qualified_name_of))
|
|
7
|
+
|
|
4
8
|
module T
|
|
5
9
|
module Types
|
|
6
10
|
class Simple
|
|
7
11
|
module NamePatch
|
|
8
12
|
def name
|
|
9
|
-
|
|
13
|
+
# Sorbet memoizes this method into the `@name` instance variable but
|
|
14
|
+
# doing so means that types get memoized before this patch is applied
|
|
15
|
+
::Tapioca::Runtime::Reflection.qualified_name_of(@raw_type)
|
|
10
16
|
end
|
|
11
17
|
end
|
|
12
18
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require "spoom"
|
|
5
5
|
|
|
6
6
|
module Tapioca
|
|
7
|
-
module
|
|
7
|
+
module Static
|
|
8
8
|
class RequiresCompiler
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ module Tapioca
|
|
|
17
17
|
def compile
|
|
18
18
|
config = Spoom::Sorbet::Config.parse_file(@sorbet_path)
|
|
19
19
|
files = collect_files(config)
|
|
20
|
-
names_in_project = files.
|
|
20
|
+
names_in_project = files.to_h { |file| [File.basename(file, ".rb"), true] }
|
|
21
21
|
files.flat_map do |file|
|
|
22
22
|
collect_requires(file).reject { |req| names_in_project[req] }
|
|
23
23
|
end.sort.uniq.map do |name|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
require "tempfile"
|
|
6
|
+
|
|
7
|
+
module Tapioca
|
|
8
|
+
module Static
|
|
9
|
+
module SymbolLoader
|
|
10
|
+
class << self
|
|
11
|
+
extend T::Sig
|
|
12
|
+
include SorbetHelper
|
|
13
|
+
include Runtime::Reflection
|
|
14
|
+
|
|
15
|
+
sig { returns(T::Set[String]) }
|
|
16
|
+
def payload_symbols
|
|
17
|
+
unless @payload_symbols
|
|
18
|
+
output = symbol_table_json_from("-e ''", table_type: "symbol-table-full-json")
|
|
19
|
+
@payload_symbols = T.let(SymbolTableParser.parse_json(output), T.nilable(T::Set[String]))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
T.must(@payload_symbols)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
sig { returns(T::Set[String]) }
|
|
26
|
+
def engine_symbols
|
|
27
|
+
unless @engine_symbols
|
|
28
|
+
@engine_symbols = T.let(load_engine_symbols, T.nilable(T::Set[String]))
|
|
29
|
+
end
|
|
30
|
+
T.must(@engine_symbols)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
sig { params(gem: Gemfile::GemSpec).returns(T::Set[String]) }
|
|
34
|
+
def gem_symbols(gem)
|
|
35
|
+
symbols_from_paths(gem.files)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
sig { params(input: String, table_type: String).returns(String) }
|
|
41
|
+
def symbol_table_json_from(input, table_type: "symbol-table-json")
|
|
42
|
+
sorbet("--no-config", "--quiet", "--print=#{table_type}", input).out
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
sig { returns(T::Set[String]) }
|
|
46
|
+
def load_engine_symbols
|
|
47
|
+
return Set.new unless Object.const_defined?("Rails::Engine")
|
|
48
|
+
|
|
49
|
+
engine = descendants_of(Object.const_get("Rails::Engine"))
|
|
50
|
+
.reject(&:abstract_railtie?)
|
|
51
|
+
.find do |klass|
|
|
52
|
+
name = name_of(klass)
|
|
53
|
+
!name.nil? && payload_symbols.include?(name)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return Set.new unless engine
|
|
57
|
+
|
|
58
|
+
paths = engine.config.eager_load_paths.flat_map do |load_path|
|
|
59
|
+
Pathname.glob("#{load_path}/**/*.rb")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
symbols_from_paths(paths)
|
|
63
|
+
rescue
|
|
64
|
+
Set.new
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
sig { params(paths: T::Array[Pathname]).returns(T::Set[String]) }
|
|
68
|
+
def symbols_from_paths(paths)
|
|
69
|
+
output = T.cast(Tempfile.create("sorbet") do |file|
|
|
70
|
+
file.write(Array(paths).join("\n"))
|
|
71
|
+
file.flush
|
|
72
|
+
|
|
73
|
+
symbol_table_json_from("@#{file.path.shellescape}")
|
|
74
|
+
end, T.nilable(String))
|
|
75
|
+
|
|
76
|
+
return Set.new if output.nil? || output.empty?
|
|
77
|
+
|
|
78
|
+
SymbolTableParser.parse_json(output)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
require "tempfile"
|
|
6
|
+
|
|
7
|
+
module Tapioca
|
|
8
|
+
module Static
|
|
9
|
+
class SymbolTableParser
|
|
10
|
+
extend T::Sig
|
|
11
|
+
|
|
12
|
+
sig { params(json_string: String).returns(T::Set[String]) }
|
|
13
|
+
def self.parse_json(json_string)
|
|
14
|
+
obj = JSON.parse(json_string)
|
|
15
|
+
|
|
16
|
+
parser = SymbolTableParser.new
|
|
17
|
+
parser.parse_object(obj)
|
|
18
|
+
parser.symbols
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
sig { returns(T::Set[String]) }
|
|
22
|
+
attr_reader :symbols
|
|
23
|
+
|
|
24
|
+
sig { void }
|
|
25
|
+
def initialize
|
|
26
|
+
@symbols = T.let(Set.new, T::Set[String])
|
|
27
|
+
@parents = T.let([], T::Array[String])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
sig { params(object: T::Hash[String, T.untyped]).void }
|
|
31
|
+
def parse_object(object)
|
|
32
|
+
children = object.fetch("children", [])
|
|
33
|
+
|
|
34
|
+
children.each do |child|
|
|
35
|
+
kind = child.fetch("kind")
|
|
36
|
+
name = child.fetch("name")
|
|
37
|
+
name = name.fetch("name") if name.is_a?(Hash)
|
|
38
|
+
|
|
39
|
+
next if kind.nil? || name.nil?
|
|
40
|
+
|
|
41
|
+
# TODO: CLASS is removed since v0.4.4730 of Sorbet
|
|
42
|
+
# but keeping here for backward compatibility. Remove
|
|
43
|
+
# once the minimum version is moved past that.
|
|
44
|
+
next unless ["CLASS", "CLASS_OR_MODULE", "STATIC_FIELD"].include?(kind)
|
|
45
|
+
next if name =~ /[<>()$]/
|
|
46
|
+
next if name =~ /^[0-9]+$/
|
|
47
|
+
next if name == "T::Helpers"
|
|
48
|
+
|
|
49
|
+
@symbols.add(fully_qualified_name(name))
|
|
50
|
+
|
|
51
|
+
@parents << name
|
|
52
|
+
parse_object(child)
|
|
53
|
+
@parents.pop
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
sig { params(name: String).returns(String) }
|
|
58
|
+
def fully_qualified_name(name)
|
|
59
|
+
[*@parents, name].join("::")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Tapioca
|
|
|
14
14
|
def self.silence_warnings(&blk)
|
|
15
15
|
original_verbosity = $VERBOSE
|
|
16
16
|
$VERBOSE = nil
|
|
17
|
-
Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do
|
|
17
|
+
::Gem::DefaultUserInteraction.use_ui(::Gem::SilentUI.new) do
|
|
18
18
|
blk.call
|
|
19
19
|
end
|
|
20
20
|
ensure
|
|
@@ -28,7 +28,7 @@ module Tapioca
|
|
|
28
28
|
TAPIOCA_DIR = T.let("#{SORBET_DIR}/tapioca", String)
|
|
29
29
|
TAPIOCA_CONFIG_FILE = T.let("#{TAPIOCA_DIR}/config.yml", String)
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
BINARY_FILE = T.let("bin/tapioca", String)
|
|
32
32
|
DEFAULT_POSTREQUIRE_FILE = T.let("#{TAPIOCA_DIR}/require.rb", String)
|
|
33
33
|
DEFAULT_RBI_DIR = T.let("#{SORBET_DIR}/rbi", String)
|
|
34
34
|
DEFAULT_DSL_DIR = T.let("#{DEFAULT_RBI_DIR}/dsl", String)
|
|
@@ -43,9 +43,4 @@ module Tapioca
|
|
|
43
43
|
}.freeze, T::Hash[String, String])
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
require "tapioca/reflection"
|
|
47
|
-
require "tapioca/trackers"
|
|
48
|
-
require "tapioca/compilers/dsl/base"
|
|
49
|
-
require "tapioca/compilers/dynamic_mixin_compiler"
|
|
50
|
-
require "tapioca/helpers/active_record_column_type_helper"
|
|
51
46
|
require "tapioca/version"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tapioca
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: exe
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2022-
|
|
14
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: bundler
|
|
@@ -50,7 +50,7 @@ dependencies:
|
|
|
50
50
|
version: 0.0.0
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.0.
|
|
53
|
+
version: 0.0.14
|
|
54
54
|
type: :runtime
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -60,9 +60,9 @@ dependencies:
|
|
|
60
60
|
version: 0.0.0
|
|
61
61
|
- - ">="
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: 0.0.
|
|
63
|
+
version: 0.0.14
|
|
64
64
|
- !ruby/object:Gem::Dependency
|
|
65
|
-
name: sorbet-
|
|
65
|
+
name: sorbet-runtime
|
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
|
67
67
|
requirements:
|
|
68
68
|
- - ">="
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
77
|
version: 0.5.9204
|
|
78
78
|
- !ruby/object:Gem::Dependency
|
|
79
|
-
name: sorbet-
|
|
79
|
+
name: sorbet-static
|
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements:
|
|
82
82
|
- - ">="
|
|
@@ -98,7 +98,7 @@ dependencies:
|
|
|
98
98
|
version: 1.1.0
|
|
99
99
|
- - ">="
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: 1.1.
|
|
101
|
+
version: 1.1.11
|
|
102
102
|
type: :runtime
|
|
103
103
|
prerelease: false
|
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -108,7 +108,7 @@ dependencies:
|
|
|
108
108
|
version: 1.1.0
|
|
109
109
|
- - ">="
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: 1.1.
|
|
111
|
+
version: 1.1.11
|
|
112
112
|
- !ruby/object:Gem::Dependency
|
|
113
113
|
name: thor
|
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,72 +151,93 @@ files:
|
|
|
151
151
|
- exe/tapioca
|
|
152
152
|
- lib/tapioca.rb
|
|
153
153
|
- lib/tapioca/cli.rb
|
|
154
|
-
- lib/tapioca/
|
|
155
|
-
- lib/tapioca/
|
|
156
|
-
- lib/tapioca/
|
|
157
|
-
- lib/tapioca/
|
|
158
|
-
- lib/tapioca/
|
|
159
|
-
- lib/tapioca/
|
|
160
|
-
- lib/tapioca/
|
|
161
|
-
- lib/tapioca/
|
|
162
|
-
- lib/tapioca/
|
|
163
|
-
- lib/tapioca/compilers/
|
|
164
|
-
- lib/tapioca/compilers/
|
|
165
|
-
- lib/tapioca/compilers/
|
|
166
|
-
- lib/tapioca/compilers/
|
|
167
|
-
- lib/tapioca/compilers/
|
|
168
|
-
- lib/tapioca/compilers/
|
|
169
|
-
- lib/tapioca/compilers/
|
|
170
|
-
- lib/tapioca/compilers/
|
|
171
|
-
- lib/tapioca/compilers/
|
|
172
|
-
- lib/tapioca/compilers/
|
|
173
|
-
- lib/tapioca/
|
|
174
|
-
- lib/tapioca/compilers/
|
|
175
|
-
- lib/tapioca/
|
|
176
|
-
- lib/tapioca/compilers/
|
|
177
|
-
- lib/tapioca/compilers/
|
|
178
|
-
- lib/tapioca/compilers/
|
|
179
|
-
- lib/tapioca/compilers/
|
|
180
|
-
- lib/tapioca/compilers/
|
|
181
|
-
- lib/tapioca/compilers/
|
|
182
|
-
- lib/tapioca/compilers/
|
|
183
|
-
- lib/tapioca/compilers/
|
|
184
|
-
- lib/tapioca/compilers/
|
|
185
|
-
- lib/tapioca/compilers/
|
|
186
|
-
- lib/tapioca/compilers/
|
|
187
|
-
- lib/tapioca/compilers/
|
|
188
|
-
- lib/tapioca/compilers/
|
|
189
|
-
- lib/tapioca/compilers/
|
|
190
|
-
- lib/tapioca/
|
|
191
|
-
- lib/tapioca/
|
|
192
|
-
- lib/tapioca/
|
|
154
|
+
- lib/tapioca/commands.rb
|
|
155
|
+
- lib/tapioca/commands/command.rb
|
|
156
|
+
- lib/tapioca/commands/dsl.rb
|
|
157
|
+
- lib/tapioca/commands/gem.rb
|
|
158
|
+
- lib/tapioca/commands/init.rb
|
|
159
|
+
- lib/tapioca/commands/require.rb
|
|
160
|
+
- lib/tapioca/commands/todo.rb
|
|
161
|
+
- lib/tapioca/dsl/compiler.rb
|
|
162
|
+
- lib/tapioca/dsl/compilers.rb
|
|
163
|
+
- lib/tapioca/dsl/compilers/aasm.rb
|
|
164
|
+
- lib/tapioca/dsl/compilers/action_controller_helpers.rb
|
|
165
|
+
- lib/tapioca/dsl/compilers/action_mailer.rb
|
|
166
|
+
- lib/tapioca/dsl/compilers/active_job.rb
|
|
167
|
+
- lib/tapioca/dsl/compilers/active_model_attributes.rb
|
|
168
|
+
- lib/tapioca/dsl/compilers/active_model_secure_password.rb
|
|
169
|
+
- lib/tapioca/dsl/compilers/active_record_associations.rb
|
|
170
|
+
- lib/tapioca/dsl/compilers/active_record_columns.rb
|
|
171
|
+
- lib/tapioca/dsl/compilers/active_record_enum.rb
|
|
172
|
+
- lib/tapioca/dsl/compilers/active_record_fixtures.rb
|
|
173
|
+
- lib/tapioca/dsl/compilers/active_record_relations.rb
|
|
174
|
+
- lib/tapioca/dsl/compilers/active_record_scope.rb
|
|
175
|
+
- lib/tapioca/dsl/compilers/active_record_typed_store.rb
|
|
176
|
+
- lib/tapioca/dsl/compilers/active_resource.rb
|
|
177
|
+
- lib/tapioca/dsl/compilers/active_storage.rb
|
|
178
|
+
- lib/tapioca/dsl/compilers/active_support_concern.rb
|
|
179
|
+
- lib/tapioca/dsl/compilers/active_support_current_attributes.rb
|
|
180
|
+
- lib/tapioca/dsl/compilers/config.rb
|
|
181
|
+
- lib/tapioca/dsl/compilers/frozen_record.rb
|
|
182
|
+
- lib/tapioca/dsl/compilers/identity_cache.rb
|
|
183
|
+
- lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb
|
|
184
|
+
- lib/tapioca/dsl/compilers/protobuf.rb
|
|
185
|
+
- lib/tapioca/dsl/compilers/rails_generators.rb
|
|
186
|
+
- lib/tapioca/dsl/compilers/sidekiq_worker.rb
|
|
187
|
+
- lib/tapioca/dsl/compilers/smart_properties.rb
|
|
188
|
+
- lib/tapioca/dsl/compilers/state_machines.rb
|
|
189
|
+
- lib/tapioca/dsl/compilers/url_helpers.rb
|
|
190
|
+
- lib/tapioca/dsl/extensions/frozen_record.rb
|
|
191
|
+
- lib/tapioca/dsl/helpers/active_record_column_type_helper.rb
|
|
192
|
+
- lib/tapioca/dsl/helpers/active_record_constants_helper.rb
|
|
193
|
+
- lib/tapioca/dsl/helpers/param_helper.rb
|
|
194
|
+
- lib/tapioca/dsl/pipeline.rb
|
|
193
195
|
- lib/tapioca/executor.rb
|
|
196
|
+
- lib/tapioca/gem/events.rb
|
|
197
|
+
- lib/tapioca/gem/listeners.rb
|
|
198
|
+
- lib/tapioca/gem/listeners/base.rb
|
|
199
|
+
- lib/tapioca/gem/listeners/dynamic_mixins.rb
|
|
200
|
+
- lib/tapioca/gem/listeners/methods.rb
|
|
201
|
+
- lib/tapioca/gem/listeners/mixins.rb
|
|
202
|
+
- lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb
|
|
203
|
+
- lib/tapioca/gem/listeners/sorbet_enums.rb
|
|
204
|
+
- lib/tapioca/gem/listeners/sorbet_helpers.rb
|
|
205
|
+
- lib/tapioca/gem/listeners/sorbet_props.rb
|
|
206
|
+
- lib/tapioca/gem/listeners/sorbet_required_ancestors.rb
|
|
207
|
+
- lib/tapioca/gem/listeners/sorbet_signatures.rb
|
|
208
|
+
- lib/tapioca/gem/listeners/sorbet_type_variables.rb
|
|
209
|
+
- lib/tapioca/gem/listeners/subconstants.rb
|
|
210
|
+
- lib/tapioca/gem/listeners/yard_doc.rb
|
|
211
|
+
- lib/tapioca/gem/pipeline.rb
|
|
194
212
|
- lib/tapioca/gemfile.rb
|
|
195
|
-
- lib/tapioca/generators.rb
|
|
196
|
-
- lib/tapioca/generators/base.rb
|
|
197
|
-
- lib/tapioca/generators/dsl.rb
|
|
198
|
-
- lib/tapioca/generators/gem.rb
|
|
199
|
-
- lib/tapioca/generators/init.rb
|
|
200
|
-
- lib/tapioca/generators/require.rb
|
|
201
|
-
- lib/tapioca/generators/todo.rb
|
|
202
|
-
- lib/tapioca/generic_type_registry.rb
|
|
203
|
-
- lib/tapioca/helpers/active_record_column_type_helper.rb
|
|
204
213
|
- lib/tapioca/helpers/cli_helper.rb
|
|
205
214
|
- lib/tapioca/helpers/config_helper.rb
|
|
215
|
+
- lib/tapioca/helpers/shims_helper.rb
|
|
216
|
+
- lib/tapioca/helpers/signatures_helper.rb
|
|
217
|
+
- lib/tapioca/helpers/sorbet_helper.rb
|
|
206
218
|
- lib/tapioca/helpers/test/content.rb
|
|
219
|
+
- lib/tapioca/helpers/test/dsl_compiler.rb
|
|
207
220
|
- lib/tapioca/helpers/test/isolation.rb
|
|
208
221
|
- lib/tapioca/helpers/test/template.rb
|
|
222
|
+
- lib/tapioca/helpers/type_variable_helper.rb
|
|
209
223
|
- lib/tapioca/internal.rb
|
|
210
|
-
- lib/tapioca/loader.rb
|
|
211
224
|
- lib/tapioca/rbi_ext/model.rb
|
|
212
|
-
- lib/tapioca/
|
|
225
|
+
- lib/tapioca/rbi_formatter.rb
|
|
226
|
+
- lib/tapioca/runtime/dynamic_mixin_compiler.rb
|
|
227
|
+
- lib/tapioca/runtime/generic_type_registry.rb
|
|
228
|
+
- lib/tapioca/runtime/loader.rb
|
|
229
|
+
- lib/tapioca/runtime/reflection.rb
|
|
230
|
+
- lib/tapioca/runtime/trackers.rb
|
|
231
|
+
- lib/tapioca/runtime/trackers/autoload.rb
|
|
232
|
+
- lib/tapioca/runtime/trackers/constant_definition.rb
|
|
233
|
+
- lib/tapioca/runtime/trackers/mixin.rb
|
|
234
|
+
- lib/tapioca/runtime/trackers/required_ancestor.rb
|
|
213
235
|
- lib/tapioca/sorbet_ext/fixed_hash_patch.rb
|
|
214
236
|
- lib/tapioca/sorbet_ext/generic_name_patch.rb
|
|
215
237
|
- lib/tapioca/sorbet_ext/name_patch.rb
|
|
216
|
-
- lib/tapioca/
|
|
217
|
-
- lib/tapioca/
|
|
218
|
-
- lib/tapioca/
|
|
219
|
-
- lib/tapioca/trackers/mixin.rb
|
|
238
|
+
- lib/tapioca/static/requires_compiler.rb
|
|
239
|
+
- lib/tapioca/static/symbol_loader.rb
|
|
240
|
+
- lib/tapioca/static/symbol_table_parser.rb
|
|
220
241
|
- lib/tapioca/version.rb
|
|
221
242
|
homepage: https://github.com/Shopify/tapioca
|
|
222
243
|
licenses:
|