Module: Mutant::AST
- Defined in:
- lib/mutant/ast.rb,
lib/mutant/ast/meta.rb,
lib/mutant/ast/sexp.rb,
lib/mutant/ast/nodes.rb,
lib/mutant/ast/types.rb,
lib/mutant/ast/named_children.rb,
lib/mutant/ast/node_predicates.rb
Overview
AST helpers
Defined Under Namespace
Modules: Meta, NamedChildren, NodePredicates, Nodes, Sexp, Types
Class Method Summary collapse
-
.find_last_path(node) {|Parser::AST::Node| ... } ⇒ Parser::AST::Node?
private
Find last node satisfying predicate (as block).
Class Method Details
.find_last_path(node) {|Parser::AST::Node| ... } ⇒ Parser::AST::Node?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find last node satisfying predicate (as block)
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mutant/ast.rb', line 46 def self.find_last_path(node, &predicate) raise ArgumentError, 'block expected' unless block_given? path = [] walk(node, [node]) do |candidate, stack| if predicate.call(candidate, &predicate) path = stack.dup end end path end |