Text vs. structured editors

Most developers currently use text-based editors to edit source code. These editors are highly specialized and integrated into an IDE to provide a comfortable editing experience. An IDE typically provides many helpful features such as background compiling, code completion, snippets, navigation, refactoring, debugging etc.

But at the ground level, to edit the program the developer still deals with characters and lines of text. The hierarchical structure of a program is represented with the help of specialized markup tokens and indentation to delimit language constructs. For example, C-family languages use the curly braces { and }, XML uses tag pairs <X> and </X> and VB.NET uses Keyword – End Keyword pairs.

Internally a program is represented by a hierarchical structure called a parse tree or an AST. It is being recovered from the source text using a scanner and a parser. The AST can be visually displayed using embedded blocks. A structured editor (also structure editor) allows the user to interact with the syntax tree directly by interacting with these blocks. Language constructs are the new editor “atoms”, in contrast to characters and lines of text. Thus a round-tripping from text to AST and back is unnecessary.

Note on terminology: some empiric web-research has revealed that the term „structure editor“ is more used in the context of chemistry and biology to denote editors for molecular and cell structures. On the contrary, the term „structured editor“ is more often used in the context of editing documents (for example, in [Amaya] ) and that is why it is preferredly used in this thesis.

We’ll use the term plain text editors, traditional editors or simply text editors to denote the currently widespread approach of editing program as text.

Such a tree-based representation can provide many advantages. The advantages are two-fold: advantages for the user of the editor (more editing comfort and improved usability through language-awareness), as well as advantages for the developers of the IDE (more consistent, robust and extensible architecture through model-view-controller approach).

Wesner Moise envisions in [WesnerM1] 2004 the development of a structured alternative to plain text editors:

“Text editors are going to go away (for source code, that is)! Don't get me wrong, source code will still be in text files. However, future code editors will parse the code directly from the text file and will be displayed in a concise, graphical and nicely presented view with each element in the view representing a parse tree node.”

However, this thesis supports a vision where structured editors won’t fully replace text editors, but rather complement text editors as yet another view on the same internal code model, to supplement richer and more intelligent editing experience where possible. It is important to note that the language underneath remains the same: it’s all about a new representation of same old language constructs.

Next: 1.2. Integration of an editor with the IDE

Contents