| 230 | } |
| 231 | |
| 232 | bool MacroMatchesSearchFilter(Macro *macro) |
| 233 | { |
| 234 | assert(macro); |
| 235 | |
| 236 | if (!searchEnabled) { |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | const auto &settings = GetMacroSearchSettings(); |
| 241 | |
| 242 | if (settings.searchString.empty()) { |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | if (macro->IsGroup()) { |
| 247 | const auto groupEntries = GetGroupMacroEntries(macro); |
| 248 | for (const auto &entry : groupEntries) { |
| 249 | if (MacroMatchesSearchFilter(entry.get())) { |
| 250 | return true; |
| 251 | } |
| 252 | } |
| 253 | return false; |
| 254 | } |
| 255 | |
| 256 | switch (settings.searchType) { |
| 257 | case MacroSearchSettings::SearchType::NAME: { |
| 258 | const auto name = macro->Name(); |
| 259 | return stringMatches(name); |
| 260 | } |
| 261 | case MacroSearchSettings::SearchType::ALL_SEGMENTS: |
| 262 | for (const auto &condition : macro->Conditions()) { |
| 263 | if (segmentTypeMatches(condition.get(), true)) { |
| 264 | return true; |
| 265 | } |
| 266 | } |
| 267 | for (const auto &action : macro->Actions()) { |
| 268 | if (segmentTypeMatches(action.get(), false)) { |
| 269 | return true; |
| 270 | } |
| 271 | } |
| 272 | for (const auto &action : macro->ElseActions()) { |
| 273 | if (segmentTypeMatches(action.get(), false)) { |
| 274 | return true; |
| 275 | } |
| 276 | } |
| 277 | return false; |
| 278 | case MacroSearchSettings::SearchType::CONDITIONS: |
| 279 | for (const auto &condition : macro->Conditions()) { |
| 280 | if (segmentTypeMatches(condition.get(), true)) { |
| 281 | return true; |
| 282 | } |
| 283 | } |
| 284 | return false; |
| 285 | case MacroSearchSettings::SearchType::ACTIONS: |
| 286 | for (const auto &action : macro->Actions()) { |
| 287 | if (segmentTypeMatches(action.get(), false)) { |
| 288 | return true; |
| 289 | } |
no test coverage detected