智能代码补全

智能代码补全[1]是一种编程环境中,有上下文感知的的代码自动完成功能。它可以通过减少打字错误和其他常见错误,使编写应用的速度得到提升。智能代码补全通常在键入、查询函数参数以及与语法错误相关的查询提示时,会弹出自动完成窗口。智能代码补全和相关工具使用反射式编程产生变量名称、函数方法的文档以及消除歧义。[2]

Qt Creator 5.0-Autocomplete

该功能出现在许多编程环境中。[3][4]其实现包括Atom中的 “autocomplete +”和Visual Studio Code中的 IntelliSense。该术语最初被命名为“选择列表”,一些实现仍然这样称呼它。[5]

概述 编辑

与其他自动完成系统相似,智能代码补全可以便捷地访问函数的定义,尤其是参数列表。这项功能因为减少键盘输入和不需要记忆名称,加速了软件开发。它同时允许用户更少地查阅外部文档,由于许多在当前范围的符号的交互式文档会以提示框的形式动态显现。[6] 智能代码补全使用内存里的自动生成数据库,其中有类,变量名,和代码中定义或提及的其他概念。典型的智能感知功能的实现,靠的是检测“标记符”,例如句号(或者其他分隔符,由语言决定)。当用户输入有可访问成员(比如成员变量或函数)的实体,紧接输入此类字符时,立刻就弹出一个智能感知建议的弹窗。用户可以通过键入一个完成语句的符号(Tab ↹,↵ Enter,或者在C++中的分号)接受建议,也可以继续输入。久而久之,智能感知会决定用户最可能需要的变量或函数。智能感知还会凭借函数的源代码中的文档,在弹窗内显示函数的简介。 在支持面向对象编程的语言中,这项功能也让用户从一系列重载的函数中选择。一些代码编辑软件以语言服务器的方式提供智能代码补全功能。

参考来源 编辑

  1. ^ Bruch, Marcel; Monperrus, Martin; Mezini, Mira. Learning from examples to improve code completion systems. Proceedings of the 7th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on the foundations of software engineering on European software engineering conference and foundations of software engineering symposium - ESEC/FSE '09 (PDF). 2009: 213 [2022-12-13]. ISBN 9781605580012. S2CID 18621745. doi:10.1145/1595696.1595728. (原始内容存档 (PDF)于2022-12-13). 
  2. ^ Definition of autocomplete | Dictionary.com. www.dictionary.com. [2022-12-13]. (原始内容存档于2023-03-06) (英语). 
  3. ^ FAQ - Code::Blocks. wiki.codeblocks.org. [2022-12-13]. (原始内容存档于2020-09-18). 
  4. ^ Qt Documentation - Completing Code页面存档备份,存于互联网档案馆). Retrieved on 2015-07-07.
  5. ^ Salesforce. Working with Picklists in Apex and Lightning Web Components. developer.salesforce.com. 2008-12-09 [2022-12-13]. (原始内容存档于2022-12-13) (美国英语). 
  6. ^ Murach. C# 2005. : 56. 
  7. ^ Earnest, Les. The First Three Spelling Checkers (PDF). Stanford University. [2011-10-10]. (原始内容 (PDF)存档于2012-10-22). 
  8. ^ Peterson, James. Computer Programs for Detecting and Correcting Spelling Errors (PDF). December 1980 [2011-02-18]. (原始内容存档 (PDF)于2018-06-25). 
  9. ^ Earnest, Les. Visible Legacies for Y3K (PDF). [2011-02-18]. (原始内容 (PDF)存档于2011-07-20). 
  10. ^ Using IntelliSense页面存档备份,存于互联网档案馆). Msdn.microsoft.com. Retrieved on 2014-04-04.
  11. ^ Visual Studio IntelliCode. [2022-12-13]. (原始内容存档于2023-04-08). 
  12. ^ Eclipse Corner Article: Unleashing the Power of Refactoring | the Eclipse Foundation. [2022-12-13]. (原始内容存档于2023-04-15). 
  13. ^ Technologies. [2022-12-13]. (原始内容存档于2017-07-08). 
  14. ^ Eclipse Code Recommenders: It’s all about intelligent code completion页面存档备份,存于互联网档案馆). Code-recommenders.blogspot.com (2010-05-03). Retrieved on 2014-04-04.
  15. ^ 542689 - Don't include Code Recommenders for 2018-12. [2022-12-13]. (原始内容存档于2022-12-13). 
  16. ^ cross-project-issues-dev Withdrawing Code Recommenders from SimRel. [2022-12-13]. (原始内容存档于2022-12-13). 
  17. ^ Archived Projects | The Eclipse Foundation. [2022-12-13]. (原始内容存档于2023-04-22). 
  18. ^ Vim Intellisense页面存档备份,存于互联网档案馆). Insenvim.sourceforge.net. Retrieved on 2014-04-04.

外部链接 编辑