Mercurial > projects > dwt-addons
annotate dwtx/text/edits/InsertEdit.d @ 136:6dcb0baaa031
Regex removal of throws decls, some instanceof
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 02:20:40 +0200 |
parents | c4fb132a086c |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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 dwtx.text.edits.InsertEdit; | |
14 | |
131 | 15 import dwtx.text.edits.MultiTextEdit; // packageimport |
16 import dwtx.text.edits.CopySourceEdit; // packageimport | |
17 import dwtx.text.edits.MoveSourceEdit; // packageimport | |
18 import dwtx.text.edits.CopyingRangeMarker; // packageimport | |
19 import dwtx.text.edits.ReplaceEdit; // packageimport | |
20 import dwtx.text.edits.EditDocument; // packageimport | |
21 import dwtx.text.edits.UndoCollector; // packageimport | |
22 import dwtx.text.edits.DeleteEdit; // packageimport | |
23 import dwtx.text.edits.MoveTargetEdit; // packageimport | |
24 import dwtx.text.edits.CopyTargetEdit; // packageimport | |
25 import dwtx.text.edits.TextEditCopier; // packageimport | |
26 import dwtx.text.edits.ISourceModifier; // packageimport | |
27 import dwtx.text.edits.TextEditMessages; // packageimport | |
28 import dwtx.text.edits.TextEditProcessor; // packageimport | |
29 import dwtx.text.edits.MalformedTreeException; // packageimport | |
30 import dwtx.text.edits.TreeIterationInfo; // packageimport | |
31 import dwtx.text.edits.TextEditVisitor; // packageimport | |
32 import dwtx.text.edits.TextEditGroup; // packageimport | |
33 import dwtx.text.edits.TextEdit; // packageimport | |
34 import dwtx.text.edits.RangeMarker; // packageimport | |
35 import dwtx.text.edits.UndoEdit; // packageimport | |
36 | |
37 | |
129 | 38 import dwt.dwthelper.utils; |
39 | |
40 | |
41 import dwtx.core.runtime.Assert; | |
42 import dwtx.jface.text.BadLocationException; | |
43 import dwtx.jface.text.IDocument; | |
44 | |
45 /** | |
46 * Text edit to insert a text at a given position in a | |
47 * document. | |
48 * <p> | |
49 * An insert edit is equivalent to <code>ReplaceEdit(offset, 0, text) | |
50 * </code> | |
51 * | |
52 * @since 3.0 | |
53 */ | |
54 public final class InsertEdit : TextEdit { | |
55 | |
56 private String fText; | |
57 | |
58 /** | |
59 * Constructs a new insert edit. | |
60 * | |
61 * @param offset the insertion offset | |
62 * @param text the text to insert | |
63 */ | |
130 | 64 public this(int offset, String text) { |
129 | 65 super(offset, 0); |
66 Assert.isNotNull(text); | |
67 fText= text; | |
68 } | |
69 | |
70 /* | |
71 * Copy constructor | |
72 */ | |
130 | 73 private this(InsertEdit other) { |
129 | 74 super(other); |
75 fText= other.fText; | |
76 } | |
77 | |
78 /** | |
79 * Returns the text to be inserted. | |
80 * | |
81 * @return the edit's text. | |
82 */ | |
83 public String getText() { | |
84 return fText; | |
85 } | |
86 | |
87 /* | |
88 * @see TextEdit#doCopy | |
89 */ | |
90 protected TextEdit doCopy() { | |
91 return new InsertEdit(this); | |
92 } | |
93 | |
94 /* | |
95 * @see TextEdit#accept0 | |
96 */ | |
97 protected void accept0(TextEditVisitor visitor) { | |
98 bool visitChildren= visitor.visit(this); | |
99 if (visitChildren) { | |
100 acceptChildren(visitor); | |
101 } | |
102 } | |
103 | |
104 /* | |
105 * @see TextEdit#performDocumentUpdating | |
106 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
107 int performDocumentUpdating(IDocument document) { |
129 | 108 document.replace(getOffset(), getLength(), fText); |
109 fDelta= fText.length() - getLength(); | |
110 return fDelta; | |
111 } | |
112 | |
113 /* | |
114 * @see TextEdit#deleteChildren | |
115 */ | |
116 bool deleteChildren() { | |
117 return false; | |
118 } | |
119 | |
120 /* | |
121 * @see dwtx.text.edits.TextEdit#internalToString(java.lang.StringBuffer, int) | |
122 * @since 3.3 | |
123 */ | |
124 void internalToString(StringBuffer buffer, int indent) { | |
125 super.internalToString(buffer, indent); | |
126 buffer.append(" <<").append(fText); //$NON-NLS-1$ | |
127 } | |
128 } |