/** * Adjusts this change region to a diff hunk. This will change the adjusted ranges. * * @param hunk the diff hunk to adjust to */ public void adjustTo(Hunk hunk) { for (ListIterator<Range> it= fAdjusted.listIterator(); it.hasNext();) { Range range= it.next(); // do we need a split? int unchanged= getUnchanged(hunk, range.start()); if (unchanged > 0) { if (unchanged >= range.length()) continue; range= range.split(unchanged); it.add(range); it.previous(); it.next(); // needed so we can remove below } int line= range.start(); Assert.isTrue(hunk.line <= line); // by how much do we shrink? int overlap= getOverlap(hunk, line); if (overlap >= range.length()) { it.remove(); continue; } // by how much do we move? range.moveBy(hunk.delta + overlap); range.resizeBy(-overlap); } }
/** * Adjusts this change region to a diff hunk. This will change the adjusted ranges. * * @param hunk the diff hunk to adjust to */ public void adjustTo(Hunk hunk) { for (ListIterator<Range> it= fAdjusted.listIterator(); it.hasNext();) { Range range= it.next(); // do we need a split? int unchanged= getUnchanged(hunk, range.start()); if (unchanged > 0) { if (unchanged >= range.length()) continue; range= range.split(unchanged); it.add(range); it.previous(); it.next(); // needed so we can remove below } int line= range.start(); Assert.isTrue(hunk.line <= line); // by how much do we shrink? int overlap= getOverlap(hunk, line); if (overlap >= range.length()) { it.remove(); continue; } // by how much do we move? range.moveBy(hunk.delta + overlap); range.resizeBy(-overlap); } }