* The position to have its text coordinates normalized
* @throws BadLocationException
* thrown by IDocument queries.
*/
private void normalizePosition(EnhancedPosition position) throws BadLocationException {
JavaPositionMetadata metadata = (JavaPositionMetadata)position.getMetadata();
int start = document.getLineOfOffset(position.getOffset());
int end = document.getLineOfOffset(position.getOffset() + position.getLength());
int offset = document.getLineOffset(start);
if (!metadata.isFilterLastLine()) {
end++;
}
int numLines = document.getNumberOfLines();
int safeEnd = Math.min(numLines-1, end);