1 11 package org.eclipse.text.edits; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.text.BadLocationException; 16 import org.eclipse.jface.text.IDocument; 17 18 24 public final class ReplaceEdit extends TextEdit { 25 26 private String fText; 27 28 35 public ReplaceEdit(int offset, int length, String text) { 36 super(offset, length); 37 Assert.isNotNull(text); 38 fText= text; 39 } 40 41 46 private ReplaceEdit(ReplaceEdit other) { 47 super(other); 48 fText= other.fText; 49 } 50 51 57 public String getText() { 58 return fText; 59 } 60 61 64 protected TextEdit doCopy() { 65 return new ReplaceEdit(this); 66 } 67 68 71 protected void accept0(TextEditVisitor visitor) { 72 boolean visitChildren= visitor.visit(this); 73 if (visitChildren) { 74 acceptChildren(visitor); 75 } 76 } 77 78 81 int performDocumentUpdating(IDocument document) throws BadLocationException { 82 document.replace(getOffset(), getLength(), fText); 83 fDelta= fText.length() - getLength(); 84 return fDelta; 85 } 86 87 90 boolean deleteChildren() { 91 return true; 92 } 93 94 98 void internalToString(StringBuffer buffer, int indent) { 99 super.internalToString(buffer, indent); 100 buffer.append(" <<").append(fText); } 102 } 103 | Popular Tags |