node_visitor 1.0.0 → 1.1.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/node_visitor/version.rb +1 -1
- data/lib/node_visitor.rb +12 -8
- 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: 38253864e4eb4cf2caaf72d169bc84397af05003c1cee6abdb9ddaf59b0fc298
|
4
|
+
data.tar.gz: 30f67d7d7aba9464089a13cf5a3c6621bb8228ea310bff8cd11ef62282d279f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d4fe4465947205a048250ca5dda8dd725719efbbf4451702a5aaf3e951d47e5d30277a66a833d569de8ee7b058e980c97a8bc65f35dda344c318bc2637a4f7
|
7
|
+
data.tar.gz: acc26f33fc58b66a5e07573899a80f9bbf10a15f43ed41fbf1d107556f567efc181899ad572dc0b7c64db68784e3e014b61f3637cbb5e80ee11cb27b936bb176
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/node_visitor/version.rb
CHANGED
data/lib/node_visitor.rb
CHANGED
@@ -19,10 +19,14 @@ class NodeVisitor
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def visit(node, block_context = self)
|
22
|
+
return if @callbacks.empty?
|
23
|
+
|
22
24
|
callbacks = @callbacks[:all]
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
catch(:abort) do
|
26
|
+
callbacks.each { |callback| block_context.instance_exec(node, &callback[:block]) if callback[:at] == 'start' } if callbacks
|
27
|
+
visit_node(node, block_context)
|
28
|
+
callbacks.each { |callback| block_context.instance_exec(node, &callback[:block]) if callback[:at] == 'end' } if callbacks
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
private
|
@@ -40,16 +44,16 @@ class NodeVisitor
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
43
|
-
def visit_node(node)
|
47
|
+
def visit_node(node, block_context)
|
44
48
|
if node.is_a?(Array)
|
45
|
-
node.each { |child_node| visit_node(child_node) }
|
49
|
+
node.each { |child_node| visit_node(child_node, block_context) }
|
46
50
|
return
|
47
51
|
end
|
48
52
|
return unless @adapter.is_node?(node)
|
49
53
|
|
50
54
|
callbacks = @callbacks[@adapter.get_node_type(node)]
|
51
|
-
callbacks.each { |callback| instance_exec(node, &callback[:block]) if callback[:at] == 'start' } if callbacks
|
52
|
-
@adapter.get_children(node).each { |child_node| visit_node(child_node) }
|
53
|
-
callbacks.each { |callback| instance_exec(node, &callback[:block]) if callback[:at] == 'end' } if callbacks
|
55
|
+
callbacks.each { |callback| block_context.instance_exec(node, &callback[:block]) if callback[:at] == 'start' } if callbacks
|
56
|
+
@adapter.get_children(node).each { |child_node| visit_node(child_node, block_context) }
|
57
|
+
callbacks.each { |callback| block_context.instance_exec(node, &callback[:block]) if callback[:at] == 'end' } if callbacks
|
54
58
|
end
|
55
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node_visitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.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: 2024-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: visit ast nodes
|
14
14
|
email:
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.5.
|
54
|
+
rubygems_version: 3.5.13
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: visit ast nodes
|