论文标题

森林:多个光标的结构代码编辑

Forest: Structural Code Editing with Multiple Cursors

论文作者

Voinov, Philippe, Rigger, Manuel, Su, Zhendong

论文摘要

软件开发人员经常重构代码。通常,单个逻辑重构变化涉及更改源基础中的多个相关组件,例如重命名每个发生变量或函数的情况。尽管许多代码编辑器可以执行这种常见和通用的重构,但它们不支持更复杂的重构或特定于给定代码库的重构。对于那些灵活的 - 尽管互动较少 - 替代方案,开发人员可以编写可以通过操纵程序的树表示来实现任意复杂逻辑的重构脚本。在这项工作中,我们介绍了森林,这是一个结构性代码编辑器,旨在弥合代码编辑器的互动性与重构脚本的表现力之间的差距。虽然结构编辑者占据了一般代码编辑者的利基市场,但这项工作的关键见解是,他们启用了一种新型的结构性多曲设计,使森林能够达到与重构脚本相似的表现力。森林允许在多个程序位置同时执行单个动作,从而支持复杂的重构。为了支持互动性,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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源