FindResult (@NotNull CharSequence text, char @Nullable [] textArray, int offset, @NotNull FindModel model, @Nullable VirtualFile file) { String toFind = model.getStringToFind(); if (toFind.isEmpty()) { return NOT_FOUND_RESULT; } if (model.isInCommentsOnly() || model.isInStringLiteralsOnly()) { if (file == null) return NOT_FOUND_RESULT; return findInCommentsAndLiterals(text, textArray, offset, model, file); } if (model.isRegularExpressions()) { return findStringByRegularExpression(text, offset, model, file); } final StringSearcher searcher = createStringSearcher(model); int index; if (model.isForward()) { final int res = searcher.scan(text, textArray, offset, text.length()); index = res < 0 ? -1 : res; } else { index = offset == 0 ? -1 : searcher.scan(text, textArray, 0, offset-1); } if (index < 0) { return NOT_FOUND_RESULT; } return new FindResultImpl(index, index + toFind.length()); }