syntax_tree-rbs 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +12 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +3 -2
- data/gemfiles/rbs1.gemfile +7 -0
- data/gemfiles/rbs2.gemfile +7 -0
- data/lib/syntax_tree/rbs/members.rb +14 -0
- data/lib/syntax_tree/rbs/shims.rb +45 -0
- data/lib/syntax_tree/rbs/types.rb +1 -1
- data/lib/syntax_tree/rbs/utils.rb +3 -2
- data/lib/syntax_tree/rbs/version.rb +1 -1
- data/lib/syntax_tree/rbs.rb +1 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76d6ef8333e7233a6fbc0bd5511c54a8e9a277f691e5a675d9fc856fdec178fd
|
4
|
+
data.tar.gz: ed5a55bf995ac0ca43efe0e046c807e701f560f5bcf7eac15df71dacc1dde9ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d9c4034fc8863f1e2176b3e7127bfe04dc2f3cdd63699474ef0d14467bd075c761bfcb295b7a2d6d1c9c983c893932f2c2972dc9c9154ad828cc074f9d0b8f
|
7
|
+
data.tar.gz: c484c057bda34ee2a2ebb54a7120a01e16a93bfd66e8b32f32493b155132d7e8cfd3b7da5e1e4940e511d5d93c6f9f35b4a85b06060f46167d8862408645ed6b
|
data/.github/workflows/main.yml
CHANGED
@@ -4,16 +4,27 @@ on:
|
|
4
4
|
- pull_request_target
|
5
5
|
jobs:
|
6
6
|
ci:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby:
|
11
|
+
- '2.7.5'
|
12
|
+
- '3.0'
|
13
|
+
- '3.1'
|
14
|
+
gemfile:
|
15
|
+
- rbs1
|
16
|
+
- rbs2
|
7
17
|
name: CI
|
8
18
|
runs-on: ubuntu-latest
|
9
19
|
env:
|
20
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
10
21
|
CI: true
|
11
22
|
steps:
|
12
23
|
- uses: actions/checkout@master
|
13
24
|
- uses: ruby/setup-ruby@v1
|
14
25
|
with:
|
15
26
|
bundler-cache: true
|
16
|
-
ruby-version:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
17
28
|
- name: Test
|
18
29
|
run: bundle exec rake test
|
19
30
|
automerge:
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,11 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.2.0] - 2022-04-22
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Support for RBS 1.0 in addition to RBS 2.0.
|
14
|
+
- Adding support back for Ruby 2.7.
|
15
|
+
- Support for inline visibility modifiers in RBS 2.0.
|
16
|
+
|
9
17
|
## [0.1.0] - 2022-04-05
|
10
18
|
|
11
19
|
### Added
|
12
20
|
|
13
21
|
- 🎉 Initial release! 🎉
|
14
22
|
|
15
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.
|
23
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.2.0...HEAD
|
24
|
+
[0.2.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/v0.1.0...v0.2.0
|
16
25
|
[0.1.0]: https://github.com/ruby-syntax-tree/syntax_tree-rbs/compare/93efc7...v0.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree-rbs (0.
|
4
|
+
syntax_tree-rbs (0.2.0)
|
5
5
|
rbs
|
6
6
|
syntax_tree (>= 2.0.1)
|
7
7
|
|
@@ -18,9 +18,10 @@ GEM
|
|
18
18
|
simplecov_json_formatter (~> 0.1)
|
19
19
|
simplecov-html (0.12.3)
|
20
20
|
simplecov_json_formatter (0.1.4)
|
21
|
-
syntax_tree (2.0
|
21
|
+
syntax_tree (2.3.0)
|
22
22
|
|
23
23
|
PLATFORMS
|
24
|
+
x86_64-darwin-19
|
24
25
|
x86_64-darwin-21
|
25
26
|
x86_64-linux
|
26
27
|
|
@@ -16,6 +16,7 @@ module SyntaxTree
|
|
16
16
|
|
17
17
|
def format(q)
|
18
18
|
q.group do
|
19
|
+
q.text("#{node.visibility} ") if node.visibility
|
19
20
|
q.text("attr_#{type} ")
|
20
21
|
q.text("self.") if node.kind == :singleton
|
21
22
|
q.text(node.name)
|
@@ -43,6 +44,12 @@ module SyntaxTree
|
|
43
44
|
q.text("name=")
|
44
45
|
q.pp(node.name)
|
45
46
|
|
47
|
+
if node.visibility
|
48
|
+
q.breakable
|
49
|
+
q.text("visibility=")
|
50
|
+
q.pp(node.visibility)
|
51
|
+
end
|
52
|
+
|
46
53
|
unless node.ivar_name.nil?
|
47
54
|
q.breakable
|
48
55
|
q.text("ivar_name=")
|
@@ -281,6 +288,7 @@ module RBS
|
|
281
288
|
SyntaxTree::RBS::Annotations.maybe_format(q, annotations)
|
282
289
|
|
283
290
|
q.group do
|
291
|
+
q.text("#{visibility} ") if visibility
|
284
292
|
q.text("def ")
|
285
293
|
|
286
294
|
if kind == :singleton
|
@@ -332,6 +340,12 @@ module RBS
|
|
332
340
|
q.text("name=")
|
333
341
|
q.pp(name)
|
334
342
|
|
343
|
+
if visibility
|
344
|
+
q.breakable
|
345
|
+
q.text("visibility=")
|
346
|
+
q.pp(visibility)
|
347
|
+
end
|
348
|
+
|
335
349
|
if overload?
|
336
350
|
q.breakable
|
337
351
|
q.text("overload")
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if defined?(RBS::AST::Declarations::ModuleTypeParams)
|
4
|
+
require "delegate"
|
5
|
+
|
6
|
+
# Previously there were specialized types that didn't include some additional
|
7
|
+
# information for type params. So here we wrap them up in order to maintain the
|
8
|
+
# same API.
|
9
|
+
module ShimTypeParams
|
10
|
+
class ShimTypeParam < SimpleDelegator
|
11
|
+
def unchecked?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def upper_bound
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Overriding the type params method to return an array of wrapped objects.
|
21
|
+
def type_params
|
22
|
+
super.params.map { |param| ShimTypeParam.new(param) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module RBS::AST::Declarations
|
27
|
+
Alias.prepend(ShimTypeParams)
|
28
|
+
Class.prepend(ShimTypeParams)
|
29
|
+
Interface.prepend(ShimTypeParams)
|
30
|
+
Module.prepend(ShimTypeParams)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Previously this attribute didn't exist on some nodes. So if they don't have
|
35
|
+
# it, we're just going to apply it and have it return nil.
|
36
|
+
module ShimVisibility
|
37
|
+
def visibility
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module RBS::AST::Members
|
42
|
+
[AttrAccessor, AttrReader, AttrWriter, MethodDefinition].each do |klass|
|
43
|
+
klass.include(ShimVisibility) unless klass.method_defined?(:visibility)
|
44
|
+
end
|
45
|
+
end
|
@@ -132,7 +132,7 @@ module SyntaxTree
|
|
132
132
|
|
133
133
|
def format(q)
|
134
134
|
node.name.format(q)
|
135
|
-
return if node.type_params.
|
135
|
+
return if node.type_params.empty?
|
136
136
|
|
137
137
|
q.text("[")
|
138
138
|
q.seplist(node.type_params, -> { q.text(", ") }) do |param|
|
@@ -308,7 +308,8 @@ module SyntaxTree
|
|
308
308
|
if node.respond_to?(:type_params) && node.type_params.any?
|
309
309
|
q.text("[")
|
310
310
|
q.seplist(node.type_params, -> { q.text(", ") }) do |param|
|
311
|
-
|
311
|
+
# We need to do a type check here to support RBS 1.0
|
312
|
+
q.text(param.is_a?(Symbol) ? param.to_s : param.name)
|
312
313
|
end
|
313
314
|
q.text("] ")
|
314
315
|
end
|
data/lib/syntax_tree/rbs.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_tree-rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -114,9 +114,12 @@ files:
|
|
114
114
|
- bin/format
|
115
115
|
- bin/parse
|
116
116
|
- bin/setup
|
117
|
+
- gemfiles/rbs1.gemfile
|
118
|
+
- gemfiles/rbs2.gemfile
|
117
119
|
- lib/syntax_tree/rbs.rb
|
118
120
|
- lib/syntax_tree/rbs/declarations.rb
|
119
121
|
- lib/syntax_tree/rbs/members.rb
|
122
|
+
- lib/syntax_tree/rbs/shims.rb
|
120
123
|
- lib/syntax_tree/rbs/types.rb
|
121
124
|
- lib/syntax_tree/rbs/utils.rb
|
122
125
|
- lib/syntax_tree/rbs/version.rb
|
@@ -141,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
144
|
- !ruby/object:Gem::Version
|
142
145
|
version: '0'
|
143
146
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.2.3
|
145
148
|
signing_key:
|
146
149
|
specification_version: 4
|
147
150
|
summary: Syntax Tree support for RBS
|