facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

Multiple patterns from a file. #118

Closed mutantzombie closed 9 years ago

mutantzombie commented 9 years ago

This PR adds a -multi option to combine with -f so that patterns are taken from a file, one per line.

It also changes sgrep so that the AST is built once and multiple patterns run against the AST instead of rebuilding a file's AST for each pattern.

One limitation is that patterns must be confined to a single line. Proposing a format to enable sgrep (e.g. JSON) to load multiple patterns of arbitrary length would be a separate PR.

Thanks, Mike