rbs 2.1.0 → 2.2.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/comments.yml +34 -0
- data/CHANGELOG.md +45 -0
- data/Rakefile +52 -21
- data/core/encoding.rbs +742 -0
- data/core/file.rbs +1 -3
- data/core/kernel.rbs +5 -3
- data/docs/syntax.md +54 -11
- data/ext/rbs_extension/extconf.rb +1 -0
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexstate.c +6 -0
- data/ext/rbs_extension/parser.c +85 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/goodcheck.yml +0 -11
- data/lib/rbs/annotate/rdoc_annotator.rb +2 -2
- data/lib/rbs/ast/members.rb +21 -13
- data/lib/rbs/buffer.rb +17 -11
- data/lib/rbs/cli.rb +5 -2
- data/lib/rbs/definition_builder/method_builder.rb +28 -16
- data/lib/rbs/definition_builder.rb +1 -1
- data/lib/rbs/environment.rb +8 -4
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +1 -1
- data/lib/rbs/validator.rb +2 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +54 -4
- data/lib/rbs.rb +0 -2
- data/schema/typeParam.json +3 -3
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/buffer.rbs +6 -2
- data/sig/members.rbs +24 -18
- data/sig/method_builder.rbs +5 -4
- data/sig/writer.rbs +79 -2
- data/stdlib/net-http/0/manifest.yaml +1 -0
- data/stdlib/net-http/0/net-http.rbs +21 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +35 -0
- metadata +3 -3
- data/sig/char_scanner.rbs +0 -9
@@ -10,7 +10,11 @@ module RBS
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def accessibility
|
13
|
-
|
13
|
+
if original.is_a?(AST::Members::Alias)
|
14
|
+
raise "alias member doesn't have accessibility"
|
15
|
+
else
|
16
|
+
accessibilities[0] or raise
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def self.empty(name:, type:)
|
@@ -102,22 +106,32 @@ module RBS
|
|
102
106
|
each_member_with_accessibility(d.decl.members) do |member, accessibility|
|
103
107
|
case member
|
104
108
|
when AST::Members::MethodDefinition
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
case member.kind
|
110
|
+
when :instance
|
111
|
+
build_method(
|
112
|
+
methods,
|
113
|
+
type,
|
114
|
+
member: member.update(types: member.types.map {|type| type.sub(subst) }),
|
115
|
+
accessibility: member.visibility || accessibility
|
116
|
+
)
|
117
|
+
when :singleton_instance
|
118
|
+
build_method(
|
119
|
+
methods,
|
120
|
+
type,
|
121
|
+
member: member.update(types: member.types.map {|type| type.sub(subst) }),
|
122
|
+
accessibility: :private
|
123
|
+
)
|
110
124
|
end
|
111
125
|
when AST::Members::AttrReader, AST::Members::AttrWriter, AST::Members::AttrAccessor
|
112
126
|
if member.kind == :instance
|
113
127
|
build_attribute(methods,
|
114
128
|
type,
|
115
129
|
member: member.update(type: member.type.sub(subst)),
|
116
|
-
accessibility: accessibility)
|
130
|
+
accessibility: member.visibility || accessibility)
|
117
131
|
end
|
118
132
|
when AST::Members::Alias
|
119
133
|
if member.kind == :instance
|
120
|
-
build_alias(methods, type, member: member
|
134
|
+
build_alias(methods, type, member: member)
|
121
135
|
end
|
122
136
|
end
|
123
137
|
end
|
@@ -134,19 +148,19 @@ module RBS
|
|
134
148
|
|
135
149
|
Methods.new(type: type).tap do |methods|
|
136
150
|
entry.decls.each do |d|
|
137
|
-
|
151
|
+
d.decl.members.each do |member|
|
138
152
|
case member
|
139
153
|
when AST::Members::MethodDefinition
|
140
154
|
if member.singleton?
|
141
|
-
build_method(methods, type, member: member, accessibility:
|
155
|
+
build_method(methods, type, member: member, accessibility: member.visibility || :public)
|
142
156
|
end
|
143
157
|
when AST::Members::AttrReader, AST::Members::AttrWriter, AST::Members::AttrAccessor
|
144
158
|
if member.kind == :singleton
|
145
|
-
build_attribute(methods, type, member: member, accessibility:
|
159
|
+
build_attribute(methods, type, member: member, accessibility: member.visibility || :public)
|
146
160
|
end
|
147
161
|
when AST::Members::Alias
|
148
162
|
if member.kind == :singleton
|
149
|
-
build_alias(methods, type, member: member
|
163
|
+
build_alias(methods, type, member: member)
|
150
164
|
end
|
151
165
|
end
|
152
166
|
end
|
@@ -168,18 +182,16 @@ module RBS
|
|
168
182
|
when AST::Members::MethodDefinition
|
169
183
|
build_method(methods, type, member: member, accessibility: :public)
|
170
184
|
when AST::Members::Alias
|
171
|
-
build_alias(methods, type, member: member
|
185
|
+
build_alias(methods, type, member: member)
|
172
186
|
end
|
173
187
|
end
|
174
188
|
end.validate!
|
175
189
|
end
|
176
190
|
end
|
177
191
|
|
178
|
-
def build_alias(methods, type, member
|
192
|
+
def build_alias(methods, type, member:)
|
179
193
|
defn = methods.methods[member.new_name] ||= Methods::Definition.empty(type: type, name: member.new_name)
|
180
|
-
|
181
194
|
defn.originals << member
|
182
|
-
defn.accessibilities << accessibility
|
183
195
|
end
|
184
196
|
|
185
197
|
def build_attribute(methods, type, member:, accessibility:)
|
@@ -587,7 +587,7 @@ module RBS
|
|
587
587
|
defs: original_method.defs.map do |defn|
|
588
588
|
defn.update(defined_in: definition.type_name, implemented_in: definition.type_name)
|
589
589
|
end,
|
590
|
-
accessibility:
|
590
|
+
accessibility: original_method.accessibility,
|
591
591
|
alias_of: original_method
|
592
592
|
)
|
593
593
|
else
|
data/lib/rbs/environment.rb
CHANGED
@@ -357,7 +357,8 @@ module RBS
|
|
357
357
|
comment: member.comment,
|
358
358
|
overload: member.overload?,
|
359
359
|
annotations: member.annotations,
|
360
|
-
location: member.location
|
360
|
+
location: member.location,
|
361
|
+
visibility: member.visibility
|
361
362
|
)
|
362
363
|
when AST::Members::AttrAccessor
|
363
364
|
AST::Members::AttrAccessor.new(
|
@@ -367,7 +368,8 @@ module RBS
|
|
367
368
|
annotations: member.annotations,
|
368
369
|
comment: member.comment,
|
369
370
|
location: member.location,
|
370
|
-
ivar_name: member.ivar_name
|
371
|
+
ivar_name: member.ivar_name,
|
372
|
+
visibility: member.visibility
|
371
373
|
)
|
372
374
|
when AST::Members::AttrReader
|
373
375
|
AST::Members::AttrReader.new(
|
@@ -377,7 +379,8 @@ module RBS
|
|
377
379
|
annotations: member.annotations,
|
378
380
|
comment: member.comment,
|
379
381
|
location: member.location,
|
380
|
-
ivar_name: member.ivar_name
|
382
|
+
ivar_name: member.ivar_name,
|
383
|
+
visibility: member.visibility
|
381
384
|
)
|
382
385
|
when AST::Members::AttrWriter
|
383
386
|
AST::Members::AttrWriter.new(
|
@@ -387,7 +390,8 @@ module RBS
|
|
387
390
|
annotations: member.annotations,
|
388
391
|
comment: member.comment,
|
389
392
|
location: member.location,
|
390
|
-
ivar_name: member.ivar_name
|
393
|
+
ivar_name: member.ivar_name,
|
394
|
+
visibility: member.visibility
|
391
395
|
)
|
392
396
|
when AST::Members::InstanceVariable
|
393
397
|
AST::Members::InstanceVariable.new(
|
data/lib/rbs/namespace.rb
CHANGED
data/lib/rbs/type_name.rb
CHANGED
data/lib/rbs/types.rb
CHANGED
data/lib/rbs/validator.rb
CHANGED
@@ -73,6 +73,8 @@ module RBS
|
|
73
73
|
if set = result.incompatible?(entry.decl.type_params)
|
74
74
|
set.each do |param_name|
|
75
75
|
param = entry.decl.type_params.find {|param| param.name == param_name } or raise
|
76
|
+
next if param.unchecked?
|
77
|
+
|
76
78
|
raise InvalidVarianceAnnotationError.new(
|
77
79
|
type_name: type_name,
|
78
80
|
param: param,
|
data/lib/rbs/version.rb
CHANGED
data/lib/rbs/writer.rb
CHANGED
@@ -6,6 +6,16 @@ module RBS
|
|
6
6
|
def initialize(out:)
|
7
7
|
@out = out
|
8
8
|
@indentation = []
|
9
|
+
@preserve = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def preserve?
|
13
|
+
@preserve
|
14
|
+
end
|
15
|
+
|
16
|
+
def preserve!(preserve: true)
|
17
|
+
@preserve = preserve
|
18
|
+
self
|
9
19
|
end
|
10
20
|
|
11
21
|
def indent(size = 2)
|
@@ -119,7 +129,9 @@ module RBS
|
|
119
129
|
when AST::Declarations::Alias
|
120
130
|
write_comment decl.comment
|
121
131
|
write_annotation decl.annotations
|
122
|
-
|
132
|
+
write_loc_source(decl) {
|
133
|
+
puts "type #{name_and_params(decl.name, decl.type_params)} = #{decl.type}"
|
134
|
+
}
|
123
135
|
|
124
136
|
when AST::Declarations::Interface
|
125
137
|
write_comment decl.comment
|
@@ -163,6 +175,16 @@ module RBS
|
|
163
175
|
end
|
164
176
|
end
|
165
177
|
|
178
|
+
def put_lines(lines, leading_spaces:)
|
179
|
+
lines.each_line.with_index do |line, index|
|
180
|
+
line.chomp!
|
181
|
+
line.rstrip!
|
182
|
+
line.sub!(/\A( {,#{leading_spaces}})/, '') if index > 0
|
183
|
+
|
184
|
+
puts line
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
166
188
|
def write_member(member)
|
167
189
|
case member
|
168
190
|
when AST::Members::Include
|
@@ -211,7 +233,7 @@ module RBS
|
|
211
233
|
when AST::Members::MethodDefinition
|
212
234
|
write_comment member.comment
|
213
235
|
write_annotation member.annotations
|
214
|
-
write_def member
|
236
|
+
write_loc_source(member) { write_def member }
|
215
237
|
else
|
216
238
|
write_decl member
|
217
239
|
end
|
@@ -230,7 +252,25 @@ module RBS
|
|
230
252
|
end
|
231
253
|
end
|
232
254
|
|
255
|
+
def write_loc_source(located)
|
256
|
+
if preserve? && loc = located.location
|
257
|
+
put_lines(loc.source, leading_spaces: loc.start_column)
|
258
|
+
else
|
259
|
+
yield
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
233
263
|
def write_def(member)
|
264
|
+
visibility =
|
265
|
+
case member.visibility
|
266
|
+
when :public
|
267
|
+
"public "
|
268
|
+
when :private
|
269
|
+
"private "
|
270
|
+
else
|
271
|
+
""
|
272
|
+
end
|
273
|
+
|
234
274
|
name = case member.kind
|
235
275
|
when :instance
|
236
276
|
"#{method_name(member.name)}"
|
@@ -242,7 +282,7 @@ module RBS
|
|
242
282
|
|
243
283
|
string = ""
|
244
284
|
|
245
|
-
prefix = "def #{name}:"
|
285
|
+
prefix = "#{visibility}def #{name}:"
|
246
286
|
padding = " " * (prefix.size-1)
|
247
287
|
|
248
288
|
string << prefix
|
@@ -270,6 +310,16 @@ module RBS
|
|
270
310
|
end
|
271
311
|
|
272
312
|
def attribute(kind, attr)
|
313
|
+
visibility =
|
314
|
+
case attr.visibility
|
315
|
+
when :public
|
316
|
+
"public "
|
317
|
+
when :private
|
318
|
+
"private "
|
319
|
+
else
|
320
|
+
""
|
321
|
+
end
|
322
|
+
|
273
323
|
var = case attr.ivar_name
|
274
324
|
when nil
|
275
325
|
""
|
@@ -286,7 +336,7 @@ module RBS
|
|
286
336
|
""
|
287
337
|
end
|
288
338
|
|
289
|
-
"attr_#{kind} #{receiver}#{attr.name}#{var}: #{attr.type}"
|
339
|
+
"#{visibility}attr_#{kind} #{receiver}#{attr.name}#{var}: #{attr.type}"
|
290
340
|
end
|
291
341
|
|
292
342
|
def preserve_empty_line(prev, decl)
|
data/lib/rbs.rb
CHANGED
data/schema/typeParam.json
CHANGED
@@ -15,13 +15,13 @@
|
|
15
15
|
"upper_bound": {
|
16
16
|
"oneOf": [
|
17
17
|
{
|
18
|
-
"$ref": "types.json
|
18
|
+
"$ref": "types.json#/definitions/classInstance"
|
19
19
|
},
|
20
20
|
{
|
21
|
-
"$ref": "types.json
|
21
|
+
"$ref": "types.json#/definitions/classSingleton"
|
22
22
|
},
|
23
23
|
{
|
24
|
-
"$ref": "types.json
|
24
|
+
"$ref": "types.json#/definitions/interface"
|
25
25
|
},
|
26
26
|
{
|
27
27
|
"type": "null"
|
data/sig/buffer.rbs
CHANGED
@@ -11,12 +11,16 @@ module RBS
|
|
11
11
|
# The content of the buffer.
|
12
12
|
attr_reader content: String
|
13
13
|
|
14
|
-
|
14
|
+
@lines: Array[String]
|
15
15
|
|
16
|
-
|
16
|
+
@ranges: Array[Range[Integer]]
|
17
17
|
|
18
18
|
def initialize: (name: untyped name, content: String content) -> void
|
19
19
|
|
20
|
+
def lines: () -> Array[String]
|
21
|
+
|
22
|
+
def ranges: () -> Array[Range[Integer]]
|
23
|
+
|
20
24
|
# Translate position to location.
|
21
25
|
def pos_to_loc: (Integer pos) -> loc
|
22
26
|
|
data/sig/members.rbs
CHANGED
@@ -12,6 +12,8 @@ module RBS
|
|
12
12
|
class Base
|
13
13
|
end
|
14
14
|
|
15
|
+
type visibility = :public | :private
|
16
|
+
|
15
17
|
class MethodDefinition < Base
|
16
18
|
type kind = :instance | :singleton | :singleton_instance
|
17
19
|
|
@@ -19,13 +21,14 @@ module RBS
|
|
19
21
|
# ^^^ keyword
|
20
22
|
# ^^^ name
|
21
23
|
#
|
22
|
-
# def self.bar: () -> void | ...
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
24
|
+
# private def self.bar: () -> void | ...
|
25
|
+
# ^^^^^^^ visibility
|
26
|
+
# ^^^ keyword
|
27
|
+
# ^^^^^ kind
|
28
|
+
# ^^^ name
|
29
|
+
# ^^^ overload
|
27
30
|
#
|
28
|
-
type loc = Location[:keyword | :name, :kind | :overload]
|
31
|
+
type loc = Location[:keyword | :name, :kind | :overload | :visibility]
|
29
32
|
|
30
33
|
attr_reader name: Symbol
|
31
34
|
attr_reader kind: kind
|
@@ -34,8 +37,9 @@ module RBS
|
|
34
37
|
attr_reader location: loc?
|
35
38
|
attr_reader comment: Comment?
|
36
39
|
attr_reader overload: bool
|
40
|
+
attr_reader visibility: visibility?
|
37
41
|
|
38
|
-
def initialize: (name: Symbol, kind: kind, types: Array[MethodType], annotations: Array[Annotation], location: loc?, comment: Comment?, overload: boolish) -> void
|
42
|
+
def initialize: (name: Symbol, kind: kind, types: Array[MethodType], annotations: Array[Annotation], location: loc?, comment: Comment?, overload: boolish, ?visibility: visibility?) -> void
|
39
43
|
|
40
44
|
include _HashEqual
|
41
45
|
include _ToJson
|
@@ -46,7 +50,7 @@ module RBS
|
|
46
50
|
|
47
51
|
def overload?: () -> bool
|
48
52
|
|
49
|
-
def update: (?name: Symbol, ?kind: kind, ?types: Array[MethodType], ?annotations: Array[Annotation], ?location: loc?, ?comment: Comment?, ?overload: boolish) -> MethodDefinition
|
53
|
+
def update: (?name: Symbol, ?kind: kind, ?types: Array[MethodType], ?annotations: Array[Annotation], ?location: loc?, ?comment: Comment?, ?overload: boolish, ?visibility: visibility?) -> MethodDefinition
|
50
54
|
end
|
51
55
|
|
52
56
|
module Var
|
@@ -133,15 +137,16 @@ module RBS
|
|
133
137
|
# ^^^^ name
|
134
138
|
# ^ colon
|
135
139
|
#
|
136
|
-
# attr_accessor self.name (@foo) : String
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
140
|
+
# public attr_accessor self.name (@foo) : String
|
141
|
+
# ^^^^^^ visibility
|
142
|
+
# ^^^^^^^^^^^^^ keyword
|
143
|
+
# ^^^^^ kind
|
144
|
+
# ^^^^ name
|
145
|
+
# ^^^^^^ ivar
|
146
|
+
# ^^^^ ivar_name
|
147
|
+
# ^ colon
|
143
148
|
#
|
144
|
-
type loc = Location[:keyword | :name | :colon, :kind | :ivar | :ivar_name]
|
149
|
+
type loc = Location[:keyword | :name | :colon, :kind | :ivar | :ivar_name | :visibility]
|
145
150
|
|
146
151
|
attr_reader name: Symbol
|
147
152
|
attr_reader type: Types::t
|
@@ -150,12 +155,13 @@ module RBS
|
|
150
155
|
attr_reader annotations: Array[Annotation]
|
151
156
|
attr_reader location: loc?
|
152
157
|
attr_reader comment: Comment?
|
158
|
+
attr_reader visibility: visibility?
|
153
159
|
|
154
|
-
def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, kind: kind, annotations: Array[Annotation], location: loc?, comment: Comment?) -> void
|
160
|
+
def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, kind: kind, annotations: Array[Annotation], location: loc?, comment: Comment?, ?visibility: visibility?) -> void
|
155
161
|
|
156
162
|
include _HashEqual
|
157
163
|
|
158
|
-
def update: (?name: Symbol, ?type: Types::t, ?ivar_name: Symbol | false | nil, ?kind: kind, ?annotations: Array[Annotation], ?location: loc?, ?comment: Comment?) -> instance
|
164
|
+
def update: (?name: Symbol, ?type: Types::t, ?ivar_name: Symbol | false | nil, ?kind: kind, ?annotations: Array[Annotation], ?location: loc?, ?comment: Comment?, ?visibility: visibility) -> instance
|
159
165
|
end
|
160
166
|
|
161
167
|
class AttrReader < Base
|
data/sig/method_builder.rbs
CHANGED
@@ -6,7 +6,8 @@ module RBS
|
|
6
6
|
|
7
7
|
class Definition
|
8
8
|
type original = AST::Members::MethodDefinition | AST::Members::Alias | AST::Members::AttrAccessor | AST::Members::AttrWriter | AST::Members::AttrReader
|
9
|
-
|
9
|
+
|
10
|
+
type accessibility = RBS::Definition::accessibility
|
10
11
|
|
11
12
|
attr_reader name: Symbol
|
12
13
|
attr_reader type: instance_type
|
@@ -59,11 +60,11 @@ module RBS
|
|
59
60
|
|
60
61
|
def build_interface: (TypeName) -> Methods
|
61
62
|
|
62
|
-
def build_alias: (Methods, Methods::instance_type, member: AST::Members::Alias
|
63
|
+
def build_alias: (Methods, Methods::instance_type, member: AST::Members::Alias) -> void
|
63
64
|
|
64
|
-
def build_attribute: (Methods, Methods::instance_type, member: AST::Members::AttrAccessor | AST::Members::AttrReader | AST::Members::AttrWriter, accessibility:
|
65
|
+
def build_attribute: (Methods, Methods::instance_type, member: AST::Members::AttrAccessor | AST::Members::AttrReader | AST::Members::AttrWriter, accessibility: Definition::accessibility) -> void
|
65
66
|
|
66
|
-
def build_method: (Methods, Methods::instance_type, member: AST::Members::MethodDefinition, accessibility:
|
67
|
+
def build_method: (Methods, Methods::instance_type, member: AST::Members::MethodDefinition, accessibility: Definition::accessibility) -> void
|
67
68
|
|
68
69
|
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
|
69
70
|
|
data/sig/writer.rbs
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module RBS
|
2
|
+
# Writer prints RBS AST to String.
|
3
|
+
#
|
2
4
|
class Writer
|
3
5
|
interface _IO
|
4
6
|
def puts: (*untyped) -> void
|
@@ -6,23 +8,96 @@ module RBS
|
|
6
8
|
def flush: () -> void
|
7
9
|
end
|
8
10
|
|
11
|
+
# Channel to output the result.
|
12
|
+
#
|
9
13
|
attr_reader out: _IO
|
14
|
+
|
15
|
+
# Array of indentations.
|
16
|
+
#
|
10
17
|
attr_reader indentation: Array[String]
|
11
18
|
|
12
19
|
def initialize: (out: _IO) -> void
|
13
20
|
|
21
|
+
# Output the array of declarations.
|
22
|
+
# It automatically inserts empty lines between the declarations.
|
23
|
+
#
|
24
|
+
def write: (Array[AST::Declarations::t]) -> void
|
25
|
+
|
26
|
+
def preserve?: () -> bool
|
27
|
+
|
28
|
+
def preserve!: (?preserve: bool) -> self
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
@preserve: bool
|
33
|
+
|
34
|
+
# Increases the indentation and yields the block.
|
35
|
+
#
|
14
36
|
def indent: (?Integer size) { () -> void } -> void
|
15
37
|
|
38
|
+
# Returns the current indentation of lines.
|
39
|
+
#
|
16
40
|
def prefix: () -> String
|
17
41
|
|
42
|
+
# Prints a string.
|
43
|
+
# Automatically appends the `#prefix` and newline at the end.
|
44
|
+
#
|
18
45
|
def puts: (?String) -> void
|
19
46
|
|
47
|
+
# Prints a (possibly) multi-line string.
|
48
|
+
#
|
49
|
+
# Drops `leading_spaces` of spaces at the beginning of each line.
|
50
|
+
#
|
51
|
+
# ```ruby
|
52
|
+
# put_lines(<<TEXT, leading_spaces: 0)
|
53
|
+
# Hello
|
54
|
+
# world!
|
55
|
+
# TEXT
|
56
|
+
#
|
57
|
+
# # Outputs
|
58
|
+
# # Hello
|
59
|
+
# # world!
|
60
|
+
#
|
61
|
+
# put_lines(<<TEXT, leading_spaces: 2)
|
62
|
+
# Hello
|
63
|
+
# world!
|
64
|
+
# TEXT
|
65
|
+
#
|
66
|
+
# # Outputs
|
67
|
+
# # Hello
|
68
|
+
# # world!
|
69
|
+
# ```
|
70
|
+
#
|
71
|
+
# This is for `Location#source`.
|
72
|
+
# The `#source` returns the text spans from the beginning to end of the element.
|
73
|
+
# It will look like the following.
|
74
|
+
#
|
75
|
+
# ```rbs
|
76
|
+
# module Foo
|
77
|
+
# type t = Integer # the definition of `t` starts from line=2, column=2
|
78
|
+
# | String
|
79
|
+
# | :false # the definition of `t` ends from line=4, column=17
|
80
|
+
# end
|
81
|
+
# ```
|
82
|
+
#
|
83
|
+
# The expected output will be something like:
|
84
|
+
#
|
85
|
+
# ```rbs
|
86
|
+
# type t = Integer # Extracted from `Foo` definition and keeps the line breaks
|
87
|
+
# | String
|
88
|
+
# | :false
|
89
|
+
# ```
|
90
|
+
#
|
91
|
+
# And it can be done with a `#put_lines(source, leading_spaces: 2)` call.
|
92
|
+
#
|
93
|
+
def put_lines: (String, leading_spaces: Integer) -> void
|
94
|
+
|
95
|
+
def write_loc_source: (_Located) { () -> void } -> void
|
96
|
+
|
20
97
|
def write_annotation: (Array[AST::Annotation]) -> void
|
21
98
|
|
22
99
|
def write_comment: (AST::Comment?) -> void
|
23
100
|
|
24
|
-
def write: (Array[AST::Declarations::t]) -> void
|
25
|
-
|
26
101
|
def write_decl: (AST::Declarations::t) -> void
|
27
102
|
|
28
103
|
def write_member: (AST::Declarations::Module::member) -> void
|
@@ -31,6 +106,8 @@ module RBS
|
|
31
106
|
|
32
107
|
def name_and_args: (TypeName, Array[Types::t]) -> String?
|
33
108
|
|
109
|
+
def write_alias: (AST::Declarations::Alias) -> void
|
110
|
+
|
34
111
|
def method_name: (Symbol) -> String
|
35
112
|
|
36
113
|
def write_def: (AST::Members::MethodDefinition) -> void
|
@@ -33,6 +33,27 @@ module Net
|
|
33
33
|
class HTTPHeaderSyntaxError < StandardError
|
34
34
|
end
|
35
35
|
|
36
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
37
|
+
# OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be
|
38
|
+
# created within the open_timeout.
|
39
|
+
#
|
40
|
+
class OpenTimeout < Timeout::Error
|
41
|
+
end
|
42
|
+
|
43
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
44
|
+
# ReadTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
45
|
+
# response cannot be read within the read_timeout.
|
46
|
+
#
|
47
|
+
class ReadTimeout < Timeout::Error
|
48
|
+
end
|
49
|
+
|
50
|
+
# <!-- rdoc-file=lib/net/protocol.rb -->
|
51
|
+
# WriteTimeout, a subclass of Timeout::Error, is raised if a chunk of the
|
52
|
+
# response cannot be written within the write_timeout. Not raised on Windows.
|
53
|
+
#
|
54
|
+
class WriteTimeout < Timeout::Error
|
55
|
+
end
|
56
|
+
|
36
57
|
# <!-- rdoc-file=lib/net/http.rb -->
|
37
58
|
# ## An HTTP client API for Ruby.
|
38
59
|
#
|
data/stdlib/uri/0/generic.rbs
CHANGED
@@ -880,7 +880,7 @@ module URI
|
|
880
880
|
# uri.merge!("/main.rbx?page=1")
|
881
881
|
# uri.to_s # => "http://my.example.com/main.rbx?page=1"
|
882
882
|
#
|
883
|
-
def merge!: (string oth) -> String
|
883
|
+
def merge!: (URI::Generic | string oth) -> String
|
884
884
|
|
885
885
|
# <!--
|
886
886
|
# rdoc-file=lib/uri/generic.rb
|
@@ -904,7 +904,7 @@ module URI
|
|
904
904
|
# uri.merge("/main.rbx?page=1")
|
905
905
|
# # => "http://my.example.com/main.rbx?page=1"
|
906
906
|
#
|
907
|
-
def merge: (string oth) -> URI::Generic
|
907
|
+
def merge: (URI::Generic | string oth) -> URI::Generic
|
908
908
|
|
909
909
|
# :stopdoc:
|
910
910
|
def route_from_path: (String src, String dst) -> String
|