Search in sources :

Example 1 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testCreation.

@Test
public void testCreation() throws Exception {
    try {
        new ChangeRegion(fRevision, null);
        fail();
    } catch (Exception e) {
    }
    try {
        new ChangeRegion(null, new LineRange(12, 3));
        fail();
    } catch (Exception e) {
    }
    try {
        new ChangeRegion(null, null);
        fail();
    } catch (Exception e) {
    }
    ChangeRegion r = new ChangeRegion(fRevision, new LineRange(12, 3));
    assertEquals(fRevision, r.getRevision());
    RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedRanges().get(0));
    RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedCoverage());
}
Also used : ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Example 2 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkRightAfter.

@Test
public void testHunkRightAfter() throws Exception {
    ChangeRegion r = new ChangeRegion(fRevision, new LineRange(12, 3));
    List<Range> before = RangeUtil.deepClone(r.getAdjustedRanges());
    r.adjustTo(new Hunk(15, 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(15, -3, 2));
    RangeUtil.assertEqualRanges(before, r.getAdjustedRanges());
    RangeUtil.assertEqualRange(before.get(0), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) Range(org.eclipse.jface.internal.text.revisions.Range) LineRange(org.eclipse.jface.text.source.LineRange) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Example 3 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkAtEnd.

@Test
public void testHunkAtEnd() throws Exception {
    ChangeRegion r;
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, 0, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, 2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(15, -2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 3), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 3), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, -2, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Example 4 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkOverStart.

@Test
public void testHunkOverStart() throws Exception {
    ChangeRegion r;
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(11, 0, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(13, 6), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(13, 6), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(11, 2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(15, 6), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(15, 6), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(11, -2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(13, 4), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(13, 4), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Example 5 with ChangeRegion

use of org.eclipse.jface.internal.text.revisions.ChangeRegion in project eclipse.platform.text by eclipse.

the class ChangeRegionTest method testHunkOverEnd.

@Test
public void testHunkOverEnd() throws Exception {
    ChangeRegion r;
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(18, 0, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 6), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 6), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(18, -2, 0));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 6), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 6), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(18, -2, 2));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 6), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 6), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, -2, 1));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, -2, 3));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
    r = new ChangeRegion(fRevision, new LineRange(12, 7));
    r.adjustTo(new Hunk(17, 2, 3));
    RangeUtil.assertEqualSingleRange(new LineRange(12, 5), r.getAdjustedRanges());
    RangeUtil.assertEqualRange(new LineRange(12, 5), r.getAdjustedCoverage());
}
Also used : Hunk(org.eclipse.jface.internal.text.revisions.Hunk) ChangeRegion(org.eclipse.jface.internal.text.revisions.ChangeRegion) LineRange(org.eclipse.jface.text.source.LineRange) Test(org.junit.Test)

Aggregations

ChangeRegion (org.eclipse.jface.internal.text.revisions.ChangeRegion)12 LineRange (org.eclipse.jface.text.source.LineRange)11 Test (org.junit.Test)11 Hunk (org.eclipse.jface.internal.text.revisions.Hunk)10 Range (org.eclipse.jface.internal.text.revisions.Range)2 ArrayList (java.util.ArrayList)1 ILineRange (org.eclipse.jface.text.source.ILineRange)1