rbs 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/constant_table.rb +10 -9
- data/lib/rbs/namespace.rb +18 -0
- data/lib/rbs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ffec56ef44262c857185b7700f17f586b8e1e857776eedc75663a0021246f2e
|
4
|
+
data.tar.gz: 53cf7480a2793dd8228cd385c40d10e767b7cb32d0216c302b8aee7c21423d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa78c2ec3746d5803709fc999737d29d5bb072cddc6ad1b3af94d25bf3f3aa24b61051a1e3753095f30393fd7378fc88420d05a8bb6fdea38ca355072f8c3ebc
|
7
|
+
data.tar.gz: bd355d3d6b3e8df2fb6e06608aaa3d12182c1e3a6d5add565c1f98032faa65c8d003d3e13ce409d22767b1cb64ad0964501cb68801488a5c4c1db01b8e075bca
|
data/CHANGELOG.md
CHANGED
data/lib/rbs/cli.rb
CHANGED
@@ -362,7 +362,7 @@ module RBS
|
|
362
362
|
name = Namespace.parse(args[0]).to_type_name
|
363
363
|
stdout.puts "Constant name: #{name}"
|
364
364
|
|
365
|
-
constant = table.resolve_constant_reference(name, context: namespace)
|
365
|
+
constant = table.resolve_constant_reference(name, context: namespace.ascend.to_a)
|
366
366
|
|
367
367
|
if constant
|
368
368
|
stdout.puts " => #{constant.name}: #{constant.type}"
|
data/lib/rbs/constant_table.rb
CHANGED
@@ -30,17 +30,18 @@ module RBS
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def resolve_constant_reference(name, context:)
|
33
|
+
raise "Context cannot be empty: Specify `[Namespace.root]`" if context.empty?
|
34
|
+
|
33
35
|
head, *tail = split_name(name)
|
34
36
|
|
35
37
|
head_constant = case
|
36
38
|
when name.absolute?
|
37
39
|
name_to_constant(TypeName.new(name: head, namespace: Namespace.root))
|
38
|
-
when
|
40
|
+
when context == [Namespace.root]
|
39
41
|
name_to_constant(TypeName.new(name: head, namespace: Namespace.root))
|
40
42
|
else
|
41
43
|
resolve_constant_reference_context(head, context: context) ||
|
42
|
-
resolve_constant_reference_inherit(head,
|
43
|
-
scopes: constant_scopes(context.to_type_name))
|
44
|
+
resolve_constant_reference_inherit(head, scopes: constant_scopes(context.first.to_type_name))
|
44
45
|
end
|
45
46
|
|
46
47
|
if head_constant
|
@@ -53,11 +54,11 @@ module RBS
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def resolve_constant_reference_context(name, context:)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
name_to_constant(TypeName.new(name: name, namespace:
|
60
|
-
resolve_constant_reference_context(name, context:
|
57
|
+
head, *tail = context
|
58
|
+
|
59
|
+
if head
|
60
|
+
name_to_constant(TypeName.new(name: name, namespace: head)) ||
|
61
|
+
resolve_constant_reference_context(name, context: tail)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -125,7 +126,7 @@ module RBS
|
|
125
126
|
|
126
127
|
scopes.unshift namespace
|
127
128
|
else
|
128
|
-
raise "Unexpected declaration: #{name}"
|
129
|
+
raise "Unexpected declaration: #{name} (#{decl.class})"
|
129
130
|
end
|
130
131
|
|
131
132
|
env.each_extension(name).sort_by {|e| e.extension_name.to_s }.each do |extension|
|
data/lib/rbs/namespace.rb
CHANGED
@@ -87,5 +87,23 @@ module RBS
|
|
87
87
|
new(path: string.split("::").map(&:to_sym), absolute: false)
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
|
92
|
+
def ascend
|
93
|
+
if block_given?
|
94
|
+
current = self
|
95
|
+
|
96
|
+
until current.empty?
|
97
|
+
yield current
|
98
|
+
current = current.parent
|
99
|
+
end
|
100
|
+
|
101
|
+
yield current
|
102
|
+
|
103
|
+
self
|
104
|
+
else
|
105
|
+
enum_for(:ascend)
|
106
|
+
end
|
107
|
+
end
|
90
108
|
end
|
91
109
|
end
|
data/lib/rbs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|