use of org.eclipse.jface.text.projection.Segment in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method assertFragmentation.
private void assertFragmentation(Position[] expected, boolean checkWellFormedness) {
if (checkWellFormedness) {
assertWellFormedSegmentation();
assertWellFormedFragmentation();
}
Position[] segmentation = fSlaveDocument.getSegments2();
assertTrue("invalid number of segments", expected.length == segmentation.length);
for (int i = 0; i < expected.length; i++) {
Segment segment = (Segment) segmentation[i];
Fragment actual = segment.fragment;
Assert.assertEquals(print(actual) + " != " + print(expected[i]), expected[i], actual);
}
}
use of org.eclipse.jface.text.projection.Segment in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method assertWellFormedFragmentation.
private void assertWellFormedFragmentation() {
Position[] segmentation = fSlaveDocument.getSegments2();
assertNotNull(segmentation);
Position[] fragmention = fSlaveDocument.getFragments2();
assertNotNull(fragmention);
assertTrue(fragmention.length == segmentation.length);
Position previous = null;
for (int i = 0; i < segmentation.length; i++) {
Segment segment = (Segment) segmentation[i];
Fragment fragment = (Fragment) fragmention[i];
assertTrue(fragment == segment.fragment);
assertTrue(segment == fragment.segment);
assertFalse(segmentation.length > 1 && (fragment.getLength() == 0 && i < segmentation.length - 1));
assertTrue(fragment.length == segment.length);
if (previous != null && i < segmentation.length - 1)
assertFalse(previous.getOffset() + previous.getLength() == fragment.getOffset());
previous = fragment;
}
}
use of org.eclipse.jface.text.projection.Segment in project eclipse.platform.text by eclipse.
the class ProjectionMappingTest method addProjection.
private void addProjection(int fragmentOffset, int segmentOffset, int length) {
Fragment fragment = new Fragment(fragmentOffset, length);
Segment segment = new Segment(segmentOffset, length);
fragment.segment = segment;
segment.fragment = fragment;
try {
fMasterDocument.addPosition(fFragmentsCategory, fragment);
fSlaveDocument.addPosition(fSegmentsCategory, segment);
} catch (BadLocationException e) {
assertTrue(false);
} catch (BadPositionCategoryException e) {
assertTrue(false);
}
}
Aggregations