一句话:提出 TreeRanker:将静态补全组织为前缀树并单次贪心解码打分,实现快速、模型无关的补全排序。
Token 级代码补全是现代 IDE 的核心功能,用于向开发者推荐相关标识符与 API。补全候选通常由静态分析产生,但其实际可用性高度依赖排序:正确预测若排在列表深处,几乎不会被用户看到。现有系统多依赖手工启发式规则或在用户日志上训练的轻量机器学习模型,在捕捉上下文信息、跨项目与跨编码风格泛化方面仍有提升空间。本文提出一种新的打分方法,以轻量且模型无关的方式利用语言模型对静态补全候选排序。该方法将所有合法补全组织为一棵前缀树,并通过一次贪心解码遍历收集树上的 token 级分数,从而在无需 beam search、prompt 工程或模型适配的情况下实现精确的 token 感知排序。该方案快速、与架构无关,并兼容已部署的代码补全模型,为在现有 IDE 工具中集成语言模型、提供更智能且响应更快的开发者辅助提供了实用路径。
Token-Level code completion is one of the most critical features in modern Integrated Development Environments (IDEs). It assists developers by suggesting relevant identifiers and APIs during coding. While completions are typically derived from static analysis, their usefulness depends heavily on how they are ranked, as correct predictions buried deep in the list are rarely seen by users. Most current systems rely on handcrafted heuristics or lightweight machine learning models trained on user logs, which can be further improved to capture context information and generalize across projects and coding styles. In this work, we propose a new scoring approach to ranking static completions using language models in a lightweight and model-agnostic way. Our method organizes all valid completions into a prefix tree and performs a single greedy decoding pass to collect token-level scores across the tree. This enables a precise token-aware ranking without needing beam search, prompt engineering, or model adaptations. The approach is fast, architecture-agnostic, and compatible with already deployed models for code completion. These findings highlight a practical and effective pathway for integrating language models into already existing tools within IDEs, and ultimately providing smarter and more responsive developer assistance.
@inproceedings{paperbot9370,
title = {TreeRanker: Fast and Model-Agnostic Ranking System for Code Suggestions in IDEs},
author = {Daniele Cipollone and Egor Bogomolov and Arie Van Deursen and Maliheh Izadi},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00290}
}