Support multiline replace
icco opened this issue · comments
Nat Welch commented
I have the following in a lot of files:
Log.send(
new LogData(
this.baseData,
`${this.tryGetPingMatterLinkedToUser.name}.ts`,
userId,
Level.Warn,
`Dms client matter code: ${filedDocument.DmsClientMatterCode()} does not exist in Ping`
)
);
I want to replace all with logger.error(error)
.
I tried lots of different things, but I expected ruplacer 'Log\.send\((?s:.)*\);' 'logger.error(error)' -t ts
to work, but it does not. Any thoughts?
Erich Gubler commented
Adding some context here: Current behavior's limitation to single-line changes is because ruplacer
's logic is very baked against processing individual lines at the moment. For reference in main
ATOW, see:
- https://github.com/dmerejkowsky/ruplacer/blob/6af0001ab37ad8e3c22ba9e229b06623a28e71eb/src/file_patcher.rs#L35-L71
- https://github.com/dmerejkowsky/ruplacer/blob/5cca234c2c57dd41b300b3b9cd03396776dd7489/src/query.rs#L8-L19
I don't see a technical reason that ruplacer
couldn't do multi-line edits, but it would involve some major shifts to ruplacer
's UX.