Language-parametric static semantic code completion

Journal Article (2022)
Author(s)

D.A.A. Pelsmaeker (TU Delft - Programming Languages)

H. Van Antwerpen (TU Delft - Programming Languages)

C.B. Bach (TU Delft - Programming Languages)

Eelco Visser (TU Delft - Programming Languages)

Research Group
Programming Languages
Copyright
© 2022 D.A.A. Pelsmaeker, H. van Antwerpen, C.B. Poulsen, Eelco Visser
DOI related publication
https://doi.org/10.1145/3527329
More Info
expand_more
Publication Year
2022
Language
English
Copyright
© 2022 D.A.A. Pelsmaeker, H. van Antwerpen, C.B. Poulsen, Eelco Visser
Research Group
Programming Languages
Issue number
OOPSLA1
Volume number
6
Pages (from-to)
1-30
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

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.