1 11 package org.eclipse.jface.text.projection; 12 13 import org.eclipse.jface.text.BadLocationException; 14 import org.eclipse.jface.text.IDocument; 15 import org.eclipse.jface.text.IRegion; 16 import org.eclipse.jface.text.Position; 17 18 27 public class ChildDocument extends ProjectionDocument { 28 29 33 static private class VisibleRegion extends Position { 34 35 41 public VisibleRegion(int regionOffset, int regionLength) { 42 super(regionOffset, regionLength); 43 } 44 45 51 public boolean overlapsWith(int regionOffset, int regionLength) { 52 boolean appending= (regionOffset == offset + length) && regionLength == 0; 53 return appending || super.overlapsWith(regionOffset, regionLength); 54 } 55 } 56 57 62 public ChildDocument(IDocument masterDocument) { 63 super(masterDocument); 64 } 65 66 72 public IDocument getParentDocument() { 73 return getMasterDocument(); 74 } 75 76 84 public void setParentDocumentRange(int offset, int length) throws BadLocationException { 85 replaceMasterDocumentRanges(offset, length); 86 } 87 88 93 public Position getParentDocumentRange() { 94 IRegion coverage= getProjectionMapping().getCoverage(); 95 return new VisibleRegion(coverage.getOffset(), coverage.getLength()); 96 } 97 } 98 | Popular Tags |