final IDocument document = textViewer.getDocument();
final IRegion lineInfo = document.getLineInformationOfOffset(offset);
final String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
final int lineRelativeOffset = offset - lineInfo.getOffset();
final int index = line.indexOf(javaElement.getElementName());
return new Region(offset - lineRelativeOffset + index, javaElement.getElementName().length());
} catch (final Exception ex) {
return null;
}
}
}