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:\nassignment_statement\n variable_list\n identifier dep\n =\n MetaVar $A\nBut 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'-
|
I'm trying to search for Lua plugin dependencies with ast-grep, but id: deps
language: lua
rule:
kind: field
has:
kind: identifier
regex: dependencies |
Beta Was this translation helpful? Give feedback.
-
|
You can use In this case, But I guess you want to find code like ast-grep -p '{dependencies = $$$}' -l lua --selector 'field' |
Beta Was this translation helpful? Give feedback.
You can use
sg -p 'dep = $A' -l lua --debug-queryto debug the pattern and usesg -p 'dep = $A' -l lua --debug-query=astto debug the AST structure.In this case,
dep = $Ais parsed asBut 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