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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eff99e85b92644bcfc8cf94291ec8e056c30cb72723bf98e571a0ffef264fcd8
4
- data.tar.gz: 75ee446a19c76662c34bf17e323d0e26101cbb3cb173eb6546088e96e11fa867
3
+ metadata.gz: 76d6ef8333e7233a6fbc0bd5511c54a8e9a277f691e5a675d9fc856fdec178fd
4
+ data.tar.gz: ed5a55bf995ac0ca43efe0e046c807e701f560f5bcf7eac15df71dacc1dde9ee
5
5
  SHA512:
6
- metadata.gz: 3121deff5c7b0b25889b95cecbe79ca611d140d00d6ebc52d6232696f944d882431c6d41f4b669bd4ec68f2452d1a48c18c4292d97c60d155491894886c73b11
7
- data.tar.gz: 3a05df94b6b1be4115e39ce358b3dbba4846fd39cc592fbf5b73825e17fb7054bc0e8e9b0c8db585c85a46c75789deb16626c07cb9bcd51679b8e9b1b98cf5df
6
+ metadata.gz: 93d9c4034fc8863f1e2176b3e7127bfe04dc2f3cdd63699474ef0d14467bd075c761bfcb295b7a2d6d1c9c983c893932f2c2972dc9c9154ad828cc074f9d0b8f
7
+ data.tar.gz: c484c057bda34ee2a2ebb54a7120a01e16a93bfd66e8b32f32493b155132d7e8cfd3b7da5e1e4940e511d5d93c6f9f35b4a85b06060f46167d8862408645ed6b
@@ -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: '3.1'
27
+ ruby-version: ${{ matrix.ruby }}
17
28
  - name: Test
18
29
  run: bundle exec rake test
19
30
  automerge:
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
 
10
10
  test.rbs
11
+ gemfiles/*.lock
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.1.0...HEAD
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.1.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.1)
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
 
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec path: ".."
6
+
7
+ gem "rbs", "~> 1"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec path: ".."
6
+
7
+ gem "rbs", "~> 2"
@@ -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
@@ -139,7 +139,7 @@ module RBS
139
139
 
140
140
  class Literal
141
141
  def format(q)
142
- unless literal in String
142
+ unless literal.is_a?(String)
143
143
  q.text(literal.inspect)
144
144
  return
145
145
  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.length == 0
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
- q.text(param.name)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SyntaxTree
4
4
  module RBS
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ require "syntax_tree"
5
5
 
6
6
  require_relative "rbs/declarations"
7
7
  require_relative "rbs/members"
8
+ require_relative "rbs/shims"
8
9
  require_relative "rbs/types"
9
10
  require_relative "rbs/utils"
10
11
  require_relative "rbs/version"
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.1.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-07 00:00:00.000000000 Z
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.3.3
147
+ rubygems_version: 3.2.3
145
148
  signing_key:
146
149
  specification_version: 4
147
150
  summary: Syntax Tree support for RBS