Module: Maccro::DSL::ASTNodeWrapper
- Included in:
- Node
- Defined in:
- lib/maccro/dsl/node.rb
Instance Method Summary collapse
- #capture(ast, placeholders) ⇒ Object
- #children ⇒ Object
- #match?(node) ⇒ Boolean
- #to_code_range ⇒ Object
Instance Method Details
#capture(ast, placeholders) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/maccro/dsl/node.rb', line 28 def capture(ast, placeholders) self.children.each_with_index do |c, i| if c.is_a?(ASTNodeWrapper) c.capture(ast.children[i], placeholders) end end end |
#children ⇒ Object
6 7 8 |
# File 'lib/maccro/dsl/node.rb', line 6 def children @child_nodes ||= super end |
#match?(node) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/maccro/dsl/node.rb', line 14 def match?(node) return false unless node.is_a?(ASTNodeWrapper) return false if node.type != self.type self.children.each_with_index do |c, i| if c.is_a?(ASTNodeWrapper) return false unless c.match?(node.children[i]) else return false unless c == node.children[i] end end # same type, all children match with others true end |
#to_code_range ⇒ Object
10 11 12 |
# File 'lib/maccro/dsl/node.rb', line 10 def to_code_range CodeRange.from_node(self) end |