parser_node_ext 0.6.0 → 0.7.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 +9 -0
- data/Gemfile.lock +1 -1
- data/lib/parser_node_ext/version.rb +1 -1
- data/lib/parser_node_ext.rb +22 -3
- data/sig/parser_node_ext.rbs +1 -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: '09b9c1f0df70d2a83780b534cb42635c55b0dfb68165b40fa07247f251d6e344'
|
4
|
+
data.tar.gz: 0ef177a30d4fdacf17d9c36dfcf9e42b4ea7e94142422c9d064dc1cd41a8674d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5825839d2153c0d21fc96ba7ee3e6b2c30490966255bb6331cac40224ceb31a426ef86c36cfb3c8ad93d69f14e4a6eb096b582bb731ad69dda0c25467a9acda8
|
7
|
+
data.tar.gz: b664575b41717991f2fc7c2a562990c876fa2239cb3d982a1ce9dea9d2bb7316bab755a6c1e3b5e380c39a2b5ccc53fe0d62c38fa3c3c019cf5f52cc724ced75
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/parser_node_ext.rb
CHANGED
@@ -21,7 +21,7 @@ module ParserNodeExt
|
|
21
21
|
cvasgn: %i[left_value right_value],
|
22
22
|
cvar: %i[name],
|
23
23
|
def: %i[name arguments body],
|
24
|
-
|
24
|
+
defined?: %i[arguments],
|
25
25
|
defs: %i[self name arguments body],
|
26
26
|
false: [],
|
27
27
|
float: %i[value],
|
@@ -119,9 +119,11 @@ module ParserNodeExt
|
|
119
119
|
def arguments
|
120
120
|
case type
|
121
121
|
when :def, :block
|
122
|
-
children[1].children
|
122
|
+
children[1].type == :args ? children[1].children : [children[1]]
|
123
123
|
when :defs
|
124
|
-
children[2].children
|
124
|
+
children[2].type == :args ? children[2].children : [children[2]]
|
125
|
+
when :block
|
126
|
+
children[1].children
|
125
127
|
when :send, :csend
|
126
128
|
children[2..-1]
|
127
129
|
when :defined?
|
@@ -159,6 +161,9 @@ module ParserNodeExt
|
|
159
161
|
end
|
160
162
|
end
|
161
163
|
|
164
|
+
# Get when statements of case node.
|
165
|
+
# @return [Array<Parser::AST::Node>] when statements of case node.
|
166
|
+
# @raise [MethodNotSupported] if calls on other node.
|
162
167
|
def when_statements
|
163
168
|
if :case == type
|
164
169
|
children[1...-1]
|
@@ -167,10 +172,24 @@ module ParserNodeExt
|
|
167
172
|
end
|
168
173
|
end
|
169
174
|
|
175
|
+
# Get else statement of case node.
|
176
|
+
# @return [Parser::AST::Node] else statement of case node.
|
177
|
+
# @raise [MethodNotSupported] if calls on other node.
|
170
178
|
def else_statement
|
171
179
|
children[-1]
|
172
180
|
end
|
173
181
|
|
182
|
+
# Get elements of array node.
|
183
|
+
# @return [Array<Parser::AST::Node>] elements of array node.
|
184
|
+
# @raise [MethodNotSupported] if calls on other node.
|
185
|
+
def elements
|
186
|
+
if :array == type
|
187
|
+
children
|
188
|
+
else
|
189
|
+
raise MethodNotSupported, "elements is not supported for #{self}"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
174
193
|
# Get pairs of :hash node.
|
175
194
|
# @example
|
176
195
|
# node # s(:hash, s(:pair, s(:sym, :foo), s(:sym, :bar)), s(:pair, s(:str, "foo"), s(:str, "bar")))
|
data/sig/parser_node_ext.rbs
CHANGED
@@ -5,6 +5,7 @@ module ParserNodeExt
|
|
5
5
|
def arguments: () -> Array[Parser::AST::Node]
|
6
6
|
def body: () -> Array[Parser::AST::Node]
|
7
7
|
def caller: () -> Parser::AST::Node
|
8
|
+
def elements: () -> Array[Parser::AST::Node]
|
8
9
|
def else_statement: () -> Parser::AST::Node
|
9
10
|
def expression: () -> Parser::AST::Node
|
10
11
|
def if_statement: () -> Parser::AST::Node
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parser_node_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|