try {
final IErlElement e1 = module.getElementAt(offset1);
final IErlElement e2 = module.getElementAt(offset2);
if (e1 instanceof ISourceReference) {
final ISourceReference ref1 = (ISourceReference) e1;
final ISourceRange r1 = ref1.getSourceRange();
final int offset = r1.getOffset();
int length = r1.getLength();
if (e1 == e2) {
final int docLength = document.getLength();
if (offset + length > docLength) {
length = docLength - offset;
}
return extendSelectionToWholeLines(document,
new TextSelection(document, offset, length));
} else if (e2 == null) {
return extendSelectionToWholeLines(
document,
new TextSelection(document, offset, selection
.getLength() + selection.getOffset() - offset));
} else if (e2 instanceof ISourceReference) {
final ISourceReference ref2 = (ISourceReference) e2;
final ISourceRange r2 = ref2.getSourceRange();
return extendSelectionToWholeLines(document,
new TextSelection(document, offset, r2.getOffset()
- offset + r2.getLength()));
}
}
} catch (final ErlModelException e) {
}
}