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

javascript not match function definition #427

Closed
nick357 opened this issue Jan 9, 2025 · 4 comments
Closed

javascript not match function definition #427

nick357 opened this issue Jan 9, 2025 · 4 comments

Comments

@nick357
Copy link

nick357 commented Jan 9, 2025

export function add(c, d) { return c + d }

add(1, 2)

add($$$A) can not match export function add(c, d)

can provide an option to search only for definitions and/or only for calls?

Environment
ast-grep 0.33.0

@HerringtonDarkholme
Copy link
Member

Hi, ast-grep is a structural search tool based on AST.
https://ast-grep.github.io/advanced/pattern-parse.html#pattern-is-ast-based

add() and function add() are two different types of AST nodes. Comparing them equally is not possible in the sense of tree structure.

For your use case, you may want to try some semi structural search tool like Comby.

@nick357
Copy link
Author

nick357 commented Jan 11, 2025

@HerringtonDarkholme
Copy link
Member

My question is whether this search plugin can support simple options to find function definitions and function calls

No, the feature should covered by #167

@nick357
Copy link
Author

nick357 commented Jan 11, 2025

get it, thanks

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

2 participants