rbs 2.8.1 → 3.0.0.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/.github/workflows/comments.yml +1 -1
- data/.github/workflows/ruby.yml +9 -6
- data/Gemfile +1 -1
- data/Gemfile.lock +16 -16
- data/ext/rbs_extension/constants.c +2 -0
- data/ext/rbs_extension/constants.h +1 -0
- data/ext/rbs_extension/parser.c +23 -13
- data/ext/rbs_extension/ruby_objs.c +15 -3
- data/ext/rbs_extension/ruby_objs.h +2 -1
- data/lib/rbs/ast/members.rb +49 -15
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/config/lockfile.rb +115 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +89 -48
- data/lib/rbs/collection/config.rb +11 -39
- data/lib/rbs/collection/installer.rb +9 -13
- data/lib/rbs/collection/sources/base.rb +2 -2
- data/lib/rbs/collection/sources/git.rb +135 -62
- data/lib/rbs/collection/sources/rubygems.rb +10 -12
- data/lib/rbs/collection/sources/stdlib.rb +10 -13
- data/lib/rbs/collection/sources.rb +7 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/method_builder.rb +3 -3
- data/lib/rbs/definition_builder.rb +449 -572
- data/lib/rbs/environment.rb +5 -3
- data/lib/rbs/environment_loader.rb +11 -10
- data/lib/rbs/locator.rb +2 -2
- data/lib/rbs/prototype/helpers.rb +29 -13
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +3 -2
- data/lib/rbs/prototype/rbi.rb +6 -4
- data/lib/rbs/prototype/runtime.rb +25 -12
- data/lib/rbs/substitution.rb +19 -0
- data/lib/rbs/types.rb +1 -5
- data/lib/rbs/validator.rb +2 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +26 -17
- data/lib/rbs.rb +1 -0
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/schema/members.json +15 -10
- data/sig/collection/config/lockfile.rbs +80 -0
- data/sig/collection/config/lockfile_generator.rbs +55 -0
- data/sig/collection/config.rbs +5 -48
- data/sig/collection/installer.rbs +1 -1
- data/sig/collection/sources.rbs +66 -29
- data/sig/definition_builder.rbs +94 -81
- data/sig/environment_loader.rbs +1 -1
- data/sig/errors.rbs +21 -0
- data/sig/members.rbs +31 -7
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/shims/bundler.rbs +13 -0
- data/sig/shims/rubygems.rbs +9 -0
- data/sig/shims.rbs +0 -22
- data/sig/substitution.rbs +6 -0
- data/sig/writer.rbs +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a07433a652ee9bdc6b90162eb974d289fafabed916044ffa8e83b78063b8c0b
|
4
|
+
data.tar.gz: 1339eae3040ab4714dd241497bbc20d643ae5eaef62b03a02138806ecf4737c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b414da0d750aefbfdaadcd0a309d2ee4157969112f6806149597fd402b4ca43aaae5cbf162e14f7bfe0a21e3369fad2b94a54f5d3610e15362afd2bd9d83d8f
|
7
|
+
data.tar.gz: 884514e8cf52edbd3e17b6c214cd113b58a6107b4a00f73f826d471521d883997a3bee6c3f0c3e7a2770e23468e6a964878504f1a5cf7de9a6ab2d5ec66fbb4e
|
data/.github/workflows/ruby.yml
CHANGED
@@ -6,6 +6,9 @@ on:
|
|
6
6
|
- master
|
7
7
|
pull_request: {}
|
8
8
|
|
9
|
+
env:
|
10
|
+
LANG: 'C.UTF-8'
|
11
|
+
|
9
12
|
jobs:
|
10
13
|
test:
|
11
14
|
runs-on: "ubuntu-latest"
|
@@ -13,9 +16,9 @@ jobs:
|
|
13
16
|
matrix:
|
14
17
|
container_tag:
|
15
18
|
- master-nightly-focal
|
16
|
-
- 3.1-focal
|
17
|
-
- 3.0-focal
|
18
|
-
- 2.7-bionic
|
19
|
+
- 3.1-dev-focal
|
20
|
+
- 3.0-dev-focal
|
21
|
+
- 2.7-dev-bionic
|
19
22
|
- 2.6-bionic
|
20
23
|
job:
|
21
24
|
- test
|
@@ -28,16 +31,16 @@ jobs:
|
|
28
31
|
job: confirm_lexer
|
29
32
|
- container_tag: 2.6-bionic
|
30
33
|
job: stdlib_test
|
31
|
-
- container_tag: 2.7-bionic
|
34
|
+
- container_tag: 2.7-dev-bionic
|
32
35
|
job: stdlib_test
|
33
|
-
- container_tag: 3.0-focal
|
36
|
+
- container_tag: 3.0-dev-focal
|
34
37
|
job: stdlib_test
|
35
38
|
container:
|
36
39
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
37
40
|
steps:
|
38
41
|
- uses: actions/checkout@v3
|
39
42
|
- name: Set working directory as safe
|
40
|
-
run:
|
43
|
+
run: git config --global --add safe.directory $(pwd)
|
41
44
|
- name: Install dependencies
|
42
45
|
run: |
|
43
46
|
apt-get update
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs (
|
4
|
+
rbs (3.0.0.dev.1)
|
5
5
|
|
6
6
|
PATH
|
7
7
|
remote: test/assets/test-gem
|
@@ -19,35 +19,35 @@ GEM
|
|
19
19
|
debase-ruby_core_source (>= 0.10.12)
|
20
20
|
debase-ruby_core_source (0.10.16)
|
21
21
|
diff-lcs (1.5.0)
|
22
|
-
digest (3.1.
|
22
|
+
digest (3.1.1)
|
23
23
|
forwardable (1.3.2)
|
24
24
|
goodcheck (3.1.0)
|
25
25
|
marcel (>= 1.0, < 2.0)
|
26
26
|
psych (>= 3.1, < 5.0)
|
27
27
|
rainbow (>= 3.0, < 4.0)
|
28
28
|
strong_json (>= 1.1, < 2.2)
|
29
|
-
json (2.6.
|
29
|
+
json (2.6.3)
|
30
30
|
json-schema (3.0.0)
|
31
31
|
addressable (>= 2.8)
|
32
32
|
marcel (1.0.2)
|
33
|
-
minitest (5.
|
33
|
+
minitest (5.17.0)
|
34
34
|
parallel (1.22.1)
|
35
|
-
parser (3.1.
|
35
|
+
parser (3.1.3.0)
|
36
36
|
ast (~> 2.4.1)
|
37
|
-
power_assert (2.0.
|
37
|
+
power_assert (2.0.2)
|
38
38
|
prime (0.1.2)
|
39
39
|
forwardable
|
40
40
|
singleton
|
41
|
-
psych (4.0.
|
41
|
+
psych (4.0.6)
|
42
42
|
stringio
|
43
43
|
public_suffix (4.0.7)
|
44
44
|
rainbow (3.1.1)
|
45
45
|
rake (13.0.6)
|
46
|
-
rake-compiler (1.2.
|
46
|
+
rake-compiler (1.2.1)
|
47
47
|
rake
|
48
48
|
rdoc (6.4.0)
|
49
49
|
psych (>= 4.0.0)
|
50
|
-
regexp_parser (2.6.
|
50
|
+
regexp_parser (2.6.1)
|
51
51
|
rexml (3.2.5)
|
52
52
|
rspec (3.12.0)
|
53
53
|
rspec-core (~> 3.12.0)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
63
|
rspec-support (~> 3.12.0)
|
64
64
|
rspec-support (3.12.0)
|
65
|
-
rubocop (1.
|
65
|
+
rubocop (1.40.0)
|
66
66
|
json (~> 2.3)
|
67
67
|
parallel (~> 1.10)
|
68
68
|
parser (>= 3.1.2.1)
|
@@ -72,7 +72,7 @@ GEM
|
|
72
72
|
rubocop-ast (>= 1.23.0, < 2.0)
|
73
73
|
ruby-progressbar (~> 1.7)
|
74
74
|
unicode-display_width (>= 1.4.0, < 3.0)
|
75
|
-
rubocop-ast (1.
|
75
|
+
rubocop-ast (1.24.0)
|
76
76
|
parser (>= 3.1.1.0)
|
77
77
|
rubocop-rubycw (0.1.6)
|
78
78
|
rubocop (~> 1.0)
|
@@ -80,11 +80,11 @@ GEM
|
|
80
80
|
rake (>= 0.8.1)
|
81
81
|
ruby-progressbar (1.11.0)
|
82
82
|
singleton (0.1.1)
|
83
|
-
stackprof (0.2.
|
84
|
-
stringio (3.0.
|
83
|
+
stackprof (0.2.23)
|
84
|
+
stringio (3.0.4)
|
85
85
|
strong_json (2.1.2)
|
86
|
-
tempfile (0.1.
|
87
|
-
test-unit (3.5.
|
86
|
+
tempfile (0.1.3)
|
87
|
+
test-unit (3.5.7)
|
88
88
|
power_assert
|
89
89
|
unicode-display_width (2.3.0)
|
90
90
|
|
@@ -105,7 +105,7 @@ DEPENDENCIES
|
|
105
105
|
rake-compiler
|
106
106
|
rbs!
|
107
107
|
rbs-amber!
|
108
|
-
rdoc
|
108
|
+
rdoc (< 6.5.0)
|
109
109
|
rspec
|
110
110
|
rubocop
|
111
111
|
rubocop-rubycw
|
@@ -30,6 +30,7 @@ VALUE RBS_AST_Members_Extend;
|
|
30
30
|
VALUE RBS_AST_Members_Include;
|
31
31
|
VALUE RBS_AST_Members_InstanceVariable;
|
32
32
|
VALUE RBS_AST_Members_MethodDefinition;
|
33
|
+
VALUE RBS_AST_Members_MethodDefinition_Overload;
|
33
34
|
VALUE RBS_AST_Members_Prepend;
|
34
35
|
VALUE RBS_AST_Members_Private;
|
35
36
|
VALUE RBS_AST_Members_Public;
|
@@ -99,6 +100,7 @@ void rbs__init_constants(void) {
|
|
99
100
|
RBS_AST_Members_Include = rb_const_get(RBS_AST_Members, rb_intern("Include"));
|
100
101
|
RBS_AST_Members_InstanceVariable = rb_const_get(RBS_AST_Members, rb_intern("InstanceVariable"));
|
101
102
|
RBS_AST_Members_MethodDefinition = rb_const_get(RBS_AST_Members, rb_intern("MethodDefinition"));
|
103
|
+
RBS_AST_Members_MethodDefinition_Overload = rb_const_get(RBS_AST_Members_MethodDefinition, rb_intern("Overload"));
|
102
104
|
RBS_AST_Members_Prepend = rb_const_get(RBS_AST_Members, rb_intern("Prepend"));
|
103
105
|
RBS_AST_Members_Private = rb_const_get(RBS_AST_Members, rb_intern("Private"));
|
104
106
|
RBS_AST_Members_Public = rb_const_get(RBS_AST_Members, rb_intern("Public"));
|
@@ -29,6 +29,7 @@ extern VALUE RBS_AST_Members_Extend;
|
|
29
29
|
extern VALUE RBS_AST_Members_Include;
|
30
30
|
extern VALUE RBS_AST_Members_InstanceVariable;
|
31
31
|
extern VALUE RBS_AST_Members_MethodDefinition;
|
32
|
+
extern VALUE RBS_AST_Members_MethodDefinition_Overload;
|
32
33
|
extern VALUE RBS_AST_Members_Prepend;
|
33
34
|
extern VALUE RBS_AST_Members_Private;
|
34
35
|
extern VALUE RBS_AST_Members_Public;
|
data/ext/rbs_extension/parser.c
CHANGED
@@ -1485,7 +1485,7 @@ VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overl
|
|
1485
1485
|
range keyword_range;
|
1486
1486
|
range name_range;
|
1487
1487
|
range kind_range;
|
1488
|
-
range
|
1488
|
+
range overloading_range = NULL_RANGE;
|
1489
1489
|
|
1490
1490
|
VALUE visibility;
|
1491
1491
|
|
@@ -1524,8 +1524,8 @@ VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overl
|
|
1524
1524
|
}
|
1525
1525
|
|
1526
1526
|
VALUE name = parse_method_name(state, &name_range);
|
1527
|
-
VALUE
|
1528
|
-
VALUE
|
1527
|
+
VALUE overloads = rb_ary_new();
|
1528
|
+
VALUE overloading = Qfalse;
|
1529
1529
|
|
1530
1530
|
if (state->next_token.type == pDOT && RB_SYM2ID(name) == rb_intern("self?")) {
|
1531
1531
|
raise_syntax_error(
|
@@ -1541,23 +1541,33 @@ VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overl
|
|
1541
1541
|
|
1542
1542
|
bool loop = true;
|
1543
1543
|
while (loop) {
|
1544
|
+
VALUE annotations = rb_ary_new();
|
1545
|
+
position overload_annot_pos = NullPosition;
|
1546
|
+
|
1547
|
+
if (state->next_token.type == tANNOTATION) {
|
1548
|
+
parse_annotations(state, annotations, &overload_annot_pos);
|
1549
|
+
}
|
1550
|
+
|
1544
1551
|
switch (state->next_token.type) {
|
1545
1552
|
case pLPAREN:
|
1546
1553
|
case pARROW:
|
1547
1554
|
case pLBRACE:
|
1548
1555
|
case pLBRACKET:
|
1549
1556
|
case pQUESTION:
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1557
|
+
{
|
1558
|
+
VALUE method_type = parse_method_type(state);
|
1559
|
+
rb_ary_push(overloads, rbs_ast_members_method_definition_overload(annotations, method_type));
|
1560
|
+
member_range.end = state->current_token.range.end;
|
1561
|
+
break;
|
1562
|
+
}
|
1553
1563
|
|
1554
1564
|
case pDOT3:
|
1555
1565
|
if (accept_overload) {
|
1556
|
-
|
1566
|
+
overloading = Qtrue;
|
1557
1567
|
parser_advance(state);
|
1558
1568
|
loop = false;
|
1559
|
-
|
1560
|
-
member_range.end =
|
1569
|
+
overloading_range = state->current_token.range;
|
1570
|
+
member_range.end = overloading_range.end;
|
1561
1571
|
break;
|
1562
1572
|
} else {
|
1563
1573
|
raise_syntax_error(
|
@@ -1604,17 +1614,17 @@ VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overl
|
|
1604
1614
|
rbs_loc_add_required_child(loc, rb_intern("keyword"), keyword_range);
|
1605
1615
|
rbs_loc_add_required_child(loc, rb_intern("name"), name_range);
|
1606
1616
|
rbs_loc_add_optional_child(loc, rb_intern("kind"), kind_range);
|
1607
|
-
rbs_loc_add_optional_child(loc, rb_intern("
|
1617
|
+
rbs_loc_add_optional_child(loc, rb_intern("overloading"), overloading_range);
|
1608
1618
|
rbs_loc_add_optional_child(loc, rb_intern("visibility"), visibility_range);
|
1609
1619
|
|
1610
1620
|
return rbs_ast_members_method_definition(
|
1611
1621
|
name,
|
1612
1622
|
k,
|
1613
|
-
|
1623
|
+
overloads,
|
1614
1624
|
annotations,
|
1615
1625
|
location,
|
1616
1626
|
comment,
|
1617
|
-
|
1627
|
+
overloading,
|
1618
1628
|
visibility
|
1619
1629
|
);
|
1620
1630
|
}
|
@@ -2343,7 +2353,7 @@ VALUE parse_class_decl_super(parserstate *state, range *lt_range) {
|
|
2343
2353
|
args = rb_ary_new();
|
2344
2354
|
class_instance_name(state, CLASS_NAME, &name, args, &name_range, &args_range);
|
2345
2355
|
|
2346
|
-
super_range.end =
|
2356
|
+
super_range.end = state->current_token.range.end;
|
2347
2357
|
|
2348
2358
|
location = rbs_new_location(state->buffer, super_range);
|
2349
2359
|
loc = rbs_check_location(location);
|
@@ -402,15 +402,27 @@ VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE
|
|
402
402
|
);
|
403
403
|
}
|
404
404
|
|
405
|
-
VALUE
|
405
|
+
VALUE rbs_ast_members_method_definition_overload(VALUE annotations, VALUE method_type) {
|
406
|
+
VALUE args = rb_hash_new();
|
407
|
+
rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
|
408
|
+
rb_hash_aset(args, ID2SYM(rb_intern("method_type")), method_type);
|
409
|
+
|
410
|
+
return CLASS_NEW_INSTANCE(
|
411
|
+
RBS_AST_Members_MethodDefinition_Overload,
|
412
|
+
1,
|
413
|
+
&args
|
414
|
+
);
|
415
|
+
}
|
416
|
+
|
417
|
+
VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE overloads, VALUE annotations, VALUE location, VALUE comment, VALUE overloading, VALUE visibility) {
|
406
418
|
VALUE args = rb_hash_new();
|
407
419
|
rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
|
408
420
|
rb_hash_aset(args, ID2SYM(rb_intern("kind")), kind);
|
409
|
-
rb_hash_aset(args, ID2SYM(rb_intern("
|
421
|
+
rb_hash_aset(args, ID2SYM(rb_intern("overloads")), overloads);
|
410
422
|
rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
|
411
423
|
rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
|
412
424
|
rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
|
413
|
-
rb_hash_aset(args, ID2SYM(rb_intern("
|
425
|
+
rb_hash_aset(args, ID2SYM(rb_intern("overloading")), overloading);
|
414
426
|
rb_hash_aset(args, ID2SYM(rb_intern("visibility")), visibility);
|
415
427
|
|
416
428
|
return CLASS_NEW_INSTANCE(
|
@@ -17,7 +17,8 @@ VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location);
|
|
17
17
|
VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE members, VALUE annotations, VALUE location, VALUE comment);
|
18
18
|
VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment);
|
19
19
|
VALUE rbs_ast_members_attribute(VALUE klass, VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility);
|
20
|
-
VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE
|
20
|
+
VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE overloads, VALUE annotations, VALUE location, VALUE comment, VALUE overloading, VALUE visibility);
|
21
|
+
VALUE rbs_ast_members_method_definition_overload(VALUE annotations, VALUE method_type);
|
21
22
|
VALUE rbs_ast_members_mixin(VALUE klass, VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment);
|
22
23
|
VALUE rbs_ast_members_variable(VALUE klass, VALUE name, VALUE type, VALUE location, VALUE comment);
|
23
24
|
VALUE rbs_ast_members_visibility(VALUE klass, VALUE location);
|
data/lib/rbs/ast/members.rb
CHANGED
@@ -7,23 +7,57 @@ module RBS
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class MethodDefinition < Base
|
10
|
+
class Overload
|
11
|
+
attr_reader :method_type, :annotations
|
12
|
+
|
13
|
+
def initialize(method_type:, annotations:)
|
14
|
+
@method_type = method_type
|
15
|
+
@annotations = annotations
|
16
|
+
end
|
17
|
+
|
18
|
+
def ==(other)
|
19
|
+
other.is_a?(Overload) && other.method_type == method_type && other.annotations == annotations
|
20
|
+
end
|
21
|
+
|
22
|
+
def hash
|
23
|
+
method_type.hash ^ annotations.hash
|
24
|
+
end
|
25
|
+
|
26
|
+
alias eql? ==
|
27
|
+
|
28
|
+
def update(annotations: self.annotations, method_type: self.method_type)
|
29
|
+
Overload.new(annotations: annotations, method_type: method_type)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sub(subst)
|
33
|
+
update(method_type: self.method_type.sub(subst))
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_json(state = _ = nil)
|
37
|
+
{
|
38
|
+
annotations: annotations,
|
39
|
+
method_type: method_type
|
40
|
+
}.to_json(state)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
10
44
|
attr_reader :name
|
11
45
|
attr_reader :kind
|
12
|
-
attr_reader :
|
46
|
+
attr_reader :overloads
|
13
47
|
attr_reader :annotations
|
14
48
|
attr_reader :location
|
15
49
|
attr_reader :comment
|
16
|
-
attr_reader :
|
50
|
+
attr_reader :overloading
|
17
51
|
attr_reader :visibility
|
18
52
|
|
19
|
-
def initialize(name:, kind:,
|
53
|
+
def initialize(name:, kind:, overloads:, annotations:, location:, comment:, overloading:, visibility:)
|
20
54
|
@name = name
|
21
55
|
@kind = kind
|
22
|
-
@
|
56
|
+
@overloads = overloads
|
23
57
|
@annotations = annotations
|
24
58
|
@location = location
|
25
59
|
@comment = comment
|
26
|
-
@
|
60
|
+
@overloading = overloading
|
27
61
|
@visibility = visibility
|
28
62
|
end
|
29
63
|
|
@@ -31,15 +65,15 @@ module RBS
|
|
31
65
|
other.is_a?(MethodDefinition) &&
|
32
66
|
other.name == name &&
|
33
67
|
other.kind == kind &&
|
34
|
-
other.
|
35
|
-
other.
|
68
|
+
other.overloads == overloads &&
|
69
|
+
other.overloading? == overloading? &&
|
36
70
|
other.visibility == visibility
|
37
71
|
end
|
38
72
|
|
39
73
|
alias eql? ==
|
40
74
|
|
41
75
|
def hash
|
42
|
-
name.hash ^ kind.hash ^
|
76
|
+
name.hash ^ kind.hash ^ overloads.hash ^ overloading?.hash ^ visibility.hash
|
43
77
|
end
|
44
78
|
|
45
79
|
def instance?
|
@@ -50,19 +84,19 @@ module RBS
|
|
50
84
|
kind == :singleton || kind == :singleton_instance
|
51
85
|
end
|
52
86
|
|
53
|
-
def
|
54
|
-
|
87
|
+
def overloading?
|
88
|
+
overloading
|
55
89
|
end
|
56
90
|
|
57
|
-
def update(name: self.name, kind: self.kind,
|
91
|
+
def update(name: self.name, kind: self.kind, overloads: self.overloads, annotations: self.annotations, location: self.location, comment: self.comment, overloading: self.overloading?, visibility: self.visibility)
|
58
92
|
self.class.new(
|
59
93
|
name: name,
|
60
94
|
kind: kind,
|
61
|
-
|
95
|
+
overloads: overloads,
|
62
96
|
annotations: annotations,
|
63
97
|
location: location,
|
64
98
|
comment: comment,
|
65
|
-
|
99
|
+
overloading: overloading,
|
66
100
|
visibility: visibility
|
67
101
|
)
|
68
102
|
end
|
@@ -72,11 +106,11 @@ module RBS
|
|
72
106
|
member: :method_definition,
|
73
107
|
name: name,
|
74
108
|
kind: kind,
|
75
|
-
|
109
|
+
overloads: overloads,
|
76
110
|
annotations: annotations,
|
77
111
|
location: location,
|
78
112
|
comment: comment,
|
79
|
-
|
113
|
+
overloading: overloading?,
|
80
114
|
visibility: visibility
|
81
115
|
}.to_json(state)
|
82
116
|
end
|
data/lib/rbs/cli.rb
CHANGED
@@ -29,7 +29,12 @@ module RBS
|
|
29
29
|
end
|
30
30
|
|
31
31
|
loader = EnvironmentLoader.new(core_root: core_root, repository: repository)
|
32
|
-
|
32
|
+
if config_path
|
33
|
+
lock_path = Collection::Config.to_lockfile_path(config_path)
|
34
|
+
if lock_path.file?
|
35
|
+
lock = Collection::Config::Lockfile.from_lockfile(lockfile_path: lock_path, data: YAML.load_file(lock_path.to_s))
|
36
|
+
end
|
37
|
+
end
|
33
38
|
loader.add_collection(lock) if lock
|
34
39
|
|
35
40
|
dirs.each do |dir|
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RBS
|
4
|
+
module Collection
|
5
|
+
class Config
|
6
|
+
class Lockfile
|
7
|
+
attr_reader :lockfile_path, :lockfile_dir, :path, :gemfile_lock_path, :sources, :gems
|
8
|
+
|
9
|
+
def initialize(lockfile_path:, path:, gemfile_lock_path:)
|
10
|
+
@lockfile_path = lockfile_path
|
11
|
+
@lockfile_dir = lockfile_path.parent
|
12
|
+
@path = path
|
13
|
+
@gemfile_lock_path = gemfile_lock_path
|
14
|
+
|
15
|
+
@sources = {}
|
16
|
+
@gems = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def fullpath
|
20
|
+
lockfile_dir + path
|
21
|
+
end
|
22
|
+
|
23
|
+
def gemfile_lock_fullpath
|
24
|
+
if gemfile_lock_path
|
25
|
+
lockfile_dir + gemfile_lock_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def each_source(&block)
|
30
|
+
if block
|
31
|
+
sources.each_value(&block)
|
32
|
+
yield Sources::Rubygems.instance
|
33
|
+
yield Sources::Stdlib.instance
|
34
|
+
else
|
35
|
+
enum_for :each_source
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_lockfile
|
40
|
+
# @type var data: lockfile_data
|
41
|
+
|
42
|
+
data = {
|
43
|
+
"sources" => sources.each_value.sort_by {|s| s.name }.map {|source| source.to_lockfile },
|
44
|
+
"path" => path.to_s,
|
45
|
+
"gems" => gems.each_value.sort_by {|g| g[:name] }.map {|hash| library_data(hash) },
|
46
|
+
"gemfile_lock_path" => gemfile_lock_path.to_s
|
47
|
+
}
|
48
|
+
|
49
|
+
data.delete("sources") if sources.empty?
|
50
|
+
data.delete("gems") if gems.empty?
|
51
|
+
|
52
|
+
data
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.from_lockfile(lockfile_path:, data:)
|
56
|
+
path = Pathname(data["path"])
|
57
|
+
if p = data["gemfile_lock_path"]
|
58
|
+
gemfile_lock_path = Pathname(p)
|
59
|
+
end
|
60
|
+
|
61
|
+
lockfile = Lockfile.new(lockfile_path: lockfile_path, path: path, gemfile_lock_path: gemfile_lock_path)
|
62
|
+
|
63
|
+
if sources = data["sources"]
|
64
|
+
sources.each do |src|
|
65
|
+
git = Sources::Git.new(
|
66
|
+
name: src["name"],
|
67
|
+
revision: src["revision"],
|
68
|
+
remote: src["remote"],
|
69
|
+
repo_dir: src["repo_dir"]
|
70
|
+
)
|
71
|
+
lockfile.sources[git.name] = git
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if gems = data["gems"]
|
76
|
+
gems.each do |gem|
|
77
|
+
src = gem["source"]
|
78
|
+
source = Sources.from_config_entry(src)
|
79
|
+
lockfile.gems[gem["name"]] = {
|
80
|
+
name: gem["name"],
|
81
|
+
version: gem["version"],
|
82
|
+
source: source
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
lockfile
|
88
|
+
end
|
89
|
+
|
90
|
+
def library_data(lib)
|
91
|
+
{
|
92
|
+
"name" => lib[:name],
|
93
|
+
"version" => lib[:version],
|
94
|
+
"source" => lib[:source].to_lockfile
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
def check_rbs_availability!
|
99
|
+
raise CollectionNotAvailable unless fullpath.exist?
|
100
|
+
|
101
|
+
gems.each_value do |gem|
|
102
|
+
source = gem[:source]
|
103
|
+
|
104
|
+
case source
|
105
|
+
when Sources::Git
|
106
|
+
meta_path = fullpath.join(gem[:name], gem[:version], Sources::Git::METADATA_FILENAME)
|
107
|
+
raise CollectionNotAvailable unless meta_path.exist?
|
108
|
+
raise CollectionNotAvailable unless library_data(gem) == YAML.load(meta_path.read)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|