Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to change a unit name and all references to it

Tags:

delphi

pascal

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

like image 480
Hamish_Fernsby Avatar asked Mar 13 '12 10:03

Hamish_Fernsby


3 Answers

I would use GExperts Grep Search and Replace.

like image 198
iamjoosy Avatar answered Oct 07 '22 18:10

iamjoosy


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.

like image 42
Andreas Hausladen Avatar answered Oct 07 '22 18:10

Andreas Hausladen


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

like image 43
Ondrej Kelle Avatar answered Oct 07 '22 18:10

Ondrej Kelle