Ast-grep doesn't match any nodes, but actually it is! (If we look inside the import)
If we join all .py files into one and rewrite def zoo(dog: Dog) -> def zoo(dog: Animal) (it's wrong, but it just for demonstration), then ast-grep matches function definition.
There is a way to get data from the whole project through the LSP server, but I don't know how implementable it is. Maybe ast-grep is not suitable for this task, but I don't know any other alternatives that can match ast-grep in terms of speed and functionality.
⭐ Suggestion
It would be really cool to use LSP server methods to write rules (specifically go to definition).
💻 Use Cases
Sometimes you need to write a rule that is contiguous for multiple files. For example
animal.py
dog.py
main.py
is-named-class.yml
Ast-grep doesn't match any nodes, but actually it is! (If we look inside the import) If we join all
.py
files into one and rewritedef zoo(dog: Dog) -> def zoo(dog: Animal)
(it's wrong, but it just for demonstration), then ast-grep matches function definition.There is a way to get data from the whole project through the LSP server, but I don't know how implementable it is. Maybe ast-grep is not suitable for this task, but I don't know any other alternatives that can match ast-grep in terms of speed and functionality.