Class: RKelly::Visitors::ParentBuilder

Inherits:
Visitor
  • Object
show all
Defined in:
lib/rkelly/parent_builder.rb

Instance Method Summary collapse

Instance Method Details

#build(node) ⇒ Object



5
6
7
8
# File 'lib/rkelly/parent_builder.rb', line 5

def build node
  link_parents node, nil
  node
end

#visit_BracketAccessorNode(o) ⇒ Object



98
99
100
101
102
103
# File 'lib/rkelly/parent_builder.rb', line 98

def visit_BracketAccessorNode(o)
  [
    link_parents(o.value, o),
    link_parents(o.accessor, o)
  ]
end

#visit_DotAccessorNode(o) ⇒ Object



105
106
107
# File 'lib/rkelly/parent_builder.rb', line 105

def visit_DotAccessorNode(o)
  link_parents(o.value, o)
end

#visit_ForInNode(o) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/rkelly/parent_builder.rb', line 81

def visit_ForInNode(o)
  [
    link_parents(o.left, o),
    link_parents(o.right, o),
    link_parents(o.value, o)
  ]
end

#visit_ForNode(o) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/rkelly/parent_builder.rb', line 72

def visit_ForNode(o)
  [
    o.init ? link_parents(o.init, o) : nil,
    o.test ? link_parents(o.test, o) : nil,
    o.counter ? link_parents(o.counter, o) : nil,
    link_parents(o.value, o)
  ]
end

#visit_TryNode(o) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/rkelly/parent_builder.rb', line 89

def visit_TryNode(o)
  [
    link_parents(o.value, o),
    o.catch_var ? o.catch_var : nil,
    o.catch_block ? link_parents(o.catch_block, o) : nil,
    o.finally_block ? link_parents(o.finally_block, o) : nil
  ]
end