use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.
the class ChangeRegionTest method testHunkBefore.
@Test
public void testHunkBefore() throws Exception {
ChangeRegion r;
r = new ChangeRegion(fRevision, new LineRange(12, 3));
r.adjustTo(new Hunk(5, 3, 2));
RangeUtil.assertEqualSingleRange(new LineRange(15, 3), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(15, 3), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 3));
r.adjustTo(new Hunk(5, 3, 0));
RangeUtil.assertEqualSingleRange(new LineRange(15, 3), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(15, 3), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 3));
r.adjustTo(new Hunk(5, -3, 0));
RangeUtil.assertEqualSingleRange(new LineRange(9, 3), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(9, 3), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 3));
r.adjustTo(new Hunk(5, 3, 3));
RangeUtil.assertEqualSingleRange(new LineRange(15, 3), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(15, 3), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 3));
r.adjustTo(new Hunk(5, -3, 2));
RangeUtil.assertEqualSingleRange(new LineRange(9, 3), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(9, 3), r.getAdjustedCoverage());
}
use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.
the class ChangeRegionTest method testHunkInBetween.
@Test
public void testHunkInBetween() throws Exception {
// TODO require merging of adjacent ranges?
ChangeRegion r;
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(15, -2, 0));
RangeUtil.assertEqualRanges(new LineRange(12, 3), new LineRange(15, 2), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(15, 2, 0));
RangeUtil.assertEqualRanges(new LineRange(12, 3), new LineRange(17, 4), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(12, 9), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(15, 0, 2));
RangeUtil.assertEqualRanges(new LineRange(12, 3), new LineRange(17, 2), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(12, 7), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(15, -1, 2));
RangeUtil.assertEqualRanges(new LineRange(12, 3), new LineRange(17, 1), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(12, 6), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(15, 2, 2));
RangeUtil.assertEqualRanges(new LineRange(12, 3), new LineRange(19, 2), r.getAdjustedRanges());
RangeUtil.assertEqualRange(new LineRange(12, 9), r.getAdjustedCoverage());
}
use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.
the class Revision method getRegions.
/**
* Returns the contained {@link RevisionRange}s adapted to the current diff state. The returned
* information is only valid at the moment it is returned, and may change as the annotated
* document is modified.
*
* @return an unmodifiable view of the contained ranges
*/
public final List<RevisionRange> getRegions() {
if (fRanges == null) {
List<RevisionRange> ranges = new ArrayList<>(fChangeRegions.size());
for (ChangeRegion region : fChangeRegions) {
for (ILineRange range : region.getAdjustedRanges()) {
ranges.add(new RevisionRange(this, range));
}
}
fRanges = Collections.unmodifiableList(ranges);
}
return fRanges;
}
use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.
the class ChangeRegionTest method testHunkAfter.
@Test
public void testHunkAfter() throws Exception {
ChangeRegion r = new ChangeRegion(fRevision, new LineRange(12, 3));
List<Range> before = RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(16, 3, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 3));
before = RangeUtil.deepClone(r.getAdjustedRanges());
r.adjustTo(new Hunk(16, -33, 2));
RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
}
use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.
the class ChangeRegionTest method testHunkCovering.
@Test
public void testHunkCovering() throws Exception {
ChangeRegion r;
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(12, 0, 7));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(11, 0, 8));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(11, 0, 9));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(12, 0, 9));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(12, -7, 0));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(12, -8, 0));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(11, -8, 0));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(11, -9, 0));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -9, 6));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -4, 8));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -3, 9));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -12, 5));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -12, 20));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, 12, 20));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
r = new ChangeRegion(fRevision, new LineRange(12, 7));
r.adjustTo(new Hunk(8, -3, 8));
assertTrue(r.getAdjustedRanges().isEmpty());
RangeUtil.assertEqualRange(new LineRange(12, 0), r.getAdjustedCoverage());
}
Aggregations