Method: Fast.search_file

Defined in:
lib/fast.rb

.search_file(pattern, file) ⇒ Array<Fast::Node>

Search with pattern directly on file

Returns:

  • (Array<Fast::Node>)

    that matches the pattern



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/fast.rb', line 179

def search_file(pattern, file)
  node = ast_from_file(file)
  return [] unless node

  case node
  when Array
    node.map { |n| search(pattern, n) }.flatten.compact
  else
    search pattern, node
  end
end