Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I match two calls to the same function in the same block? #124

Open
danielrozenberg opened this issue Jun 8, 2018 · 0 comments
Open

Comments

@danielrozenberg
Copy link

I'm trying to match any body block that has two calls to the same (explicitly named) function, e.g. it should match this block:

it('should match this sub-block', () => {
  // do Javascript things
  thisFunctionShouldOnlyBeCalledOnce(123);
  // do JavaScript things
  thisFunctionShouldOnlyBeCalledOnce(456);
  // do JavaScript things
});

And it should not match this block:

it('should match this sub-block', () => {
  // do Javascript things
  thisFunctionShouldOnlyBeCalledOnce(123);
  // do JavaScript things
});

I tried a bunch of things, the "closest" I got were:

  • grasp --squery 'call[callee=#it].arguments:nth(1).body! call[callee=#funcName] ~ call[callee=#funcName]'
  • grasp --equery 'funcName(__); _$; funcName(__);

But to no avail. Is this something that can be done with grasp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant