This application is related to commonly owned U.S. patent application Ser. No. 10/185,752, entitled “TOKEN-ORIENTED REPRESENTATION OF PROGRAM CODE WITH SUPPORT FOR TEXTUAL EDITING THEREOF,” naming Van De Vanter and Urquhart as inventors and filed on even date herewith, Ser. No. 10/185,753, entitled “EFFICIENT COMPUTATION OF CHARACTER OFFSETS FOR TOKEN-ORIENTED REPRESENTATION OF PROGRAM CODE,” naming Van De Vanter and Urquhart as inventors and filed on even date herewith and Ser. No. 10/185,754, entitled “UNDO/REDO TECHNIQUE WITH INSERTION POINT STATE HANDLING FOR TOKEN-ORIENTED REPRESENTATION OF PROGRAM CODE,” naming Van De Vanter and Urquhart as inventors and filed on even date herewith.
1. Field of the Invention
The present invention relates generally to interactive software engineering tools including editors for source code such as a programming or mark-up language, and more particularly to facilities for supporting undo and/or redo operations on a token-oriented representation.
2. Description of the Related Art
In an editor for computer programs, it may be desirable to represent program code using a token-oriented representation, rather than as simply a linear sequence of characters. In such a representation, the linear sequence of characters that corresponds to program code may be divided into substrings corresponding to the lexical tokens of the particular language. In some implementations, this representation of a stream of tokens can updated incrementally after each user action (for example, after each keystroke) using techniques such as those described in U.S. Pat. No. 5,737,608 to Van De Vanter, entitled “PER KEYSTROKE INCREMENTAL LEXING USING A CONVENTIONAL BATCH LEXER.” In general, such updates may require the insertion and/or deletion of tokens in or from the token stream.
A commonly supported and highly desirable function of conventional text editors is “Undo-Redo.” This function permits a user to reverse the effects of the most recently performed editing operation (i.e., to Undo it), and then optionally to reverse the undo in order to get back to the original state (i.e., Redo the Undo). It is generally desirable for such Undo-Redo functionality to permit a compound or multi-step Undo operation, thereby permitting the user to unwind as many of the most recently performed editing operations as desired. A compound Redo correspondingly reverses a sequence of Undo operations.
While undo-redo facilities are common in conventional text editors that employ a conventional text buffer, provision of an undo-redo facility in a software engineering tool environment that employs a token-oriented representation of program code presents unique design challenges. In general, it would desirable if undo-redo operation support could be provided for an underlying token-oriented representation in a way that ensures that such operations take no more time than other basic editing operations. In particular, it is desirable for computational requirements associated with undo-redo operations to scale such that an operation takes no more than O(N) time, where N corresponds to the size of the operation (i.e., content inserted or deleted) and where the computational requirements are generally insensitive to the size of the program being edited.
Accordingly, it has been discovered that an editor or software engineering tool may be configured to represent program code as a doubly-linked list of lexical tokens and to maintain, coincident with an operation that modifies contents of the list, an undo object that identifies opposing end nodes of a sublist of one or more lexical tokens corresponding to a substring that is either inserted into or removed from the list by the operation. In this way, lexical tokens corresponding to an inserted substring can be readily and efficiently excised to restore a pre-insertion tokenized list state. Similarly, lexical tokens corresponding to a removed substring can be readily and efficiently reinstated to restore a pre-deletion tokenized list state. Advantageously, undo support once employed to restore a prior tokenized list state is symmetrically available to support redo operations. In some embodiments in accordance with the present invention, undo-redo entries are maintained in an operation ordered set that is traversed to support one or more operations in either the undo or redo directions. In some realizations, such an ordered set of undo-redo entries is maintained by, or in conjunction with, an undo-redo manager.
By identifying at least opposing end nodes of respective sublists of one or more lexical tokens that correspond to substrings inserted into and removed from the tokenized program representation, even lengthy, complex undo (or redo) sequences can be supported with a computational overhead that scales with the number of undone (or redone) operations rather than buffer size or even size of the edits performed. As a result, a software engineering tool that employs techniques in accordance with the present invention provides extremely efficient undo-redo support even in software engineering environments that handle large bodies of program code or that provide language-oriented features such as advanced program typography or editor behavior specialized based on lexical context.
The present invention may be better understood, and its numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings.
The use of the same reference symbols in different drawings indicates similar or identical items.
Exploitations of the techniques of the present invention are many. In particular, a variety of software engineering tools are envisioned, which employ aspects of the present invention to facilitate undo-redo in a token-oriented representation of program code. One exemplary software engineering tool is a source code editor that provides specialized behavior or typography based on lexical context using a tokenized program representation. Such a source code editor provides a useful descriptive context in which to present various aspects of the present invention. Nonetheless, the invention is not limited thereto. Indeed, applications to editors, analyzers, builders, compilers, debuggers and other such software engineering tools are envisioned. In this regard, some exploitations of the present invention may provide language-oriented behaviors within suites of tools or within tools that provide functions in addition to manipulation of program code.
In addition, while traditional procedural or object-oriented programming languages provide a useful descriptive context, exploitations of the present invention are not limited thereto. Indeed, other software engineering tool environments such as those adapted for editing, analysis, manipulation, transformation, compilation, debugging or other operations on functionally descriptive information or code, such as other forms of source code, machine code, bytecode sequences, scripts, macro language directives or information encoded using markup languages such as HTML or XML, may also employ structures, methods and techniques in accordance with the present invention. Furthermore, the structures, methods and techniques of the present invention may be exploited in the manipulation or editing of other information, such as software documentation or even prose. Based on the description herein, persons of ordinary skill in the art will appreciate applications to a wide variety of tools and language contexts.
Accordingly, in view of the above and without limitation, an exemplary exploitation of the present invention is now described.
Tokenized Program Representation with Undo-Redo Support
In the illustration of
As illustrated in
An undo-redo manager 130 maintains an ordered set 131 of undo-redo objects or structures that facilitate manipulations of tokenized program representation 110 to achieve the semantics of undo and redo operations. In general, undo-redo manager 130 is responsive to undo-redo directives 142 supplied by software engineering tool 120. Typically, undo-redo directives are themselves responsive to user manipulations, although other sources (such as from automated tools) are also possible. In the illustration of
Moving on to
Turning to
Results of a redo are illustrated in
Based on the description above, persons of ordinary skill in the art will appreciate a variety suitable functional implementations to support the above-described token insertion, undo of token insertion, and redo of token insertion. The exemplary code that follows illustrates one such suitable functional implementation.
The preceding code is object-oriented and is generally suitable for use in an implementation framework such as that presented by the previously described Swing graphical user interface (GUI) component toolkit, part of the Java Foundation Classes (JFC) integrated into Java 2 platform, Standard Edition (J2SE). However, other implementations, including procedural implementation and implementations adapted to design constraints of other environments, are also suitable.
Turning to
As before, undo-redo object 311 maintains its identification of leading and trailing nodes of tokenized program fragment 314 to support an efficient redo. Reinstatement of the removal is effectuated by updating bi-directional pointers of the tokenized program representation (see state 310D) to bridge the excised fragment 314. As before, undo-redo structure 311 identifies (through respective pointers) opposing end nodes of the excised fragment 314 and excised fragment 314 maintains its single direction pointers into respective excision point nodes to facilitate efficient undo.
The exemplary code that follows illustrates one suitable functional implementation of the above-described token removal, undo of token removal, and redo of token removal.
While the previously described insertion and removal operations have been illustrated primarily in the context of a single operation and its associated undo and redo methods, based on the description herein, persons of ordinary skill in the art will recognize that in a typical editing session, or for that matter, in the course of operation another programming tool, multiple insertions and removals of program fragments will occur. Indeed, large number of such insertions and removals will occur and, in general, can be represented as an ordered set of such operations. In some cases, one operation (e.g., a removal) will operate on results of the previous operation (e.g., an insertion). Accordingly, in the general case, it is desirable to represent an ordered set 410 of undo-redo objects (e.g., objects 411A, 411B, etc.) to facilitate the undoing and/or redoing of arbitrary sequences of operations.
In general, semantics of undo and redo operations are well understood in the art. Of course, a given implementation may seek to limit the amount of storage allocated to undo and redo support and, accordingly, may restrict the growth of the ordered set to a predetermined size. Nonetheless, the techniques described herein may be employed more generally in an unbounded ordered set of undo-redo objects and any particular limitation on sizing of such a structure may be selected based on constraints of a particular implementation or design.
Turning to
Referring now to
In the preceding exemplary code, the oldFirst field or attribute corresponds to additional field 511A.
Exemplary Editor Implementation
In general, techniques of the present invention may be implemented using a variety of editor implementations. Nonetheless, for purposes of illustration, the description of exemplary editor implementations in U.S. Pat. No. 5,737,608, entitled “PER-KEYSTROKE INCREMENTAL LEXING USING A CONVENTIONAL BATCH LEXER” is incorporated herein by reference. In particular, while the preceding code implements token operations, persons of ordinary skill in the art will recognize that editor and/or programming tools implementations may often include operations that operate at a level of abstraction that corresponds to character manipulations. Such character-oriented manipulations typically affect the state of an underlying token-oriented representation and such state changes can be effectuated using token operations such as the insertion, removal and replacement operations described herein. To generate sequences of token-oriented operations that correspond to character manipulations, incremental lexing techniques described in the '608 patent may be employed in some realizations.
While the invention has been described with reference to various embodiments, it will be understood that these embodiments are illustrative and that the scope of the invention is not limited to them. Many variations, modifications, additions, and improvements are possible. In particular, a wide variety of lexical contexts may be supported. For example, while a lexical context typical of program code has been illustrated, other lexical contexts such as those appropriate to markup languages, comments, even multimedia content may be supported. Similarly, although much of the description has focused on functionality of an editor, the techniques described herein may apply equally to other interactive or even batch oriented tools. While lexical analysis of textual content has been presumed in many illustrations, persons of ordinary skill in the art will recognize that the techniques described herein also apply to structure-oriented editors and to implementations that provide syntactic, as well as lexical, analysis of content.
More generally, plural instances may be provided for components described herein as a single instance. Boundaries between various components, operations and data stores are somewhat arbitrary, and particular operations are illustrated in the context of specific illustrative configurations. Other allocations of functionality are envisioned. Structures and functionality presented as discrete in the exemplary configurations may be implemented as a combined structure or component. These and other variations, modifications, additions, and improvements may fall within the scope of the invention as defined in the claims that follow.
| Number | Name | Date | Kind |
|---|---|---|---|
| 3893084 | Kotok et al. | Jul 1975 | A |
| 4558413 | Schmidt et al. | Dec 1985 | A |
| 4809170 | Leblang et al. | Feb 1989 | A |
| 4809710 | Williamson | Mar 1989 | A |
| 4931928 | Greenfeld | Jun 1990 | A |
| 4989145 | Kyushima | Jan 1991 | A |
| 5006992 | Skeirik | Apr 1991 | A |
| 5070478 | Abbott | Dec 1991 | A |
| 5079700 | Kozoll et al. | Jan 1992 | A |
| 5140521 | Kozol et al. | Aug 1992 | A |
| 5155847 | Kirouac et al. | Oct 1992 | A |
| 5224038 | Bespalko | Jun 1993 | A |
| 5239298 | Wei | Aug 1993 | A |
| 5263174 | Layman | Nov 1993 | A |
| 5287501 | Lomet | Feb 1994 | A |
| 5293629 | Conley et al. | Mar 1994 | A |
| 5311422 | Loftin et al. | May 1994 | A |
| 5313387 | McKeeman et al. | May 1994 | A |
| 5377318 | Wolber | Dec 1994 | A |
| 5386559 | Eisenberg et al. | Jan 1995 | A |
| 5386570 | Lindhorst | Jan 1995 | A |
| 5410701 | Gopalraman | Apr 1995 | A |
| 5430836 | Wolf et al. | Jul 1995 | A |
| 5446895 | White et al. | Aug 1995 | A |
| 5481711 | Sotani | Jan 1996 | A |
| 5481712 | Silver et al. | Jan 1996 | A |
| 5485618 | Smith | Jan 1996 | A |
| 5487000 | Takahashi et al. | Jan 1996 | A |
| 5487147 | Brisson | Jan 1996 | A |
| 5490097 | Swenson et al. | Feb 1996 | A |
| 5493678 | Arcuri et al. | Feb 1996 | A |
| 5502805 | Anderson et al. | Mar 1996 | A |
| 5504902 | McGrath et al. | Apr 1996 | A |
| 5513305 | Maghbouleh | Apr 1996 | A |
| 5537630 | Berry et al. | Jul 1996 | A |
| 5557730 | Frid-Nielsen | Sep 1996 | A |
| 5574898 | Leblang et al. | Nov 1996 | A |
| 5577241 | Spencer | Nov 1996 | A |
| 5579469 | Pike | Nov 1996 | A |
| 5583762 | Shafer | Dec 1996 | A |
| 5604853 | Nagashima | Feb 1997 | A |
| 5625773 | Bespalko et al. | Apr 1997 | A |
| 5627958 | Potts et al. | May 1997 | A |
| 5628016 | Kukol | May 1997 | A |
| 5644737 | Tuniman et al. | Jul 1997 | A |
| 5649192 | Stucky | Jul 1997 | A |
| 5649200 | Leblang et al. | Jul 1997 | A |
| 5649222 | Mogilevsky | Jul 1997 | A |
| 5652899 | Mays et al. | Jul 1997 | A |
| 5671403 | Shekita et al. | Sep 1997 | A |
| 5673390 | Mueller | Sep 1997 | A |
| 5680619 | Gudmundson et al. | Oct 1997 | A |
| 5680630 | Saint-Laurent | Oct 1997 | A |
| 5694559 | Hobson et al. | Dec 1997 | A |
| 5724593 | Hargrave, III et al. | Mar 1998 | A |
| 5734749 | Yamada et al. | Mar 1998 | A |
| 5737608 | Van De Vanter | Apr 1998 | A |
| 5740444 | Frid-Nielsen | Apr 1998 | A |
| 5748975 | Van De Vanter | May 1998 | A |
| 5752058 | Van De Vanter | May 1998 | A |
| 5754737 | Gipson | May 1998 | A |
| 5778402 | Gipson | Jul 1998 | A |
| 5781720 | Parker et al. | Jul 1998 | A |
| 5781732 | Adams | Jul 1998 | A |
| 5790778 | Bush et al. | Aug 1998 | A |
| 5798757 | Smith | Aug 1998 | A |
| 5802262 | Van De Vanter | Sep 1998 | A |
| 5805889 | Van De Vanter | Sep 1998 | A |
| 5813019 | Van De Vanter | Sep 1998 | A |
| 5825355 | Palmer et al. | Oct 1998 | A |
| 5832494 | Egger et al. | Nov 1998 | A |
| 5844554 | Geller et al. | Dec 1998 | A |
| 5845120 | Reddy et al. | Dec 1998 | A |
| 5845300 | Comer et al. | Dec 1998 | A |
| 5848394 | D'Arrigo et al. | Dec 1998 | A |
| 5850561 | Church et al. | Dec 1998 | A |
| 5857212 | Van De Vanter | Jan 1999 | A |
| 5859638 | Coleman et al. | Jan 1999 | A |
| 5870608 | Gregory | Feb 1999 | A |
| 5872974 | Mezick | Feb 1999 | A |
| 5877758 | Seybold | Mar 1999 | A |
| 5890103 | Carus | Mar 1999 | A |
| 5905892 | Nielsen et al. | May 1999 | A |
| 5911059 | Profit, Jr. | Jun 1999 | A |
| 5911075 | Glaser et al. | Jun 1999 | A |
| 5924089 | Mocek et al. | Jul 1999 | A |
| 5959629 | Masui | Sep 1999 | A |
| 5960196 | Carrier, III et al. | Sep 1999 | A |
| 5990906 | Hudson et al. | Nov 1999 | A |
| 5991799 | Yen et al. | Nov 1999 | A |
| 6002874 | Bahrs et al. | Dec 1999 | A |
| 6012075 | Fein et al. | Jan 2000 | A |
| 6014135 | Fernandes | Jan 2000 | A |
| 6016467 | Newsted et al. | Jan 2000 | A |
| 6018524 | Turner et al. | Jan 2000 | A |
| 6023715 | Burkes et al. | Feb 2000 | A |
| 6026233 | Shulman et al. | Feb 2000 | A |
| 6053951 | McDonald et al. | Apr 2000 | A |
| 6061513 | Scandura | May 2000 | A |
| 6071317 | Nagel | Jun 2000 | A |
| 6115544 | Mueller | Sep 2000 | A |
| 6119120 | Miller | Sep 2000 | A |
| 6154847 | Schofield et al. | Nov 2000 | A |
| 6163879 | Mackey | Dec 2000 | A |
| 6185591 | Baker et al. | Feb 2001 | B1 |
| 6205579 | Southgate | Mar 2001 | B1 |
| 6212534 | Lo et al. | Apr 2001 | B1 |
| 6226785 | Peterson et al. | May 2001 | B1 |
| 6247020 | Minard | Jun 2001 | B1 |
| 6266665 | Vaidyanathan et al. | Jul 2001 | B1 |
| 6275976 | Scandura | Aug 2001 | B1 |
| 6282551 | Anderson et al. | Aug 2001 | B1 |
| 6286138 | Purcell | Sep 2001 | B1 |
| 6305008 | Vaidyanathan et al. | Oct 2001 | B1 |
| 6311323 | Shulman et al. | Oct 2001 | B1 |
| 6349327 | Tang et al. | Feb 2002 | B1 |
| 6425016 | Banavar et al. | Jul 2002 | B1 |
| 6426761 | Kanevsky et al. | Jul 2002 | B1 |
| 6470306 | Pringle et al. | Oct 2002 | B1 |
| 6470349 | Heninger et al. | Oct 2002 | B1 |
| 6507845 | Cohen et al. | Jan 2003 | B1 |
| 6519763 | Kaufer et al. | Feb 2003 | B1 |
| 6604109 | Federighi et al. | Aug 2003 | B1 |
| 6643661 | Polizzi et al. | Nov 2003 | B2 |
| 6658624 | Savitzky et al. | Dec 2003 | B1 |
| 6658643 | Bera | Dec 2003 | B1 |
| 6678882 | Hurley et al. | Jan 2004 | B1 |
| 6760695 | Kuno et al. | Jul 2004 | B1 |
| 6792595 | Storistenau et al. | Sep 2004 | B1 |
| 6795826 | Flinn et al. | Sep 2004 | B2 |
| 6801026 | Schrom et al. | Oct 2004 | B2 |
| 6901448 | Zhu et al. | May 2005 | B2 |
| 6993723 | Danielsen et al. | Jan 2006 | B1 |
| 7127704 | Van De Vanter et al. | Oct 2006 | B2 |
| 7159207 | Tang et al. | Jan 2007 | B2 |
| 20010052190 | Duncan | Dec 2001 | A1 |
| 20010052910 | Parekh et al. | Dec 2001 | A1 |
| 20020100016 | Van De Vanter et al. | Jul 2002 | A1 |
| 20020106991 | Foore et al. | Aug 2002 | A1 |
| 20020107866 | Cousins et al. | Aug 2002 | A1 |
| 20030061046 | Zhao et al. | Mar 2003 | A1 |
| 20030066058 | Van De Vanter et al. | Apr 2003 | A1 |
| 20030208427 | Peters et al. | Nov 2003 | A1 |
| 20030229648 | Tang et al. | Dec 2003 | A1 |
| 20040003373 | Van De Vanter et al. | Jan 2004 | A1 |
| 20040003374 | Van De Vanter et al. | Jan 2004 | A1 |
| 20040006763 | Van De Vanter et al. | Jan 2004 | A1 |
| 20040030741 | Wolton et al. | Feb 2004 | A1 |
| 20040054644 | Ganesh et al. | Mar 2004 | A1 |
| 20040225997 | Van Der Vanter et al. | Nov 2004 | A1 |
| 20040225998 | Van Der Vanter et al. | Nov 2004 | A1 |
| 20050022132 | Herzberg et al. | Jan 2005 | A1 |
| Number | Date | Country | |
|---|---|---|---|
| 20040006764 A1 | Jan 2004 | US |