grasp
grasp copied to clipboard
Question: How to escape dollar sign?
I want to match this js code:
$stateProvider.state('stateName', {})
And if I do this in equery '$stateProvider.state(,)' - $stateProvider is actually named match in equery, so it will match "ANYSTRING.state('stateName', {})". I have tried to esacape it with $stateProvider or with $$stateProvider, but they don't work.
There is no way to do so currently using equery, you can do it some of it with squery:
grasp 'call[callee=member[obj=#$stateProvider][prop=#state]]'
With squery am I losing ability to have named matches? I want to use them like matching the first parameter '$stateProvider.state($name,__)'
I have made a little patch in grasp-equery/parse.js and it works for my example above with $$stateProvider. I don't know would it work in more complex query as I don't know grasp-equery internals. Here it is:
function processNode(node){
...
} else if (that = /^_\$(\w*)$/.exec(name)) {
...
>>> my addition >>>
} else if (that = /^\$\$(\w+)$/.exec(name)) {
node.name = node.name.substr(1);
return;
<<< my addition <<<
} else if (that = /^\$(\w+)$/.exec(name)) {
....
@gkz Hi, I'd like to confirm with you that not only dollar sign, but even underscore is not really available for lookup with equery, is it not?
A single underscore should work