A Partition Strategy for Programming Language Editors
Original Publication Date: 2004-Jan-21
Included in the Prior Art Database: 2004-Jan-21
Text-based source code editors are often equipped with user-friendly features like syntax-highlighting, content assist, and document outline. For performance reasons, it is not appropriate to update the presentation of entire document on every change. A technique used to perform updates in a performance-sensitive way is referred to as document partitioning. The objectives of partitioning is to determine the range of text to be updated when user edits the document. An example of a product using this technique is WebSphere Studio Application Developer. The partitions are required to be consecutive and non-overlapping. Source code of a program is parsed and a syntax tree is constructed. Language constructs, such as user-defined routines and modules, which can be nested, are represented with syntax nodes in the tree. The first task towards non-overlapping partitions is to divide any nested language construct, and corresponding syntax nodes, into a wrapping header, the nested constructs and a wrapping trailer. Two special partition types are ?error? and ?interim?, each has its unique role in the partition strategy. Besides them, a SQL-based document has partition types of document header, module header and module trailer, routine header and routine trailer, and statement. The parser is defined in such a way that each of the above content types, except ?error? and ?interim? types, are guaranteed to be parsed into a meaningful syntax node. Document updater updates only the partitions affected by an edit. One partition is parsed for content assist purposes. A delayed re-partition of entire document happens where there is a pause of activity in the editor, at which time the outline view is updated.