skip to main content
10.1145/3563835.3567663acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Forest: Structural Code Editing with Multiple Cursors

Published: 01 December 2022 Publication History

Abstract

Software developers frequently refactor code. Often, a single logical refactoring change involves changing multiple related components in a source base such as renaming each occurrence of a variable or function. While many code editors can perform such common and generic refactorings, they do not support more complex refactorings or those that are specific to a given code base. For those, as a flexible---albeit less interactive---alternative, developers can write refactoring scripts that can implement arbitrarily complex logic by manipulating the program's tree representation. In this work, we present Forest, a structural code editor that aims to bridge the gap between the interactiveness of code editors and the expressiveness of refactoring scripts. While structural editors have occupied a niche as general code editors, the key insight of this work is that they enable a novel structural multi-cursor design that allows Forest to reach a similar expressiveness as refactoring scripts; Forest allows to perform a single action simultaneously in multiple program locations and thus support complex refactorings. To support interactivity, Forest provides features typical for text code editors such as writing and displaying the program through its textual representation. Our evaluation demonstrates that Forest allows performing edits similar to those from refactoring scripts, while still being interactive. We attempted to perform edits from 48 real-world refactoring scripts using Forest and found that 11 were possible, while another 17 would be possible with added features. We believe that a multi-cursor setting plays to the strengths of structural editing, since it benefits from reliable and expressive commands. Our results suggest that multi-cursor structural editors could be practical for performing small-scale specialized refactorings.

References

[1]
[n.d.]. Envision: A fast and flexible visual code editor with fluid interactions (Overview). Melbourne, Australia.
[2]
[n.d.]. MPS: The Domain-Specific Language Creator by JetBrains. https://www.jetbrains.com/mps/
[3]
2021. jscodeshift. https://github.com/facebook/jscodeshift original-date: 2015-03-07T00:32:16Z.
[4]
2021. reactjs/react-codemod. https://github.com/reactjs/react-codemod original-date: 2015-10-19T20:47:22Z.
[5]
Thorsten Berger, Markus Völter, Hans Peter Jensen, Taweesap Dangprasert, and Janet Siegmund. 2016. Efficiency of projectional editing: a controlled experiment. In Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2016). Association for Computing Machinery, New York, NY, USA. 763–774. isbn:978-1-4503-4218-6 https://doi.org/10.1145/2950290.2950315
[6]
Rajasegar Chandran. 2021. Awesome Codemods. https://github.com/rajasegar/awesome-codemods original-date: 2019-12-11T00:38:56Z.
[7]
Yair Chuchem and Eyal Lotem. [n.d.]. Lamdu. https://www.lamdu.org/
[8]
James R. Cordy. 2006. The TXL source transformation language. Science of Computer Programming, 61, 3 (2006), Aug., 190–210. issn:01676423 https://doi.org/10.1016/j.scico.2006.04.002
[9]
Maxime Coste. [n.d.]. Kakoune - Official site. https://kakoune.org/
[10]
Véronique Donzeau-Gouge, Gérard Huet, Bernard Lang, and Gilles Kahn. 1980. Programming environments based on structured editors: the Mentor experience. INRIA.
[11]
Robert J. Ellison and Barbara J. Staudt. 1985. The evolution of the GANDALF system. Journal of Systems and Software, 5, 2 (1985), May, 107–119. issn:0164-1212 https://doi.org/10.1016/0164-1212(85)90012-3
[12]
C. N. Fischer, Gregory F. Johnson, Jon Mauney, Anil Pal, and Daniel L. Stock. 1984. The Poe language-based editor project. In Proceedings of the first ACM SIGSOFT/SIGPLAN software engineering symposium on Practical software development environments (SDE 1). Association for Computing Machinery, New York, NY, USA. 21–29. isbn:978-0-89791-131-3 https://doi.org/10.1145/800020.808245
[13]
E. Gansner, J. R. Horgan, D. J. Moore, P. Surko, D. Swartwout, and J. Reppy. 1983. Syned – A Language-Based Editor for an Interactive Programming Environment.
[14]
Kiran Gopinathan. 2021. GopCaml: A Structural Editor for OCaml. https://icfp21.sigplan.org/details/ocaml-2021-papers/11/GopCaml-A-Structural-Editor-for-OCaml
[15]
Wilfred J. Hansen. 1971. User engineering principles for interactive systems. In Proceedings of the May 16-18, 1972, spring joint computer conference on - AFIPS ’72 (Spring). ACM Press, Atlantic City, New Jersey. 523. https://doi.org/10.1145/1479064.1479159
[16]
Miryung Kim and Na Meng. 2014. Recommending Program Transformations. In Recommendation Systems in Software Engineering, Martin P. Robillard, Walid Maalej, Robert J. Walker, and Thomas Zimmermann (Eds.). Springer, Berlin, Heidelberg. 421–453. isbn:978-3-642-45135-5 https://doi.org/10.1007/978-3-642-45135-5_16
[17]
L. Meertens, S. Pemberton, and G. Rossum. 1992. The ABC structure editor – Structure-based editing for the ABC programming environment.
[18]
B Melese, V Migot, and D Verove. 1985. The Mentor-V5 documentation. INRIA.
[19]
Na Meng, Miryung Kim, and Kathryn S. McKinley. 2011. Systematic editing: generating program transformations from an example. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’11). Association for Computing Machinery, New York, NY, USA. 329–342. isbn:978-1-4503-0663-8 https://doi.org/10.1145/1993498.1993537
[20]
Martin Mikelsons. 1983. Interactive program execution in Lispedit. In Proceedings of the symposium on High-level debugging (SIGSOFT ’83). Association for Computing Machinery, New York, NY, USA. 71–80. isbn:978-0-89791-111-5 https://doi.org/10.1145/1006147.1006164
[21]
Robert C. Miller and B. Myers. 2001. Interactive Simultaneous Editing of Multiple Text Regions. In USENIX Annual Technical Conference, General Track.
[22]
Christoph Nakazawa. 2022. cpojer/js-codemod. https://github.com/cpojer/js-codemod original-date: 2015-03-23T04:45:13Z.
[23]
Wode Ni, Joshua Sunshine, Vu Le, Sumit Gulwani, and Titus Barik. 2021. reCode : A Lightweight Find-and-Replace Interaction in the IDE for Transforming Code by Example. In The 34th Annual ACM Symposium on User Interface Software and Technology. ACM, Virtual Event USA. 258–269. isbn:978-1-4503-8635-7 https://doi.org/10.1145/3472749.3474748
[24]
Cyrus Omar, Ian Voysey, Ravi Chugh, and Matthew A. Hammer. 2019. Live functional programming with typed holes. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 14:1–14:32. https://doi.org/10.1145/3290327
[25]
Rob Pike. 1987. Structural Regular Expressions. AT&T Bell Laboratories.
[26]
Yevgen Safronov. 2021. awesome jscodeshift. https://github.com/sejoker/awesome-jscodeshift original-date: 2016-03-05T21:07:18Z.
[27]
Magnar Sveen. 2021. multiple-cursors.el. https://github.com/magnars/multiple-cursors.el original-date: 2012-01-24T08:45:50Z.
[28]
Tim Teitelbaum and Thomas Reps. 1981. The Cornell program synthesizer: a syntax-directed programming environment. Commun. ACM, 24, 9 (1981), Sept., 563–573. issn:0001-0782, 1557-7317 https://doi.org/10.1145/358746.358755

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
Onward! 2022: Proceedings of the 2022 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software
November 2022
269 pages
ISBN:9781450399098
DOI:10.1145/3563835
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 December 2022

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Structural editing
  2. multi-cursor
  3. refactoring

Qualifiers

  • Research-article

Conference

Onward! '22
Sponsor:

Acceptance Rates

Overall Acceptance Rate 40 of 105 submissions, 38%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)21
  • Downloads (Last 6 weeks)2
Reflects downloads up to 04 Feb 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media