Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c25290

Browse files
committed
Add visit_and to more visitors
1 parent fd7dfeb commit 7c25290

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/syntax_tree/mutation_visitor.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def visit_alias(node)
6565
node.copy(left: visit(node.left), right: visit(node.right))
6666
end
6767

68+
# Visit a AndNode node.
69+
def visit_and(node)
70+
node.copy(left: visit(node.left), right: visit(node.right))
71+
end
72+
6873
# Visit a ARef node.
6974
def visit_aref(node)
7075
node.copy(index: visit(node.index))

lib/syntax_tree/pretty_print_visitor.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ def initialize(q)
99
@q = q
1010
end
1111

12+
# This is here because we need to make sure the operator is cast to a string
13+
# before we print it out.
14+
def visit_and(node)
15+
node(node, "and") do
16+
field("left", node.left)
17+
text("operator", node.operator.to_s)
18+
field("right", node.right)
19+
comments(node)
20+
end
21+
end
22+
1223
# This is here because we need to make sure the operator is cast to a string
1324
# before we print it out.
1425
def visit_binary(node)

0 commit comments

Comments
 (0)