rbs 1.5.1 → 1.7.0.beta.1

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +10 -0
  3. data/.github/workflows/ruby.yml +0 -4
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +51 -0
  6. data/Gemfile +2 -0
  7. data/Rakefile +7 -22
  8. data/Steepfile +9 -1
  9. data/core/enumerator.rbs +1 -0
  10. data/core/io.rbs +3 -1
  11. data/core/kernel.rbs +4 -4
  12. data/core/trace_point.rbs +1 -1
  13. data/docs/collection.md +116 -0
  14. data/ext/rbs/extension/constants.c +140 -0
  15. data/ext/rbs/extension/constants.h +72 -0
  16. data/ext/rbs/extension/extconf.rb +3 -0
  17. data/ext/rbs/extension/lexer.c +1070 -0
  18. data/ext/rbs/extension/lexer.h +145 -0
  19. data/ext/rbs/extension/location.c +295 -0
  20. data/ext/rbs/extension/location.h +59 -0
  21. data/ext/rbs/extension/main.c +9 -0
  22. data/ext/rbs/extension/parser.c +2418 -0
  23. data/ext/rbs/extension/parser.h +23 -0
  24. data/ext/rbs/extension/parserstate.c +313 -0
  25. data/ext/rbs/extension/parserstate.h +141 -0
  26. data/ext/rbs/extension/rbs_extension.h +40 -0
  27. data/ext/rbs/extension/ruby_objs.c +585 -0
  28. data/ext/rbs/extension/ruby_objs.h +46 -0
  29. data/ext/rbs/extension/unescape.c +65 -0
  30. data/goodcheck.yml +1 -1
  31. data/lib/rbs/ast/comment.rb +0 -12
  32. data/lib/rbs/buffer.rb +4 -0
  33. data/lib/rbs/builtin_names.rb +1 -0
  34. data/lib/rbs/cli.rb +98 -10
  35. data/lib/rbs/collection/cleaner.rb +29 -0
  36. data/lib/rbs/collection/config/lockfile_generator.rb +95 -0
  37. data/lib/rbs/collection/config.rb +85 -0
  38. data/lib/rbs/collection/installer.rb +27 -0
  39. data/lib/rbs/collection/sources/git.rb +162 -0
  40. data/lib/rbs/collection/sources/rubygems.rb +40 -0
  41. data/lib/rbs/collection/sources/stdlib.rb +38 -0
  42. data/lib/rbs/collection/sources.rb +22 -0
  43. data/lib/rbs/collection.rb +13 -0
  44. data/lib/rbs/environment_loader.rb +12 -0
  45. data/lib/rbs/errors.rb +16 -1
  46. data/lib/rbs/location.rb +221 -217
  47. data/lib/rbs/location_aux.rb +108 -0
  48. data/lib/rbs/locator.rb +10 -7
  49. data/lib/rbs/parser_aux.rb +24 -0
  50. data/lib/rbs/repository.rb +13 -7
  51. data/lib/rbs/types.rb +2 -3
  52. data/lib/rbs/validator.rb +4 -1
  53. data/lib/rbs/version.rb +1 -1
  54. data/lib/rbs/writer.rb +4 -2
  55. data/lib/rbs.rb +4 -7
  56. data/rbs.gemspec +2 -1
  57. data/sig/ancestor_builder.rbs +2 -2
  58. data/sig/annotation.rbs +2 -2
  59. data/sig/builtin_names.rbs +1 -0
  60. data/sig/cli.rbs +5 -0
  61. data/sig/collection/cleaner.rbs +13 -0
  62. data/sig/collection/collections.rbs +112 -0
  63. data/sig/collection/config.rbs +69 -0
  64. data/sig/collection/installer.rbs +15 -0
  65. data/sig/collection.rbs +4 -0
  66. data/sig/comment.rbs +7 -7
  67. data/sig/constant_table.rbs +1 -1
  68. data/sig/declarations.rbs +9 -9
  69. data/sig/definition.rbs +1 -1
  70. data/sig/definition_builder.rbs +2 -2
  71. data/sig/environment_loader.rbs +3 -0
  72. data/sig/errors.rbs +30 -25
  73. data/sig/location.rbs +42 -79
  74. data/sig/locator.rbs +2 -2
  75. data/sig/members.rbs +7 -7
  76. data/sig/method_types.rbs +3 -3
  77. data/sig/parser.rbs +11 -21
  78. data/sig/polyfill.rbs +12 -3
  79. data/sig/repository.rbs +4 -0
  80. data/sig/types.rbs +45 -27
  81. data/sig/writer.rbs +1 -1
  82. data/stdlib/json/0/json.rbs +3 -3
  83. data/stdlib/objspace/0/objspace.rbs +406 -0
  84. data/stdlib/openssl/0/openssl.rbs +1 -1
  85. data/stdlib/tempfile/0/tempfile.rbs +270 -0
  86. data/steep/Gemfile.lock +10 -10
  87. metadata +43 -7
  88. data/lib/rbs/parser.rb +0 -3614
@@ -0,0 +1,4 @@
1
+ module RBS
2
+ module Collection
3
+ end
4
+ end
data/sig/comment.rbs CHANGED
@@ -2,15 +2,17 @@ module RBS
2
2
  module AST
3
3
  # RBS allows writing documentation of declarations and members.
4
4
  #
5
- # # This is a doc for class.
6
- # class Hello
7
- # end
5
+ # ```
6
+ # # This is a doc for class.
7
+ # class Hello
8
+ # end
9
+ # ```
8
10
  #
9
11
  class Comment
10
12
  attr_reader string: String
11
- attr_reader location: Location?
13
+ attr_reader location: Location[bot, bot]?
12
14
 
13
- def initialize: (string: String, location: Location?) -> void
15
+ def initialize: (string: String, location: Location[bot, bot]?) -> void
14
16
 
15
17
  def ==: (untyped other) -> bool
16
18
 
@@ -19,8 +21,6 @@ module RBS
19
21
  def hash: () -> Integer
20
22
 
21
23
  include _ToJson
22
-
23
- def concat: (string: String, location: Location?) -> self
24
24
  end
25
25
  end
26
26
  end
@@ -9,7 +9,7 @@ module RBS
9
9
 
10
10
  def absolute_type: (Types::t, context: Array[Namespace]) -> Types::t
11
11
 
12
- def absolute_type_name: (TypeName, context: Array[Namespace], location: Location?) -> TypeName
12
+ def absolute_type_name: (TypeName, context: Array[Namespace], location: Location[untyped, untyped]?) -> TypeName
13
13
 
14
14
  def name_to_constant: (TypeName) -> Constant?
15
15
 
data/sig/declarations.rbs CHANGED
@@ -17,7 +17,7 @@ module RBS
17
17
  # ^^^^^^^^^ unchecked
18
18
  # ^^^ variance
19
19
  # ^^^^ name
20
- type loc = Location::WithChildren[:name, :variance | :unchecked]
20
+ type loc = Location[:name, :variance | :unchecked]
21
21
 
22
22
  attr_reader name: Symbol
23
23
  attr_reader variance: variance
@@ -86,7 +86,7 @@ module RBS
86
86
  # ^^^^^ name
87
87
  # ^^^^^^^^ args
88
88
  #
89
- type loc = Location::WithChildren[:name, :args]
89
+ type loc = Location[:name, :args]
90
90
 
91
91
  attr_reader name: TypeName
92
92
  attr_reader args: Array[Types::t]
@@ -112,7 +112,7 @@ module RBS
112
112
  # ^ lt
113
113
  # ^^^ end
114
114
  #
115
- type loc = Location::WithChildren[:keyword | :name | :end, :type_params | :lt]
115
+ type loc = Location[:keyword | :name | :end, :type_params | :lt]
116
116
 
117
117
  include NestedDeclarationHelper
118
118
  include MixinHelper
@@ -137,7 +137,7 @@ module RBS
137
137
  # ^^^^^ name
138
138
  # ^^^^^^^^ args
139
139
  #
140
- type loc = Location::WithChildren[:name, :args]
140
+ type loc = Location[:name, :args]
141
141
 
142
142
  attr_reader name: TypeName
143
143
  attr_reader args: Array[Types::t]
@@ -166,7 +166,7 @@ module RBS
166
166
  # ^^^^^^^^^^^ self_types
167
167
  # ^^^ end
168
168
  #
169
- type loc = Location::WithChildren[:keyword | :name | :end, :type_params | :colon | :self_types]
169
+ type loc = Location[:keyword | :name | :end, :type_params | :colon | :self_types]
170
170
 
171
171
  include NestedDeclarationHelper
172
172
  include MixinHelper
@@ -199,7 +199,7 @@ module RBS
199
199
  # ^^^^^^ type_params
200
200
  # ^^^ end
201
201
  #
202
- type loc = Location::WithChildren[:name | :keyword | :end, :type_params]
202
+ type loc = Location[:name | :keyword | :end, :type_params]
203
203
 
204
204
  attr_reader name: TypeName
205
205
  attr_reader type_params: ModuleTypeParams
@@ -221,7 +221,7 @@ module RBS
221
221
  # ^^^^ keyword
222
222
  # ^^^ name
223
223
  # ^ eq
224
- type loc = Location::WithChildren[:keyword | :name | :eq, bot]
224
+ type loc = Location[:keyword | :name | :eq, bot]
225
225
 
226
226
  attr_reader name: TypeName
227
227
  attr_reader type: Types::t
@@ -240,7 +240,7 @@ module RBS
240
240
  # ^^^^^^^ name
241
241
  # ^ colon
242
242
  #
243
- type loc = Location::WithChildren[:name | :colon, bot]
243
+ type loc = Location[:name | :colon, bot]
244
244
 
245
245
  attr_reader name: TypeName
246
246
  attr_reader type: Types::t
@@ -258,7 +258,7 @@ module RBS
258
258
  # ^^^^^ name
259
259
  # ^ colon
260
260
  #
261
- type loc = Location::WithChildren[:name | :colon, bot]
261
+ type loc = Location[:name | :colon, bot]
262
262
 
263
263
  attr_reader name: Symbol
264
264
  attr_reader type: Types::t
data/sig/definition.rbs CHANGED
@@ -90,7 +90,7 @@ module RBS
90
90
 
91
91
  def initialize: (type_name: TypeName, params: Array[Symbol], ancestors: Array[Ancestor::t]) -> void
92
92
 
93
- def apply: (Array[Types::t], location: Location?) -> Array[Ancestor::t]
93
+ def apply: (Array[Types::t], location: Location[untyped, untyped]?) -> Array[Ancestor::t]
94
94
  end
95
95
 
96
96
  class SingletonAncestors
@@ -14,7 +14,7 @@ module RBS
14
14
 
15
15
  def validate_super_class!: (TypeName, Environment::ClassEntry) -> void
16
16
 
17
- def ensure_namespace!: (Namespace, location: Location?) -> void
17
+ def ensure_namespace!: (Namespace, location: Location[untyped, untyped]?) -> void
18
18
 
19
19
  def build_interface: (TypeName) -> Definition
20
20
 
@@ -37,7 +37,7 @@ module RBS
37
37
 
38
38
  def validate_type_params: (Definition, ancestors: AncestorBuilder::OneAncestors, methods: MethodBuilder::Methods) -> void
39
39
 
40
- def source_location: (Definition::Ancestor::Instance::source, AST::Declarations::t) -> Location?
40
+ def source_location: (Definition::Ancestor::Instance::source, AST::Declarations::t) -> Location[untyped, untyped]?
41
41
 
42
42
  def insert_variable: (TypeName, Hash[Symbol, Definition::Variable], name: Symbol, type: Types::t) -> void
43
43
 
@@ -78,6 +78,9 @@ module RBS
78
78
  def add: (path: Pathname) -> void
79
79
  | (library: String, version: String?) -> void
80
80
 
81
+ # Add repository path and libraries via rbs_collection.lock.yaml.
82
+ def add_collection: (Collection::Config collection_config) -> void
83
+
81
84
  # This is helper function to test if RBS for a library is available or not.
82
85
  #
83
86
  def has_library?: (library: String, version: String?) -> bool
data/sig/errors.rbs CHANGED
@@ -19,6 +19,11 @@ module RBS
19
19
  # Error class for errors raised during parsing.
20
20
  #
21
21
  class ParsingError < BaseError
22
+ attr_reader location: Location[untyped, untyped]
23
+ attr_reader error_message: String
24
+ attr_reader token_type: String
25
+
26
+ def initialize: (Location[untyped, untyped], String error_message, String token_type) -> void
22
27
  end
23
28
 
24
29
  # Error class for errors raised during loading environments.
@@ -35,45 +40,45 @@ module RBS
35
40
  attr_reader type_name: TypeName
36
41
  attr_reader args: Array[Types::t]
37
42
  attr_reader params: Array[Symbol]
38
- attr_reader location: Location?
43
+ attr_reader location: Location[untyped, untyped]?
39
44
 
40
- def initialize: (type_name: TypeName, args: Array[Types::t], params: Array[Symbol], location: Location?) -> void
45
+ def initialize: (type_name: TypeName, args: Array[Types::t], params: Array[Symbol], location: Location[untyped, untyped]?) -> void
41
46
 
42
- def self.check!: (type_name: TypeName, args: Array[Types::t], params: Array[Symbol], location: Location?) -> void
47
+ def self.check!: (type_name: TypeName, args: Array[Types::t], params: Array[Symbol], location: Location[untyped, untyped]?) -> void
43
48
  end
44
49
 
45
50
  class RecursiveAncestorError < DefinitionError
46
51
  attr_reader ancestors: Array[Definition::Ancestor::t]
47
- attr_reader location: Location?
52
+ attr_reader location: Location[untyped, untyped]?
48
53
 
49
- def initialize: (ancestors: Array[Definition::Ancestor::t], location: Location?) -> void
54
+ def initialize: (ancestors: Array[Definition::Ancestor::t], location: Location[untyped, untyped]?) -> void
50
55
 
51
- def self.check!: (Definition::Ancestor::t, ancestors: Array[Definition::Ancestor::t], location: Location?) -> void
56
+ def self.check!: (Definition::Ancestor::t, ancestors: Array[Definition::Ancestor::t], location: Location[untyped, untyped]?) -> void
52
57
  end
53
58
 
54
59
  class NoTypeFoundError < DefinitionError
55
60
  attr_reader type_name: TypeName
56
- attr_reader location: Location?
61
+ attr_reader location: Location[untyped, untyped]?
57
62
 
58
- def initialize: (type_name: TypeName, location: Location?) -> void
63
+ def initialize: (type_name: TypeName, location: Location[untyped, untyped]?) -> void
59
64
 
60
- def self.check!: (TypeName, env: Environment, location: Location?) -> TypeName
65
+ def self.check!: (TypeName, env: Environment, location: Location[untyped, untyped]?) -> TypeName
61
66
  end
62
67
 
63
68
  class NoSuperclassFoundError < DefinitionError
64
69
  attr_reader type_name: TypeName
65
- attr_reader location: Location?
70
+ attr_reader location: Location[untyped, untyped]?
66
71
 
67
- def initialize: (type_name: TypeName, location: Location?) -> void
72
+ def initialize: (type_name: TypeName, location: Location[untyped, untyped]?) -> void
68
73
 
69
- def self.check!: (TypeName, env: Environment, location: Location?) -> void
74
+ def self.check!: (TypeName, env: Environment, location: Location[untyped, untyped]?) -> void
70
75
  end
71
76
 
72
77
  class NoSelfTypeFoundError < DefinitionError
73
78
  attr_reader type_name: TypeName
74
- attr_reader location: Location?
79
+ attr_reader location: Location[untyped, untyped]?
75
80
 
76
- def initialize: (type_name: TypeName, location: Location?) -> void
81
+ def initialize: (type_name: TypeName, location: Location[untyped, untyped]?) -> void
77
82
 
78
83
  def self.check!: (AST::Declarations::Module::Self, env: Environment) -> void
79
84
  end
@@ -84,7 +89,7 @@ module RBS
84
89
 
85
90
  def initialize: (type_name: TypeName, member: AST::Members::t) -> void
86
91
 
87
- def location: () -> Location?
92
+ def location: () -> Location[untyped, untyped]?
88
93
 
89
94
  def self.check!: (TypeName, env: Environment, member: AST::Members::t) -> void
90
95
  end
@@ -103,9 +108,9 @@ module RBS
103
108
 
104
109
  def qualified_method_name: () -> String
105
110
 
106
- def location: () -> Location?
111
+ def location: () -> Location[untyped, untyped]?
107
112
 
108
- def other_locations: () -> Array[Location?]
113
+ def other_locations: () -> Array[Location[untyped, untyped]?]
109
114
  end
110
115
 
111
116
  class DuplicatedInterfaceMethodDefinitionError < DefinitionError
@@ -127,9 +132,9 @@ module RBS
127
132
  attr_reader type_name: TypeName
128
133
  attr_reader original_name: Symbol
129
134
  attr_reader aliased_name: Symbol
130
- attr_reader location: Location?
135
+ attr_reader location: Location[untyped, untyped]?
131
136
 
132
- def initialize: (type_name: TypeName, original_name: Symbol, aliased_name: Symbol, location: Location?) -> void
137
+ def initialize: (type_name: TypeName, original_name: Symbol, aliased_name: Symbol, location: Location[untyped, untyped]?) -> void
133
138
  end
134
139
 
135
140
  class SuperclassMismatchError < DefinitionError
@@ -165,9 +170,9 @@ module RBS
165
170
  class InvalidVarianceAnnotationError < DefinitionError
166
171
  attr_reader type_name: TypeName
167
172
  attr_reader param: AST::Declarations::ModuleTypeParams::TypeParam
168
- attr_reader location: Location?
173
+ attr_reader location: Location[untyped, untyped]?
169
174
 
170
- def initialize: (type_name: TypeName, param: AST::Declarations::ModuleTypeParams::TypeParam, location: Location?) -> void
175
+ def initialize: (type_name: TypeName, param: AST::Declarations::ModuleTypeParams::TypeParam, location: Location[untyped, untyped]?) -> void
171
176
  end
172
177
 
173
178
  class RecursiveAliasDefinitionError < DefinitionError
@@ -179,7 +184,7 @@ module RBS
179
184
 
180
185
  def initialize: (type: ty, defs: Array[defn]) -> void
181
186
 
182
- def location: () -> Location?
187
+ def location: () -> Location[untyped, untyped]?
183
188
  end
184
189
 
185
190
  class MixinClassError < DefinitionError
@@ -190,7 +195,7 @@ module RBS
190
195
 
191
196
  def initialize: (type_name: TypeName, member: member) -> void
192
197
 
193
- def location: () -> Location?
198
+ def location: () -> Location[untyped, untyped]?
194
199
 
195
200
  def self.check!: (type_name: TypeName, env: Environment, member: member) -> void
196
201
 
@@ -199,9 +204,9 @@ module RBS
199
204
 
200
205
  class RecursiveTypeAliasError < LoadingError
201
206
  attr_reader alias_names: Array[TypeName]
202
- attr_reader location: Location
207
+ attr_reader location: Location[untyped, untyped]?
203
208
 
204
- def initialize: (alias_names: Array[TypeName], location: Location) -> void
209
+ def initialize: (alias_names: Array[TypeName], location: Location[untyped, untyped]?) -> void
205
210
 
206
211
  def name: () -> String
207
212
  end
data/sig/location.rbs CHANGED
@@ -1,17 +1,24 @@
1
1
  module RBS
2
2
  # Location is the range on buffer, `start_pos..end_pos`.
3
3
  # The index is based on characters.
4
- class Location
4
+ #
5
+ # A location can have _child_ locations.
6
+ #
7
+ # ```
8
+ #
9
+ # ```
10
+ #
11
+ class Location[RequiredChildKeys, OptionalChildKeys]
5
12
  # The buffer this location points on.
6
- attr_reader buffer: Buffer
13
+ attr_reader buffer (): Buffer
7
14
 
8
15
  # The index of character the range starts from.
9
- attr_reader start_pos: Integer
16
+ attr_reader start_pos (): Integer
10
17
 
11
18
  # The index of character the range ends at.
12
- attr_reader end_pos: Integer
19
+ attr_reader end_pos (): Integer
13
20
 
14
- def initialize: (buffer: Buffer, start_pos: Integer, end_pos: Integer) -> void
21
+ def initialize: (Buffer, Integer start_pos, Integer end_pos) -> void
15
22
 
16
23
  def inspect: () -> String
17
24
 
@@ -19,22 +26,22 @@ module RBS
19
26
  def name: () -> untyped
20
27
 
21
28
  # Line of the `start_pos` (1 origin)
22
- def start_line: () -> Integer
29
+ attr_reader start_line (): Integer
23
30
 
24
31
  # Column of the `start_pos` (0 origin)
25
- def start_column: () -> Integer
32
+ attr_reader start_column (): Integer
26
33
 
27
34
  # Line of the `end_pos` (1 origin)
28
- def end_line: () -> Integer
35
+ attr_reader end_line (): Integer
29
36
 
30
37
  # Column of the `end_pos` (0 origin)
31
- def end_column: () -> Integer
38
+ attr_reader end_column (): Integer
32
39
 
33
- def start_loc: () -> Buffer::loc
40
+ attr_reader start_loc (): Buffer::loc
34
41
 
35
- def end_loc: () -> Buffer::loc
42
+ attr_reader end_loc (): Buffer::loc
36
43
 
37
- def range: () -> Range[Integer]
44
+ attr_reader range (): Range[Integer]
38
45
 
39
46
  # A substring of buffer associated to the location.
40
47
  def source: () -> String
@@ -46,88 +53,44 @@ module RBS
46
53
  # Location.to_string(loc) # => a.rb:1:0...3:4
47
54
  # Location.to_string(nil) # => *:*:*..*:*
48
55
  #
49
- def self.to_string: (Location? location, ?default: ::String default) -> String
56
+ def self.to_string: (Location[untyped, untyped]? location, ?default: ::String default) -> String
50
57
 
51
58
  def ==: (untyped other) -> bool
52
59
 
53
- # Returns a new location with starting positionof `self` and ending position of `other`.
54
- #
55
- # l1 = Location.new(buffer: buffer, start_pos: 0, end_pox: x)
56
- # l2 = Location.new(buffer: buffer, start_pos: y, end_pos: 20)
57
- # l1 + l2 # => Location.new(buffer: buffer, start_pos: 0, end_pos: 20)
58
- #
59
- def +: (Location other) -> Location
60
-
61
- # Returns true if `loc` is exact predecessor of `self`.
62
- #
63
- # l1 = Location.new(...) # 0..10
64
- # l2 = Location.new(...) # 10..13
65
- # l3 = Location.new(...) # 13..20
66
- #
67
- # l1.pred?(l2) # => true
68
- # l2.pred?(l3) # => true
69
- # l1.pred?(l3) # => false
70
- #
71
- def pred?: (Location loc) -> bool
72
-
73
60
  include _ToJson
74
61
 
75
- # `<<` locations given as argument.
76
- #
77
- def concat: (*Location?) -> Location
78
-
79
- # Inplace version of `+`.
80
- #
81
- def <<: (Location?) -> Location
62
+ def add_optional_child: (OptionalChildKeys name, Range[Integer]? range) -> void
82
63
 
83
- # Returns WithChildren instance with given children.
84
- #
85
- # location.with_children(
86
- # required: { name: name.location },
87
- # optional: { args: nil }
88
- # )
89
- #
90
- def with_children: [R, O](?required: Hash[R, Range[Integer] | Location], ?optional: Hash[O, Range[Integer] | Location | nil]) -> WithChildren[R, O]
64
+ def add_required_child: (RequiredChildKeys name, Range[Integer] range) -> void
91
65
 
92
- # Location::WithChildren contains _child_ locations.
66
+ # Returns `Location` instance for given _child_ name.
93
67
  #
94
- # # Array[String]
95
- # # ^^^^^ <= name
96
- # # ^^^^^^^^ <= args
97
- # #
98
68
  # # @type var loc: Location::WithChildren[:name, :args]
99
- # loc = Location::WithChildren.new(buffer: buffer, start_pos: 0, end_pos: 13)
100
- # loc = loc.merge_required({ name: 1...5 })
101
- # loc = loc.merge_optional({ args: 5...13 })
69
+ # loc[:name] # => Location
70
+ # loc[:args] # => may be nil
102
71
  #
103
- # loc[:name] # => Location instance for `Array`
104
- # loc[:args] # => Location instance for `[String]`
72
+ # Note that passing unknown symbol raises an error even if the child is _optional_.
73
+ # You need explicitly set `nil` for absent optional children.
105
74
  #
106
- class WithChildren[RequiredChildKeys, OptionalChildKeys] < Location
107
- attr_reader required_children: Hash[RequiredChildKeys, Range[Integer]]
108
-
109
- attr_reader optional_children: Hash[OptionalChildKeys, Range[Integer]?]
75
+ def []: (RequiredChildKeys) -> Location[bot, bot]
76
+ | (OptionalChildKeys) -> Location[bot, bot]?
77
+ | (Symbol) -> Location[bot, bot]?
110
78
 
111
- def initialize: ...
79
+ def each_optional_key: () { (Symbol) -> void } -> void
80
+ | () -> Enumerator[Symbol, void]
112
81
 
113
- def initialize_copy: ...
82
+ def each_required_key: () { (Symbol) -> void } -> void
83
+ | () -> Enumerator[Symbol, void]
114
84
 
115
- # Returns `Location` instance for given _child_ name.
116
- #
117
- # # @type var loc: Location::WithChildren[:name, :args]
118
- # loc[:name] # => Location
119
- # loc[:args] # => may be nil
120
- #
121
- # Note that passing unknown symbol raises an error even if the child is _optional_.
122
- # You need explicitly set `nil` for absent optional children.
123
- #
124
- def []: (RequiredChildKeys) -> Location
125
- | (OptionalChildKeys) -> Location?
126
- | (Symbol) -> Location?
85
+ private
127
86
 
128
- def merge_required: (Hash[RequiredChildKeys, Range[Integer] | Location]) -> self
87
+ def _start_loc: () -> Buffer::loc?
88
+ def _end_loc: () -> Buffer::loc?
129
89
 
130
- def merge_optional: (Hash[OptionalChildKeys, Range[Integer] | Location | nil]) -> self
131
- end
90
+ def _add_required_child: (RequiredChildKeys name, Integer start_pos, Integer end_pos) -> void
91
+ def _add_optional_child: (OptionalChildKeys name, Integer start_pos, Integer end_pos) -> void
92
+ def _add_optional_no_child: (OptionalChildKeys name) -> void
93
+ def _optional_keys: () -> Array[Symbol]
94
+ def _required_keys: () -> Array[Symbol]
132
95
  end
133
96
  end