* @param region1NodeStart
* @param region2NodeStart
* @return outer dirty region or null if none exists.
*/
private DirtyRegion _getOuterRegion(DirtyRegion region1, DirtyRegion region2, IStructuredModel sModel, int region1NodeStart, int region2NodeStart) {
DirtyRegion outer = null;
int region1NodeEnd = -1;
int region2NodeEnd = -1;
// then check if region1's end appears after
// region2's end
IndexedRegion region1EndNode = sModel.getIndexedRegion(region1.getOffset() + region1.getLength());
if (region1EndNode == null) {
// if no end, just assume region spans all the
// way to the end so it includes other region
outer = region1;
}
else {
region1NodeEnd = region1EndNode.getEndOffset();
IndexedRegion region2EndNode = sModel.getIndexedRegion(region2.getOffset() + region2.getLength());
region2NodeEnd = region2EndNode != null ? region2EndNode.getEndOffset() : getDocument().getLength();
if (region1NodeEnd >= region2NodeEnd) {
// root contains or is equal to possible
outer = region1;
}
else if (region1NodeStart == region2NodeStart && region2NodeEnd >= region1NodeEnd) {
// possible contains root because they
// both start at same place but possible
// is longer
outer = region2;
}
}
if (DEBUG) {
if (outer != null)
System.out.println("checking if [" + region1NodeStart + ":" + region1NodeEnd + "] contains [" + region2NodeStart + ":" + region2NodeEnd + "] ... " + outer.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
else
System.out.println("checking if [" + region1NodeStart + ":" + region1NodeEnd + "] contains [" + region2NodeStart + ":" + region2NodeEnd + "] ... NO CONTAIN"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
return outer;
}