IRegion reg= searcher.find(firstPosition, searchPattern, true, CASE_SENSITIVE, false, true);
while (reg != null) {
// since the boundary may be of nonzero length
int wordSearchPos= reg.getOffset() + reg.getLength() - prefix.length();
// try to complete to a word. case is irrelevant here.
IRegion word= searcher.find(wordSearchPos, COMPLETION_WORD_REGEX, true, true, false, true);
if (word.getLength() > prefix.length() ) { // empty suggestion will be added later
String wholeWord= document.get(word.getOffset(), word.getLength());
String completion= wholeWord.substring(prefix.length());
if (currentWordLast && reg.getOffset() == firstPosition) { // we got the word at caret as completion
currentWordCompletion= completion; // add it as the last word.