module RuboCop::Yast::NodeHelpers

helpers for traversing the AST tree

Public Instance Methods

parent_node_type(node, types) click to toggle source

Find the parend node of the requested type @param [Array<Symbol>] types requested node types @param node @return the requested type node or the root node if not found

# File lib/rubocop/yast/node_helpers.rb, line 10
def parent_node_type(node, types)
  target_node = node

  # find parent "class" node or the root node
  while !target_node.root? && !types.include?(target_node.type)
    target_node = target_node.parent
  end

  target_node
end