use of org.eclipse.xtext.ui.editor.model.DocumentCharacterIterator in project xtext-eclipse by eclipse.
the class AbstractWordAwareDoubleClickStrategy method findWord.
@Override
protected IRegion findWord(IDocument document, int offset) {
try {
IRegion line = document.getLineInformationOfOffset(offset);
if (offset == line.getOffset() + line.getLength())
return null;
com.ibm.icu.text.BreakIterator breakIter = createBreakIterator();
breakIter.setText(new DocumentCharacterIterator(document));
int start = breakIter.preceding(offset);
if (start == BreakIterator.DONE)
start = line.getOffset();
int end = breakIter.following(offset);
if (end == BreakIterator.DONE)
end = line.getOffset() + line.getLength();
if (breakIter.isBoundary(offset)) {
if (end - offset > offset - start)
start = offset;
else
end = offset;
}
if (end == start)
return null;
return new Region(start, end - start);
} catch (BadLocationException e) {
return null;
}
}
Aggregations