arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2210.11124cs.SE
收藏

Forest:使用多个光标编辑结构代码

Forest: Structural Code Editing with Multiple Cursors

Philippe Voinov, Manuel Rigger, Zhendong Su

摘要:

软件开发人员经常重构代码。通常,单个逻辑重构更改涉及更改源代码库中的多个相关组件,例如重命名变量或函数的每次出现。虽然许多代码编辑器可以执行这种常见和通用的重构,但它们不支持更复杂的重构或特定于给定代码库的重构。对于这些,作为一种灵活的(尽管交互性较低)替代方案,开发人员可以编写重构脚本,通过操纵程序的树表示来实现任意复杂的逻辑。在这项工作中,我们提出了森林,结构化的代码编辑器,旨在弥合代码编辑器的交互性和重构脚本的表现力之间的差距。虽然结构化编辑器作为通用代码编辑器占据了一席之地,但这项工作的关键见解是,它们实现了一种新颖的结构化多光标设计,使Forest能够达到与重构脚本类似的表现力; Forest允许在多个程序位置同时执行单个操作,从而支持复杂的重构。为了支持交互性,Forest提供了文本代码编辑器的典型功能,例如通过其文本表示编写和显示程序。我们的评估表明,森林允许执行类似于那些从重构脚本的编辑,同时仍然是交互式的。我们尝试使用Forest对48个真实的重构脚本进行编辑,发现其中11个是可行的,而另外17个添加了新功能也是可行的。我们相信,多光标设置发挥了结构化编辑的优势,因为它受益于可靠和富有表现力的命令。我们的研究结果表明,多光标结构化编辑器可以用于执行小规模的专门重构。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑