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.CopyingRangeMarker;
|
|
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.ReplaceEdit; // 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 import dwtx.jface.text.BadLocationException;
|
|
41 import dwtx.jface.text.IDocument;
|
|
42
|
|
43 /**
|
|
44 * A <code>CopyingRangeMarker</code> can be used to track positions when executing
|
|
45 * text edits. Additionally a copying range marker stores a local copy of the
|
|
46 * text it captures when it gets executed.
|
|
47 *
|
|
48 * @since 3.0
|
|
49 */
|
|
50 public final class CopyingRangeMarker : TextEdit {
|
|
51
|
|
52 private String fText;
|
|
53
|
|
54 /**
|
|
55 * Creates a new <tt>CopyRangeMarker</tt> for the given
|
|
56 * offset and length.
|
|
57 *
|
|
58 * @param offset the marker's offset
|
|
59 * @param length the marker's length
|
|
60 */
|
130
|
61 public this(int offset, int length) {
|
129
|
62 super(offset, length);
|
|
63 }
|
|
64
|
|
65 /*
|
|
66 * Copy constructor
|
|
67 */
|
130
|
68 private this(CopyingRangeMarker other) {
|
129
|
69 super(other);
|
|
70 fText= other.fText;
|
|
71 }
|
|
72
|
|
73 /*
|
|
74 * @see TextEdit#doCopy
|
|
75 */
|
|
76 protected TextEdit doCopy() {
|
|
77 return new CopyingRangeMarker(this);
|
|
78 }
|
|
79
|
|
80 /*
|
|
81 * @see TextEdit#accept0
|
|
82 */
|
|
83 protected void accept0(TextEditVisitor visitor) {
|
|
84 bool visitChildren= visitor.visit(this);
|
|
85 if (visitChildren) {
|
|
86 acceptChildren(visitor);
|
|
87 }
|
|
88 }
|
|
89
|
|
90 /*
|
|
91 * @see TextEdit#performDocumentUpdating
|
|
92 */
|
|
93 int performDocumentUpdating(IDocument document) throws BadLocationException {
|
|
94 fText= document.get(getOffset(), getLength());
|
|
95 fDelta= 0;
|
|
96 return fDelta;
|
|
97 }
|
|
98
|
|
99 /*
|
|
100 * @see TextEdit#deleteChildren
|
|
101 */
|
|
102 bool deleteChildren() {
|
|
103 return false;
|
|
104 }
|
|
105 }
|