your-tools / ruplacer

Find and replace text in source files
BSD 3-Clause "New" or "Revised" License
443 stars 25 forks source link

Support multiline replace #70

Open icco opened 3 years ago

icco commented 3 years ago

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?

ErichDonGubler commented 2 years ago

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:

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.