This plug-in allows you to quickly rename or delete all occurances of a unit.
Upon installation, this plug-in will insert two new menu options, "Rename Unit..." and "Delete Unit...", into the File menu. These new options will appear directly below the File|Save All menu option, as seen below...
When this option is selected, CodeRush will prompt you to save the active unit. A standard File Save dialog will appear requesting a unit name, defaulting to the name of the unit currently loaded in the editor. So if you are working on a file named Unit1.pas, as below:
the following dialog will appear:
In the dialog above, we renamed our unit, Unit1.pas, to MyUnit.pas. In addition to the *.PAS file, any associated *.DFM file is also renamed. Of course, the Delphi editor immediately updates to reflect this change, as seen below:
One interesting side effect of using this plug-in is the "garbage collection" that is automatically performed for you. Witness our Projects folder just before the renaming of our Unit1.pas file:
Notice how the seven instances of the Unit1 file (*.pas, *.dfm, *.bkm, *.dcu, *.ddp, *.~dfm, and *.~pas) have been reduced to simply MyUnit.pas, MyUnit.dfm, and MyUnit.bkm.
MyUnit.pas is essentially saved as if it was a new unit, therefore the "extra" files that would have been created as a result of repetitive saves (*.~pas, *.~dfm) or from prior compiles (*.dcu, *.ddp) are removed. The backup files MyUnit.~pas and MyUnit.~dfm will, of course, be recreated the next time the user saves. Likewise, the MyUnit.dcu and MyUnit.ddp files will be created the next time the user compiles/builds this project.
When this option is selected, CodeRush will prompt you with a standard file access dialog requesting a unit name, defaulting to the name of the active unit in the editor. So, for example, assume our Projects folder contained the file Unit1.pas, as mentioned above. When the Delete Unit menu option is selected, the dialog that appears will look like this:
Selecting Unit1.pas from this dialog and clicking Open will result in the file being deleted from the Projects folder. In addition, all occurances of a file named "Unit1" will also be removed. Observe the contents of our Projects folder just after executing the Delete Unit command.
If the file was active in the Delphi IDE, it will be automatically closed.
The identity of the author of the original (CR 5) version of this plug-in is unknown. If anyone knows who wrote this useful add-on, please e-mail me so proper credit can be given.
This plug-in is not the property of Developer Express; it is the sole property of its author. As such, Developer Express cannot be held liable for any incidental damages that may be related to the usage of this plug-in.