In programming, better tools often yield better results. For that, modern programming environments offer mechanisms to allow for their extensibility. The closer those tools are to the code, the easier it is for programmers to map the information provided by a tool to the code this information is about. However, existing extension mechanisms do not facilitate the close integration of tools with textual source code. Tools must be able to track program structures across edits to appear at the right positions but the parsing step of text complicates tracking structures. We propose hybrid structured editing, an approach that supports tool builders by providing structural guarantees while providing tool users with a familiar and consistent text editing interface. Hybrid structured editing allows tool builders to declare constraints on the structure that a program must conform to and ensures their observance. We present an implementation and several case studies of tools based on hybrid structured editing to demonstrate its effectiveness. Hybrid structured editing supports the safe extension of programming environments with tools that work on a structured representation of code and provide a consistent and reliable user experience.
翻译:在编程中,更好的工具往往能带来更好的成果。为此,现代编程环境提供了允许其扩展的机制。工具与代码的距离越近,程序员就越容易将工具提供的信息映射到该信息所对应的代码上。然而,现有的扩展机制并未促进工具与文本源代码的紧密集成。工具必须能够追踪程序结构在编辑过程中的变化,以出现在正确的位置,但文本的解析步骤使得结构追踪变得复杂。我们提出混合结构化编辑,这是一种为工具构建者提供结构保证,同时为工具用户提供熟悉且一致的文本编辑界面的方法。混合结构化编辑允许工具构建者声明程序必须遵守的结构约束,并确保这些约束得到遵守。我们展示了一个实现以及基于混合结构化编辑的多个工具案例研究,以证明其有效性。混合结构化编辑支持以安全的方式扩展编程环境,使工具能够基于代码的结构化表示工作,并提供一致且可靠的用户体验。