searchOccurrences method

List<OccurrenceSearchResult> searchOccurrences(
  1. String query, {
  2. int? limit,
})

Search for occurrences and return enriched OccurrenceSearchResult objects.

Automatically dispatches to searchOccurrencesRegex when the query contains glob or regex metacharacters (*, ?, [, (, |, +). Otherwise uses searchOccurrencePaths for prefix-based matching.

Implementation

List<OccurrenceSearchResult> searchOccurrences(String query, {int? limit}) {
  final effectiveLimit = limit ?? defaultHierarchySearchLimit;
  if (hasRegexChars(query)) {
    final pattern = (query.startsWith('**/') || query.startsWith('*/'))
        ? query
        : '**/$query';
    return searchOccurrencesRegex(pattern, limit: effectiveLimit);
  }
  return _toOccurrenceResults(
      searchOccurrencePaths(query, limit: effectiveLimit));
}