MCPcopy Create free account
hub / github.com/comaps/comaps / Search

Method Search

libs/editor/new_feature_categories.cpp:112–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112NewFeatureCategories::TypeNames NewFeatureCategories::Search(std::string const & query) const
113{
114 if (query.empty())
115 return {};
116
117 std::vector<std::string> tokens;
118 search::ForEachNormalizedToken(query, [&](strings::UniString const & token) {
119 tokens.push_back(strings::ToUtf8(token));
120 });
121
122 if (tokens.empty())
123 return {};
124
125 TypeNames result;
126
127 for (auto const & data : m_categoriesData)
128 {
129 for (auto const & syn : data.m_synonyms)
130 {
131 bool allTokensFound = true;
132 for (auto const & token : tokens)
133 {
134 if (syn.find(token) == std::string::npos)
135 {
136 allTokensFound = false;
137 break;
138 }
139 }
140
141 if (allTokensFound)
142 {
143 result.push_back(data.m_typeName);
144 break;
145 }
146 }
147 }
148
149 std::sort(result.begin(), result.end());
150 return result;
151}
152
153void NewFeatureCategories::AddToRecentCategories(std::string const & category)
154{

Callers

nothing calls this directly

Calls 7

ForEachNormalizedTokenFunction · 0.85
ToUtf8Function · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected