Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any tool to suggest unit reference automatically for Delphi 2010?

MS Visual Studio has a great feature: it automatically suggests the units to add in using clause when you typing the code with refrences to absent standard classes.

Is there any 3-rd party tool to implement similar feature for Delphi?

I'm tired to add all those SysUtils, Windows, Messages etc in each new unit.

like image 595
Andrew Avatar asked Feb 23 '12 08:02

Andrew


2 Answers

If the unit which contains the reference is not yet in the uses list, this is how I save many manual steps:

  • right-click on the underlined (error-insighted) text
  • choose “Refactoring | Find Unit…“.

A dialog will present the available unit which contains the unknown type or symbol, and a mouse click adds the selected unit to the uses list of the current file.

like image 120
mjn Avatar answered Oct 17 '22 20:10

mjn


CNPack Input Helper can sugest and autocomplete units (sorry for another answer, but I can't comment other).

CNPack unfortunately don't auto-add units from place of code input but you can:

  • Copy a word from cursor place (CNPack->Editor enchancements->Tabset/Button->Clipboard operations->Cut/copy token...).
  • Eventually search this word in source files (grep) to identify unit.
  • Use CNPack->Toggle Uses/Include Field (Ctrl+u) and start typing and use CNPack->Input Helper sugestion/autocompletion, or IDE/GExperts/CNPack use unit future
  • Back to place of code edition
like image 20
g2mk Avatar answered Oct 17 '22 18:10

g2mk