Any tool to suggest unit reference automatically f

2019-03-14 15:48发布

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.

6条回答
欢心
2楼-- · 2019-03-14 16:11

This is not a tool to suggest references, it only cleans up unneeded unit clauses.

CnPack IDE Wizards is an excellent opensource plugin for Delphi.
http://www.cnpack.org/index.php?lang=en

I use its Uses cleaner feature a lot. There is a menu item:
CnPack->Project Enhancements->Use Unit

I think this can be helpful for your needs.

查看更多
太酷不给撩
3楼-- · 2019-03-14 16:12

The rFindUnit IDE extension is the enhanced version of built-in "Refactoring | Find Unit…" function suggested by @mjn above.

查看更多
Emotional °昔
4楼-- · 2019-03-14 16:20

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
查看更多
叛逆
5楼-- · 2019-03-14 16:24

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.

查看更多
冷血范
6楼-- · 2019-03-14 16:27

The JCL includes the "Uses Wizard." It watches for compilation errors mentioning "Undeclared identifier," and when it sees one, it automatically adds the unit where that identifier is declared.

The package JclUsesExpert.dpk is only available for certain Delphi versions. I don't know if that's because the plug-in doesn't work in later versions, or if someone merely neglected to copy the project into later versions' folders.

查看更多
Summer. ? 凉城
7楼-- · 2019-03-14 16:32

Or maybe you can try this: http://www.epocalipse.com/products.htm

Unit Expert

"A freeware Delphi add-in that allows you to quickly open units and also add them to the uses clause."

I never tried this expert but it semms promising.

查看更多
登录 后发表回答