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 27 public final class InsertEdit extends TextEdit { 28 29 private String fText; 30 31 37 public InsertEdit(int offset, String text) { 38 super(offset, 0); 39 Assert.isNotNull(text); 40 fText= text; 41 } 42 43 46 private InsertEdit(InsertEdit other) { 47 super(other); 48 fText= other.fText; 49 } 50 51 56 public String getText() { 57 return fText; 58 } 59 60 63 protected TextEdit doCopy() { 64 return new InsertEdit(this); 65 } 66 67 70 protected void accept0(TextEditVisitor visitor) { 71 boolean visitChildren= visitor.visit(this); 72 if (visitChildren) { 73 acceptChildren(visitor); 74 } 75 } 76 77 80 int performDocumentUpdating(IDocument document) throws BadLocationException { 81 document.replace(getOffset(), getLength(), fText); 82 fDelta= fText.length() - getLength(); 83 return fDelta; 84 } 85 86 89 boolean deleteChildren() { 90 return false; 91 } 92 93 97 void internalToString(StringBuffer buffer, int indent) { 98 super.internalToString(buffer, indent); 99 buffer.append(" <<").append(fText); } 101 } 102 | Popular Tags |