Skip to content
This repository
Newer
Older
100644 60 lines (40 sloc) 2.15 kb
b676cbfa »
2012-01-06 Added a README file.
1 # jsgrep: a syntactically-aware grep for JavaScript
2
4c6b655c »
2012-01-08 Add support for loose object matching
3 Jsgrep is program that searches for a particular JavaScript pattern using the
4 abstract syntax tree (AST) of the program. This enables matching expressions
5 based on their JavaScript meaning, rather than based on simple strings.
b676cbfa »
2012-01-06 Added a README file.
6
58384b5f »
2012-01-07 Updated README
7 ## Examples
b676cbfa »
2012-01-06 Added a README file.
8
9 **Find calls to window.setTimeout with a 0 timeout**
10
8beed8ee »
2012-01-08 Swap out option parser
11 $ jsgrep 'setTimeout(A, 0)' tests/*.js
b676cbfa »
2012-01-06 Added a README file.
12 tests/jquery.js: setTimeout( function() {
13 tests/jquery.js: setTimeout( clearFxNow, 0 );
14
4c6b655c »
2012-01-08 Add support for loose object matching
15 Jsgrep uses metavariables as wildcards. Metavariables match any valid JavaScript
16 chunk, so in this case, the first match was an entire inline function. In both
17 cases, the second parameter to setTimeout was a literal value of 0.
8beed8ee »
2012-01-08 Swap out option parser
18
19 **Find value defaulting**
20
4c6b655c »
2012-01-08 Add support for loose object matching
21 $ jsgrep "A = A || B;" tests/*.js
8beed8ee »
2012-01-08 Swap out option parser
22 tests/jquery.js: args = args || [];
23 tests/jquery.js: dataType = dataType || options.dataTypes[ 0 ];
24
25 When the pattern references the same metavariable multiple times, jsgrep ensures
26 that the value of the metavariable is the same throughout the match.
27
2cf1d47c »
2012-01-09 Add support for ...
28 **Find the names of all invoked events**
29
3ea9eac9 »
2012-01-10 matchStrict/findStrict
30 $ ./jsgrep -p B "A.fire(B, ...)" tests/*.js
2cf1d47c »
2012-01-09 Add support for ...
31 tests/connect.js: 'auth.logout'
32 tests/connect.js: 'auth.login'
33
34 The `...` operator matches 0 or more expressions in function calls and array
612f1f0d »
2012-01-10 [WIP] jspatch
35 initializers. This example also uses the `-p` flag to print only a particular
36 matched variable.
2cf1d47c »
2012-01-09 Add support for ...
37
4c6b655c »
2012-01-08 Add support for loose object matching
38 **Find classes that have a 'path' property**
39
40 $ jsgrep -p C "JX.install(C, { properties: { path: X } })" tests/*.js
41 tests/javelin.js: 'Event'
42 tests/javelin.js: 'URI'
43
44 Jsgrep allows you to search object initializations partially, which enables
612f1f0d »
2012-01-10 [WIP] jspatch
45 easily drilling into the structure of JavaScript classes.
4c6b655c »
2012-01-08 Add support for loose object matching
46
58384b5f »
2012-01-07 Updated README
47 ## TODO
48
8bb3d606 »
2012-01-09 Add some protection to metavars
49 * Consider a metavar that matches but doesn't save, to prevent ambiguities.
2cf1d47c »
2012-01-09 Add support for ...
50 * Consider support for --where/--eval and/or not-patterns
4c6b655c »
2012-01-08 Add support for loose object matching
51 * Support for most statements in patterns
612f1f0d »
2012-01-10 [WIP] jspatch
52 * Formally testing the pattern matchers
58384b5f »
2012-01-07 Updated README
53
54 ## Contributors
55
56 Jsgrep was written by Ryan Patterson at Facebook. Inspiration for this project
57 draws heavily from pfff, a source code analyzer written at Facebook.
58
59 * pfff - https://github.com/facebook/pfff
Something went wrong with that request. Please try again.