Hamish_Fernsby
Hamish_Fernsby

Reputation: 578

Tool to change a unit name and all references to it

If I make major changes to a unit I like to change its name to make it clear this is a different version and avoid confusion with other archived versions for example: CSVUtils.PAS becomes CsvUtilsNew.PAS

But all references to it from other units have to be changed manually, eg:

Unit ManiForm

Uses
  CSVUtils 

becomes

Unit ManiForm

Uses
  CsvUtilsNew

This gets very laborious in complex projects.

Icarus is very good at finding all the references, but I cant find any tool that would automatically update all the other units.

Does anyone know of any tools which automatically update unit references?

Many thanks

Upvotes: 9

Views: 3209

Answers (3)

Ondrej Kelle
Ondrej Kelle

Reputation: 37211

You could also define a unit alias in your project options. E.g. CSVUtils=CsvUtilsNew

Upvotes: 3

iamjoosy
iamjoosy

Reputation: 3349

I would use GExperts Grep Search and Replace.

Upvotes: 11

Andreas Hausladen
Andreas Hausladen

Reputation: 8141

I would use Notepad++ or UltraEdit to Search&Replace in all files (*.pas, *.dpr, *.dproj) the old unit name with the new unit name. Unless you have variables or functions that have the same name as the unit, this works very well, is fast and does not require any specialized parser.

Upvotes: 8

Related Questions