gkz / grasp

JavaScript structural search, replace, and refactor
http://graspjs.com
MIT License
1.28k stars 33 forks source link

how to reference nodes in replacement with -s query #93

Open belusky opened 8 years ago

belusky commented 8 years ago

How can I reference arr,item arguments call in replacement string with s-query? grasp -s 'call[callee=member[obj=#array][prop=#indexOf]]' test.js 1:array.indexOf(arr, item);

grasp -s 'call[callee=member[obj=#array][prop=#indexOf]]' -R ' ??? ' test.js

Result after replacement should be arr.indexOf(item)

With e-query it should be grasp -e 'array.indexOf($arr,$item)' -R '{{arr}}.indexOf({{item}})' test.js