#include "components/query_parser/query_parser.h"
#include <algorithm>
#include <memory>
#include <ostream>
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/i18n/break_iterator.h"
#include "base/i18n/case_conversion.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
namespace query_parser {
namespace {
int CompareMatchPosition(const Snippet::MatchPosition& mp1,
const Snippet::MatchPosition& mp2) { … }
bool SnippetIntersects(const Snippet::MatchPosition& mp1,
const Snippet::MatchPosition& mp2) { … }
void CoalesceMatchesFrom(size_t index, Snippet::MatchPositions* matches) { … }
bool IsQueryQuote(wchar_t ch) { … }
}
class QueryNodeWord : public QueryNode { … };
QueryNodeWord::QueryNodeWord(const std::u16string& word,
MatchingAlgorithm matching_algorithm)
: … { … }
QueryNodeWord::~QueryNodeWord() { … }
int QueryNodeWord::AppendToSQLiteQuery(std::u16string* query) const { … }
bool QueryNodeWord::IsWord() const { … }
bool QueryNodeWord::Matches(const std::u16string& word, bool exact) const { … }
bool QueryNodeWord::HasMatchIn(const QueryWordVector& words,
Snippet::MatchPositions* match_positions) const { … }
bool QueryNodeWord::HasMatchIn(const QueryWordVector& words, bool exact) const { … }
void QueryNodeWord::AppendWords(std::vector<std::u16string>* words) const { … }
class QueryNodeList : public QueryNode { … };
QueryNodeList::QueryNodeList() { … }
QueryNodeList::~QueryNodeList() { … }
void QueryNodeList::AddChild(std::unique_ptr<QueryNode> node) { … }
void QueryNodeList::RemoveEmptySubnodes() { … }
int QueryNodeList::AppendToSQLiteQuery(std::u16string* query) const { … }
bool QueryNodeList::IsWord() const { … }
bool QueryNodeList::Matches(const std::u16string& word, bool exact) const { … }
bool QueryNodeList::HasMatchIn(const QueryWordVector& words,
Snippet::MatchPositions* match_positions) const { … }
bool QueryNodeList::HasMatchIn(const QueryWordVector& words, bool exact) const { … }
void QueryNodeList::AppendWords(std::vector<std::u16string>* words) const { … }
int QueryNodeList::AppendChildrenToString(std::u16string* query) const { … }
class QueryNodePhrase : public QueryNodeList { … };
QueryNodePhrase::QueryNodePhrase() { … }
QueryNodePhrase::~QueryNodePhrase() { … }
int QueryNodePhrase::AppendToSQLiteQuery(std::u16string* query) const { … }
bool QueryNodePhrase::MatchesAll(const QueryWordVector& words,
const QueryWord** first_word,
const QueryWord** last_word) const { … }
bool QueryNodePhrase::HasMatchIn(
const QueryWordVector& words,
Snippet::MatchPositions* match_positions) const { … }
bool QueryNodePhrase::HasMatchIn(const QueryWordVector& words,
bool exact) const { … }
bool QueryParser::IsWordLongEnoughForPrefixSearch(
const std::u16string& word,
MatchingAlgorithm matching_algorithm) { … }
int QueryParser::ParseQuery(const std::u16string& query,
MatchingAlgorithm matching_algorithm,
std::u16string* sqlite_query) { … }
void QueryParser::ParseQueryWords(const std::u16string& query,
MatchingAlgorithm matching_algorithm,
std::vector<std::u16string>* words) { … }
void QueryParser::ParseQueryNodes(const std::u16string& query,
MatchingAlgorithm matching_algorithm,
QueryNodeVector* nodes) { … }
bool QueryParser::DoesQueryMatch(const std::u16string& find_in_text,
const QueryNodeVector& find_nodes,
Snippet::MatchPositions* match_positions) { … }
bool QueryParser::DoesQueryMatch(const QueryWordVector& find_in_words,
const QueryNodeVector& find_nodes,
bool exact) { … }
bool QueryParser::ParseQueryImpl(const std::u16string& query,
MatchingAlgorithm matching_algorithm,
QueryNodeList* root) { … }
void QueryParser::ExtractQueryWords(const std::u16string& text,
QueryWordVector* words) { … }
void QueryParser::SortAndCoalesceMatchPositions(
Snippet::MatchPositions* matches) { … }
}