rubocop-ast 1.5.0 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4e1919e281d2cc09eca1c8f18effe89cd4c818f7981070e5cb222bde40d6be5
4
- data.tar.gz: e7368a014cc2c9881552f935b6a841357275940e63ee567655f3bb151b118977
3
+ metadata.gz: c1f86e6a6bcb200cfd73b5bf9d959584812252f6cc365b115e1448daae6f1430
4
+ data.tar.gz: 5c40556b0692122859f39f0dbe2d9dbf5fea1aeaed67b654828b815dd3ea85f1
5
5
  SHA512:
6
- metadata.gz: b1c16200ecf6bc69027525ac88c1214d9fb69ce8840307422560ac9c6e314c6d720e278100640da86a406e0d4ae7d229d3f943b4dd5a3446739584baa205336a
7
- data.tar.gz: eafb7d829dd9c17182b43bc9ed091933bcb4ce7904b499a12a79054f76ecc25896917ae4f043f84790c2b2754f6563ab1457ce86fd58b8ddf490f8188263479a
6
+ metadata.gz: 40ced8eab14849512c8d5c4096716a27786d95a5e1d14b300c5f1b52fd009e685e93fa472b842beaa67e9141e21465ef155ae2876d7020566a61da23855a57af
7
+ data.tar.gz: 259e988322fa736908819654e29ecdafe791db5336b06a790ca268b8a73f7031fd262560508743a137dd3ba996405c92ad7d97354c630182e82f9c3d1e0baf43
data/lib/rubocop/ast.rb CHANGED
@@ -53,6 +53,7 @@ require_relative 'ast/node/forward_args_node'
53
53
  require_relative 'ast/node/float_node'
54
54
  require_relative 'ast/node/hash_node'
55
55
  require_relative 'ast/node/if_node'
56
+ require_relative 'ast/node/in_pattern_node'
56
57
  require_relative 'ast/node/index_node'
57
58
  require_relative 'ast/node/indexasgn_node'
58
59
  require_relative 'ast/node/int_node'
@@ -49,6 +49,7 @@ module RuboCop
49
49
  float: FloatNode,
50
50
  hash: HashNode,
51
51
  if: IfNode,
52
+ in_pattern: InPatternNode,
52
53
  int: IntNode,
53
54
  index: IndexNode,
54
55
  indexasgn: IndexasgnNode,
@@ -24,9 +24,9 @@ module RuboCop
24
24
  self
25
25
  end
26
26
 
27
- # Returns an array of all the when branches in the `case` statement.
27
+ # Returns an array of all the `in` pattern branches in the `case` statement.
28
28
  #
29
- # @return [Array<Node>] an array of `in_pattern` nodes
29
+ # @return [Array<InPatternNode>] an array of `in_pattern` nodes
30
30
  def in_pattern_branches
31
31
  node_parts[1...-1]
32
32
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `in` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available
7
+ # to all `in` nodes within RuboCop.
8
+ class InPatternNode < Node
9
+ # Returns the index of the `in` branch within the `case` statement.
10
+ #
11
+ # @return [Integer] the index of the `in` branch
12
+ def branch_index
13
+ parent.in_pattern_branches.index(self)
14
+ end
15
+
16
+ # Checks whether the `in` node has a `then` keyword.
17
+ #
18
+ # @return [Boolean] whether the `in` node has a `then` keyword
19
+ def then?
20
+ loc.begin&.is?('then')
21
+ end
22
+
23
+ # Returns the body of the `in` node.
24
+ #
25
+ # @return [Node, nil] the body of the `in` node
26
+ def body
27
+ node_parts[-1]
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.1
4
+ # This file is automatically generated by Racc 1.5.2
5
5
  # from Racc grammar file "".
6
6
  #
7
7
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.5.0'
6
+ STRING = '1.6.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-05-02 00:00:00.000000000 Z
13
+ date: 2021-05-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -82,6 +82,7 @@ files:
82
82
  - lib/rubocop/ast/node/forward_args_node.rb
83
83
  - lib/rubocop/ast/node/hash_node.rb
84
84
  - lib/rubocop/ast/node/if_node.rb
85
+ - lib/rubocop/ast/node/in_pattern_node.rb
85
86
  - lib/rubocop/ast/node/index_node.rb
86
87
  - lib/rubocop/ast/node/indexasgn_node.rb
87
88
  - lib/rubocop/ast/node/int_node.rb
@@ -153,7 +154,7 @@ metadata:
153
154
  source_code_uri: https://github.com/rubocop-hq/rubocop-ast/
154
155
  documentation_uri: https://docs.rubocop.org/rubocop-ast/
155
156
  bug_tracker_uri: https://github.com/rubocop-hq/rubocop-ast/issues
156
- post_install_message:
157
+ post_install_message:
157
158
  rdoc_options: []
158
159
  require_paths:
159
160
  - lib
@@ -168,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubygems_version: 3.2.3
172
- signing_key:
172
+ rubygems_version: 3.1.2
173
+ signing_key:
173
174
  specification_version: 4
174
175
  summary: RuboCop tools to deal with Ruby code AST.
175
176
  test_files: []