FindResult (CharSequence text, int offset, FindModel model, VirtualFile file, @Nullable Predicate<? super FindResult> filter) { final char[] textArray = CharArrayUtil.fromSequenceWithoutCopying(text); while(true) { FindResult result = doFindString(text, textArray, offset, model, file); if (filter == null || filter.test(result)) { if (!model.isWholeWordsOnly() || !result.isStringFound() || isWholeWord(text, result.getStartOffset(), result.getEndOffset())) { return result; } } offset = model.isForward() ? result.getStartOffset() + 1 : result.getEndOffset() - 1; if (offset > text.length() || offset < 0) return NOT_FOUND_RESULT; } }