Mercurial > projects > dwt2
comparison org.eclipse.text/src/org/eclipse/text/edits/UndoEdit.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | 5feec68b4556 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.text.edits.UndoEdit; | |
14 | |
15 import org.eclipse.text.edits.MultiTextEdit; // packageimport | |
16 import org.eclipse.text.edits.CopySourceEdit; // packageimport | |
17 import org.eclipse.text.edits.MoveSourceEdit; // packageimport | |
18 import org.eclipse.text.edits.CopyingRangeMarker; // packageimport | |
19 import org.eclipse.text.edits.ReplaceEdit; // packageimport | |
20 import org.eclipse.text.edits.EditDocument; // packageimport | |
21 import org.eclipse.text.edits.UndoCollector; // packageimport | |
22 import org.eclipse.text.edits.DeleteEdit; // packageimport | |
23 import org.eclipse.text.edits.MoveTargetEdit; // packageimport | |
24 import org.eclipse.text.edits.CopyTargetEdit; // packageimport | |
25 import org.eclipse.text.edits.TextEditCopier; // packageimport | |
26 import org.eclipse.text.edits.ISourceModifier; // packageimport | |
27 import org.eclipse.text.edits.TextEditMessages; // packageimport | |
28 import org.eclipse.text.edits.TextEditProcessor; // packageimport | |
29 import org.eclipse.text.edits.MalformedTreeException; // packageimport | |
30 import org.eclipse.text.edits.TreeIterationInfo; // packageimport | |
31 import org.eclipse.text.edits.TextEditVisitor; // packageimport | |
32 import org.eclipse.text.edits.TextEditGroup; // packageimport | |
33 import org.eclipse.text.edits.TextEdit; // packageimport | |
34 import org.eclipse.text.edits.RangeMarker; // packageimport | |
35 import org.eclipse.text.edits.InsertEdit; // packageimport | |
36 | |
37 | |
38 import java.lang.all; | |
39 import java.util.List; | |
40 import java.util.ArrayList; | |
41 import java.util.Set; | |
42 | |
43 | |
44 | |
45 import org.eclipse.jface.text.BadLocationException; | |
46 import org.eclipse.jface.text.IDocument; | |
47 | |
48 | |
49 /** | |
50 * This class encapsulates the reverse changes of an executed text | |
51 * edit tree. To apply an undo memento to a document use method | |
52 * <code>apply(IDocument)</code>. | |
53 * <p> | |
54 * Clients can't add additional children to an undo edit nor can they | |
55 * add an undo edit as a child to another edit. Doing so results in | |
56 * both cases in a <code>MalformedTreeException<code>. | |
57 * | |
58 * @since 3.0 | |
59 * @noinstantiate This class is not intended to be instantiated by clients. | |
60 */ | |
61 public final class UndoEdit : TextEdit { | |
62 | |
63 this() { | |
64 super(0, Integer.MAX_VALUE); | |
65 } | |
66 | |
67 private this(UndoEdit other) { | |
68 super(other); | |
69 } | |
70 | |
71 /* | |
72 * @see org.eclipse.text.edits.TextEdit#internalAdd(org.eclipse.text.edits.TextEdit) | |
73 */ | |
74 void internalAdd(TextEdit child) { | |
75 throw new MalformedTreeException(null, this, TextEditMessages.getString("UndoEdit.no_children")); //$NON-NLS-1$ | |
76 } | |
77 | |
78 /* | |
79 * @see org.eclipse.text.edits.MultiTextEdit#aboutToBeAdded(org.eclipse.text.edits.TextEdit) | |
80 */ | |
81 void aboutToBeAdded(TextEdit parent) { | |
82 throw new MalformedTreeException(parent, this, TextEditMessages.getString("UndoEdit.can_not_be_added")); //$NON-NLS-1$ | |
83 } | |
84 | |
85 UndoEdit dispatchPerformEdits(TextEditProcessor processor) { | |
86 return processor.executeUndo(); | |
87 } | |
88 | |
89 void dispatchCheckIntegrity(TextEditProcessor processor) { | |
90 processor.checkIntegrityUndo(); | |
91 } | |
92 | |
93 /* | |
94 * @see org.eclipse.text.edits.TextEdit#doCopy() | |
95 */ | |
96 protected TextEdit doCopy() { | |
97 return new UndoEdit(this); | |
98 } | |
99 | |
100 /* | |
101 * @see TextEdit#accept0 | |
102 */ | |
103 protected void accept0(TextEditVisitor visitor) { | |
104 bool visitChildren= visitor.visit(this); | |
105 if (visitChildren) { | |
106 acceptChildren(visitor); | |
107 } | |
108 } | |
109 | |
110 /* | |
111 * @see TextEdit#performDocumentUpdating | |
112 */ | |
113 int performDocumentUpdating(IDocument document) { | |
114 fDelta= 0; | |
115 return fDelta; | |
116 } | |
117 | |
118 void add(ReplaceEdit edit) { | |
119 List children= internalGetChildren(); | |
120 if (children is null) { | |
121 children= new ArrayList(2); | |
122 internalSetChildren(children); | |
123 } | |
124 children.add(edit); | |
125 } | |
126 | |
127 void defineRegion(int offset, int length) { | |
128 internalSetOffset(offset); | |
129 internalSetLength(length); | |
130 } | |
131 | |
132 bool deleteChildren() { | |
133 return false; | |
134 } | |
135 } | |
136 |