rbs 1.6.1 → 1.7.0.beta.3
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/.github/workflows/ruby.yml +18 -3
- data/.gitignore +10 -1
- data/CHANGELOG.md +25 -0
- data/Gemfile +1 -0
- data/Rakefile +22 -22
- data/core/enumerator.rbs +1 -0
- data/core/io.rbs +1 -1
- data/core/kernel.rbs +4 -4
- data/core/trace_point.rbs +1 -1
- data/ext/rbs_extension/constants.c +139 -0
- data/ext/rbs_extension/constants.h +72 -0
- data/ext/rbs_extension/extconf.rb +3 -0
- data/ext/rbs_extension/lexer.c +2533 -0
- data/ext/rbs_extension/lexer.h +161 -0
- data/ext/rbs_extension/lexer.re +140 -0
- data/ext/rbs_extension/lexstate.c +139 -0
- data/ext/rbs_extension/location.c +295 -0
- data/ext/rbs_extension/location.h +59 -0
- data/ext/rbs_extension/main.c +9 -0
- data/ext/rbs_extension/parser.c +2390 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +313 -0
- data/ext/rbs_extension/parserstate.h +141 -0
- data/ext/rbs_extension/rbs_extension.h +40 -0
- data/ext/rbs_extension/ruby_objs.c +521 -0
- data/ext/rbs_extension/ruby_objs.h +46 -0
- data/ext/rbs_extension/unescape.c +65 -0
- data/goodcheck.yml +1 -1
- data/lib/rbs/ast/comment.rb +0 -12
- data/lib/rbs/buffer.rb +4 -0
- data/lib/rbs/cli.rb +5 -8
- data/lib/rbs/collection/installer.rb +1 -0
- data/lib/rbs/collection/sources/git.rb +18 -3
- data/lib/rbs/errors.rb +28 -1
- data/lib/rbs/location.rb +221 -217
- data/lib/rbs/location_aux.rb +121 -0
- data/lib/rbs/locator.rb +10 -7
- data/lib/rbs/parser_aux.rb +63 -0
- data/lib/rbs/parser_compat/lexer_error.rb +4 -0
- data/lib/rbs/parser_compat/located_value.rb +5 -0
- data/lib/rbs/parser_compat/semantics_error.rb +4 -0
- data/lib/rbs/parser_compat/syntax_error.rb +4 -0
- data/lib/rbs/types.rb +2 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -2
- data/lib/rbs.rb +14 -7
- data/rbs.gemspec +2 -1
- data/sig/ancestor_builder.rbs +2 -2
- data/sig/annotation.rbs +2 -2
- data/sig/comment.rbs +7 -7
- data/sig/constant_table.rbs +1 -1
- data/sig/declarations.rbs +9 -9
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +2 -2
- data/sig/errors.rbs +40 -25
- data/sig/location.rbs +46 -78
- data/sig/locator.rbs +2 -2
- data/sig/members.rbs +7 -7
- data/sig/method_types.rbs +3 -3
- data/sig/parser.rbs +15 -20
- data/sig/rbs.rbs +4 -0
- data/sig/types.rbs +45 -27
- data/sig/writer.rbs +1 -1
- data/stdlib/io-console/0/io-console.rbs +137 -0
- data/stdlib/json/0/json.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +2 -1
- data/stdlib/tempfile/0/tempfile.rbs +4 -6
- metadata +32 -7
- data/lib/rbs/parser.rb +0 -3614
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'digest/sha2'
|
2
2
|
require 'open3'
|
3
|
+
require 'find'
|
3
4
|
|
4
5
|
module RBS
|
5
6
|
module Collection
|
@@ -52,12 +53,26 @@ module RBS
|
|
52
53
|
private def _install(dest:, config_entry:)
|
53
54
|
gem_name = config_entry['name']
|
54
55
|
version = config_entry['version'] or raise
|
55
|
-
dest = dest.join(gem_name)
|
56
|
+
dest = dest.join(gem_name, version)
|
56
57
|
dest.mkpath
|
57
58
|
src = gem_repo_dir.join(gem_name, version)
|
58
59
|
|
59
|
-
|
60
|
-
dest.join(
|
60
|
+
cp_r(src, dest)
|
61
|
+
dest.join(METADATA_FILENAME).write(YAML.dump(config_entry))
|
62
|
+
end
|
63
|
+
|
64
|
+
private def cp_r(src, dest)
|
65
|
+
Find.find(src) do |file_src|
|
66
|
+
file_src = Pathname(file_src)
|
67
|
+
|
68
|
+
# Skip file if it starts with _, such as _test/
|
69
|
+
Find.prune if file_src.basename.to_s.start_with?('_')
|
70
|
+
|
71
|
+
file_src_relative = file_src.relative_path_from(src)
|
72
|
+
file_dest = dest.join(file_src_relative)
|
73
|
+
file_dest.dirname.mkpath
|
74
|
+
FileUtils.copy_entry(file_src, file_dest, false, true) unless file_src.directory?
|
75
|
+
end
|
61
76
|
end
|
62
77
|
|
63
78
|
def to_lockfile
|
data/lib/rbs/errors.rb
CHANGED
@@ -15,10 +15,37 @@ module RBS
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class ErrorBase < StandardError; end
|
18
|
-
class ParsingError < ErrorBase; end
|
19
18
|
class LoadingError < ErrorBase; end
|
20
19
|
class DefinitionError < ErrorBase; end
|
21
20
|
|
21
|
+
class ParsingError < ErrorBase
|
22
|
+
attr_reader :location
|
23
|
+
attr_reader :error_message
|
24
|
+
attr_reader :token_type
|
25
|
+
|
26
|
+
def initialize(location, error_message, token_type)
|
27
|
+
@location = location
|
28
|
+
@error_message = error_message
|
29
|
+
@token_type = token_type
|
30
|
+
|
31
|
+
super "#{Location.to_string location}: Syntax error: #{error_message}, token=`#{location.source}` (#{token_type})"
|
32
|
+
end
|
33
|
+
|
34
|
+
def error_value
|
35
|
+
RBS.print_warning {
|
36
|
+
"#{self.class.name}#error_value is deprecated and will be deleted in RBS 2.0. Consider using `location.source` instead."
|
37
|
+
}
|
38
|
+
location.source
|
39
|
+
end
|
40
|
+
|
41
|
+
def token_str
|
42
|
+
RBS.print_warning {
|
43
|
+
"#{self.class.name}#token_str is deprecated and will be deleted in RBS 2.0. Consider using `token_type` instead."
|
44
|
+
}
|
45
|
+
token_type
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
22
49
|
class InvalidTypeApplicationError < DefinitionError
|
23
50
|
attr_reader :type_name
|
24
51
|
attr_reader :args
|
data/lib/rbs/location.rb
CHANGED
@@ -1,217 +1,221 @@
|
|
1
|
-
module RBS
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
1
|
+
# module RBS
|
2
|
+
# class Location
|
3
|
+
# attr_reader :buffer
|
4
|
+
# attr_reader :start_pos
|
5
|
+
# attr_reader :end_pos
|
6
|
+
|
7
|
+
# def initialize(buffer, start_pos, end_pos)
|
8
|
+
# @buffer = buffer
|
9
|
+
# @start_pos = start_pos
|
10
|
+
# @end_pos = end_pos
|
11
|
+
# end
|
12
|
+
|
13
|
+
# # def self.new(buffer_ = nil, start_pos_ = nil, end_pos_ = nil)
|
14
|
+
# # __skip__ = super(buffer_, start_pos_, end_pos_)
|
15
|
+
# # end
|
16
|
+
|
17
|
+
# # def inspect
|
18
|
+
# # "#<#{self.class}:#{self.__id__} @buffer=#{buffer.name}, @pos=#{start_pos}...#{end_pos}, source='#{source.lines.first}', start_line=#{start_line}, start_column=#{start_column}>"
|
19
|
+
# # end
|
20
|
+
|
21
|
+
# def name
|
22
|
+
# buffer.name
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def start_line
|
26
|
+
# start_loc[0]
|
27
|
+
# end
|
28
|
+
|
29
|
+
# def start_column
|
30
|
+
# start_loc[1]
|
31
|
+
# end
|
32
|
+
|
33
|
+
# def end_line
|
34
|
+
# end_loc[0]
|
35
|
+
# end
|
36
|
+
|
37
|
+
# def end_column
|
38
|
+
# end_loc[1]
|
39
|
+
# end
|
40
|
+
|
41
|
+
# def start_loc
|
42
|
+
# @start_loc ||= buffer.pos_to_loc(start_pos)
|
43
|
+
# end
|
44
|
+
|
45
|
+
# def end_loc
|
46
|
+
# @end_loc ||= buffer.pos_to_loc(end_pos)
|
47
|
+
# end
|
48
|
+
|
49
|
+
# def range
|
50
|
+
# start_pos...end_pos
|
51
|
+
# end
|
52
|
+
|
53
|
+
# def source
|
54
|
+
# @source ||= buffer.content[start_pos...end_pos] or raise
|
55
|
+
# end
|
56
|
+
|
57
|
+
# def to_s
|
58
|
+
# "#{name || "-"}:#{start_line}:#{start_column}...#{end_line}:#{end_column}"
|
59
|
+
# end
|
60
|
+
|
61
|
+
# def self.to_string(location, default: "*:*:*...*:*")
|
62
|
+
# location&.to_s || default
|
63
|
+
# end
|
64
|
+
|
65
|
+
# def ==(other)
|
66
|
+
# other.is_a?(Location) &&
|
67
|
+
# other.buffer == buffer &&
|
68
|
+
# other.start_pos == start_pos &&
|
69
|
+
# other.end_pos == end_pos
|
70
|
+
# end
|
71
|
+
|
72
|
+
# def +(other)
|
73
|
+
# if other
|
74
|
+
# raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
|
75
|
+
|
76
|
+
# self.class.new(buffer: buffer,
|
77
|
+
# start_pos: start_pos,
|
78
|
+
# end_pos: other.end_pos)
|
79
|
+
# else
|
80
|
+
# self
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
|
84
|
+
# def concat(*others)
|
85
|
+
# others.each { |other| self << other }
|
86
|
+
# self
|
87
|
+
# end
|
88
|
+
|
89
|
+
# def <<(other)
|
90
|
+
# if other
|
91
|
+
# raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
|
92
|
+
# @end_pos = other.end_pos
|
93
|
+
# @source = nil
|
94
|
+
# @end_loc = nil
|
95
|
+
# end
|
96
|
+
# self
|
97
|
+
# end
|
98
|
+
|
99
|
+
# def pred?(loc)
|
100
|
+
# loc.is_a?(Location) &&
|
101
|
+
# loc.name == name &&
|
102
|
+
# loc.start_pos == end_pos
|
103
|
+
# end
|
104
|
+
|
105
|
+
# def to_json(state = _ = nil)
|
106
|
+
# {
|
107
|
+
# start: {
|
108
|
+
# line: start_line,
|
109
|
+
# column: start_column
|
110
|
+
# },
|
111
|
+
# end: {
|
112
|
+
# line: end_line,
|
113
|
+
# column: end_column
|
114
|
+
# },
|
115
|
+
# buffer: {
|
116
|
+
# name: name&.to_s
|
117
|
+
# }
|
118
|
+
# }.to_json(state)
|
119
|
+
# end
|
120
|
+
|
121
|
+
# def with_children(required: {}, optional: {})
|
122
|
+
# # @type var required: Hash[Symbol, Range[Integer] | Location]
|
123
|
+
# # @type var optional: Hash[Symbol, Range[Integer] | Location | nil]
|
124
|
+
|
125
|
+
# this = WithChildren.new(buffer: buffer, start_pos: start_pos, end_pos: end_pos)
|
126
|
+
|
127
|
+
# req = required.transform_values do |value|
|
128
|
+
# case value
|
129
|
+
# when Location
|
130
|
+
# value.range
|
131
|
+
# else
|
132
|
+
# value
|
133
|
+
# end
|
134
|
+
# end
|
135
|
+
|
136
|
+
# opt = optional.transform_values do |value|
|
137
|
+
# case value
|
138
|
+
# when Location
|
139
|
+
# value.range
|
140
|
+
# else
|
141
|
+
# value
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
|
145
|
+
# this.required_children.merge!(req)
|
146
|
+
# this.optional_children.merge!(opt)
|
147
|
+
|
148
|
+
# this
|
149
|
+
# end
|
150
|
+
|
151
|
+
# class WithChildren < Location
|
152
|
+
# attr_reader :required_children, :optional_children
|
153
|
+
|
154
|
+
# def initialize(buffer, start_pos, end_pos)
|
155
|
+
# super(buffer, start_pos, end_pos)
|
156
|
+
|
157
|
+
# @optional_children = {}
|
158
|
+
# @required_children = {}
|
159
|
+
# end
|
160
|
+
|
161
|
+
# def initialize_copy(from)
|
162
|
+
# required_children.merge!(from.required_children)
|
163
|
+
# optional_children.merge!(from.optional_children)
|
164
|
+
# self
|
165
|
+
# end
|
166
|
+
|
167
|
+
# def [](key)
|
168
|
+
# case
|
169
|
+
# when required_children.key?(_ = key)
|
170
|
+
# range = required_children[_ = key]
|
171
|
+
# Location.new(buffer: buffer, start_pos: range.begin, end_pos: range.end)
|
172
|
+
# when optional_children.key?(_ = key)
|
173
|
+
# range = required_children[_ = key] || optional_children[_ = key]
|
174
|
+
# if range
|
175
|
+
# Location.new(buffer: buffer, start_pos: range.begin, end_pos: range.end)
|
176
|
+
# end
|
177
|
+
# else
|
178
|
+
# raise "Unknown key given: `#{key}`"
|
179
|
+
# end
|
180
|
+
# end
|
181
|
+
|
182
|
+
# def merge_required(hash)
|
183
|
+
# this = dup
|
184
|
+
|
185
|
+
# h = hash.transform_values do |value|
|
186
|
+
# case value
|
187
|
+
# when Range
|
188
|
+
# value
|
189
|
+
# when Location
|
190
|
+
# value.range
|
191
|
+
# else
|
192
|
+
# raise
|
193
|
+
# end
|
194
|
+
# end
|
195
|
+
|
196
|
+
# this.required_children.merge!(h)
|
197
|
+
|
198
|
+
# this
|
199
|
+
# end
|
200
|
+
|
201
|
+
# def merge_optional(hash)
|
202
|
+
# this = dup
|
203
|
+
|
204
|
+
# h = hash.transform_values do |value|
|
205
|
+
# case value
|
206
|
+
# when Range
|
207
|
+
# value
|
208
|
+
# when Location
|
209
|
+
# value.range
|
210
|
+
# else
|
211
|
+
# nil
|
212
|
+
# end
|
213
|
+
# end
|
214
|
+
|
215
|
+
# this.optional_children.merge!(h)
|
216
|
+
|
217
|
+
# this
|
218
|
+
# end
|
219
|
+
# end
|
220
|
+
# end
|
221
|
+
# end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module RBS
|
2
|
+
class Location
|
3
|
+
def inspect
|
4
|
+
rks = each_required_key.to_a
|
5
|
+
ops = each_optional_key.to_a.map {|x| "?#{x}" }
|
6
|
+
"#<#{self.class}:#{self.__id__} buffer=#{buffer.name}, start=#{start_line}:#{start_column}, pos=#{start_pos}...#{end_pos}, children=#{(rks + ops).join(",")} source='#{source.lines.first&.chomp}'>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.new(buffer_ = nil, start_pos_ = nil, end_pos_ = nil, buffer: nil, start_pos: nil, end_pos: nil)
|
10
|
+
__skip__ =
|
11
|
+
begin
|
12
|
+
if buffer && start_pos && end_pos
|
13
|
+
super(buffer, start_pos, end_pos)
|
14
|
+
else
|
15
|
+
super(buffer_, start_pos_, end_pos_)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
WithChildren = self
|
21
|
+
|
22
|
+
def name
|
23
|
+
buffer.name
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_line
|
27
|
+
start_loc[0]
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_column
|
31
|
+
start_loc[1]
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_line
|
35
|
+
end_loc[0]
|
36
|
+
end
|
37
|
+
|
38
|
+
def end_column
|
39
|
+
end_loc[1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def start_loc
|
43
|
+
@start_loc ||= begin
|
44
|
+
_start_loc || buffer.pos_to_loc(start_pos)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def end_loc
|
49
|
+
@end_loc ||= begin
|
50
|
+
_end_loc || buffer.pos_to_loc(end_pos)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def range
|
55
|
+
@range ||= start_pos...end_pos
|
56
|
+
end
|
57
|
+
|
58
|
+
def source
|
59
|
+
@source ||= buffer.content[range] or raise
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_s
|
63
|
+
"#{name || "-"}:#{start_line}:#{start_column}...#{end_line}:#{end_column}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def ==(other)
|
67
|
+
other.is_a?(Location) &&
|
68
|
+
other.buffer == buffer &&
|
69
|
+
other.start_pos == start_pos &&
|
70
|
+
other.end_pos == end_pos
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_json(state = _ = nil)
|
74
|
+
{
|
75
|
+
start: {
|
76
|
+
line: start_line,
|
77
|
+
column: start_column
|
78
|
+
},
|
79
|
+
end: {
|
80
|
+
line: end_line,
|
81
|
+
column: end_column
|
82
|
+
},
|
83
|
+
buffer: {
|
84
|
+
name: name&.to_s
|
85
|
+
}
|
86
|
+
}.to_json(state)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.to_string(location, default: "*:*:*...*:*")
|
90
|
+
location&.to_s || default
|
91
|
+
end
|
92
|
+
|
93
|
+
def add_required_child(name, range)
|
94
|
+
_add_required_child(name, range.begin, range.end)
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_optional_child(name, range)
|
98
|
+
if range
|
99
|
+
_add_optional_child(name, range.begin, range.end)
|
100
|
+
else
|
101
|
+
_add_optional_no_child(name);
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def each_optional_key(&block)
|
106
|
+
if block
|
107
|
+
_optional_keys.uniq.each(&block)
|
108
|
+
else
|
109
|
+
enum_for(:each_optional_key)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def each_required_key(&block)
|
114
|
+
if block
|
115
|
+
_required_keys.uniq.each(&block)
|
116
|
+
else
|
117
|
+
enum_for(:each_required_key)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/rbs/locator.rb
CHANGED
@@ -172,16 +172,19 @@ module RBS
|
|
172
172
|
|
173
173
|
def find_in_loc(pos, location:, array:)
|
174
174
|
if test_loc(pos, location: location)
|
175
|
-
if location.is_a?(Location
|
176
|
-
location.
|
177
|
-
if
|
178
|
-
|
179
|
-
|
175
|
+
if location.is_a?(Location)
|
176
|
+
location.each_optional_key do |key|
|
177
|
+
if loc = location[key]
|
178
|
+
if loc.range === pos
|
179
|
+
array.unshift(key)
|
180
|
+
return true
|
181
|
+
end
|
180
182
|
end
|
181
183
|
end
|
182
184
|
|
183
|
-
location.
|
184
|
-
|
185
|
+
location.each_required_key do |key|
|
186
|
+
loc = location[key] or raise
|
187
|
+
if loc.range === pos
|
185
188
|
array.unshift(key)
|
186
189
|
return true
|
187
190
|
end
|