steep 0.13.0 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +28 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep.rb +33 -1
- data/lib/steep/annotation_parser.rb +4 -4
- data/lib/steep/ast/buffer.rb +11 -7
- data/lib/steep/ast/builtin.rb +8 -0
- data/lib/steep/ast/types/factory.rb +124 -89
- data/lib/steep/cli.rb +16 -1
- data/lib/steep/drivers/annotations.rb +1 -1
- data/lib/steep/drivers/check.rb +20 -4
- data/lib/steep/drivers/init.rb +5 -5
- data/lib/steep/drivers/langserver.rb +13 -287
- data/lib/steep/drivers/utils/driver_helper.rb +1 -1
- data/lib/steep/drivers/vendor.rb +2 -2
- data/lib/steep/drivers/watch.rb +97 -85
- data/lib/steep/drivers/worker.rb +51 -0
- data/lib/steep/project.rb +9 -5
- data/lib/steep/project/completion_provider.rb +298 -0
- data/lib/steep/project/dsl.rb +14 -0
- data/lib/steep/project/file.rb +54 -47
- data/lib/steep/project/hover_content.rb +17 -8
- data/lib/steep/project/options.rb +25 -3
- data/lib/steep/project/target.rb +40 -24
- data/lib/steep/server/base_worker.rb +56 -0
- data/lib/steep/server/code_worker.rb +151 -0
- data/lib/steep/server/interaction_worker.rb +281 -0
- data/lib/steep/server/master.rb +196 -0
- data/lib/steep/server/signature_worker.rb +148 -0
- data/lib/steep/server/utils.rb +36 -0
- data/lib/steep/server/worker_process.rb +62 -0
- data/lib/steep/signature/errors.rb +1 -1
- data/lib/steep/signature/validator.rb +13 -13
- data/lib/steep/source.rb +1 -1
- data/lib/steep/type_construction.rb +1004 -727
- data/lib/steep/type_inference/constant_env.rb +3 -11
- data/lib/steep/type_inference/context.rb +8 -3
- data/lib/steep/type_inference/context_array.rb +111 -0
- data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
- data/lib/steep/type_inference/logic.rb +130 -0
- data/lib/steep/type_inference/type_env.rb +5 -69
- data/lib/steep/typing.rb +91 -23
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/Steepfile +1 -0
- data/smoke/alias/a.rb +1 -1
- data/smoke/and/Steepfile +1 -0
- data/smoke/array/Steepfile +1 -0
- data/smoke/array/b.rb +0 -2
- data/smoke/block/Steepfile +1 -0
- data/smoke/case/Steepfile +1 -0
- data/smoke/class/Steepfile +1 -0
- data/smoke/const/Steepfile +1 -0
- data/smoke/dstr/Steepfile +1 -0
- data/smoke/ensure/Steepfile +1 -0
- data/smoke/enumerator/Steepfile +1 -0
- data/smoke/extension/Steepfile +1 -0
- data/smoke/extension/c.rb +1 -0
- data/smoke/hash/Steepfile +1 -0
- data/smoke/hello/Steepfile +1 -0
- data/smoke/if/Steepfile +1 -0
- data/smoke/if/a.rb +1 -1
- data/smoke/implements/Steepfile +1 -0
- data/smoke/initialize/Steepfile +1 -0
- data/smoke/integer/Steepfile +1 -0
- data/smoke/interface/Steepfile +1 -0
- data/smoke/kwbegin/Steepfile +1 -0
- data/smoke/lambda/Steepfile +1 -0
- data/smoke/literal/Steepfile +1 -0
- data/smoke/map/Steepfile +1 -0
- data/smoke/method/Steepfile +1 -0
- data/smoke/module/Steepfile +1 -0
- data/smoke/regexp/Steepfile +1 -0
- data/smoke/regexp/b.rb +4 -4
- data/smoke/regression/Steepfile +1 -0
- data/smoke/rescue/Steepfile +1 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +1 -0
- data/smoke/skip/Steepfile +1 -0
- data/smoke/stdout/Steepfile +1 -0
- data/smoke/super/Steepfile +1 -0
- data/smoke/type_case/Steepfile +1 -0
- data/smoke/yield/Steepfile +1 -0
- data/steep.gemspec +8 -8
- metadata +38 -138
- data/exe/rbs +0 -3
- data/exe/ruby-signature +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -66
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -88
- data/vendor/ruby-signature/bin/test_runner.rb +0 -17
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -3
- data/vendor/ruby-signature/exe/ruby-signature +0 -7
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -534
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1343
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -441
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -324
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
- data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -35
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -419
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -193
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -476
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -121
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -141
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -426
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -10
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -131
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -770
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -77
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,364 +0,0 @@
|
|
1
|
-
module Ruby
|
2
|
-
module Signature
|
3
|
-
module AST
|
4
|
-
module Members
|
5
|
-
class MethodDefinition
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :kind
|
8
|
-
attr_reader :types
|
9
|
-
attr_reader :annotations
|
10
|
-
attr_reader :location
|
11
|
-
attr_reader :comment
|
12
|
-
attr_reader :attributes
|
13
|
-
|
14
|
-
def initialize(name:, kind:, types:, annotations:, location:, comment:, attributes:)
|
15
|
-
@name = name
|
16
|
-
@kind = kind
|
17
|
-
@types = types
|
18
|
-
@annotations = annotations
|
19
|
-
@location = location
|
20
|
-
@comment = comment
|
21
|
-
@attributes = attributes
|
22
|
-
end
|
23
|
-
|
24
|
-
def ==(other)
|
25
|
-
other.is_a?(MethodDefinition) &&
|
26
|
-
other.name == name &&
|
27
|
-
other.kind == kind &&
|
28
|
-
other.types == types &&
|
29
|
-
other.attributes == attributes
|
30
|
-
end
|
31
|
-
|
32
|
-
alias eql? ==
|
33
|
-
|
34
|
-
def hash
|
35
|
-
self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ attributes.hash
|
36
|
-
end
|
37
|
-
|
38
|
-
def instance?
|
39
|
-
kind == :instance || kind == :singleton_instance
|
40
|
-
end
|
41
|
-
|
42
|
-
def singleton?
|
43
|
-
kind == :singleton || kind == :singleton_instance
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_json(*a)
|
47
|
-
{
|
48
|
-
member: :method_definition,
|
49
|
-
kind: kind,
|
50
|
-
types: types,
|
51
|
-
annotations: annotations,
|
52
|
-
location: location,
|
53
|
-
comment: comment,
|
54
|
-
attributes: attributes
|
55
|
-
}.to_json(*a)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
module Var
|
60
|
-
attr_reader :name
|
61
|
-
attr_reader :type
|
62
|
-
attr_reader :location
|
63
|
-
attr_reader :comment
|
64
|
-
|
65
|
-
def initialize(name:, type:, location:, comment:)
|
66
|
-
@name = name
|
67
|
-
@type = type
|
68
|
-
@location = location
|
69
|
-
@comment = comment
|
70
|
-
end
|
71
|
-
|
72
|
-
def ==(other)
|
73
|
-
other.is_a?(self.class) && other.name == name && other.type == type
|
74
|
-
end
|
75
|
-
|
76
|
-
alias eql? ==
|
77
|
-
|
78
|
-
def hash
|
79
|
-
self.class.hash ^ name.hash ^ type.hash
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
class InstanceVariable
|
84
|
-
include Var
|
85
|
-
|
86
|
-
def to_json(*a)
|
87
|
-
{
|
88
|
-
member: :instance_variable,
|
89
|
-
name: name,
|
90
|
-
type: type,
|
91
|
-
location: location,
|
92
|
-
comment: comment
|
93
|
-
}.to_json(*a)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class ClassInstanceVariable
|
98
|
-
include Var
|
99
|
-
|
100
|
-
def to_json(*a)
|
101
|
-
{
|
102
|
-
member: :class_instance_variable,
|
103
|
-
name: name,
|
104
|
-
type: type,
|
105
|
-
location: location,
|
106
|
-
comment: comment
|
107
|
-
}.to_json(*a)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class ClassVariable
|
112
|
-
include Var
|
113
|
-
|
114
|
-
def to_json(*a)
|
115
|
-
{
|
116
|
-
member: :class_variable,
|
117
|
-
name: name,
|
118
|
-
type: type,
|
119
|
-
location: location,
|
120
|
-
comment: comment
|
121
|
-
}.to_json(*a)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
module Mixin
|
126
|
-
attr_reader :name
|
127
|
-
attr_reader :args
|
128
|
-
attr_reader :annotations
|
129
|
-
attr_reader :location
|
130
|
-
attr_reader :comment
|
131
|
-
|
132
|
-
def initialize(name:, args:, annotations:, location:, comment:)
|
133
|
-
@name = name
|
134
|
-
@args = args
|
135
|
-
@annotations = annotations
|
136
|
-
@location = location
|
137
|
-
@comment = comment
|
138
|
-
end
|
139
|
-
|
140
|
-
def ==(other)
|
141
|
-
other.is_a?(self.class) && other.name == name && other.args == args
|
142
|
-
end
|
143
|
-
|
144
|
-
def eql?(other)
|
145
|
-
self == other
|
146
|
-
end
|
147
|
-
|
148
|
-
def hash
|
149
|
-
self.class.hash ^ name.hash ^ args.hash
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
class Include
|
154
|
-
include Mixin
|
155
|
-
|
156
|
-
def to_json(*a)
|
157
|
-
{
|
158
|
-
member: :include,
|
159
|
-
name: name,
|
160
|
-
args: args,
|
161
|
-
annotations: annotations,
|
162
|
-
location: location,
|
163
|
-
comment: comment
|
164
|
-
}.to_json(*a)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
class Extend
|
169
|
-
include Mixin
|
170
|
-
|
171
|
-
def to_json(*a)
|
172
|
-
{
|
173
|
-
member: :extend,
|
174
|
-
name: name,
|
175
|
-
args: args,
|
176
|
-
annotations: annotations,
|
177
|
-
location: location,
|
178
|
-
comment: comment
|
179
|
-
}.to_json(*a)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
class Prepend
|
184
|
-
include Mixin
|
185
|
-
|
186
|
-
def to_json(*a)
|
187
|
-
{
|
188
|
-
member: :prepend,
|
189
|
-
name: name,
|
190
|
-
args: args,
|
191
|
-
annotations: annotations,
|
192
|
-
location: location,
|
193
|
-
comment: comment
|
194
|
-
}.to_json(*a)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
module Attribute
|
199
|
-
attr_reader :name
|
200
|
-
attr_reader :type
|
201
|
-
attr_reader :ivar_name
|
202
|
-
attr_reader :annotations
|
203
|
-
attr_reader :location
|
204
|
-
attr_reader :comment
|
205
|
-
|
206
|
-
def initialize(name:, type:, ivar_name:, annotations:, location:, comment:)
|
207
|
-
@name = name
|
208
|
-
@type = type
|
209
|
-
@ivar_name = ivar_name
|
210
|
-
@annotations = annotations
|
211
|
-
@location = location
|
212
|
-
@comment = comment
|
213
|
-
end
|
214
|
-
|
215
|
-
def ==(other)
|
216
|
-
other.is_a?(self.class) &&
|
217
|
-
other.name == name &&
|
218
|
-
other.type == type &&
|
219
|
-
other.ivar_name == ivar_name
|
220
|
-
end
|
221
|
-
|
222
|
-
alias eql? ==
|
223
|
-
|
224
|
-
def hash
|
225
|
-
self.class.hash ^ name.hash ^ type.hash ^ ivar_name.hash
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
class AttrReader
|
230
|
-
include Attribute
|
231
|
-
|
232
|
-
def to_json(*a)
|
233
|
-
{
|
234
|
-
member: :attr_reader,
|
235
|
-
name: name,
|
236
|
-
type: type,
|
237
|
-
ivar_name: ivar_name,
|
238
|
-
annotations: annotations,
|
239
|
-
location: location,
|
240
|
-
comment: comment
|
241
|
-
}.to_json(*a)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
class AttrAccessor
|
246
|
-
include Attribute
|
247
|
-
|
248
|
-
def to_json(*a)
|
249
|
-
{
|
250
|
-
member: :attr_accessor,
|
251
|
-
name: name,
|
252
|
-
type: type,
|
253
|
-
ivar_name: ivar_name,
|
254
|
-
annotations: annotations,
|
255
|
-
location: location,
|
256
|
-
comment: comment
|
257
|
-
}.to_json(*a)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
class AttrWriter
|
262
|
-
include Attribute
|
263
|
-
|
264
|
-
def to_json(*a)
|
265
|
-
{
|
266
|
-
member: :attr_writer,
|
267
|
-
name: name,
|
268
|
-
type: type,
|
269
|
-
ivar_name: ivar_name,
|
270
|
-
annotations: annotations,
|
271
|
-
location: location,
|
272
|
-
comment: comment
|
273
|
-
}.to_json(*a)
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
module LocationOnly
|
278
|
-
attr_reader :location
|
279
|
-
|
280
|
-
def initialize(location:)
|
281
|
-
@location = location
|
282
|
-
end
|
283
|
-
|
284
|
-
def ==(other)
|
285
|
-
other.is_a?(self.class)
|
286
|
-
end
|
287
|
-
|
288
|
-
alias eql? ==
|
289
|
-
|
290
|
-
def hash
|
291
|
-
self.class.hash
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
class Public
|
296
|
-
include LocationOnly
|
297
|
-
|
298
|
-
def to_json(*a)
|
299
|
-
{ member: :public, location: location }.to_json(*a)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
class Private
|
304
|
-
include LocationOnly
|
305
|
-
|
306
|
-
def to_json(*a)
|
307
|
-
{ member: :private, location: location }.to_json(*a)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
class Alias
|
312
|
-
attr_reader :new_name
|
313
|
-
attr_reader :old_name
|
314
|
-
attr_reader :kind
|
315
|
-
attr_reader :annotations
|
316
|
-
attr_reader :location
|
317
|
-
attr_reader :comment
|
318
|
-
|
319
|
-
def initialize(new_name:, old_name:, kind:, annotations:, location:, comment:)
|
320
|
-
@new_name = new_name
|
321
|
-
@old_name = old_name
|
322
|
-
@kind = kind
|
323
|
-
@annotations = annotations
|
324
|
-
@location = location
|
325
|
-
@comment = comment
|
326
|
-
end
|
327
|
-
|
328
|
-
def ==(other)
|
329
|
-
other.is_a?(self.class) &&
|
330
|
-
other.new_name == new_name &&
|
331
|
-
other.old_name == old_name &&
|
332
|
-
other.kind == kind
|
333
|
-
end
|
334
|
-
|
335
|
-
alias eql? ==
|
336
|
-
|
337
|
-
def hash
|
338
|
-
self.class.hash ^ new_name.hash ^ old_name.hash ^ kind.hash
|
339
|
-
end
|
340
|
-
|
341
|
-
def to_json(*a)
|
342
|
-
{
|
343
|
-
member: :alias,
|
344
|
-
new_name: new_name,
|
345
|
-
old_name: old_name,
|
346
|
-
kind: kind,
|
347
|
-
annotations: annotations,
|
348
|
-
location: location,
|
349
|
-
comment: comment
|
350
|
-
}.to_json(*a)
|
351
|
-
end
|
352
|
-
|
353
|
-
def instance?
|
354
|
-
kind == :instance
|
355
|
-
end
|
356
|
-
|
357
|
-
def singleton?
|
358
|
-
kind == :singleton
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Ruby
|
2
|
-
module Signature
|
3
|
-
class Buffer
|
4
|
-
attr_reader :name
|
5
|
-
attr_reader :content
|
6
|
-
attr_reader :lines
|
7
|
-
attr_reader :ranges
|
8
|
-
|
9
|
-
def initialize(name:, content:)
|
10
|
-
@name = name
|
11
|
-
@content = content
|
12
|
-
|
13
|
-
@lines = content.lines
|
14
|
-
|
15
|
-
@ranges = []
|
16
|
-
offset = 0
|
17
|
-
lines.each do |line|
|
18
|
-
size = line.size
|
19
|
-
range = offset...(offset+size)
|
20
|
-
ranges << range
|
21
|
-
offset += size
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def pos_to_loc(pos)
|
26
|
-
index = ranges.bsearch_index do |range|
|
27
|
-
pos < range.end
|
28
|
-
end
|
29
|
-
|
30
|
-
if index
|
31
|
-
[index + 1, pos - ranges[index].begin]
|
32
|
-
else
|
33
|
-
[ranges.size + 1, 0]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def loc_to_pos(loc)
|
38
|
-
line, column = loc
|
39
|
-
|
40
|
-
if range = ranges[line - 1]
|
41
|
-
range.begin + column
|
42
|
-
else
|
43
|
-
last_position
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def last_position
|
48
|
-
content.size
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Ruby
|
2
|
-
module Signature
|
3
|
-
module BuiltinNames
|
4
|
-
class Name
|
5
|
-
attr_reader :name
|
6
|
-
|
7
|
-
def initialize(name:)
|
8
|
-
@name = name
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_s
|
12
|
-
name.to_s
|
13
|
-
end
|
14
|
-
|
15
|
-
def instance_type(*args)
|
16
|
-
Types::ClassInstance.new(name: name, args: args, location: nil)
|
17
|
-
end
|
18
|
-
|
19
|
-
def instance_type?(type)
|
20
|
-
type.is_a?(Types::ClassInstance) && type.name == name
|
21
|
-
end
|
22
|
-
|
23
|
-
def singleton_type
|
24
|
-
@singleton_type ||= Types::ClassSingleton.new(name: name, location: nil)
|
25
|
-
end
|
26
|
-
|
27
|
-
def singleton_type?(type)
|
28
|
-
type.is_a?(Types::ClassSingleton) && type.name == name
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.define(name, namespace: Namespace.root)
|
32
|
-
new(name: TypeName.new(name: name, namespace: namespace))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
BasicObject = Name.new(name: TypeName.new(name: :BasicObject, namespace: Namespace.root))
|
37
|
-
Object = Name.new(name: TypeName.new(name: :Object, namespace: Namespace.root))
|
38
|
-
Kernel = Name.new(name: TypeName.new(name: :Kernel, namespace: Namespace.root))
|
39
|
-
String = Name.define(:String)
|
40
|
-
Comparable = Name.define(:Comparable)
|
41
|
-
Enumerable = Name.define(:Enumerable)
|
42
|
-
Class = Name.define(:Class)
|
43
|
-
Module = Name.define(:Module)
|
44
|
-
Array = Name.define(:Array)
|
45
|
-
Hash = Name.define(:Hash)
|
46
|
-
Range = Name.define(:Range)
|
47
|
-
Enumerator = Name.define(:Enumerator)
|
48
|
-
Set = Name.define(:Set)
|
49
|
-
Symbol = Name.define(:Symbol)
|
50
|
-
Integer = Name.define(:Integer)
|
51
|
-
Float = Name.define(:Float)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|