Mercurial > projects > dwt2
comparison org.eclipse.text/src/org/eclipse/text/edits/TreeIterationInfo.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, 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 org.eclipse.text.edits.TreeIterationInfo; | |
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.TextEditVisitor; // packageimport | |
31 import org.eclipse.text.edits.TextEditGroup; // packageimport | |
32 import org.eclipse.text.edits.TextEdit; // packageimport | |
33 import org.eclipse.text.edits.RangeMarker; // packageimport | |
34 import org.eclipse.text.edits.UndoEdit; // packageimport | |
35 import org.eclipse.text.edits.InsertEdit; // packageimport | |
36 | |
37 | |
38 import java.lang.all; | |
39 import java.util.Set; | |
40 | |
41 import org.eclipse.core.runtime.Assert; | |
42 | |
43 | |
44 class TreeIterationInfo { | |
45 | |
46 interface Visitor { | |
47 void visit(TextEdit edit); | |
48 } | |
49 | |
50 private int fMark= -1; | |
51 private TextEdit[][] fEditStack; | |
52 private int[] fIndexStack; | |
53 | |
54 public this(){ | |
55 fEditStack= new TextEdit[][](10); | |
56 fIndexStack= new int[10]; | |
57 } | |
58 | |
59 public int getSize() { | |
60 return fMark + 1; | |
61 } | |
62 public void push(TextEdit[] edits) { | |
63 if (++fMark is fEditStack.length) { | |
64 TextEdit[][] t1= new TextEdit[][](fEditStack.length * 2); | |
65 SimpleType!(TextEdit[]).arraycopy(fEditStack, 0, t1, 0, fEditStack.length); | |
66 fEditStack= t1; | |
67 int[] t2= new int[fEditStack.length]; | |
68 System.arraycopy(fIndexStack, 0, t2, 0, fIndexStack.length); | |
69 fIndexStack= t2; | |
70 } | |
71 fEditStack[fMark]= edits; | |
72 fIndexStack[fMark]= -1; | |
73 } | |
74 public void setIndex(int index) { | |
75 fIndexStack[fMark]= index; | |
76 } | |
77 public void pop() { | |
78 fEditStack[fMark]= null; | |
79 fIndexStack[fMark]= -1; | |
80 fMark--; | |
81 } | |
82 public void accept(Visitor visitor) { | |
83 for (int i= fMark; i >= 0; i--) { | |
84 Assert.isTrue(fIndexStack[i] >= 0); | |
85 int start= fIndexStack[i] + 1; | |
86 TextEdit[] edits= fEditStack[i]; | |
87 for (int s= start; s < edits.length; s++) { | |
88 visitor.visit(edits[s]); | |
89 } | |
90 } | |
91 } | |
92 } |