gogrep icon indicating copy to clipboard operation
gogrep copied to clipboard

Suggestion: Add debug argument to print ast.Node type information

Open sebastien-rosset opened this issue 4 years ago • 0 comments

How about having a -d (or -v) argument to print the AST type information of the matched node and the $x patterns? Currently, when a pattern match occurs, gogrep prints the value of the AST node: https://github.com/mvdan/gogrep/blob/master/main.go#L326

For example, given the following code:

func main() {
  v := mypkg.MyStruct{}

The command gogrep -x '$x.$y{$*_}' will print something like this:

main.go:24:10: mypkg.MyStruct{}

This is great, but when exploring various patterns, I find it would be very useful to know the exact ast nodes of the entire pattern and each of the $X sub matches.

sebastien-rosset avatar Dec 01 '20 01:12 sebastien-rosset