if (node1 == null) {
IDOMPosition endOfDoc = new DOMRefPosition2(model.getDocument(),
true);
DesignPosition p = DOMPositionHelper.toDesignPosition(endOfDoc);
return new DesignRange(p, p);
}
if ((region1 == region2 || node1.getEndOffset() == offset + length)
&& !(node1 instanceof Text)) {
// ok, we selected a single node.
EditPart part = (EditPart) node1.getAdapterFor(EditPart.class);
if (part != null) {
return new StructuredSelection(part);
}
}
// when we reach here, we'll create a DesignerRange
IDOMPosition position1 = toDOMPosition(model, region1, offset);
IDOMPosition position2 = (length == 0 ? position1 : toDOMPosition(
model, region2, offset + length));
if (position1 == null || position2 == null) {
return new DesignRange(null, null);
}
DesignPosition p1 = DOMPositionHelper.toDesignPosition(position1);
DesignPosition p2 = (length == 0 ? p1 : DOMPositionHelper
.toDesignPosition(position2));
if (p1 == null || p2 == null) {
return new DesignRange(null, null);
}
return new DesignRange(p1, p2);
}