简体   繁体   English

任何为Delphi 2010自动建议单位参考的工具?

[英]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. MS Visual Studio有一个很棒的功能:当您输入代码时,它会自动建议using子句添加单元,而不需要标准类。

Is there any 3-rd party tool to implement similar feature for Delphi? 是否有任何第三方工具来实现Delphi的类似功能?

I'm tired to add all those SysUtils, Windows, Messages etc in each new unit. 我很想在每个新单元中添加所有这些SysUtils,Windows,Message等。

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. 对话框将显示包含未知类型或符号的可用单元,单击鼠标将所选单元添加到当前文件的使用列表中。

CNPack Input Helper can sugest and autocomplete units (sorry for another answer, but I can't comment other). CNPack输入助手可以提取和自动完成单位(对不起另一个答案,但我无法评论其他)。

CNPack unfortunately don't auto-add units from place of code input but you can: 不幸的是,CNPack不会从代码输入位置自动添加单位,但您可以:

  • Copy a word from cursor place (CNPack->Editor enchancements->Tabset/Button->Clipboard operations->Cut/copy token...). 从光标位置复制一个单词(CNPack-> Editor enchancements-> Tabset / Button-> Clipboard operations-> Cut / copy token ...)。
  • Eventually search this word in source files (grep) to identify unit. 最终在源文件(grep)中搜索此单词以识别单位。
  • 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 使用CNPack->切换使用/包含字段(Ctrl + u)并开始输入并使用CNPack-> Input Helper sugestion / autocompletion,或IDE / GExperts / CNPack使用单位future
  • Back to place of code edition 回到代码版的地方

The JCL includes the "Uses Wizard." JCL包括“使用向导”。 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. JclUsesExpert.dpk包仅适用于某些Delphi版本。 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. 我不知道是不是因为插件在以后的版本中不起作用,或者有人只是忽略了将项目复制到更高版本的文件夹中。

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. CnPack IDE Wizards是Delphi的优秀开源插件。
http://www.cnpack.org/index.php?lang=en http://www.cnpack.org/index.php?lang=en

I use its Uses cleaner feature a lot. 我使用它的Uses cleaner功能很多。 There is a menu item: 有一个菜单项:
CnPack -> Project Enhancements -> Use Unit CnPack - > 项目增强 - > 使用单位

I think this can be helpful for your needs. 我认为这对您的需求很有帮助。

rFindUnit IDE扩展是上面@mjn建议的内置“Refactoring | Find Unit ...”功能的增强版本。

Or maybe you can try this: http://www.epocalipse.com/products.htm 或者你可以尝试这个: 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." “一个免费的Delphi插件,允许您快速打开单元,并将它们添加到uses子句中。”

I never tried this expert but it semms promising. 我从未尝试过这位专家,但它很有希望。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM