ABSTRACT
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 the Spoofax Language Workbench.
- S. Amann, S. Proksch, S. Nadi, and M. Mezini. A study of visual studio usage in practice. In SANER, 2016.Google ScholarCross Ref
- P. Borras, D. Clément, T. Despeyroux, J. Incerpi, G. Kahn, B. Lang, and V. Pascual. CENTAUR: The system. In Proceedings of the third ACM SIGSOFT/SIGPLAN software engineering symposium on Practical software development environments, pages 14–24, New York, USA, 1988. ACM. Google ScholarDigital Library
- M. de Jonge, L. C. L. Kats, E. Visser, and E. Söderberg. Natural and flexible error recovery for generated modular language environments. ACM Transactions on Programming Languages and Systems, 34(4):15, 2012. Google ScholarDigital Library
- P. Degano and C. Priami. Comparison of syntactic error handling in LR parsers. Software: Practice and Experience, 25(6):657–679, 1995. Google ScholarDigital Library
- S. Efftinge and M. Völter. oAW xText: A framework for textual DSLs. In Workshop on Modeling Symposium at Eclipse Summit, 2006.Google Scholar
- D. Harkes, D. M. Groenewegen, and E. Visser. IceDust: Incremental and eventual computation of derived values in persistent object graphs. In S. Krishnamurthi and B. S. Lerner, editors, 30th European Conference on Object-Oriented Programming, ECOOP 2016, July 18-22, 2016, Rome, Italy, volume 56 of LIPIcs. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2016.Google Scholar
- L. C. L. Kats and E. Visser. The Spoofax language workbench: rules for declarative specification of languages and IDEs. In W. R. Cook, S. Clarke, and M. C. Rinard, editors, Proceedings of the 25th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2010, pages 444–463, Reno/Tahoe, Nevada, 2010. ACM. Google ScholarDigital Library
- P. Klint. A meta-environment for generating programming environments. ACM Trans. Softw. Eng. Methodol., 2(2):176– 201, Apr. 1993. Google ScholarDigital Library
- D. E. Knuth. Semantics of context-free languages. In In Mathematical Systems Theory, pages 127–145, 1968.Google ScholarCross Ref
- G. D. P. Konat, L. C. L. Kats, G. Wachsmuth, and E. Visser. Declarative name binding and scope rules. In K. Czarnecki and G. Hedin, editors, Software Language Engineering, 5th International Conference, SLE 2012, Dresden, Germany, September 26-28, 2012, Revised Selected Papers, volume 7745 of Lecture Notes in Computer Science, pages 311–331. Springer, 2012.Google Scholar
- J. Koorn. GSE: a generic text and structure editor. In University of Amsterdam, pages 168–177, 1992.Google Scholar
- L. Moonen. Generating robust parsers using island grammars. In WCRE, page 13, 2001. Google ScholarDigital Library
- L. Moonen. Lightweight impact analysis using island grammars. In 10th International Workshop on Program Comprehension (IWPC 2002), 27-29 June 2002, Paris, France, pages 219–228. IEEE Computer Society, 2002. Google ScholarDigital Library
- P. Neron, A. P. Tolmach, E. Visser, and G. Wachsmuth. A theory of name resolution. In J. Vitek, editor, Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings, volume 9032 of Lecture Notes in Computer Science, pages 205–231. Springer, 2015.Google Scholar
- T. Reps and T. Teitelbaum. The synthesizer generator. SIGSOFT Softw. Eng. Notes, 9(3):42–48, Apr. 1984. Google ScholarDigital Library
- R. Robbes and M. Lanza. How program history can improve code completion. In 23rd IEEE/ACM International Conference on Automated Software Engineering (ASE 2008), 15-19 September 2008, L Aquila, Italy, pages 317–326. IEEE, 2008. Google ScholarDigital Library
- M. M. Schrage. Proxima – a presentation-oriented editor for structured documents. PhD thesis, Utrecht University, The Netherlands, Oct 2004.Google Scholar
- M. Tomita. Efficient Parsing for Natural Language: A Fast Algorithm for Practical Systems. Kluwer Academic Publishers, Norwell, MA, USA, 1985. Google ScholarDigital Library
- H. van Antwerpen, P. Neron, A. P. Tolmach, E. Visser, and G. Wachsmuth. A constraint language for static semantic analysis based on scope graphs. In M. Erwig and T. Rompf, editors, Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2016, St. Petersburg, FL, USA, January 20 - 22, 2016, pages 49–60. ACM, 2016. Google ScholarDigital Library
- E. Visser. Scannerless generalized-LR parsing. Technical Report P9707, Programming Research Group, University of Amsterdam, July 1997.Google Scholar
- E. Visser. Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam, September 1997.Google Scholar
- E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in Stratego/XT 0.9. In C. Lengauer, D. S. Batory, C. Consel, and M. Odersky, editors, Domain-Specific Program Generation, International Seminar, Dagstuhl Castle, Germany, March 23-28, 2003, Revised Papers, volume 3016 of Lecture Notes in Computer Science, pages 216–238. Springer, 2003.Google Scholar
- T. Vollebregt, L. C. L. Kats, and E. Visser. Declarative specification of template-based textual editors. In A. Sloane and S. Andova, editors, International Workshop on Language Descriptions, Tools, and Applications, LDTA ’12, Tallinn, Estonia, March 31 - April 1, 2012, page 8. ACM, 2012. Google ScholarDigital Library
- M. Völter. Language and IDE modularization and composition with MPS. In R. Lämmel, J. Saraiva, and J. Visser, editors, Generative and Transformational Techniques in Software Engineering IV, International Summer School, GTTSE 2011, Braga, Portugal, July 3-9, 2011. Revised Papers, volume 7680 of Lecture Notes in Computer Science, pages 383–430. Springer, 2011.Google Scholar
- M. Völter, D. Ratiu, B. Kolb, and B. Schaetz. mbeddr: Instantiating a language workbench in the embedded software domain. Journal of Automated Software Engineering, 2013.Google ScholarCross Ref
- M. Völter, J. Siegmund, T. Berger, and B. Kolb. Towards userfriendly projectional editors. In B. Combemale, D. J. Pearce, O. Barais, and J. J. Vinju, editors, Software Language Engineering - 7th International Conference, SLE 2014, Västeras, Sweden, September 15-16, 2014. Proceedings, volume 8706 of Lecture Notes in Computer Science, pages 41–61. Springer, 2014.Google Scholar
Index Terms
- Principled syntactic code completion using placeholders
Recommendations
Language-parametric static semantic code completion
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 ...
The hidden cost of code completion: understanding the impact of the recommendation-list length on its efficiency
MSR '18: Proceedings of the 15th International Conference on Mining Software RepositoriesAutomatic code completion is a useful and popular technique that software developers use to write code more effectively and efficiently. However, while the benefits of code completion are clear, its cost is yet not well understood. We hypothesize the ...
Next Syntactic-Unit Code Completion and Applications
ASE '22: Proceedings of the 37th IEEE/ACM International Conference on Automated Software EngineeringCode completion is an important feature in an IDE to improve developers’ productivity. Existing code completion approaches focus on completing the current code token, next token or statement, or code pattern. We propose AstCC, a code completion ...
Comments