rbs 0.11.0 → 0.12.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Rakefile +9 -4
  4. data/Steepfile +28 -0
  5. data/bin/steep +4 -0
  6. data/bin/test_runner.rb +10 -5
  7. data/lib/rbs/ast/comment.rb +7 -1
  8. data/lib/rbs/ast/declarations.rb +15 -9
  9. data/lib/rbs/buffer.rb +1 -1
  10. data/lib/rbs/definition.rb +22 -13
  11. data/lib/rbs/definition_builder.rb +79 -55
  12. data/lib/rbs/environment.rb +24 -10
  13. data/lib/rbs/location.rb +1 -5
  14. data/lib/rbs/method_type.rb +5 -5
  15. data/lib/rbs/namespace.rb +14 -3
  16. data/lib/rbs/parser.y +0 -8
  17. data/lib/rbs/prototype/rb.rb +3 -4
  18. data/lib/rbs/prototype/rbi.rb +1 -2
  19. data/lib/rbs/substitution.rb +4 -3
  20. data/lib/rbs/type_name.rb +18 -1
  21. data/lib/rbs/type_name_resolver.rb +10 -3
  22. data/lib/rbs/types.rb +27 -21
  23. data/lib/rbs/variance_calculator.rb +8 -5
  24. data/lib/rbs/version.rb +1 -1
  25. data/sig/annotation.rbs +26 -0
  26. data/sig/buffer.rbs +28 -0
  27. data/sig/builtin_names.rbs +41 -0
  28. data/sig/comment.rbs +26 -0
  29. data/sig/declarations.rbs +202 -0
  30. data/sig/definition.rbs +129 -0
  31. data/sig/definition_builder.rbs +95 -0
  32. data/sig/environment.rbs +94 -0
  33. data/sig/environment_loader.rbs +4 -0
  34. data/sig/location.rbs +52 -0
  35. data/sig/members.rbs +160 -0
  36. data/sig/method_types.rbs +40 -0
  37. data/sig/namespace.rbs +124 -0
  38. data/sig/polyfill.rbs +3 -0
  39. data/sig/rbs.rbs +3 -0
  40. data/sig/substitution.rbs +39 -0
  41. data/sig/type_name_resolver.rbs +24 -0
  42. data/sig/typename.rbs +70 -0
  43. data/sig/types.rbs +361 -0
  44. data/sig/util.rbs +13 -0
  45. data/sig/variance_calculator.rbs +35 -0
  46. data/stdlib/bigdecimal/big_decimal.rbs +887 -0
  47. data/stdlib/bigdecimal/math/big_math.rbs +142 -0
  48. data/stdlib/builtin/builtin.rbs +0 -3
  49. data/stdlib/builtin/math.rbs +26 -26
  50. data/stdlib/builtin/struct.rbs +9 -10
  51. data/stdlib/forwardable/forwardable.rbs +204 -0
  52. data/stdlib/set/set.rbs +1 -1
  53. data/stdlib/uri/file.rbs +167 -0
  54. data/stdlib/uri/generic.rbs +875 -0
  55. data/steep/Gemfile +3 -0
  56. data/steep/Gemfile.lock +55 -0
  57. metadata +36 -6
@@ -0,0 +1,95 @@
1
+ module RBS
2
+ class DefinitionBuilder
3
+ class OneAncestors
4
+ attr_reader type_name: TypeName
5
+ attr_reader params: Array[Symbol]?
6
+ attr_reader super_class: Definition::Ancestor::t?
7
+ attr_reader self_types: Array[Definition::Ancestor::Instance]?
8
+ attr_reader included_modules: Array[Definition::Ancestor::Instance]?
9
+ attr_reader prepended_modules: Array[Definition::Ancestor::Instance]?
10
+ attr_reader extended_modules: Array[Definition::Ancestor::Instance]?
11
+
12
+ def initialize: (type_name: TypeName,
13
+ params: Array[Symbol]?,
14
+ super_class: Definition::Ancestor::t?,
15
+ self_types: Array[Definition::Ancestor::Instance]?,
16
+ included_modules: Array[Definition::Ancestor::Instance]?,
17
+ prepended_modules: Array[Definition::Ancestor::Instance]?,
18
+ extended_modules: Array[Definition::Ancestor::Instance]?) -> void
19
+
20
+ def each_ancestor: { (Definition::Ancestor::t) -> void } -> void
21
+ | -> Enumerator[Definition::Ancestor::t, void]
22
+
23
+ def self.class_instance: (type_name: TypeName, params: Array[Symbol], super_class: Definition::Ancestor::t?) -> instance
24
+
25
+ def self.singleton: (type_name: TypeName, super_class: Definition::Ancestor::t?) -> instance
26
+
27
+ def self.module_instance: (type_name: TypeName, params: Array[Symbol]) -> instance
28
+ end
29
+
30
+ attr_reader env: Environment
31
+ attr_reader type_name_resolver: TypeNameResolver
32
+
33
+ attr_reader instance_cache: Hash[TypeName, Definition | false | nil]
34
+ attr_reader singleton_cache: Hash[TypeName, Definition | false | nil]
35
+ attr_reader interface_cache: Hash[TypeName, Definition | false | nil]
36
+
37
+ attr_reader one_instance_cache: Hash[TypeName, Definition]
38
+ attr_reader one_singleton_cache: Hash[TypeName, Definition]
39
+
40
+ attr_reader instance_ancestors_cache: Hash[TypeName, Definition::InstanceAncestors]
41
+ attr_reader singleton_ancestor_cache: Hash[TypeName, Definition::SingletonAncestors]
42
+
43
+ attr_reader one_instance_ancestors_cache: Hash[TypeName, OneAncestors]
44
+ attr_reader one_singleton_ancestors_cache: Hash[TypeName, OneAncestors]
45
+
46
+ def initialize: (env: Environment) -> void
47
+
48
+ def validate_super_class!: (TypeName, Environment::ClassEntry) -> void
49
+
50
+ def one_instance_ancestors: (TypeName) -> OneAncestors
51
+
52
+ def one_singleton_ancestors: (TypeName) -> OneAncestors
53
+
54
+ def instance_ancestors: (TypeName, ?building_ancestors: Array[Definition::Ancestor::t]) -> Definition::InstanceAncestors
55
+
56
+ def singleton_ancestors: (TypeName, ?building_ancestors: Array[Definition::Ancestor::t]) -> Definition::SingletonAncestors
57
+
58
+ def mixin_ancestors: (Environment::ClassEntry | Environment::ModuleEntry, included_modules: Array[Definition::Ancestor::Instance]?, prepended_modules: Array[Definition::Ancestor::Instance]?, extended_modules: Array[Definition::Ancestor::Instance]?) -> void
59
+
60
+ def each_member_with_accessibility: (Array[AST::Members::t | AST::Declarations::t], ?accessibility: Definition::accessibility) { (AST::Members::t | AST::Declarations::t, Definition::accessibility) -> void } -> void
61
+
62
+ def ensure_namespace!: (Namespace, location: Location?) -> void
63
+
64
+ def build_instance: (TypeName) -> Definition
65
+
66
+ def build_interface: (TypeName) -> Definition
67
+
68
+ def build_one_instance: (TypeName) -> Definition
69
+
70
+ def build_one_singleton: (TypeName) -> Definition
71
+
72
+ def merge_definitions: (TypeName,
73
+ Array[[Definition::Ancestor::t, Definition]],
74
+ entry: Environment::ModuleEntry | Environment::ClassEntry,
75
+ self_type: Definition::self_type,
76
+ ancestors: Array[Definition::Ancestor::t]) -> Definition
77
+
78
+ type method_kind = :instance | :singleton
79
+ def merge_method: (TypeName, Hash[Symbol, Definition::Method], Symbol, Definition::Method, Substitution, kind: method_kind) -> void
80
+
81
+ def merge_variable: (Hash[Symbol, Definition::Variable], Symbol, Definition::Variable) -> void
82
+
83
+ def try_cache: (TypeName, cache: Hash[TypeName, Definition | false | nil]) { () -> Definition } -> Definition
84
+
85
+ type member_detail = [Definition::accessibility, Definition::Method?, AST::Members::MethodDefinition?, Array[AST::Members::MethodDefinition]]
86
+ def method_definition_members: (TypeName, Environment::ClassEntry | Environment::ModuleEntry, kind: :singleton | :instance) -> Hash[Symbol, member_detail]
87
+
88
+ def validate_params_with: (AST::Declarations::ModuleTypeParams, result: VarianceCalculator::Result) { (AST::Declarations::ModuleTypeParams::TypeParam) -> void } -> void
89
+
90
+ def validate_parameter_variance: (decl: AST::Declarations::Class | AST::Declarations::Module | AST::Declarations::Interface, methods: Hash[Symbol, Definition::Method]) -> void
91
+
92
+ def expand_alias: (TypeName) -> Types::t
93
+ end
94
+ end
95
+
@@ -0,0 +1,94 @@
1
+ module RBS
2
+ class Environment
3
+ type module_decl = AST::Declarations::Class | AST::Declarations::Module
4
+
5
+ interface _WithContext
6
+ def outer: () -> Array[module_decl]
7
+
8
+ def decl: () -> module_decl
9
+ end
10
+
11
+ module ContextUtil : _WithContext
12
+ def context: () -> Array[Namespace]
13
+ end
14
+
15
+ class MultiEntry
16
+ class D[M]
17
+ attr_reader decl: M
18
+ attr_reader outer: Array[module_decl]
19
+
20
+ def initialize: (decl: module_decl, outer: Array[module_decl]) -> void
21
+
22
+ include ContextUtil
23
+ end
24
+
25
+ attr_reader name: TypeName
26
+ attr_reader decls: Array[D[module_decl]]
27
+
28
+ def initialize: (name: TypeName) -> void
29
+
30
+ def insert: (decl: module_decl, outer: Array[module_decl]) -> void
31
+
32
+ def validate_type_params: () -> void
33
+
34
+ def type_params: () -> AST::Declarations::ModuleTypeParams
35
+
36
+ def primary: () -> D[module_decl]
37
+ end
38
+
39
+ class ModuleEntry < MultiEntry
40
+ attr_reader decls: Array[MultiEntry::D[AST::Declarations::Module]]
41
+ attr_reader primary: MultiEntry::D[AST::Declarations::Module]
42
+
43
+ def self_types: () -> Array[AST::Declarations::Module::Self]
44
+ end
45
+
46
+ class ClassEntry < MultiEntry
47
+ attr_reader decls: Array[MultiEntry::D[AST::Declarations::Class]]
48
+ attr_reader primary: MultiEntry::D[AST::Declarations::Class]
49
+ end
50
+
51
+ class SingleEntry[N, D]
52
+ include ContextUtil
53
+
54
+ attr_reader name: N
55
+ attr_reader decl: D
56
+ attr_reader outer: Array[module_decl]
57
+
58
+ def initialize: (name: N, decl: D, outer: Array[module_decl]) -> void
59
+ end
60
+
61
+ attr_reader buffers: Array[Buffer]
62
+ attr_reader declarations: Array[AST::Declarations::t]
63
+
64
+ attr_reader class_decls: Hash[TypeName, ModuleEntry | ClassEntry]
65
+ attr_reader interface_decls: Hash[TypeName, SingleEntry[TypeName, AST::Declarations::Interface]]
66
+ attr_reader alias_decls: Hash[TypeName, SingleEntry[TypeName, AST::Declarations::Alias]]
67
+ attr_reader constant_decls: Hash[TypeName, SingleEntry[TypeName, AST::Declarations::Constant]]
68
+ attr_reader global_decls: Hash[Symbol, SingleEntry[Symbol, AST::Declarations::Global]]
69
+
70
+ def initialize: () -> void
71
+
72
+ def initialize_copy: (Environment) -> void
73
+
74
+ def self.from_loader: (EnvironmentLoader) -> Environment
75
+
76
+ def cache_name: [Key, D] (Hash[Key, SingleEntry[Key, D]] cache, name: Key, decl: D, outer: Array[module_decl]) -> SingleEntry[Key, D]
77
+
78
+ def insert_decl: (AST::Declarations::t, outer: Array[module_decl], namespace: Namespace) -> void
79
+
80
+ def <<: (AST::Declarations::t decl) -> self
81
+
82
+ def resolve_type_names: () -> Environment
83
+
84
+ def resolve_declaration: (TypeNameResolver resolver, AST::Declarations::t decl, outer: Array[module_decl], prefix: Namespace) -> AST::Declarations::t
85
+
86
+ def resolve_member: (TypeNameResolver, AST::Members::t, context: Array[Namespace]) -> AST::Members::t
87
+
88
+ def absolute_type: (TypeNameResolver, Types::t, context: Array[Namespace]) -> Types::t
89
+
90
+ def absolute_type_name: (TypeNameResolver, TypeName, context: Array[Namespace]) -> TypeName
91
+
92
+ def inspect: () -> String
93
+ end
94
+ end
@@ -0,0 +1,4 @@
1
+ module RBS
2
+ class EnvironmentLoader
3
+ end
4
+ end
@@ -0,0 +1,52 @@
1
+ module RBS
2
+ # Location is the range on buffer, `start_pos..end_pos`.
3
+ # The index is based on characters.
4
+ class Location
5
+ # The buffer this location points on.
6
+ attr_reader buffer: Buffer
7
+
8
+ # The index of character the range starts from.
9
+ attr_reader start_pos: Integer
10
+
11
+ # The index of character the range ends at.
12
+ attr_reader end_pos: Integer
13
+
14
+ def initialize: (buffer: Buffer, start_pos: Integer, end_pos: Integer) -> void
15
+
16
+ def inspect: () -> ::String
17
+
18
+ def name: () -> untyped
19
+
20
+ def start_line: () -> Integer
21
+
22
+ def start_column: () -> Integer
23
+
24
+ def end_line: () -> Integer
25
+
26
+ def end_column: () -> Integer
27
+
28
+ def start_loc: () -> Buffer::loc
29
+
30
+ def end_loc: () -> Buffer::loc
31
+
32
+ def source: () -> String
33
+
34
+ def to_s: () -> String
35
+
36
+ def self.to_string: (Location? location, ?default: ::String default) -> String
37
+
38
+ def ==: (untyped other) -> bool
39
+
40
+ def +: (Location other) -> Location
41
+
42
+ def pred?: (Location loc) -> bool
43
+
44
+ def to_json: (*untyped args) -> untyped
45
+
46
+ # `<<` locations given as argument.
47
+ def concat: (*Location?) -> Location
48
+
49
+ # Append given location destructively.
50
+ def <<: (Location?) -> Location
51
+ end
52
+ end
@@ -0,0 +1,160 @@
1
+ module RBS
2
+ module AST
3
+ module Members
4
+ type t = MethodDefinition
5
+ | InstanceVariable | ClassInstanceVariable | ClassVariable
6
+ | Include | Extend | Prepend
7
+ | AttrReader | AttrWriter | AttrAccessor
8
+ | Public | Private
9
+ | Alias
10
+
11
+ # Base class for members.
12
+ class Base
13
+ end
14
+
15
+ class MethodDefinition < Base
16
+ type kind = :instance | :singleton | :singleton_instance
17
+
18
+ attr_reader name: Symbol
19
+ attr_reader kind: kind
20
+ attr_reader types: Array[MethodType]
21
+ attr_reader annotations: Array[Annotation]
22
+ attr_reader location: Location?
23
+ attr_reader comment: Comment?
24
+ attr_reader overload: bool
25
+
26
+ def initialize: (name: Symbol, kind: kind, types: Array[MethodType], annotations: Array[Annotation], location: Location?, comment: Comment?, overload: bool) -> void
27
+
28
+ include _HashEqual
29
+ include _ToJson
30
+
31
+ def instance?: () -> bool
32
+
33
+ def singleton?: () -> bool
34
+
35
+ def overload?: () -> bool
36
+
37
+ def update: (?name: Symbol, ?kind: kind, ?types: Array[MethodType], ?annotations: Array[Annotation], ?location: Location?, ?comment: Comment?, ?overload: bool) -> MethodDefinition
38
+ end
39
+
40
+ module Var
41
+ attr_reader name: Symbol
42
+ attr_reader type: Types::t
43
+ attr_reader location: Location?
44
+ attr_reader comment: Comment?
45
+
46
+ def initialize: (name: Symbol, type: Types::t, location: Location?, comment: Comment?) -> void
47
+
48
+ include _HashEqual
49
+ end
50
+
51
+ class InstanceVariable < Base
52
+ include Var
53
+ include _ToJson
54
+ end
55
+
56
+ class ClassInstanceVariable < Base
57
+ include Var
58
+ include _ToJson
59
+ end
60
+
61
+ class ClassVariable < Base
62
+ include Var
63
+ include _ToJson
64
+ end
65
+
66
+ module Mixin
67
+ attr_reader name: TypeName
68
+ attr_reader args: Array[Types::t]
69
+ attr_reader annotations: Array[Annotation]
70
+ attr_reader location: Location?
71
+ attr_reader comment: Comment?
72
+
73
+ def initialize: (name: TypeName, args: Array[Types::t], annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
74
+
75
+ include _HashEqual
76
+ end
77
+
78
+ class Include < Base
79
+ include Mixin
80
+ include _ToJson
81
+ end
82
+
83
+ class Extend < Base
84
+ include Mixin
85
+ include _ToJson
86
+ end
87
+
88
+ class Prepend < Base
89
+ include Mixin
90
+ include _ToJson
91
+ end
92
+
93
+ module Attribute
94
+ attr_reader name: Symbol
95
+ attr_reader type: Types::t
96
+ attr_reader ivar_name: Symbol | false | nil
97
+ attr_reader annotations: Array[Annotation]
98
+ attr_reader location: Location?
99
+ attr_reader comment: Comment?
100
+
101
+ def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
102
+
103
+ include _HashEqual
104
+ end
105
+
106
+ class AttrReader < Base
107
+ include Attribute
108
+ include _ToJson
109
+ end
110
+
111
+ class AttrAccessor < Base
112
+ include Attribute
113
+ include _ToJson
114
+ end
115
+
116
+ class AttrWriter < Base
117
+ include Attribute
118
+ include _ToJson
119
+ end
120
+
121
+ module LocationOnly
122
+ attr_reader location: Location?
123
+
124
+ def initialize: (location: Location?) -> void
125
+
126
+ include _HashEqual
127
+ end
128
+
129
+ class Public < Base
130
+ include LocationOnly
131
+ include _ToJson
132
+ end
133
+
134
+ class Private < Base
135
+ include LocationOnly
136
+ include _ToJson
137
+ end
138
+
139
+ class Alias < Base
140
+ type kind = :instance | :singleton
141
+
142
+ attr_reader new_name: Symbol
143
+ attr_reader old_name: Symbol
144
+ attr_reader kind: kind
145
+ attr_reader annotations: Array[Annotation]
146
+ attr_reader location: Location?
147
+ attr_reader comment: Comment?
148
+
149
+ def initialize: (new_name: Symbol, old_name: Symbol, kind: kind, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
150
+
151
+ include _HashEqual
152
+ include _ToJson
153
+
154
+ def instance?: () -> bool
155
+
156
+ def singleton?: () -> bool
157
+ end
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,40 @@
1
+ module RBS
2
+ class MethodType
3
+ class Block
4
+ attr_reader type: Types::Function
5
+ attr_reader required: bool
6
+
7
+ def initialize: (type: Types::Function, required: bool) -> void
8
+
9
+ def ==: (untyped other) -> bool
10
+
11
+ def to_json: (*untyped) -> String
12
+
13
+ def sub: (Substitution) -> Block
14
+ end
15
+
16
+ attr_reader type_params: Array[Symbol]
17
+ attr_reader type: Types::Function
18
+ attr_reader block: Block?
19
+ attr_reader location: Location?
20
+
21
+ def initialize: (type_params: Array[Symbol], type: Types::Function, block: Block?, location: Location?) -> void
22
+
23
+ def ==: (untyped other) -> bool
24
+
25
+ def to_json: (*untyped) -> String
26
+
27
+ def sub: (Substitution) -> MethodType
28
+
29
+ def update: (?type_params: Array[Symbol], ?type: Types::Function, ?block: Block?, ?location: Location?) -> MethodType
30
+
31
+ def free_variables: (?Set[Symbol] set) -> Set[Symbol]
32
+
33
+ def map_type: () { (Types::t) -> Types::t } -> MethodType
34
+
35
+ def each_type: () { (Types::t) -> void } -> void
36
+ | () -> Enumerator[Types::t, void]
37
+
38
+ def to_s: () -> String
39
+ end
40
+ end