rbs 3.5.0.pre.2 → 3.5.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -4
- data/.github/workflows/dependabot.yml +26 -0
- data/.github/workflows/ruby.yml +7 -1
- data/CHANGELOG.md +102 -1
- data/README.md +3 -2
- data/Rakefile +18 -1
- data/Steepfile +1 -1
- data/core/float.rbs +2 -1
- data/core/integer.rbs +2 -1
- data/core/proc.rbs +1 -1
- data/core/rational.rbs +2 -1
- data/core/ruby_vm.rbs +6 -2
- data/core/rubygems/rubygems.rbs +1 -1
- data/core/set.rbs +13 -7
- data/docs/gem.md +0 -1
- data/ext/rbs_extension/lexer.c +1338 -1341
- data/ext/rbs_extension/lexer.h +2 -0
- data/ext/rbs_extension/lexer.re +2 -3
- data/ext/rbs_extension/lexstate.c +5 -1
- data/ext/rbs_extension/location.c +5 -4
- data/ext/rbs_extension/location.h +4 -2
- data/ext/rbs_extension/parser.c +69 -21
- data/ext/rbs_extension/parserstate.c +8 -1
- data/ext/rbs_extension/parserstate.h +9 -0
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +4 -6
- data/lib/rbs/location_aux.rb +6 -1
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/rbs.gemspec +6 -2
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +28 -0
- data/stdlib/uri/0/mailto.rbs +84 -0
- metadata +6 -19
- data/Gemfile +0 -41
- data/Gemfile.lock +0 -134
data/ext/rbs_extension/lexer.h
CHANGED
data/ext/rbs_extension/lexer.re
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
token rbsparser_next_token(lexstate *state) {
|
4
4
|
lexstate backup;
|
5
5
|
|
6
|
-
start:
|
7
6
|
backup = *state;
|
8
7
|
|
9
8
|
/*!re2c
|
@@ -139,9 +138,9 @@ start:
|
|
139
138
|
|
140
139
|
"$" global_ident { return next_token(state, tGIDENT); }
|
141
140
|
|
142
|
-
skip = [ \t\n
|
141
|
+
skip = ([ \t]+|[\r\n]);
|
143
142
|
|
144
|
-
skip {
|
143
|
+
skip { return next_token(state, tTRIVIA); }
|
145
144
|
"\x00" { return next_token(state, pEOF); }
|
146
145
|
* { return next_token(state, ErrorToken); }
|
147
146
|
*/
|
@@ -77,6 +77,8 @@ static const char *RBS_TOKENTYPE_NAMES[] = {
|
|
77
77
|
"tCOMMENT",
|
78
78
|
"tLINECOMMENT",
|
79
79
|
|
80
|
+
"tTRIVIA",
|
81
|
+
|
80
82
|
"tDQSTRING", /* Double quoted string */
|
81
83
|
"tSQSTRING", /* Single quoted string */
|
82
84
|
"tINTEGER", /* Integer */
|
@@ -120,7 +122,9 @@ token next_token(lexstate *state, enum TokenType type) {
|
|
120
122
|
t.range.start = state->start;
|
121
123
|
t.range.end = state->current;
|
122
124
|
state->start = state->current;
|
123
|
-
|
125
|
+
if (type != tTRIVIA) {
|
126
|
+
state->first_token_of_line = false;
|
127
|
+
}
|
124
128
|
|
125
129
|
return t;
|
126
130
|
}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#define RBS_LOC_REQUIRED_P(loc, i) ((loc)->children->required_p & (1 << (i)))
|
4
4
|
#define RBS_LOC_OPTIONAL_P(loc, i) (!RBS_LOC_REQUIRED_P((loc), (i)))
|
5
|
+
#define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * ((cap) - 1))
|
5
6
|
|
6
7
|
VALUE RBS_Location;
|
7
8
|
|
@@ -25,7 +26,7 @@ static void check_children_max(unsigned short n) {
|
|
25
26
|
void rbs_loc_alloc_children(rbs_loc *loc, unsigned short cap) {
|
26
27
|
check_children_max(cap);
|
27
28
|
|
28
|
-
size_t s =
|
29
|
+
size_t s = RBS_LOC_CHILDREN_SIZE(cap);
|
29
30
|
loc->children = malloc(s);
|
30
31
|
|
31
32
|
loc->children->len = 0;
|
@@ -39,7 +40,7 @@ static void check_children_cap(rbs_loc *loc) {
|
|
39
40
|
} else {
|
40
41
|
if (loc->children->len == loc->children->cap) {
|
41
42
|
check_children_max(loc->children->cap + 1);
|
42
|
-
size_t s =
|
43
|
+
size_t s = RBS_LOC_CHILDREN_SIZE(++loc->children->cap);
|
43
44
|
loc->children = realloc(loc->children, s);
|
44
45
|
}
|
45
46
|
}
|
@@ -85,7 +86,7 @@ static size_t rbs_loc_memsize(const void *ptr) {
|
|
85
86
|
if (loc->children == NULL) {
|
86
87
|
return sizeof(rbs_loc);
|
87
88
|
} else {
|
88
|
-
return sizeof(rbs_loc) +
|
89
|
+
return sizeof(rbs_loc) + RBS_LOC_CHILDREN_SIZE(loc->children->cap);
|
89
90
|
}
|
90
91
|
}
|
91
92
|
|
@@ -129,7 +130,7 @@ static VALUE location_initialize_copy(VALUE self, VALUE other) {
|
|
129
130
|
self_loc->rg = other_loc->rg;
|
130
131
|
if (other_loc->children != NULL) {
|
131
132
|
rbs_loc_alloc_children(self_loc, other_loc->children->cap);
|
132
|
-
memcpy(self_loc->children, other_loc->children,
|
133
|
+
memcpy(self_loc->children, other_loc->children, RBS_LOC_CHILDREN_SIZE(other_loc->children->cap));
|
133
134
|
}
|
134
135
|
|
135
136
|
return Qnil;
|
@@ -16,17 +16,19 @@ typedef struct {
|
|
16
16
|
|
17
17
|
typedef unsigned int rbs_loc_entry_bitmap;
|
18
18
|
|
19
|
+
// The flexible array always allocates, but it's okay.
|
20
|
+
// This struct is not allocated when the `rbs_loc` doesn't have children.
|
19
21
|
typedef struct {
|
20
22
|
unsigned short len;
|
21
23
|
unsigned short cap;
|
22
24
|
rbs_loc_entry_bitmap required_p;
|
23
|
-
rbs_loc_entry entries[
|
25
|
+
rbs_loc_entry entries[1];
|
24
26
|
} rbs_loc_children;
|
25
27
|
|
26
28
|
typedef struct {
|
27
29
|
VALUE buffer;
|
28
30
|
range rg;
|
29
|
-
rbs_loc_children *children;
|
31
|
+
rbs_loc_children *children; // NULL when no children is allocated
|
30
32
|
} rbs_loc;
|
31
33
|
|
32
34
|
/**
|
data/ext/rbs_extension/parser.c
CHANGED
@@ -2805,56 +2805,103 @@ VALUE parse_signature(parserstate *state) {
|
|
2805
2805
|
return ret;
|
2806
2806
|
}
|
2807
2807
|
|
2808
|
+
struct parse_type_arg {
|
2809
|
+
parserstate *parser;
|
2810
|
+
VALUE require_eof;
|
2811
|
+
};
|
2812
|
+
|
2808
2813
|
static VALUE
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2814
|
+
ensure_free_parser(VALUE parser) {
|
2815
|
+
free_parser((parserstate *)parser);
|
2816
|
+
return Qnil;
|
2817
|
+
}
|
2818
|
+
|
2819
|
+
static VALUE
|
2820
|
+
parse_type_try(VALUE a) {
|
2821
|
+
struct parse_type_arg *arg = (struct parse_type_arg *)a;
|
2812
2822
|
|
2813
|
-
if (parser->next_token.type == pEOF) {
|
2814
|
-
free_parser(parser);
|
2823
|
+
if (arg->parser->next_token.type == pEOF) {
|
2815
2824
|
return Qnil;
|
2816
2825
|
}
|
2817
2826
|
|
2818
|
-
VALUE type = parse_type(parser);
|
2827
|
+
VALUE type = parse_type(arg->parser);
|
2819
2828
|
|
2820
|
-
if (RB_TEST(require_eof)) {
|
2821
|
-
parser_advance_assert(parser, pEOF);
|
2829
|
+
if (RB_TEST(arg->require_eof)) {
|
2830
|
+
parser_advance_assert(arg->parser, pEOF);
|
2822
2831
|
}
|
2823
2832
|
|
2824
|
-
free_parser(parser);
|
2825
|
-
|
2826
2833
|
return type;
|
2827
2834
|
}
|
2828
2835
|
|
2829
2836
|
static VALUE
|
2830
|
-
|
2837
|
+
rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_eof)
|
2831
2838
|
{
|
2832
2839
|
parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables);
|
2840
|
+
struct parse_type_arg arg = {
|
2841
|
+
parser,
|
2842
|
+
require_eof
|
2843
|
+
};
|
2844
|
+
return rb_ensure(parse_type_try, (VALUE)&arg, ensure_free_parser, (VALUE)parser);
|
2845
|
+
}
|
2833
2846
|
|
2834
|
-
|
2835
|
-
|
2847
|
+
static VALUE
|
2848
|
+
parse_method_type_try(VALUE a) {
|
2849
|
+
struct parse_type_arg *arg = (struct parse_type_arg *)a;
|
2850
|
+
|
2851
|
+
if (arg->parser->next_token.type == pEOF) {
|
2836
2852
|
return Qnil;
|
2837
2853
|
}
|
2838
2854
|
|
2839
|
-
VALUE method_type = parse_method_type(parser);
|
2855
|
+
VALUE method_type = parse_method_type(arg->parser);
|
2840
2856
|
|
2841
|
-
if (RB_TEST(require_eof)) {
|
2842
|
-
parser_advance_assert(parser, pEOF);
|
2857
|
+
if (RB_TEST(arg->require_eof)) {
|
2858
|
+
parser_advance_assert(arg->parser, pEOF);
|
2843
2859
|
}
|
2844
2860
|
|
2845
|
-
free_parser(parser);
|
2846
|
-
|
2847
2861
|
return method_type;
|
2848
2862
|
}
|
2849
2863
|
|
2864
|
+
static VALUE
|
2865
|
+
rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_eof)
|
2866
|
+
{
|
2867
|
+
parserstate *parser = alloc_parser(buffer, FIX2INT(start_pos), FIX2INT(end_pos), variables);
|
2868
|
+
struct parse_type_arg arg = {
|
2869
|
+
parser,
|
2870
|
+
require_eof
|
2871
|
+
};
|
2872
|
+
return rb_ensure(parse_method_type_try, (VALUE)&arg, ensure_free_parser, (VALUE)parser);
|
2873
|
+
}
|
2874
|
+
|
2875
|
+
static VALUE
|
2876
|
+
parse_signature_try(VALUE a) {
|
2877
|
+
parserstate *parser = (parserstate *)a;
|
2878
|
+
return parse_signature(parser);
|
2879
|
+
}
|
2880
|
+
|
2850
2881
|
static VALUE
|
2851
2882
|
rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE end_pos)
|
2852
2883
|
{
|
2853
2884
|
parserstate *parser = alloc_parser(buffer, 0, FIX2INT(end_pos), Qnil);
|
2854
|
-
VALUE
|
2855
|
-
|
2885
|
+
return rb_ensure(parse_signature_try, (VALUE)parser, ensure_free_parser, (VALUE)parser);
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
static VALUE
|
2889
|
+
rbsparser_lex(VALUE self, VALUE buffer, VALUE end_pos) {
|
2890
|
+
lexstate *lexer = alloc_lexer(buffer, 0, FIX2INT(end_pos));
|
2891
|
+
VALUE results = rb_ary_new();
|
2892
|
+
|
2893
|
+
token token = NullToken;
|
2894
|
+
while (token.type != pEOF) {
|
2895
|
+
token = rbsparser_next_token(lexer);
|
2896
|
+
VALUE type = ID2SYM(rb_intern(token_type_str(token.type)));
|
2897
|
+
VALUE location = rbs_new_location(buffer, token.range);
|
2898
|
+
VALUE pair = rb_ary_new3(2, type, location);
|
2899
|
+
rb_ary_push(results, pair);
|
2900
|
+
}
|
2901
|
+
|
2902
|
+
free(lexer);
|
2856
2903
|
|
2857
|
-
return
|
2904
|
+
return results;
|
2858
2905
|
}
|
2859
2906
|
|
2860
2907
|
void rbs__init_parser(void) {
|
@@ -2862,4 +2909,5 @@ void rbs__init_parser(void) {
|
|
2862
2909
|
rb_define_singleton_method(RBS_Parser, "_parse_type", rbsparser_parse_type, 5);
|
2863
2910
|
rb_define_singleton_method(RBS_Parser, "_parse_method_type", rbsparser_parse_method_type, 5);
|
2864
2911
|
rb_define_singleton_method(RBS_Parser, "_parse_signature", rbsparser_parse_signature, 2);
|
2912
|
+
rb_define_singleton_method(RBS_Parser, "_lex", rbsparser_lex, 2);
|
2865
2913
|
}
|
@@ -109,6 +109,8 @@ void parser_advance(parserstate *state) {
|
|
109
109
|
// skip
|
110
110
|
} else if (state->next_token3.type == tLINECOMMENT) {
|
111
111
|
insert_comment_line(state, state->next_token3);
|
112
|
+
} else if (state->next_token3.type == tTRIVIA) {
|
113
|
+
//skip
|
112
114
|
} else {
|
113
115
|
break;
|
114
116
|
}
|
@@ -272,7 +274,7 @@ VALUE comment_to_ruby(comment *com, VALUE buffer) {
|
|
272
274
|
);
|
273
275
|
}
|
274
276
|
|
275
|
-
|
277
|
+
lexstate *alloc_lexer(VALUE buffer, int start_pos, int end_pos) {
|
276
278
|
VALUE string = rb_funcall(buffer, rb_intern("content"), 0);
|
277
279
|
|
278
280
|
StringValue(string);
|
@@ -290,6 +292,11 @@ parserstate *alloc_parser(VALUE buffer, int start_pos, int end_pos, VALUE variab
|
|
290
292
|
lexer->start = lexer->current;
|
291
293
|
lexer->first_token_of_line = lexer->current.column == 0;
|
292
294
|
|
295
|
+
return lexer;
|
296
|
+
}
|
297
|
+
|
298
|
+
parserstate *alloc_parser(VALUE buffer, int start_pos, int end_pos, VALUE variables) {
|
299
|
+
lexstate *lexer = alloc_lexer(buffer, start_pos, end_pos);
|
293
300
|
parserstate *parser = calloc(1, sizeof(parserstate));
|
294
301
|
parser->lexstate = lexer;
|
295
302
|
parser->buffer = buffer;
|
@@ -93,6 +93,15 @@ void parser_insert_typevar(parserstate *state, ID id);
|
|
93
93
|
* */
|
94
94
|
bool parser_typevar_member(parserstate *state, ID id);
|
95
95
|
|
96
|
+
/**
|
97
|
+
* Allocate new lexstate object.
|
98
|
+
*
|
99
|
+
* ```
|
100
|
+
* alloc_lexer(buffer, 0, 31) // New lexstate with buffer
|
101
|
+
* ```
|
102
|
+
* */
|
103
|
+
lexstate *alloc_lexer(VALUE buffer, int start_pos, int end_pos);
|
104
|
+
|
96
105
|
/**
|
97
106
|
* Allocate new parserstate object.
|
98
107
|
*
|
data/lib/rbs/cli/validate.rb
CHANGED
@@ -66,8 +66,8 @@ Examples:
|
|
66
66
|
$ rbs validate
|
67
67
|
EOU
|
68
68
|
|
69
|
-
opts.on("--silent") do
|
70
|
-
RBS.print_warning { "`--silent` option is deprecated." }
|
69
|
+
opts.on("--silent", "This option has been deprecated and does nothing.") do
|
70
|
+
RBS.print_warning { "`--silent` option is deprecated because it's silent by default. You can use --log-level option of rbs command to display more information." }
|
71
71
|
end
|
72
72
|
opts.on("--[no-]exit-error-on-syntax-error", "exit(1) if syntax error is detected") {|bool|
|
73
73
|
exit_error = bool
|
data/lib/rbs/cli.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require "open3"
|
4
4
|
require "optparse"
|
5
5
|
require "shellwords"
|
6
|
-
require "abbrev"
|
7
6
|
require "stringio"
|
8
7
|
|
9
8
|
module RBS
|
@@ -1062,14 +1061,13 @@ EOB
|
|
1062
1061
|
config_path = options.config_path or raise
|
1063
1062
|
lock_path = Collection::Config.to_lockfile_path(config_path)
|
1064
1063
|
|
1065
|
-
|
1066
|
-
|
1067
|
-
when 'install'
|
1064
|
+
case args[0]
|
1065
|
+
when 'install', 'instal', 'insta', 'inst', 'ins', 'in', 'i'
|
1068
1066
|
unless params[:frozen]
|
1069
1067
|
Collection::Config.generate_lockfile(config_path: config_path, definition: Bundler.definition)
|
1070
1068
|
end
|
1071
1069
|
Collection::Installer.new(lockfile_path: lock_path, stdout: stdout).install_from_lockfile
|
1072
|
-
when 'update'
|
1070
|
+
when 'update', 'updat', 'upda', 'upd', 'up', 'u'
|
1073
1071
|
# TODO: Be aware of argv to update only specified gem
|
1074
1072
|
Collection::Config.generate_lockfile(config_path: config_path, definition: Bundler.definition, with_lockfile: false)
|
1075
1073
|
Collection::Installer.new(lockfile_path: lock_path, stdout: stdout).install_from_lockfile
|
@@ -1107,7 +1105,7 @@ EOB
|
|
1107
1105
|
exit 1
|
1108
1106
|
end
|
1109
1107
|
Collection::Cleaner.new(lockfile_path: lock_path)
|
1110
|
-
when 'help'
|
1108
|
+
when 'help', 'hel', 'he', 'h'
|
1111
1109
|
puts opts.help
|
1112
1110
|
else
|
1113
1111
|
puts opts.help
|
data/lib/rbs/location_aux.rb
CHANGED
@@ -5,7 +5,12 @@ module RBS
|
|
5
5
|
def inspect
|
6
6
|
rks = each_required_key.to_a
|
7
7
|
ops = each_optional_key.to_a.map {|x| "?#{x}" }
|
8
|
-
|
8
|
+
src = if source.length <= 1
|
9
|
+
source.inspect
|
10
|
+
else
|
11
|
+
source.each_line.first&.chomp&.inspect
|
12
|
+
end
|
13
|
+
"#<#{self.class}:#{self.__id__} buffer=#{buffer.name}, start=#{start_line}:#{start_column}, pos=#{start_pos}...#{end_pos}, children=#{(rks + ops).join(",")} source=#{src}>"
|
9
14
|
end
|
10
15
|
|
11
16
|
def self.new(buffer_ = nil, start_pos_ = nil, end_pos_ = nil, buffer: nil, start_pos: nil, end_pos: nil)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBS
|
4
|
+
class Parser
|
5
|
+
class Token
|
6
|
+
attr_reader :type
|
7
|
+
attr_reader :location
|
8
|
+
|
9
|
+
def initialize(type:, location:)
|
10
|
+
@type = type
|
11
|
+
@location = location
|
12
|
+
end
|
13
|
+
|
14
|
+
def value
|
15
|
+
@location.source
|
16
|
+
end
|
17
|
+
|
18
|
+
def comment?
|
19
|
+
@type == :tCOMMENT || @type == :tLINECOMMENT
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rbs/parser_aux.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "parser/lex_result"
|
4
|
+
require_relative "parser/token"
|
5
|
+
|
3
6
|
module RBS
|
4
7
|
class Parser
|
5
8
|
def self.parse_type(source, range: 0..., variables: [], require_eof: false)
|
@@ -19,6 +22,15 @@ module RBS
|
|
19
22
|
[buf, dirs, decls]
|
20
23
|
end
|
21
24
|
|
25
|
+
def self.lex(source)
|
26
|
+
buf = buffer(source)
|
27
|
+
list = _lex(buf, buf.last_position)
|
28
|
+
value = list.map do |type, location|
|
29
|
+
Token.new(type: type, location: location)
|
30
|
+
end
|
31
|
+
LexResult.new(buffer: buf, value: value)
|
32
|
+
end
|
33
|
+
|
22
34
|
def self.buffer(source)
|
23
35
|
case source
|
24
36
|
when String
|
data/lib/rbs/version.rb
CHANGED
data/rbs.gemspec
CHANGED
@@ -28,7 +28,12 @@ Gem::Specification.new do |spec|
|
|
28
28
|
# Specify which files should be added to the gem when it is released.
|
29
29
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
30
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
-
`git ls-files -z`.split("\x0").reject
|
31
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
32
|
+
[
|
33
|
+
%r{^(test|spec|features|bin|steep|benchmark)/},
|
34
|
+
/Gemfile/
|
35
|
+
].any? {|r| f.match(r) }
|
36
|
+
end
|
32
37
|
end
|
33
38
|
spec.extensions = %w{ext/rbs_extension/extconf.rb}
|
34
39
|
|
@@ -36,5 +41,4 @@ Gem::Specification.new do |spec|
|
|
36
41
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
42
|
spec.require_paths = ["lib"]
|
38
43
|
spec.required_ruby_version = ">= 3.0"
|
39
|
-
spec.add_dependency "abbrev"
|
40
44
|
end
|
data/sig/manifest.yaml
CHANGED
data/sig/parser.rbs
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
module RBS
|
2
2
|
class Parser
|
3
|
+
# Result of `Parser.lex`
|
4
|
+
class LexResult
|
5
|
+
attr_reader buffer: Buffer
|
6
|
+
attr_reader value: Array[Token]
|
7
|
+
|
8
|
+
def initialize: (buffer: Buffer, value: Array[Token]) -> void
|
9
|
+
end
|
10
|
+
|
11
|
+
# Represents a token per result of `Parser.lex`.
|
12
|
+
class Token
|
13
|
+
attr_reader type: Symbol
|
14
|
+
attr_reader location: Location[untyped, untyped]
|
15
|
+
|
16
|
+
def initialize: (type: Symbol, location: Location[untyped, untyped]) -> void
|
17
|
+
def value: () -> String
|
18
|
+
def comment?: () -> bool
|
19
|
+
end
|
20
|
+
|
3
21
|
# Parse a method type and return it
|
4
22
|
#
|
5
23
|
# When `range` keyword is specified, it starts parsing from the `begin` to the `end` of the range.
|
@@ -50,6 +68,14 @@ module RBS
|
|
50
68
|
#
|
51
69
|
def self.parse_signature: (Buffer | String) -> [Buffer, Array[AST::Directives::t], Array[AST::Declarations::t]]
|
52
70
|
|
71
|
+
# Parse whole RBS file and return result.
|
72
|
+
#
|
73
|
+
# ```ruby
|
74
|
+
# RBS::Parser.lex("# Comment\nmodule A\nend\n").value.map(&:type)
|
75
|
+
# # => [:tLINECOMMENT, :kMODULE, :tUIDENT, :kEND, :pEOF]
|
76
|
+
# ```
|
77
|
+
def self.lex: (Buffer | String) -> LexResult
|
78
|
+
|
53
79
|
KEYWORDS: Hash[String, bot]
|
54
80
|
|
55
81
|
private
|
@@ -62,6 +88,8 @@ module RBS
|
|
62
88
|
|
63
89
|
def self._parse_signature: (Buffer, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
|
64
90
|
|
91
|
+
def self._lex: (Buffer, Integer end_pos) -> Array[[Symbol, Location[untyped, untyped]]]
|
92
|
+
|
65
93
|
class LocatedValue
|
66
94
|
end
|
67
95
|
end
|
data/stdlib/uri/0/mailto.rbs
CHANGED
@@ -4,5 +4,89 @@ module URI
|
|
4
4
|
# RFC6068, the mailto URL scheme.
|
5
5
|
#
|
6
6
|
class MailTo < Generic
|
7
|
+
EMAIL_REGEXP: Regexp
|
8
|
+
|
9
|
+
# <!--
|
10
|
+
# rdoc-file=lib/uri/mailto.rb
|
11
|
+
# - build(args)
|
12
|
+
# -->
|
13
|
+
# ## Description
|
14
|
+
#
|
15
|
+
# Creates a new URI::MailTo object from components, with syntax checking.
|
16
|
+
#
|
17
|
+
# Components can be provided as an Array or Hash. If an Array is used, the
|
18
|
+
# components must be supplied as `[to, headers]`.
|
19
|
+
#
|
20
|
+
# If a Hash is used, the keys are the component names preceded by colons.
|
21
|
+
#
|
22
|
+
# The headers can be supplied as a pre-encoded string, such as
|
23
|
+
# `"subject=subscribe&cc=address"`, or as an Array of Arrays like `[['subject',
|
24
|
+
# 'subscribe'], ['cc', 'address']]`.
|
25
|
+
#
|
26
|
+
# Examples:
|
27
|
+
#
|
28
|
+
# require 'uri'
|
29
|
+
#
|
30
|
+
# m1 = URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
|
31
|
+
# m1.to_s # => "mailto:joe@example.com?subject=Ruby"
|
32
|
+
#
|
33
|
+
# m2 = URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
|
34
|
+
# m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
|
35
|
+
#
|
36
|
+
# m3 = URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
|
37
|
+
# m3.to_s # => "mailto:listman@example.com?subject=subscribe"
|
38
|
+
#
|
39
|
+
def self.build: (Array[String]) -> instance
|
40
|
+
| ([String, Array[Array[String]]]) -> instance
|
41
|
+
| (Hash[Symbol, String | Array[Array[String]]]) -> instance
|
42
|
+
|
43
|
+
# <!-- rdoc-file=lib/uri/mailto.rb -->
|
44
|
+
# E-mail headers set by the URL, as an Array of Arrays.
|
45
|
+
#
|
46
|
+
def headers: () -> Array[[String, String]]
|
47
|
+
|
48
|
+
# <!--
|
49
|
+
# rdoc-file=lib/uri/mailto.rb
|
50
|
+
# - headers=(v)
|
51
|
+
# -->
|
52
|
+
# Setter for headers `v`.
|
53
|
+
#
|
54
|
+
def headers=: (String) -> String
|
55
|
+
|
56
|
+
# <!-- rdoc-file=lib/uri/mailto.rb -->
|
57
|
+
# The primary e-mail address of the URL, as a String.
|
58
|
+
#
|
59
|
+
def to: () -> String
|
60
|
+
|
61
|
+
# <!--
|
62
|
+
# rdoc-file=lib/uri/mailto.rb
|
63
|
+
# - to=(v)
|
64
|
+
# -->
|
65
|
+
# Setter for to `v`.
|
66
|
+
#
|
67
|
+
def to=: (String) -> String
|
68
|
+
|
69
|
+
# <!--
|
70
|
+
# rdoc-file=lib/uri/mailto.rb
|
71
|
+
# - to_mailtext()
|
72
|
+
# -->
|
73
|
+
# Returns the RFC822 e-mail text equivalent of the URL, as a String.
|
74
|
+
#
|
75
|
+
# Example:
|
76
|
+
#
|
77
|
+
# require 'uri'
|
78
|
+
#
|
79
|
+
# uri = URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
|
80
|
+
# uri.to_mailtext
|
81
|
+
# # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
|
82
|
+
#
|
83
|
+
def to_mailtext: () -> String
|
84
|
+
|
85
|
+
# <!--
|
86
|
+
# rdoc-file=lib/uri/mailto.rb
|
87
|
+
# - to_rfc822text()
|
88
|
+
# -->
|
89
|
+
#
|
90
|
+
def to_rfc822text: () -> String
|
7
91
|
end
|
8
92
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: abbrev
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: RBS is the language for type signatures for Ruby and standard library
|
28
14
|
definitions.
|
29
15
|
email:
|
@@ -36,6 +22,7 @@ extra_rdoc_files: []
|
|
36
22
|
files:
|
37
23
|
- ".github/dependabot.yml"
|
38
24
|
- ".github/workflows/comments.yml"
|
25
|
+
- ".github/workflows/dependabot.yml"
|
39
26
|
- ".github/workflows/ruby.yml"
|
40
27
|
- ".github/workflows/typecheck.yml"
|
41
28
|
- ".gitignore"
|
@@ -43,8 +30,6 @@ files:
|
|
43
30
|
- BSDL
|
44
31
|
- CHANGELOG.md
|
45
32
|
- COPYING
|
46
|
-
- Gemfile
|
47
|
-
- Gemfile.lock
|
48
33
|
- README.md
|
49
34
|
- Rakefile
|
50
35
|
- Steepfile
|
@@ -210,6 +195,8 @@ files:
|
|
210
195
|
- lib/rbs/locator.rb
|
211
196
|
- lib/rbs/method_type.rb
|
212
197
|
- lib/rbs/namespace.rb
|
198
|
+
- lib/rbs/parser/lex_result.rb
|
199
|
+
- lib/rbs/parser/token.rb
|
213
200
|
- lib/rbs/parser_aux.rb
|
214
201
|
- lib/rbs/prototype/helpers.rb
|
215
202
|
- lib/rbs/prototype/node_usage.rb
|