Skip to content
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

You can use sg -p 'dep = $A' -l lua --debug-query to debug the pattern and use sg -p 'dep = $A' -l lua --debug-query=ast to debug the AST structure.

\n

In this case, dep = $A is parsed as

\n
Debug Pattern:\nassignment_statement\n  variable_list\n    identifier dep\n  =\n  MetaVar $A\n
\n

But I guess you want to find code like { dep = $A }. So https://ast-grep.github.io/guide/rule-config/atomic-rule.html#pattern-object can help you

\n
ast-grep -p '{dependencies = $$$}' -l lua --selector 'field'
","upvoteCount":1,"url":"https://github.com/ast-grep/ast-grep/discussions/2298#discussioncomment-14762988"}}}
Discussion options

You must be logged in to vote

You can use sg -p 'dep = $A' -l lua --debug-query to debug the pattern and use sg -p 'dep = $A' -l lua --debug-query=ast to debug the AST structure.

In this case, dep = $A is parsed as

Debug Pattern:
assignment_statement
  variable_list
    identifier dep
  =
  MetaVar $A

But I guess you want to find code like { dep = $A }. So https://ast-grep.github.io/guide/rule-config/atomic-rule.html#pattern-object can help you

ast-grep -p '{dependencies = $$$}' -l lua --selector 'field'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HerringtonDarkholme
Comment options

Answer selected by iwinux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants