steep 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +27 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +48 -90
- data/Rakefile +10 -6
- data/Steepfile +1 -0
- data/bin/setup +1 -0
- data/bin/smoke_runner.rb +9 -14
- data/exe/rbs +3 -0
- data/exe/ruby-signature +3 -0
- data/exe/steep +1 -0
- data/lib/steep.rb +32 -26
- data/lib/steep/annotation_parser.rb +167 -0
- data/lib/steep/ast/annotation/collection.rb +7 -7
- data/lib/steep/ast/types.rb +60 -0
- data/lib/steep/ast/types/any.rb +1 -1
- data/lib/steep/ast/types/factory.rb +535 -0
- data/lib/steep/ast/types/name.rb +3 -3
- data/lib/steep/ast/types/var.rb +1 -1
- data/lib/steep/cli.rb +56 -240
- data/lib/steep/drivers/annotations.rb +36 -19
- data/lib/steep/drivers/check.rb +55 -91
- data/lib/steep/drivers/init.rb +54 -0
- data/lib/steep/drivers/langserver.rb +241 -150
- data/lib/steep/drivers/print_project.rb +56 -0
- data/lib/steep/drivers/signature_error_printer.rb +25 -0
- data/lib/steep/drivers/trace_printer.rb +25 -0
- data/lib/steep/drivers/utils/driver_helper.rb +26 -0
- data/lib/steep/drivers/validate.rb +18 -38
- data/lib/steep/drivers/vendor.rb +46 -0
- data/lib/steep/drivers/watch.rb +78 -140
- data/lib/steep/errors.rb +22 -13
- data/lib/steep/interface/interface.rb +91 -0
- data/lib/steep/interface/method.rb +0 -4
- data/lib/steep/interface/method_type.rb +362 -2
- data/lib/steep/interface/substitution.rb +22 -0
- data/lib/steep/project.rb +25 -233
- data/lib/steep/project/dsl.rb +132 -0
- data/lib/steep/project/file.rb +93 -76
- data/lib/steep/project/file_loader.rb +63 -0
- data/lib/steep/project/options.rb +7 -0
- data/lib/steep/project/target.rb +190 -0
- data/lib/steep/signature/errors.rb +25 -77
- data/lib/steep/signature/validator.rb +122 -0
- data/lib/steep/source.rb +12 -7
- data/lib/steep/subtyping/check.rb +357 -633
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/subtyping/trace.rb +23 -0
- data/lib/steep/type_construction.rb +509 -455
- data/lib/steep/type_inference/constant_env.rb +16 -24
- data/lib/steep/type_inference/type_env.rb +26 -18
- data/lib/steep/version.rb +1 -1
- data/sample/Steepfile +6 -0
- data/sample/lib/conference.rb +12 -0
- data/sample/sig/conference.rbs +6 -0
- data/smoke/alias/Steepfile +4 -0
- data/smoke/alias/a.rb +2 -2
- data/smoke/alias/{a.rbi → a.rbs} +1 -1
- data/smoke/and/Steepfile +4 -0
- data/smoke/array/Steepfile +4 -0
- data/smoke/array/a.rb +2 -2
- data/smoke/array/b.rb +4 -4
- data/smoke/array/c.rb +2 -2
- data/smoke/block/Steepfile +5 -0
- data/smoke/block/{a.rbi → a.rbs} +1 -1
- data/smoke/block/{c.rbi → c.rbs} +0 -0
- data/smoke/block/d.rb +6 -6
- data/smoke/case/Steepfile +4 -0
- data/smoke/case/a.rb +4 -3
- data/smoke/class/Steepfile +4 -0
- data/smoke/class/a.rb +1 -4
- data/smoke/class/a.rbs +24 -0
- data/smoke/class/h.rb +6 -2
- data/smoke/class/{h.rbi → h.rbs} +1 -2
- data/smoke/class/i.rb +1 -2
- data/smoke/class/i.rbs +9 -0
- data/smoke/const/Steepfile +4 -0
- data/smoke/dstr/Steepfile +4 -0
- data/smoke/ensure/Steepfile +4 -0
- data/smoke/ensure/a.rb +1 -1
- data/smoke/enumerator/Steepfile +4 -0
- data/smoke/enumerator/a.rb +7 -7
- data/smoke/enumerator/b.rb +6 -6
- data/smoke/extension/Steepfile +4 -0
- data/smoke/extension/{a.rbi → a.rbs} +2 -2
- data/smoke/extension/{e.rbi → e.rbs} +2 -2
- data/smoke/hash/Steepfile +4 -0
- data/smoke/hash/{a.rbi → a.rbs} +0 -0
- data/smoke/hash/b.rb +2 -2
- data/smoke/hash/c.rb +1 -1
- data/smoke/hash/e.rbs +3 -0
- data/smoke/hash/f.rb +1 -1
- data/smoke/hello/Steepfile +4 -0
- data/smoke/hello/hello.rbs +7 -0
- data/smoke/if/Steepfile +4 -0
- data/smoke/implements/Steepfile +4 -0
- data/smoke/implements/a.rbs +6 -0
- data/smoke/initialize/Steepfile +4 -0
- data/smoke/initialize/a.rbs +3 -0
- data/smoke/integer/Steepfile +4 -0
- data/smoke/integer/a.rb +5 -3
- data/smoke/interface/Steepfile +4 -0
- data/smoke/interface/{a.rbi → a.rbs} +0 -0
- data/smoke/kwbegin/Steepfile +4 -0
- data/smoke/lambda/Steepfile +4 -0
- data/smoke/lambda/a.rb +9 -2
- data/smoke/literal/Steepfile +4 -0
- data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
- data/smoke/map/Steepfile +4 -0
- data/smoke/map/a.rb +1 -1
- data/smoke/method/Steepfile +4 -0
- data/smoke/method/{a.rbi → a.rbs} +0 -0
- data/smoke/method/b.rb +1 -4
- data/smoke/method/d.rb +1 -0
- data/smoke/method/d.rbs +3 -0
- data/smoke/module/Steepfile +4 -0
- data/smoke/module/a.rb +1 -1
- data/smoke/module/a.rbs +16 -0
- data/smoke/module/c.rb +1 -1
- data/smoke/regexp/Steepfile +4 -0
- data/smoke/regexp/a.rb +2 -2
- data/smoke/regexp/b.rb +16 -16
- data/smoke/regression/Steepfile +5 -0
- data/smoke/regression/array.rb +2 -2
- data/smoke/regression/hash.rb +2 -2
- data/smoke/regression/poly_new.rb +2 -0
- data/smoke/regression/poly_new.rbs +4 -0
- data/smoke/regression/set_divide.rb +2 -2
- data/smoke/rescue/Steepfile +4 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +4 -0
- data/smoke/self/a.rbs +4 -0
- data/smoke/skip/Steepfile +4 -0
- data/smoke/stdout/Steepfile +4 -0
- data/smoke/stdout/{a.rbi → a.rbs} +1 -1
- data/smoke/super/Steepfile +4 -0
- data/smoke/super/a.rbs +10 -0
- data/smoke/type_case/Steepfile +4 -0
- data/smoke/type_case/a.rb +1 -1
- data/smoke/yield/Steepfile +4 -0
- data/smoke/yield/a.rb +2 -2
- data/steep.gemspec +14 -7
- data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
- data/vendor/ruby-signature/.gitignore +12 -0
- data/vendor/ruby-signature/.rubocop.yml +15 -0
- data/vendor/ruby-signature/BSDL +22 -0
- data/vendor/ruby-signature/COPYING +56 -0
- data/vendor/ruby-signature/Gemfile +6 -0
- data/vendor/ruby-signature/README.md +93 -0
- data/vendor/ruby-signature/Rakefile +66 -0
- data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
- data/vendor/ruby-signature/bin/console +14 -0
- data/vendor/ruby-signature/bin/query-rdoc +103 -0
- data/vendor/ruby-signature/bin/setup +10 -0
- data/vendor/ruby-signature/bin/sort +88 -0
- data/vendor/ruby-signature/bin/test_runner.rb +17 -0
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
- data/vendor/ruby-signature/docs/sigs.md +148 -0
- data/vendor/ruby-signature/docs/stdlib.md +152 -0
- data/vendor/ruby-signature/docs/syntax.md +528 -0
- data/vendor/ruby-signature/exe/rbs +3 -0
- data/vendor/ruby-signature/exe/ruby-signature +7 -0
- data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
- data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
- data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
- data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +244 -54
- data/.travis.yml +0 -7
- data/lib/steep/ast/signature/alias.rb +0 -19
- data/lib/steep/ast/signature/class.rb +0 -33
- data/lib/steep/ast/signature/const.rb +0 -17
- data/lib/steep/ast/signature/env.rb +0 -138
- data/lib/steep/ast/signature/extension.rb +0 -21
- data/lib/steep/ast/signature/gvar.rb +0 -17
- data/lib/steep/ast/signature/interface.rb +0 -31
- data/lib/steep/ast/signature/members.rb +0 -115
- data/lib/steep/ast/signature/module.rb +0 -21
- data/lib/steep/drivers/print_interface.rb +0 -94
- data/lib/steep/drivers/scaffold.rb +0 -321
- data/lib/steep/drivers/utils/each_signature.rb +0 -31
- data/lib/steep/interface/abstract.rb +0 -68
- data/lib/steep/interface/builder.rb +0 -637
- data/lib/steep/interface/instantiated.rb +0 -163
- data/lib/steep/interface/ivar_chain.rb +0 -26
- data/lib/steep/parser.y +0 -1278
- data/lib/steep/project/listener.rb +0 -53
- data/smoke/class/a.rbi +0 -24
- data/smoke/class/d.rb +0 -9
- data/smoke/class/e.rb +0 -12
- data/smoke/class/i.rbi +0 -9
- data/smoke/hash/e.rbi +0 -3
- data/smoke/hello/hello.rbi +0 -7
- data/smoke/implements/a.rbi +0 -6
- data/smoke/initialize/a.rbi +0 -3
- data/smoke/module/a.rbi +0 -16
- data/smoke/self/a.rbi +0 -4
- data/smoke/super/a.rbi +0 -10
- data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,64 @@
|
|
1
|
+
require "ruby/signature/version"
|
2
|
+
|
3
|
+
require "set"
|
4
|
+
require "json"
|
5
|
+
require "pathname"
|
6
|
+
require "pp"
|
7
|
+
require "ripper"
|
8
|
+
require "logger"
|
9
|
+
require "tsort"
|
10
|
+
|
11
|
+
require "ruby/signature/errors"
|
12
|
+
require "ruby/signature/buffer"
|
13
|
+
require "ruby/signature/location"
|
14
|
+
require "ruby/signature/namespace"
|
15
|
+
require "ruby/signature/type_name"
|
16
|
+
require "ruby/signature/types"
|
17
|
+
require "ruby/signature/method_type"
|
18
|
+
require "ruby/signature/ast/declarations"
|
19
|
+
require "ruby/signature/ast/members"
|
20
|
+
require "ruby/signature/ast/annotation"
|
21
|
+
require "ruby/signature/environment"
|
22
|
+
require "ruby/signature/environment_loader"
|
23
|
+
require "ruby/signature/builtin_names"
|
24
|
+
require "ruby/signature/definition"
|
25
|
+
require "ruby/signature/definition_builder"
|
26
|
+
require "ruby/signature/variance_calculator"
|
27
|
+
require "ruby/signature/substitution"
|
28
|
+
require "ruby/signature/constant"
|
29
|
+
require "ruby/signature/constant_table"
|
30
|
+
require "ruby/signature/ast/comment"
|
31
|
+
require "ruby/signature/writer"
|
32
|
+
require "ruby/signature/prototype/rbi"
|
33
|
+
require "ruby/signature/prototype/rb"
|
34
|
+
require "ruby/signature/prototype/runtime"
|
35
|
+
require "ruby/signature/environment_walker"
|
36
|
+
require "ruby/signature/vendorer"
|
37
|
+
|
38
|
+
begin
|
39
|
+
require "ruby/signature/parser"
|
40
|
+
rescue LoadError
|
41
|
+
STDERR.puts "Missing parser Ruby code? Running `rake parser` may solve the issue"
|
42
|
+
raise
|
43
|
+
end
|
44
|
+
|
45
|
+
module Ruby::Signature
|
46
|
+
class <<self
|
47
|
+
attr_reader :logger_level
|
48
|
+
attr_reader :logger_output
|
49
|
+
|
50
|
+
def logger
|
51
|
+
@logger ||= Logger.new(logger_output || STDERR, level: logger_level || "warn", progname: "ruby-signature")
|
52
|
+
end
|
53
|
+
|
54
|
+
def logger_output=(val)
|
55
|
+
@logger_output = val
|
56
|
+
@logger = nil
|
57
|
+
end
|
58
|
+
|
59
|
+
def logger_level=(level)
|
60
|
+
@logger_level = level
|
61
|
+
@logger = nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ruby
|
2
|
+
module Signature
|
3
|
+
module AST
|
4
|
+
class Annotation
|
5
|
+
attr_reader :string
|
6
|
+
attr_reader :location
|
7
|
+
|
8
|
+
def initialize(string:, location:)
|
9
|
+
@string = string
|
10
|
+
@location = location
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
other.is_a?(Annotation) && other.string == string
|
15
|
+
end
|
16
|
+
|
17
|
+
alias eql? ==
|
18
|
+
|
19
|
+
def hash
|
20
|
+
self.class.hash ^ string.hash
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json(*a)
|
24
|
+
{ string: string, location: location }.to_json(*a)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ruby
|
2
|
+
module Signature
|
3
|
+
module AST
|
4
|
+
class Comment
|
5
|
+
attr_reader :string
|
6
|
+
attr_reader :location
|
7
|
+
|
8
|
+
def initialize(string:, location:)
|
9
|
+
@string = string
|
10
|
+
@location = location
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
other.is_a?(Comment) && other.string == string
|
15
|
+
end
|
16
|
+
|
17
|
+
alias eql? ==
|
18
|
+
|
19
|
+
def hash
|
20
|
+
self.class.hash ^ string.hash
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_json(*a)
|
24
|
+
{ string: string, location: location }.to_json(*a)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,391 @@
|
|
1
|
+
module Ruby
|
2
|
+
module Signature
|
3
|
+
module AST
|
4
|
+
module Declarations
|
5
|
+
class ModuleTypeParams
|
6
|
+
attr_reader :params
|
7
|
+
|
8
|
+
TypeParam = Struct.new(:name, :variance, :skip_validation, keyword_init: true)
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
@params = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(param)
|
15
|
+
params << param
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def ==(other)
|
20
|
+
other.is_a?(ModuleTypeParams) && other.params == params
|
21
|
+
end
|
22
|
+
|
23
|
+
def [](name)
|
24
|
+
params.find {|p| p.name == name }
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json(*a)
|
28
|
+
{
|
29
|
+
params: params
|
30
|
+
}.to_json(*a)
|
31
|
+
end
|
32
|
+
|
33
|
+
def each(&block)
|
34
|
+
params.each(&block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.empty
|
38
|
+
new
|
39
|
+
end
|
40
|
+
|
41
|
+
def variance(name)
|
42
|
+
self[name].variance
|
43
|
+
end
|
44
|
+
|
45
|
+
def skip_validation?(name)
|
46
|
+
self[name].skip_validation
|
47
|
+
end
|
48
|
+
|
49
|
+
def empty?
|
50
|
+
params.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def size
|
54
|
+
params.size
|
55
|
+
end
|
56
|
+
|
57
|
+
def rename_to(names)
|
58
|
+
ModuleTypeParams.new().tap do |params|
|
59
|
+
names.each.with_index do |new_name, index|
|
60
|
+
param = self.params[index]
|
61
|
+
params.add(TypeParam.new(name: new_name, variance: param.variance, skip_validation: param.skip_validation))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Class
|
68
|
+
class Super
|
69
|
+
attr_reader :name
|
70
|
+
attr_reader :args
|
71
|
+
|
72
|
+
def initialize(name:, args:)
|
73
|
+
@name = name
|
74
|
+
@args = args
|
75
|
+
end
|
76
|
+
|
77
|
+
def ==(other)
|
78
|
+
other.is_a?(Super) && other.name == name && other.args == args
|
79
|
+
end
|
80
|
+
|
81
|
+
alias eql? ==
|
82
|
+
|
83
|
+
def hash
|
84
|
+
self.class.hash ^ name.hash ^ args.hash
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_json(*a)
|
88
|
+
{
|
89
|
+
name: name,
|
90
|
+
args: args
|
91
|
+
}.to_json(*a)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
attr_reader :name
|
96
|
+
attr_reader :type_params
|
97
|
+
attr_reader :members
|
98
|
+
attr_reader :super_class
|
99
|
+
attr_reader :annotations
|
100
|
+
attr_reader :location
|
101
|
+
attr_reader :comment
|
102
|
+
|
103
|
+
def initialize(name:, type_params:, super_class:, members:, annotations:, location:, comment:)
|
104
|
+
@name = name
|
105
|
+
@type_params = type_params
|
106
|
+
@super_class = super_class
|
107
|
+
@members = members
|
108
|
+
@annotations = annotations
|
109
|
+
@location = location
|
110
|
+
@comment = comment
|
111
|
+
end
|
112
|
+
|
113
|
+
def ==(other)
|
114
|
+
other.is_a?(Class) &&
|
115
|
+
other.name == name &&
|
116
|
+
other.type_params == type_params &&
|
117
|
+
other.super_class == super_class &&
|
118
|
+
other.members == members
|
119
|
+
end
|
120
|
+
|
121
|
+
alias eql? ==
|
122
|
+
|
123
|
+
def hash
|
124
|
+
self.class.hash ^ name.hash ^ type_params.hash ^ super_class.hash ^ members.hash
|
125
|
+
end
|
126
|
+
|
127
|
+
def to_json(*a)
|
128
|
+
{
|
129
|
+
declaration: :class,
|
130
|
+
name: name,
|
131
|
+
type_params: type_params,
|
132
|
+
members: members,
|
133
|
+
super_class: super_class,
|
134
|
+
annotations: annotations,
|
135
|
+
location: location,
|
136
|
+
comment: comment
|
137
|
+
}.to_json(*a)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class Module
|
142
|
+
attr_reader :name
|
143
|
+
attr_reader :type_params
|
144
|
+
attr_reader :members
|
145
|
+
attr_reader :location
|
146
|
+
attr_reader :annotations
|
147
|
+
attr_reader :self_type
|
148
|
+
attr_reader :comment
|
149
|
+
|
150
|
+
def initialize(name:, type_params:, members:, self_type:, annotations:, location:, comment:)
|
151
|
+
@name = name
|
152
|
+
@type_params = type_params
|
153
|
+
@self_type = self_type
|
154
|
+
@members = members
|
155
|
+
@annotations = annotations
|
156
|
+
@location = location
|
157
|
+
@comment = comment
|
158
|
+
end
|
159
|
+
|
160
|
+
def ==(other)
|
161
|
+
other.is_a?(Module) &&
|
162
|
+
other.name == name &&
|
163
|
+
other.type_params == type_params &&
|
164
|
+
other.self_type == self_type &&
|
165
|
+
other.members == members
|
166
|
+
end
|
167
|
+
|
168
|
+
alias eql? ==
|
169
|
+
|
170
|
+
def hash
|
171
|
+
self.class.hash ^ name.hash ^ type_params.hash ^ self_type.hash ^ members.hash
|
172
|
+
end
|
173
|
+
|
174
|
+
def to_json(*a)
|
175
|
+
{
|
176
|
+
declaration: :module,
|
177
|
+
name: name,
|
178
|
+
type_params: type_params,
|
179
|
+
members: members,
|
180
|
+
self_type: self_type,
|
181
|
+
annotations: annotations,
|
182
|
+
location: location,
|
183
|
+
comment: comment
|
184
|
+
}.to_json(*a)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
class Extension
|
189
|
+
attr_reader :name
|
190
|
+
attr_reader :type_params
|
191
|
+
attr_reader :extension_name
|
192
|
+
attr_reader :members
|
193
|
+
attr_reader :annotations
|
194
|
+
attr_reader :location
|
195
|
+
attr_reader :comment
|
196
|
+
|
197
|
+
def initialize(name:, type_params:, extension_name:, members:, annotations:, location:, comment:)
|
198
|
+
@name = name
|
199
|
+
@type_params = type_params
|
200
|
+
@extension_name = extension_name
|
201
|
+
@members = members
|
202
|
+
@annotations = annotations
|
203
|
+
@location = location
|
204
|
+
@comment = comment
|
205
|
+
end
|
206
|
+
|
207
|
+
def ==(other)
|
208
|
+
other.is_a?(Extension) &&
|
209
|
+
other.name == name &&
|
210
|
+
other.type_params == type_params &&
|
211
|
+
other.extension_name == extension_name &&
|
212
|
+
other.members == members
|
213
|
+
end
|
214
|
+
|
215
|
+
alias eql? ==
|
216
|
+
|
217
|
+
def hash
|
218
|
+
self.class.hash ^ name.hash ^ type_params.hash ^ extension_name.hash ^ members.hash
|
219
|
+
end
|
220
|
+
|
221
|
+
def to_json(*a)
|
222
|
+
{
|
223
|
+
declaration: :extension,
|
224
|
+
name: name,
|
225
|
+
type_params: type_params,
|
226
|
+
extension_name: extension_name,
|
227
|
+
members: members,
|
228
|
+
annotations: annotations,
|
229
|
+
location: location,
|
230
|
+
comment: comment
|
231
|
+
}.to_json(*a)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
class Interface
|
236
|
+
attr_reader :name
|
237
|
+
attr_reader :type_params
|
238
|
+
attr_reader :members
|
239
|
+
attr_reader :annotations
|
240
|
+
attr_reader :location
|
241
|
+
attr_reader :comment
|
242
|
+
|
243
|
+
def initialize(name:, type_params:, members:, annotations:, location:, comment:)
|
244
|
+
@name = name
|
245
|
+
@type_params = type_params
|
246
|
+
@members = members
|
247
|
+
@annotations = annotations
|
248
|
+
@location = location
|
249
|
+
@comment = comment
|
250
|
+
end
|
251
|
+
|
252
|
+
def ==(other)
|
253
|
+
other.is_a?(Interface) &&
|
254
|
+
other.name == name &&
|
255
|
+
other.type_params == type_params &&
|
256
|
+
other.members == members
|
257
|
+
end
|
258
|
+
|
259
|
+
alias eql? ==
|
260
|
+
|
261
|
+
def hash
|
262
|
+
self.class.hash ^ type_params.hash ^ members.hash
|
263
|
+
end
|
264
|
+
|
265
|
+
def to_json(*a)
|
266
|
+
{
|
267
|
+
declaration: :interface,
|
268
|
+
name: name,
|
269
|
+
type_params: type_params,
|
270
|
+
members: members,
|
271
|
+
annotations: annotations,
|
272
|
+
location: location,
|
273
|
+
comment: comment
|
274
|
+
}.to_json(*a)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
class Alias
|
279
|
+
attr_reader :name
|
280
|
+
attr_reader :type
|
281
|
+
attr_reader :annotations
|
282
|
+
attr_reader :location
|
283
|
+
attr_reader :comment
|
284
|
+
|
285
|
+
def initialize(name:, type:, annotations:, location:, comment:)
|
286
|
+
@name = name
|
287
|
+
@type = type
|
288
|
+
@annotations = annotations
|
289
|
+
@location = location
|
290
|
+
@comment = comment
|
291
|
+
end
|
292
|
+
|
293
|
+
def ==(other)
|
294
|
+
other.is_a?(Alias) &&
|
295
|
+
other.name == name &&
|
296
|
+
other.type == type
|
297
|
+
end
|
298
|
+
|
299
|
+
alias eql? ==
|
300
|
+
|
301
|
+
def hash
|
302
|
+
self.class.hash ^ name.hash ^ type.hash
|
303
|
+
end
|
304
|
+
|
305
|
+
def to_json(*a)
|
306
|
+
{
|
307
|
+
declaration: :alias,
|
308
|
+
name: name,
|
309
|
+
type: type,
|
310
|
+
annotations: annotations,
|
311
|
+
location: location,
|
312
|
+
comment: comment
|
313
|
+
}.to_json(*a)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
class Constant
|
318
|
+
attr_reader :name
|
319
|
+
attr_reader :type
|
320
|
+
attr_reader :location
|
321
|
+
attr_reader :comment
|
322
|
+
|
323
|
+
def initialize(name:, type:, location:, comment:)
|
324
|
+
@name = name
|
325
|
+
@type = type
|
326
|
+
@location = location
|
327
|
+
@comment = comment
|
328
|
+
end
|
329
|
+
|
330
|
+
def ==(other)
|
331
|
+
other.is_a?(Constant) &&
|
332
|
+
other.name == name &&
|
333
|
+
other.type == type
|
334
|
+
end
|
335
|
+
|
336
|
+
alias eql? ==
|
337
|
+
|
338
|
+
def hash
|
339
|
+
self.class.hash ^ name.hash ^ type.hash
|
340
|
+
end
|
341
|
+
|
342
|
+
def to_json(*a)
|
343
|
+
{
|
344
|
+
declaration: :constant,
|
345
|
+
name: name,
|
346
|
+
type: type,
|
347
|
+
location: location,
|
348
|
+
comment: comment
|
349
|
+
}.to_json(*a)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
class Global
|
354
|
+
attr_reader :name
|
355
|
+
attr_reader :type
|
356
|
+
attr_reader :location
|
357
|
+
attr_reader :comment
|
358
|
+
|
359
|
+
def initialize(name:, type:, location:, comment:)
|
360
|
+
@name = name
|
361
|
+
@type = type
|
362
|
+
@location = location
|
363
|
+
@comment = comment
|
364
|
+
end
|
365
|
+
|
366
|
+
def ==(other)
|
367
|
+
other.is_a?(Global) &&
|
368
|
+
other.name == name &&
|
369
|
+
other.type == type
|
370
|
+
end
|
371
|
+
|
372
|
+
alias eql? ==
|
373
|
+
|
374
|
+
def hash
|
375
|
+
self.class.hash ^ name.hash ^ type.hash
|
376
|
+
end
|
377
|
+
|
378
|
+
def to_json(*a)
|
379
|
+
{
|
380
|
+
declaration: :global,
|
381
|
+
name: name,
|
382
|
+
type: type,
|
383
|
+
location: location,
|
384
|
+
comment: comment
|
385
|
+
}.to_json(*a)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|