Mercurial > projects > dwt-addons
annotate dwtx/text/edits/ReplaceEdit.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 | 7926b636c282 |
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.ReplaceEdit; | |
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.EditDocument; // packageimport | |
20 import dwtx.text.edits.UndoCollector; // packageimport | |
21 import dwtx.text.edits.DeleteEdit; // packageimport | |
22 import dwtx.text.edits.MoveTargetEdit; // packageimport | |
23 import dwtx.text.edits.CopyTargetEdit; // packageimport | |
24 import dwtx.text.edits.TextEditCopier; // packageimport | |
25 import dwtx.text.edits.ISourceModifier; // packageimport | |
26 import dwtx.text.edits.TextEditMessages; // packageimport | |
27 import dwtx.text.edits.TextEditProcessor; // packageimport | |
28 import dwtx.text.edits.MalformedTreeException; // packageimport | |
29 import dwtx.text.edits.TreeIterationInfo; // packageimport | |
30 import dwtx.text.edits.TextEditVisitor; // packageimport | |
31 import dwtx.text.edits.TextEditGroup; // packageimport | |
32 import dwtx.text.edits.TextEdit; // packageimport | |
33 import dwtx.text.edits.RangeMarker; // packageimport | |
34 import dwtx.text.edits.UndoEdit; // packageimport | |
35 import dwtx.text.edits.InsertEdit; // 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 replace a range in a document with a different | |
47 * string. | |
48 * | |
49 * @since 3.0 | |
50 */ | |
51 public final class ReplaceEdit : TextEdit { | |
52 | |
53 private String fText; | |
54 | |
55 /** | |
56 * Constructs a new replace edit. | |
57 * | |
58 * @param offset the offset of the range to replace | |
59 * @param length the length of the range to replace | |
60 * @param text the new text | |
61 */ | |
130 | 62 public this(int offset, int length, String text) { |
129 | 63 super(offset, length); |
64 Assert.isNotNull(text); | |
65 fText= text; | |
66 } | |
67 | |
68 /* | |
69 * Copy constructor | |
70 * | |
71 * @param other the edit to copy from | |
72 */ | |
130 | 73 private this(ReplaceEdit other) { |
129 | 74 super(other); |
75 fText= other.fText; | |
76 } | |
77 | |
78 /** | |
79 * Returns the new text replacing the text denoted | |
80 * by the edit. | |
81 * | |
82 * @return the edit's text. | |
83 */ | |
84 public String getText() { | |
85 return fText; | |
86 } | |
87 | |
88 /* | |
89 * @see TextEdit#doCopy | |
90 */ | |
91 protected TextEdit doCopy() { | |
92 return new ReplaceEdit(this); | |
93 } | |
94 | |
95 /* | |
96 * @see TextEdit#accept0 | |
97 */ | |
98 protected void accept0(TextEditVisitor visitor) { | |
99 bool visitChildren= visitor.visit(this); | |
100 if (visitChildren) { | |
101 acceptChildren(visitor); | |
102 } | |
103 } | |
104 | |
105 /* | |
106 * @see TextEdit#performDocumentUpdating | |
107 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
108 int performDocumentUpdating(IDocument document) { |
129 | 109 document.replace(getOffset(), getLength(), fText); |
110 fDelta= fText.length() - getLength(); | |
111 return fDelta; | |
112 } | |
113 | |
114 /* | |
115 * @see TextEdit#deleteChildren | |
116 */ | |
117 bool deleteChildren() { | |
118 return true; | |
119 } | |
120 | |
121 /* | |
122 * @see dwtx.text.edits.TextEdit#internalToString(java.lang.StringBuffer, int) | |
123 * @since 3.3 | |
124 */ | |
125 void internalToString(StringBuffer buffer, int indent) { | |
126 super.internalToString(buffer, indent); | |
127 buffer.append(" <<").append(fText); //$NON-NLS-1$ | |
128 } | |
129 } |