gkz / grasp

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

if,else equery fails on if without else #89

Open ainthek opened 8 years ago

ainthek commented 8 years ago

fails with: Cannot read property 'type' of null any suggestions ? how to find if, else with single boolean returns ?

echo 'function _test(x){ if(x){ return true; } }

function _0059_useless_if(x){ if(x){ return true; } else{ return false; } }' | grasp -e 'if(__){ return _bool }else{ return _bool }'

also s-query would be fine. Is this bug or my misconcept ? I also tried -e "_ifelse{ return _bool }else{ return _bool }" but that does not work at all,

based on your sentence: After a wildcard , node type or literal type, you can append an attribute selector as well: [right] matches any node that has a right attribute.

not working.