rbs 4.0.0.dev.5 → 4.0.1.dev.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.
- checksums.yaml +4 -4
- data/.clang-format +1 -0
- data/.github/workflows/c-check.yml +8 -4
- data/.github/workflows/comments.yml +3 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +10 -0
- data/.github/workflows/rust.yml +95 -0
- data/CHANGELOG.md +323 -0
- data/Rakefile +12 -29
- data/Steepfile +1 -0
- data/config.yml +393 -37
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +52 -40
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +5 -5
- data/core/enumerable.rbs +96 -91
- data/core/enumerator.rbs +4 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +36 -36
- data/core/file.rbs +186 -113
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +41 -32
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -28
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +120 -135
- data/core/kernel.rbs +189 -139
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -6
- data/core/module.rbs +146 -85
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +35 -32
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -33
- data/core/process.rbs +219 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +4 -3
- data/core/range.rbs +52 -47
- data/core/rational.rbs +5 -5
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -5
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +311 -292
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -34
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +110 -4
- data/docs/syntax.md +13 -12
- data/ext/rbs_extension/ast_translation.c +489 -135
- data/ext/rbs_extension/class_constants.c +8 -0
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/legacy_location.c +28 -51
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +12 -20
- data/include/rbs/ast.h +423 -195
- data/include/rbs/lexer.h +2 -2
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +2 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/ruby/annotations.rb +157 -4
- data/lib/rbs/ast/ruby/members.rb +374 -22
- data/lib/rbs/cli/validate.rb +5 -60
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
- data/lib/rbs/definition_builder.rb +60 -27
- data/lib/rbs/errors.rb +0 -11
- data/lib/rbs/inline_parser.rb +1 -1
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +1 -26
- data/lib/rbs/prototype/rbi.rb +1 -20
- data/lib/rbs/test/type_check.rb +3 -0
- data/lib/rbs/types.rb +62 -52
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +0 -1
- data/rbs.gemspec +1 -1
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/sig/ast/ruby/annotations.rbs +191 -4
- data/sig/ast/ruby/members.rbs +21 -1
- data/sig/cli/validate.rbs +1 -6
- data/sig/definition_builder.rbs +2 -0
- data/sig/errors.rbs +0 -8
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +17 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/types.rbs +10 -11
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +339 -161
- data/src/lexstate.c +1 -1
- data/src/location.c +7 -47
- data/src/parser.c +674 -480
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +138 -125
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +135 -108
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -7
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +36 -35
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +18 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +61 -8
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/securerandom.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +26 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +4 -4
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +23 -5
- data/.github/workflows/valgrind.yml +0 -42
data/include/rbs/lexer.h
CHANGED
|
@@ -136,8 +136,8 @@ typedef struct {
|
|
|
136
136
|
* */
|
|
137
137
|
typedef struct {
|
|
138
138
|
rbs_string_t string;
|
|
139
|
-
int start_pos; /* The
|
|
140
|
-
int end_pos; /* The
|
|
139
|
+
int start_pos; /* The byte position that defines the start of the input */
|
|
140
|
+
int end_pos; /* The byte position that defines the end of the input */
|
|
141
141
|
rbs_position_t current; /* The current position: just before the current_character */
|
|
142
142
|
rbs_position_t start; /* The start position of the current token */
|
|
143
143
|
|
data/include/rbs/location.h
CHANGED
|
@@ -1,59 +1,40 @@
|
|
|
1
1
|
#ifndef RBS__RBS_LOCATION_H
|
|
2
2
|
#define RBS__RBS_LOCATION_H
|
|
3
3
|
|
|
4
|
-
#include "lexer.h"
|
|
5
|
-
|
|
6
|
-
#include "rbs/util/rbs_constant_pool.h"
|
|
7
4
|
#include "rbs/util/rbs_allocator.h"
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
#define RBS_LOCATION_NULL_RANGE ((rbs_location_range) { -1, -1, -1, -1 })
|
|
7
|
+
#define RBS_LOCATION_NULL_RANGE_P(rg) ((rg).start_char == -1)
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts a lexer range (rbs_range_t) to an AST location range (rbs_location_range) by extracting character and byte positions.
|
|
11
|
+
*/
|
|
12
|
+
#define RBS_RANGE_LEX2AST(rg) ((rbs_location_range) { .start_char = (rg).start.char_pos, .start_byte = (rg).start.byte_pos, .end_char = (rg).end.char_pos, .end_byte = (rg).end.byte_pos })
|
|
13
13
|
|
|
14
14
|
typedef struct {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} rbs_loc_entry;
|
|
15
|
+
int start_char;
|
|
16
|
+
int start_byte;
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
int end_char;
|
|
19
|
+
int end_byte;
|
|
20
|
+
} rbs_location_range;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
rbs_loc_entry entries[1];
|
|
28
|
-
} rbs_loc_children;
|
|
29
|
-
|
|
30
|
-
typedef struct rbs_location {
|
|
31
|
-
rbs_range_t rg;
|
|
32
|
-
rbs_loc_children *children;
|
|
33
|
-
} rbs_location_t;
|
|
34
|
-
|
|
35
|
-
typedef struct rbs_location_list_node {
|
|
36
|
-
rbs_location_t *loc;
|
|
37
|
-
struct rbs_location_list_node *next;
|
|
38
|
-
} rbs_location_list_node_t;
|
|
39
|
-
|
|
40
|
-
typedef struct rbs_location_list {
|
|
22
|
+
typedef struct rbs_location_range_list_node {
|
|
23
|
+
rbs_location_range range;
|
|
24
|
+
struct rbs_location_range_list_node *next;
|
|
25
|
+
} rbs_location_range_list_node_t;
|
|
26
|
+
|
|
27
|
+
typedef struct rbs_location_range_list {
|
|
41
28
|
rbs_allocator_t *allocator;
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
struct rbs_location_range_list_node *head;
|
|
30
|
+
struct rbs_location_range_list_node *tail;
|
|
44
31
|
size_t length;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
void rbs_loc_alloc_children(rbs_allocator_t *, rbs_location_t *loc, size_t capacity);
|
|
48
|
-
void rbs_loc_add_required_child(rbs_location_t *loc, rbs_constant_id_t name, rbs_range_t r);
|
|
49
|
-
void rbs_loc_add_optional_child(rbs_location_t *loc, rbs_constant_id_t name, rbs_range_t r);
|
|
32
|
+
} rbs_location_range_list_t;
|
|
50
33
|
|
|
51
34
|
/**
|
|
52
|
-
* Allocate new
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
rbs_location_list_t *rbs_location_list_new(rbs_allocator_t *allocator);
|
|
57
|
-
void rbs_location_list_append(rbs_location_list_t *list, rbs_location_t *loc);
|
|
35
|
+
* Allocate new rbs_location_range_list_t object through the given allocator.
|
|
36
|
+
*/
|
|
37
|
+
rbs_location_range_list_t *rbs_location_range_list_new(rbs_allocator_t *allocator);
|
|
38
|
+
void rbs_location_range_list_append(rbs_location_range_list_t *list, rbs_location_range range);
|
|
58
39
|
|
|
59
40
|
#endif
|
data/include/rbs/parser.h
CHANGED
|
@@ -126,8 +126,8 @@ rbs_ast_comment_t *rbs_parser_get_comment(rbs_parser_t *parser, int subject_line
|
|
|
126
126
|
|
|
127
127
|
void rbs_parser_set_error(rbs_parser_t *parser, rbs_token_t tok, bool syntax_error, const char *fmt, ...) RBS_ATTRIBUTE_FORMAT(4, 5);
|
|
128
128
|
|
|
129
|
-
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type, bool void_allowed, bool self_allowed);
|
|
130
|
-
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type, bool require_eof);
|
|
129
|
+
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type, bool void_allowed, bool self_allowed, bool classish_allowed);
|
|
130
|
+
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type, bool require_eof, bool classish_allowed);
|
|
131
131
|
bool rbs_parse_signature(rbs_parser_t *parser, rbs_signature_t **signature);
|
|
132
132
|
|
|
133
133
|
bool rbs_parse_type_params(rbs_parser_t *parser, bool module_type_params, rbs_node_list_t **params);
|
|
@@ -81,9 +81,6 @@ typedef struct {
|
|
|
81
81
|
uint32_t capacity;
|
|
82
82
|
} rbs_constant_pool_t;
|
|
83
83
|
|
|
84
|
-
// A global constant pool for storing permenant keywords, such as the names of location children in `parser.c`.
|
|
85
|
-
extern rbs_constant_pool_t *RBS_GLOBAL_CONSTANT_POOL;
|
|
86
|
-
|
|
87
84
|
/**
|
|
88
85
|
* Initialize a new constant pool with a given capacity.
|
|
89
86
|
*
|
data/include/rbs.h
CHANGED
|
@@ -109,12 +109,13 @@ module RBS
|
|
|
109
109
|
class MethodTypesAnnotation < Base
|
|
110
110
|
Overload = AST::Members::MethodDefinition::Overload
|
|
111
111
|
|
|
112
|
-
attr_reader :overloads, :vertical_bar_locations
|
|
112
|
+
attr_reader :overloads, :vertical_bar_locations, :dot3_location
|
|
113
113
|
|
|
114
|
-
def initialize(location:, prefix_location:, overloads:, vertical_bar_locations:)
|
|
114
|
+
def initialize(location:, prefix_location:, overloads:, vertical_bar_locations:, dot3_location:)
|
|
115
115
|
super(location, prefix_location)
|
|
116
116
|
@overloads = overloads
|
|
117
117
|
@vertical_bar_locations = vertical_bar_locations
|
|
118
|
+
@dot3_location = dot3_location
|
|
118
119
|
end
|
|
119
120
|
|
|
120
121
|
def map_type_name(&block)
|
|
@@ -125,13 +126,14 @@ module RBS
|
|
|
125
126
|
)
|
|
126
127
|
end
|
|
127
128
|
|
|
128
|
-
self.class.new(location:, prefix_location:, overloads: ovs, vertical_bar_locations:) #: self
|
|
129
|
+
self.class.new(location:, prefix_location:, overloads: ovs, vertical_bar_locations:, dot3_location:) #: self
|
|
129
130
|
end
|
|
130
131
|
|
|
131
132
|
def type_fingerprint
|
|
132
133
|
[
|
|
133
134
|
"annots/method_types",
|
|
134
|
-
overloads.map { |o| [o.annotations.map(&:to_s), o.method_type.to_s] }
|
|
135
|
+
overloads.map { |o| [o.annotations.map(&:to_s), o.method_type.to_s] },
|
|
136
|
+
overloading: dot3_location ? true : false
|
|
135
137
|
]
|
|
136
138
|
end
|
|
137
139
|
end
|
|
@@ -250,6 +252,157 @@ module RBS
|
|
|
250
252
|
]
|
|
251
253
|
end
|
|
252
254
|
end
|
|
255
|
+
|
|
256
|
+
class ParamTypeAnnotation < Base
|
|
257
|
+
attr_reader :name_location, :colon_location, :param_type, :comment_location
|
|
258
|
+
|
|
259
|
+
def initialize(location:, prefix_location:, name_location:, colon_location:, param_type:, comment_location:)
|
|
260
|
+
super(location, prefix_location)
|
|
261
|
+
@name_location = name_location
|
|
262
|
+
@colon_location = colon_location
|
|
263
|
+
@param_type = param_type
|
|
264
|
+
@comment_location = comment_location
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def map_type_name(&block)
|
|
268
|
+
self.class.new(
|
|
269
|
+
location:,
|
|
270
|
+
prefix_location:,
|
|
271
|
+
name_location: name_location,
|
|
272
|
+
colon_location: colon_location,
|
|
273
|
+
param_type: param_type.map_type_name { yield _1 },
|
|
274
|
+
comment_location: comment_location
|
|
275
|
+
) #: self
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def type_fingerprint
|
|
279
|
+
[
|
|
280
|
+
"annots/param_type",
|
|
281
|
+
name_location.source,
|
|
282
|
+
param_type.to_s,
|
|
283
|
+
comment_location&.source
|
|
284
|
+
]
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
class SplatParamTypeAnnotation < Base
|
|
289
|
+
attr_reader :star_location, :name_location, :colon_location, :param_type, :comment_location
|
|
290
|
+
|
|
291
|
+
def initialize(location:, prefix_location:, star_location:, name_location:, colon_location:, param_type:, comment_location:)
|
|
292
|
+
super(location, prefix_location)
|
|
293
|
+
@star_location = star_location
|
|
294
|
+
@name_location = name_location
|
|
295
|
+
@colon_location = colon_location
|
|
296
|
+
@param_type = param_type
|
|
297
|
+
@comment_location = comment_location
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def map_type_name(&block)
|
|
301
|
+
self.class.new(
|
|
302
|
+
location:,
|
|
303
|
+
prefix_location:,
|
|
304
|
+
star_location: star_location,
|
|
305
|
+
name_location: name_location,
|
|
306
|
+
colon_location: colon_location,
|
|
307
|
+
param_type: param_type.map_type_name { yield _1 },
|
|
308
|
+
comment_location: comment_location
|
|
309
|
+
) #: self
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def type_fingerprint
|
|
313
|
+
[
|
|
314
|
+
"annots/splat_param_type",
|
|
315
|
+
name_location&.source,
|
|
316
|
+
param_type.to_s,
|
|
317
|
+
comment_location&.source
|
|
318
|
+
]
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
class DoubleSplatParamTypeAnnotation < Base
|
|
323
|
+
attr_reader :star2_location, :name_location, :colon_location, :param_type, :comment_location
|
|
324
|
+
|
|
325
|
+
def initialize(location:, prefix_location:, star2_location:, name_location:, colon_location:, param_type:, comment_location:)
|
|
326
|
+
super(location, prefix_location)
|
|
327
|
+
@star2_location = star2_location
|
|
328
|
+
@name_location = name_location
|
|
329
|
+
@colon_location = colon_location
|
|
330
|
+
@param_type = param_type
|
|
331
|
+
@comment_location = comment_location
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def map_type_name(&block)
|
|
335
|
+
self.class.new(
|
|
336
|
+
location:,
|
|
337
|
+
prefix_location:,
|
|
338
|
+
star2_location: star2_location,
|
|
339
|
+
name_location: name_location,
|
|
340
|
+
colon_location: colon_location,
|
|
341
|
+
param_type: param_type.map_type_name { yield _1 },
|
|
342
|
+
comment_location: comment_location
|
|
343
|
+
) #: self
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def type_fingerprint
|
|
347
|
+
[
|
|
348
|
+
"annots/double_splat_param_type",
|
|
349
|
+
name_location&.source,
|
|
350
|
+
param_type.to_s,
|
|
351
|
+
comment_location&.source
|
|
352
|
+
]
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
class BlockParamTypeAnnotation < Base
|
|
357
|
+
attr_reader :ampersand_location, :name_location, :colon_location, :question_location, :type_location, :type, :comment_location
|
|
358
|
+
|
|
359
|
+
def initialize(location:, prefix_location:, ampersand_location:, name_location:, colon_location:, question_location:, type_location:, type:, comment_location:)
|
|
360
|
+
super(location, prefix_location)
|
|
361
|
+
@ampersand_location = ampersand_location
|
|
362
|
+
@name_location = name_location
|
|
363
|
+
@colon_location = colon_location
|
|
364
|
+
@question_location = question_location
|
|
365
|
+
@type_location = type_location
|
|
366
|
+
@type = type
|
|
367
|
+
@comment_location = comment_location
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def map_type_name(&block)
|
|
371
|
+
self.class.new(
|
|
372
|
+
location:,
|
|
373
|
+
prefix_location:,
|
|
374
|
+
ampersand_location: ampersand_location,
|
|
375
|
+
name_location: name_location,
|
|
376
|
+
colon_location: colon_location,
|
|
377
|
+
question_location: question_location,
|
|
378
|
+
type_location: type_location,
|
|
379
|
+
type: type.map_type_name { yield _1 },
|
|
380
|
+
comment_location: comment_location
|
|
381
|
+
) #: self
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def name
|
|
385
|
+
name_location&.source&.to_sym
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def optional?
|
|
389
|
+
question_location ? true : false
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def required?
|
|
393
|
+
!optional?
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def type_fingerprint
|
|
397
|
+
[
|
|
398
|
+
"annots/block_param_type",
|
|
399
|
+
name_location&.source,
|
|
400
|
+
type.to_s,
|
|
401
|
+
optional? ? "optional" : "required",
|
|
402
|
+
comment_location&.source
|
|
403
|
+
]
|
|
404
|
+
end
|
|
405
|
+
end
|
|
253
406
|
end
|
|
254
407
|
end
|
|
255
408
|
end
|