Table of Contents
Fetching ...

SmartDoc: A Context-Aware Agentic Method Comment Generation Plugin

Vahid Etemadi, Gregorio Robles

TL;DR

The paper addresses the challenge of outdated or missing method comments that hinder code comprehension during maintenance. It introduces SmartDoc, an IntelliJ plugin that builds full method-context via a DFS-derived call graph and uses Retrieval-Augmented Generation to generate JavaDoc-style comments with an AI agent that maintains memory across requests. Evaluations on ground-truth JavaDocs show high semantic similarity (BERTScore 0.80–0.90) and structured output quality, while highlighting non-determinism in LLM outputs and the impact of context richness. The work demonstrates a practical, context-aware approach to automatic documentation generation with potential for multi-language support and broader model integration in future iterations.

Abstract

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.

SmartDoc: A Context-Aware Agentic Method Comment Generation Plugin

TL;DR

The paper addresses the challenge of outdated or missing method comments that hinder code comprehension during maintenance. It introduces SmartDoc, an IntelliJ plugin that builds full method-context via a DFS-derived call graph and uses Retrieval-Augmented Generation to generate JavaDoc-style comments with an AI agent that maintains memory across requests. Evaluations on ground-truth JavaDocs show high semantic similarity (BERTScore 0.80–0.90) and structured output quality, while highlighting non-determinism in LLM outputs and the impact of context richness. The work demonstrates a practical, context-aware approach to automatic documentation generation with potential for multi-language support and broader model integration in future iterations.

Abstract

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.

Paper Structure

This paper contains 10 sections, 8 figures.

Figures (8)

  • Figure 1: SmartDoc workflow representing interaction of user with the system and internal data flow
  • Figure 2: The workflow of the comment generation request
  • Figure 3: SmartDoc agent component. It comprises the system core, acting as key runner for producing precise comment.
  • Figure 4: An example of classes that are coupled via method calls. Assume methodA1 in ClassA has a call to methodA2
  • Figure 5: Call graph and the order of visiting each method, according to the class diagram shown in Figure \ref{['fig:cd-example']}
  • ...and 3 more figures