paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Language-parametric static semantic code completion

语言参数化的静态语义代码补全
OOPSLA 6(OOPSLA1)2022匹配度 3/10 · 论文研究基于语法与静态语义规约的语言参数化代码补全,属于静态分析与程序语言方向,但未涉及 LLM/Agent、机器学习系统或浮点/贝叶斯程序分析,与画像核心的 PL×AI 交叉问题不匹配。引用 10 inbox
Daniel A. A. Pelsmaeker, Hendrik van Antwerpen, Casper Bach Poulsen, Eelco Visser
crossref: 2026-09-10

AI 速览

一句话:基于语法与静态语义规约,语言参数化地合成可靠且完备的代码补全建议。

代码补全是 IDE 的重要编辑服务,但要做到既可靠(不违反语法与静态语义规则)又完备(能提出所有合法片段),通常需要为每种语言单独实现。本文提出一种语言参数化的静态语义代码补全框架,直接基于语言的 SDF3 语法定义与 Statix 静态语义规约:算法重新解释静态语义,在作用域图中搜索谓词的可靠扩展与名字解析查询的解,并通过策略语言探索解空间,合成补全候选。该实现扩展 Statix 求解器,可用于任何 Statix 定义的语言。作者论证了补全候选合成的可靠性与完备性,并评估了性能。

问题
如何从语言的语法与静态语义定义出发,以最小额外实现获得可靠且完备的代码补全,而不是为每种语言单独开发编辑器服务。
方法
框架基于 SDF3 与 Statix,将静态语义定义重新解释为在作用域图中搜索谓词扩展与名字解析解,并用策略语言探索解空间以合成补全建议。
评估
作者证明补全建议合成的可靠性与完备性,并通过扩展 Statix 求解器的实现评估其性能。
原文摘要(Abstract)

Code completion is an editor service in IDEs that proposes code fragments for the user to insert at the caret position in their code. Code completion should be sound and complete. It should be sound, such that it only proposes fragments that do not violate the syntactic and static semantic rules of the language. It should be complete, such that it proposes all valid fragments so that code completion can be used to construct all programs. To realize soundness and completeness, code completion should be informed by the language definition. In practice, the implementation of code completion is an additional effort in the implementation of a language. In this paper, we develop a framework for language-parametric semantic code completion for statically typed programming languages based on their specification of syntax and static semantics, realizing the implementation of a code completion editor service with minimal additional effort. The framework builds on the SDF3 syntax definition formalism and the Statix static semantics specification language. The algorithm reinterprets the static semantics definition to find sound expansions of predicates and solutions to name resolution queries in scope graphs. This allows a search strategy to explore the solution space and synthesize completion proposals. The implementation of the strategy language and code completion algorithm extend the implementation of the Statix solver, and can be used for any language defined in Statix. We demonstrate soundness and completeness of the completion proposal synthesis, and evaluate its performance.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1515,
  title = {Language-parametric static semantic code completion},
  author = {Daniel A. A. Pelsmaeker and Hendrik van Antwerpen and Casper Bach Poulsen and Eelco Visser},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA1},
  year = {2022},
  doi = {10.1145/3527329}
}