getgrit / gritql

GritQL is a query language for searching, linting, and modifying code.

Home Page:https://docs.grit.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: re-use `$...` meta variable in rewrite expression

jonathan-s opened this issue · comments

Since the $... expression can capture a number of nodes it would be useful if this could in one way or another be re-used in the re-write expression.

Right now the docs say "Spread metavariables are anonymous, so they cannot be bound to a name.", so anything captured there can't really be used.

The workaround I guess would be to use regex patterns.

$... on its own doesn't have a name, so it wouldn't be possible to bind them with the current syntax, I don't think it would be too hard to add something like $...name where $name binds to whatever $... would have matched

That would be lovely!