rbs 0.8.0 → 0.9.0
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/CHANGELOG.md +5 -0
- data/lib/rbs/ast/comment.rb +6 -0
- data/lib/rbs/cli.rb +4 -1
- data/lib/rbs/definition_builder.rb +12 -0
- data/lib/rbs/location.rb +15 -0
- data/lib/rbs/parser.y +6 -8
- data/lib/rbs/validator.rb +4 -0
- data/lib/rbs/version.rb +1 -1
- data/stdlib/json/json.rbs +6 -0
- 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: cbe5937993dd712f397e9008911a67bea344277222c45f94f09d1fe6e30399d8
|
4
|
+
data.tar.gz: 914834d0f1bcb1d5e13dd8bb8446f8bfd544625ed8bf49d673fce5d47063b20c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab09d820f4254c7be5648c64c43fd349414393eaecc7875fea580442f34f88b6284d4af360bcc3a9c4181cf6c0c041f39cf58b49c81ce913fe2051872517719
|
7
|
+
data.tar.gz: e27fd8bd3df37c73efeb6e56c355b76c6f12aa3ff538e4b6dacf5d627a9894947decd5edcdb76715fc3bb94bff42bb6ef286f6c1cfc69aeab20ae2db3a8f7ddc
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.9.0 (2020-08-03)
|
6
|
+
|
7
|
+
* Fix signature validation [#351](https://github.com/ruby/rbs/pull/351), [#352](https://github.com/ruby/rbs/pull/352)
|
8
|
+
* Parsing performance improvement [#350](https://github.com/ruby/rbs/pull/350)
|
9
|
+
|
5
10
|
## 0.8.0 (2020-08-01)
|
6
11
|
|
7
12
|
* Signature updates for `Enumerator` and `PTY`
|
data/lib/rbs/ast/comment.rb
CHANGED
data/lib/rbs/cli.rb
CHANGED
@@ -413,6 +413,7 @@ EOU
|
|
413
413
|
env.constant_decls.each do |name, const|
|
414
414
|
stdout.puts "Validating constant: `#{name}`..."
|
415
415
|
validator.validate_type const.decl.type, context: const.context
|
416
|
+
builder.ensure_namespace!(name.namespace, location: const.decl.location)
|
416
417
|
end
|
417
418
|
|
418
419
|
env.global_decls.each do |name, global|
|
@@ -422,7 +423,9 @@ EOU
|
|
422
423
|
|
423
424
|
env.alias_decls.each do |name, decl|
|
424
425
|
stdout.puts "Validating alias: `#{name}`..."
|
425
|
-
|
426
|
+
builder.expand_alias(name).tap do |type|
|
427
|
+
validator.validate_type type, context: [Namespace.root]
|
428
|
+
end
|
426
429
|
end
|
427
430
|
end
|
428
431
|
|
@@ -385,9 +385,18 @@ module RBS
|
|
385
385
|
end
|
386
386
|
end
|
387
387
|
|
388
|
+
def ensure_namespace!(namespace, location:)
|
389
|
+
namespace.ascend do |ns|
|
390
|
+
unless ns.empty?
|
391
|
+
NoTypeFoundError.check!(ns.to_type_name, env: env, location: location)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
388
396
|
def build_instance(type_name)
|
389
397
|
try_cache type_name, cache: instance_cache do
|
390
398
|
entry = env.class_decls[type_name] or raise "Unknown name for build_instance: #{type_name}"
|
399
|
+
ensure_namespace!(type_name.namespace, location: entry.decls[0].decl.location)
|
391
400
|
|
392
401
|
case entry
|
393
402
|
when Environment::ClassEntry, Environment::ModuleEntry
|
@@ -434,6 +443,7 @@ module RBS
|
|
434
443
|
def build_singleton(type_name)
|
435
444
|
try_cache type_name, cache: singleton_cache do
|
436
445
|
entry = env.class_decls[type_name] or raise "Unknown name for build_singleton: #{type_name}"
|
446
|
+
ensure_namespace!(type_name.namespace, location: entry.decls[0].decl.location)
|
437
447
|
|
438
448
|
case entry
|
439
449
|
when Environment::ClassEntry, Environment::ModuleEntry
|
@@ -1020,6 +1030,7 @@ module RBS
|
|
1020
1030
|
try_cache(type_name, cache: interface_cache) do
|
1021
1031
|
entry = env.interface_decls[type_name] or raise "Unknown name for build_interface: #{type_name}"
|
1022
1032
|
declaration = entry.decl
|
1033
|
+
ensure_namespace!(type_name.namespace, location: declaration.location)
|
1023
1034
|
|
1024
1035
|
self_type = Types::Interface.new(
|
1025
1036
|
name: type_name,
|
@@ -1111,6 +1122,7 @@ module RBS
|
|
1111
1122
|
|
1112
1123
|
def expand_alias(type_name)
|
1113
1124
|
entry = env.alias_decls[type_name] or raise "Unknown name for expand_alias: #{type_name}"
|
1125
|
+
ensure_namespace!(type_name.namespace, location: entry.decl.location)
|
1114
1126
|
entry.decl.type
|
1115
1127
|
end
|
1116
1128
|
end
|
data/lib/rbs/location.rb
CHANGED
@@ -77,6 +77,21 @@ module RBS
|
|
77
77
|
locations.inject {|l1, l2| l1 + l2 }
|
78
78
|
end
|
79
79
|
|
80
|
+
def concat(*others)
|
81
|
+
others.each { |other| self << other }
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
85
|
+
def <<(other)
|
86
|
+
if other
|
87
|
+
raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
|
88
|
+
@end_pos = other.end_pos
|
89
|
+
@source = nil
|
90
|
+
@end_loc = nil
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
80
95
|
def pred?(loc)
|
81
96
|
loc.is_a?(Location) &&
|
82
97
|
loc.name == name &&
|
data/lib/rbs/parser.y
CHANGED
@@ -1164,15 +1164,13 @@ def leading_comment(location)
|
|
1164
1164
|
end
|
1165
1165
|
|
1166
1166
|
def push_comment(string, location)
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
new_comment = AST::Comment.new(string:
|
1172
|
-
|
1167
|
+
if (comment = leading_comment(location)) && comment.location.start_column == location.start_column
|
1168
|
+
comment.concat(string: "#{string}\n", location: location)
|
1169
|
+
@comments[comment.location.end_line] = comment
|
1170
|
+
else
|
1171
|
+
new_comment = AST::Comment.new(string: "#{string}\n", location: location)
|
1172
|
+
@comments[new_comment.location.end_line] = new_comment
|
1173
1173
|
end
|
1174
|
-
|
1175
|
-
@comments[new_comment.location.end_line] = new_comment
|
1176
1174
|
end
|
1177
1175
|
|
1178
1176
|
def new_token(type, value = input.matched)
|
data/lib/rbs/validator.rb
CHANGED
@@ -41,6 +41,10 @@ module RBS
|
|
41
41
|
params: type_params.each.map(&:name),
|
42
42
|
location: type.location
|
43
43
|
)
|
44
|
+
|
45
|
+
when Types::Alias, Types::ClassSingleton
|
46
|
+
type = absolute_type(type, context: context) { type.name.absolute! }
|
47
|
+
NoTypeFoundError.check!(type.name, env: env, location: type.location)
|
44
48
|
end
|
45
49
|
|
46
50
|
type.each_type do |type|
|
data/lib/rbs/version.rb
CHANGED
data/stdlib/json/json.rbs
CHANGED
@@ -42,6 +42,9 @@ end
|
|
42
42
|
class JSON::Ext::Generator::State
|
43
43
|
end
|
44
44
|
|
45
|
+
class JSON::Ext::Parser
|
46
|
+
end
|
47
|
+
|
45
48
|
module JSON::Pure
|
46
49
|
end
|
47
50
|
|
@@ -51,6 +54,9 @@ end
|
|
51
54
|
class JSON::Pure::Generator::State
|
52
55
|
end
|
53
56
|
|
57
|
+
class JSON::Pure::Parser
|
58
|
+
end
|
59
|
+
|
54
60
|
type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
|
55
61
|
type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
|
56
62
|
type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
|
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.9.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-08-
|
11
|
+
date: 2020-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: RBS is the language for type signatures for Ruby and standard library
|
14
14
|
definitions.
|