Principled Syntactic Code Completion using Placeholders

Research output: Chapter in Book/Conference proceedings/Edited volumeConference contributionScientificpeer-review

8 Citations (Scopus)
57 Downloads (Pure)


Principled syntactic code completion enables developers to change source code by inserting code templates, thus increasing developer efficiency and supporting language exploration. However, existing code completion systems are ad-hoc and neither complete nor sound. They are not complete and only provide few code templates for selected programming languages. They also are not sound and propose code templates that yield invalid programs when inserted. This paper presents a generic framework that automatically derives complete and sound syntactic code completion from the syntax definition of arbitrary languages. A key insight of our work is to provide an explicit syntactic representation for incomplete programs using placeholders. This enables us to address the following challenges for code completion separately: (i) completing incomplete programs by replacing placeholders with code templates, (ii) injecting placeholders into complete programs to make them incomplete, and (iii) introducing lexemes and placeholders into incorrect programs through error-recovery parsing to make them correct so we can apply one of the previous strategies. We formalize our framework and provide an implementation in Spoofax.

Original languageEnglish
Title of host publicationProceedings of the 2016 ACM SIGPLAN International Conference on Software Language Engineering, co-located with SPLASH 2016
EditorsD. Varro, E. Balland, T. van der Storm
Place of PublicationNew York, NY
PublisherAssociation for Computing Machinery (ACM)
Number of pages13
ISBN (Electronic)978-1-4503-4447-0
Publication statusPublished - 20 Oct 2016
EventSLE 2016: 9th ACM SIGPLAN International Conference on Software Language Engineering - Amsterdam, Netherlands
Duration: 31 Oct 20161 Nov 2016
Conference number: 9


ConferenceSLE 2016


  • Code completion
  • Ides
  • Language workbenches


Dive into the research topics of 'Principled Syntactic Code Completion using Placeholders'. Together they form a unique fingerprint.

Cite this