1 11 package org.eclipse.jface.text.reconciler; 12 13 import org.eclipse.jface.text.ITypedRegion; 14 15 16 19 public class DirtyRegion implements ITypedRegion { 20 21 24 final static public String INSERT= "__insert"; 28 final static public String REMOVE= "__remove"; 30 31 private int fOffset; 32 33 private int fLength; 34 35 private String fType; 36 37 private String fText; 38 39 47 public DirtyRegion(int offset, int length, String type, String text) { 48 fOffset= offset; 49 fLength= length; 50 fType= normalizeTypeValue(type); 51 fText= text; 52 } 53 54 62 private String normalizeTypeValue(String type) { 63 if (INSERT.equals(type)) 64 return INSERT; 65 if (REMOVE.equals(type)) 66 return REMOVE; 67 return null; 68 } 69 70 73 public int getOffset() { 74 return fOffset; 75 } 76 77 80 public int getLength() { 81 return fLength; 82 } 83 84 87 public String getType() { 88 return fType; 89 } 90 91 96 public String getText() { 97 return fText; 98 } 99 100 105 void mergeWith(DirtyRegion dr) { 106 int start= Math.min(fOffset, dr.fOffset); 107 int end= Math.max(fOffset + fLength, dr.fOffset + dr.fLength); 108 fOffset= start; 109 fLength= end - start; 110 fText= (dr.fText == null ? fText : (fText == null) ? dr.fText : fText + dr.fText); 111 } 112 } 113 | Popular Tags |