getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.
https://docs.grit.io/
MIT License
3.17k stars 83 forks source link

Higher level equivalence classes #531

Open morgante opened 1 month ago

morgante commented 1 month ago

We would like a way to 'expand' ASTs patterns into higher level "equivalent" ASTs that we then match against.

This can reduce AST surprises and allow simpler matching fragments so the actual matching engine is closer to developer intuitions.

Examples

Alex-ley-scrub commented 3 weeks ago

is this related to #394 as well @morgante ?

morgante commented 3 weeks ago

Kind of, but it's a higher level concept. That approach only works for leaf nodes (where we can strip characters to get a normalized representation).

For this we actually want to support much higher level equivalence classes to rewrite queries into "equivalent" queries that are more likely to capture the user intent.