Context: The software maintenance phase involves many activities such as code refactoring, bug fixing, code review or testing. Program comprehension is key to all these activities, as it demands developers to grasp the knowledge (e.g., implementation details) required to modify the codebase. Methods as main building blocks in a program can offer developers this knowledge source for code comprehension. However, reading entire method statements can be challenging, which necessitates precise and up-to-date comments. Objective: We propose a solution as an IntelliJ IDEA plugin, named SmartDoc, that assists developers in generating context-aware method comments. Method: This plugin acts as an Artificial Intelligence (AI) agent that has its own memory and is augmented by target methods' context. When a request is initiated by the end-user, the method content and all its nested method calls are used in the comment generation. At the beginning, these nested methods are visited and a call graph is generated. This graph is then traversed using depth-first search (DFS), enabling the provision of full-context to enrich Large Language Model (LLM) prompts. Result: The product is a software, as a plugin, developed for Java codebase and installable on IntelliJ IDEA. This plugin can serve concurrently for methods whose comments are being updated , and it shares memory across all flows to avoid redundant calls. o measure the accuracy of this solution, a dedicated test case is run to record SmartDoc generated comments and their corresponding ground truth. For each collected result-set, three metrics are computed, BERTScore, BLEU and ROUGE-1. These metrics will determine how accurate the generated comments are in comparison to the ground truth. Result: The obtained accuracy, in terms of the precision, recall and F1, is promising, and lies in the range of 0.80 to 0.90 for BERTScore.
翻译:背景:软件维护阶段涉及代码重构、缺陷修复、代码审查或测试等多种活动。程序理解是所有这些活动的关键,因为它要求开发人员掌握修改代码库所需的知识(例如实现细节)。方法作为程序中的主要构建块,可以为开发人员提供代码理解的知识来源。然而,阅读完整的方法语句可能具有挑战性,这需要精确且最新的注释。目标:我们提出了一种作为IntelliJ IDEA插件的解决方案,命名为SmartDoc,旨在协助开发人员生成上下文感知的方法注释。方法:该插件作为一个具有自身记忆的人工智能(AI)代理,并通过目标方法的上下文进行增强。当最终用户发起请求时,方法内容及其所有嵌套方法调用将用于注释生成。初始阶段会访问这些嵌套方法并生成调用图。随后使用深度优先搜索(DFS)遍历该图,从而提供完整上下文以丰富大型语言模型(LLM)的提示。结果:该产品是一个为Java代码库开发、可安装于IntelliJ IDEA的插件软件。该插件可同时为正在更新注释的方法提供服务,并在所有流程间共享内存以避免冗余调用。为评估该方案的准确性,运行了专用测试用例以记录SmartDoc生成的注释及其对应真实值。针对每个收集的结果集,计算了三个指标:BERTScore、BLEU和ROUGE-1。这些指标将确定生成注释相较于真实值的准确程度。结果:获得的准确率(包括精确率、召回率和F1值)表现良好,其中BERTScore的数值范围在0.80至0.90之间。