first version of 'Code Assist" template engine
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / textmanipulation / NopTextEdit.java
1 /*
2  * (c) Copyright IBM Corp. 2000, 2001.
3  * All Rights Reserved.
4  */
5 package net.sourceforge.phpdt.internal.corext.textmanipulation;
6
7 import org.eclipse.core.runtime.CoreException;
8
9 /**
10  * A text edit that does nothing. A <code>NopTextEdit</code> can be used to track
11  * positions when executing <code>TextEdits</code> associated with a <code>
12  * TextBufferEditor</code>.
13  */
14 public class NopTextEdit extends TextEdit {
15         
16         private TextRange fTextRange;
17         
18         /**
19          * Creates a new <code>NopTextEdit</code> for the given
20          * offset and length.
21          * 
22          * @param offset the starting offset this text edit is "working on"
23          * @param length the length this text edit is "working on"
24          */
25         public NopTextEdit(int offset, int length) {
26                 this(new TextRange(offset, length));
27         }
28         
29         /**
30          * Creates a new <code>NopTextEdit</code> for the given
31          * range.
32          * 
33          * @param range the <code>TextRange</code> this text edit is "working on"
34          */
35         public NopTextEdit(TextRange range) {
36                 fTextRange= range;
37         }
38
39         /* non Java-doc
40          * @see TextEdit#getTextRange
41          */     
42         public TextRange getTextRange() {
43                 return fTextRange;
44         }
45
46         /* non Java-doc
47          * @see TextEdit#perform
48          */     
49         public TextEdit perform(TextBuffer buffer) throws CoreException {
50                 return new NopTextEdit(fTextRange);
51         }
52         
53         /* non Java-doc
54          * @see TextEdit#perform
55          */     
56         public TextEdit copy() {
57                 return new NopTextEdit(fTextRange.copy());
58         }       
59 }
60