use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionMapping method getCoverage.
@Override
public IRegion getCoverage() {
Position[] fragments = getFragments();
if (fragments != null && fragments.length > 0) {
Position first = fragments[0];
Position last = fragments[fragments.length - 1];
return new Region(first.offset, exclusiveEnd(last) - first.offset);
}
return new Region(0, 0);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionMapping method toOriginLines.
@Override
public IRegion toOriginLines(int imageLine) throws BadLocationException {
IRegion imageRegion = fSlaveDocument.getLineInformation(imageLine);
IRegion originRegion = toOriginRegion(imageRegion);
int originStartLine = fMasterDocument.getLineOfOffset(originRegion.getOffset());
if (originRegion.getLength() == 0)
return new Region(originStartLine, 1);
int originEndLine = fMasterDocument.getLineOfOffset(inclusiveEnd(originRegion));
return new Region(originStartLine, (originEndLine + 1) - originStartLine);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionTextStore method get.
@Override
public String get(int offset, int length) {
try {
IRegion[] fragments = fMapping.toExactOriginRegions(new Region(offset, length));
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < fragments.length; i++) {
IRegion fragment = fragments[i];
buffer.append(fMasterDocument.get(fragment.getOffset(), fragment.getLength()));
}
return buffer.toString();
} catch (BadLocationException e) {
internalError();
}
// unreachable
return null;
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test29_20.
@Test
public void test29_20() {
// test computation of unprojected master regions
// spanning multiple fragments
// starting touching left fragment border
// ending touching right fragment border
IRegion[] expected = { new Region(80, 20), new Region(120, 20) };
assertUnprojectedMasterRegions(expected, 60, 100);
}
use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test29_22.
@Test
public void test29_22() {
// test computation of unprojected master regions
// spanning multiple fragments
// starting inside fragment
// ending left of fragment
IRegion[] expected = { new Region(80, 20), new Region(120, 10) };
assertUnprojectedMasterRegions(expected, 70, 60);
}
Aggregations