parser_node_ext 0.4.0 → 0.5.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 +5 -1
- data/Gemfile.lock +3 -2
- data/lib/parser_node_ext/version.rb +1 -1
- data/lib/parser_node_ext.rb +18 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9bee187df49c963339ad5b6ed34721fb558e93b066593ac8fdf34ae453932f4
|
4
|
+
data.tar.gz: 960b04b95fb1ae5414d4ca820f22e1b2ae117c47e2d4502c9503848fc5048c19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a1432adf0618a77279d580ae9ad8de92a5e601c15256bedbafd870d3f46348c07143c11e25c4e3717dd6de19a99f22f1ce0306247ef5ad0f9529799d04fe0e1
|
7
|
+
data.tar.gz: 84e0d2ed48ba5650714e0bf994b43b7d9ef8f1191cf24941bf8a376963128145cbb970adb05f3e22f60ba6184d31f598f3b38b1a333b3d8a541149f3298cf9b5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
parser_node_ext (0.
|
4
|
+
parser_node_ext (0.5.0)
|
5
5
|
parser
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
diff-lcs (1.5.0)
|
12
|
-
parser (3.1.
|
12
|
+
parser (3.1.3.0)
|
13
13
|
ast (~> 2.4.1)
|
14
14
|
rake (13.0.6)
|
15
15
|
rspec (3.11.0)
|
@@ -28,6 +28,7 @@ GEM
|
|
28
28
|
|
29
29
|
PLATFORMS
|
30
30
|
x86_64-darwin-21
|
31
|
+
x86_64-darwin-22
|
31
32
|
x86_64-linux
|
32
33
|
|
33
34
|
DEPENDENCIES
|
data/lib/parser_node_ext.rb
CHANGED
@@ -22,20 +22,27 @@ module ParserNodeExt
|
|
22
22
|
def: %i[name arguments body],
|
23
23
|
definded?: %i[arguments],
|
24
24
|
defs: %i[self name arguments body],
|
25
|
+
false: [],
|
26
|
+
float: [],
|
25
27
|
hash: %i[pairs],
|
28
|
+
int: [],
|
26
29
|
ivasgn: %i[left_value right_value],
|
27
30
|
ivar: %i[name],
|
28
31
|
lvar: %i[name],
|
29
32
|
lvasgn: %i[left_value right_value],
|
30
33
|
masgn: %i[left_value right_value],
|
31
34
|
module: %i[name body],
|
35
|
+
nil: [],
|
32
36
|
or: %i[left_value right_value],
|
33
37
|
or_asgn: %i[left_value right_value],
|
34
38
|
pair: %i[key value],
|
35
39
|
restarg: %i[name],
|
36
40
|
send: %i[receiver message arguments],
|
41
|
+
str: [],
|
37
42
|
super: %i[arguments],
|
38
|
-
|
43
|
+
sym: [],
|
44
|
+
true: [],
|
45
|
+
zsuper: []
|
39
46
|
}
|
40
47
|
|
41
48
|
def self.included(base)
|
@@ -93,7 +100,7 @@ module ParserNodeExt
|
|
93
100
|
index = TYPE_CHILDREN[type]&.index(method_name)
|
94
101
|
return children[index] if index
|
95
102
|
|
96
|
-
raise MethodNotSupported, "#{method_name} is not
|
103
|
+
raise MethodNotSupported, "#{method_name} is not supported for #{self}"
|
97
104
|
end
|
98
105
|
end
|
99
106
|
|
@@ -110,7 +117,7 @@ module ParserNodeExt
|
|
110
117
|
index = TYPE_CHILDREN[type]&.index(:left_value)
|
111
118
|
return children[index] if index
|
112
119
|
|
113
|
-
raise MethodNotSupported, "#{left_value} is not
|
120
|
+
raise MethodNotSupported, "#{left_value} is not supported for #{self}"
|
114
121
|
end
|
115
122
|
|
116
123
|
# Get arguments of node.
|
@@ -131,7 +138,7 @@ module ParserNodeExt
|
|
131
138
|
when :defined?
|
132
139
|
children
|
133
140
|
else
|
134
|
-
raise MethodNotSupported, "arguments is not
|
141
|
+
raise MethodNotSupported, "arguments is not supported for #{self}"
|
135
142
|
end
|
136
143
|
end
|
137
144
|
|
@@ -155,7 +162,7 @@ module ParserNodeExt
|
|
155
162
|
|
156
163
|
:begin == children[3].type ? children[3].body : children[3..-1]
|
157
164
|
else
|
158
|
-
raise MethodNotSupported, "body is not
|
165
|
+
raise MethodNotSupported, "body is not supported for #{self}"
|
159
166
|
end
|
160
167
|
end
|
161
168
|
|
@@ -170,7 +177,7 @@ module ParserNodeExt
|
|
170
177
|
if :if == type
|
171
178
|
children[0]
|
172
179
|
else
|
173
|
-
raise MethodNotSupported, "condition is not
|
180
|
+
raise MethodNotSupported, "condition is not supported for #{self}"
|
174
181
|
end
|
175
182
|
end
|
176
183
|
|
@@ -184,7 +191,7 @@ module ParserNodeExt
|
|
184
191
|
if :hash == type
|
185
192
|
children.map { |child| child.children[0] }
|
186
193
|
else
|
187
|
-
raise MethodNotSupported, "keys is not
|
194
|
+
raise MethodNotSupported, "keys is not supported for #{self}"
|
188
195
|
end
|
189
196
|
end
|
190
197
|
|
@@ -198,7 +205,7 @@ module ParserNodeExt
|
|
198
205
|
if :hash == type
|
199
206
|
children.map { |child| child.children[1] }
|
200
207
|
else
|
201
|
-
raise MethodNotSupported, "keys is not
|
208
|
+
raise MethodNotSupported, "keys is not supported for #{self}"
|
202
209
|
end
|
203
210
|
end
|
204
211
|
|
@@ -213,7 +220,7 @@ module ParserNodeExt
|
|
213
220
|
if :hash == type
|
214
221
|
children.any? { |pair_node| pair_node.key.to_value == key }
|
215
222
|
else
|
216
|
-
raise MethodNotSupported, "key? is not
|
223
|
+
raise MethodNotSupported, "key? is not supported for #{self}"
|
217
224
|
end
|
218
225
|
end
|
219
226
|
|
@@ -229,7 +236,7 @@ module ParserNodeExt
|
|
229
236
|
value_node = children.find { |pair_node| pair_node.key.to_value == key }
|
230
237
|
value_node&.value
|
231
238
|
else
|
232
|
-
raise MethodNotSupported, "hash_value is not
|
239
|
+
raise MethodNotSupported, "hash_value is not supported for #{self}"
|
233
240
|
end
|
234
241
|
end
|
235
242
|
|
@@ -330,19 +337,6 @@ module ParserNodeExt
|
|
330
337
|
|
331
338
|
super
|
332
339
|
end
|
333
|
-
|
334
|
-
# Return the debug info.
|
335
|
-
#
|
336
|
-
# @return [String] file, line, source and node.
|
337
|
-
def debug_info
|
338
|
-
"\n" +
|
339
|
-
[
|
340
|
-
"file: #{loc.expression.source_buffer.name}",
|
341
|
-
"line: #{loc.expression.line}",
|
342
|
-
"source: #{to_source}",
|
343
|
-
"node: #{inspect}"
|
344
|
-
].join("\n")
|
345
|
-
end
|
346
340
|
end
|
347
341
|
end
|
348
342
|
end
|
@@ -373,7 +367,7 @@ end
|
|
373
367
|
# +type: 'send', receiver: { type: 'send', receiver: { type: 'send', message: 'config' }, message: 'active_record' }, message: 'identity_map='+
|
374
368
|
#
|
375
369
|
# Source Code to Ast Node
|
376
|
-
# {https://
|
370
|
+
# {https://playground.synvert.net/ruby}
|
377
371
|
class Parser::AST::Node
|
378
372
|
include ParserNodeExt
|
379
373
|
end
|
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.5.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: 2022-
|
11
|
+
date: 2022-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.3.
|
66
|
+
rubygems_version: 3.3.26
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: extend parser node
|