HierarchyQuery class abstract

Abstract base class for hierarchy search queries.

A HierarchyQuery encapsulates the matching strategy (how names are compared) independently of the tree traversal (which is always performed by HierarchyService).

Contract with HierarchyService

The service walks the HierarchyOccurrence tree depth-first. At each node it calls:

  1. matchOccurrence — does this occurrence name satisfy the query at the current match state? Returns a set of successor states (empty = prune this branch).
  2. matchSignal — does this signal name satisfy the query at the current match state?
  3. isComplete — have all parts of the query been consumed at the given state?

"Match state" is an opaque integer that the query owns. It typically tracks how many segments/tokens of the query have been consumed so far. The initial state is always 0.

Crossing hierarchy boundaries

If crossesBoundaries is true the service will, at each depth, additionally try advancing with the current state even when the occurrence doesn't match — allowing matches to span across intermediate hierarchy levels (like ** in glob patterns).

Subclassing

Implement a concrete query by overriding at least matchOccurrence, matchSignal, isComplete, and segmentCount.

The factory HierarchyQuery.prefix creates the default prefix-substring query. HierarchyQuery.regex creates a regex/glob query.

// Custom fuzzy query
class FuzzyQuery extends HierarchyQuery {
  FuzzyQuery(String rawQuery)
      : super(rawQuery, target: SearchTarget.signals);
  ...
}

Constructors

HierarchyQuery(String rawQuery, {SearchTarget target = SearchTarget.signals, bool crossesBoundaries = false})
Creates a query from rawQuery.
const
HierarchyQuery.prefix(String rawQuery, {SearchTarget target})
Create a prefix-substring query.
factory
HierarchyQuery.regex(String rawQuery, {SearchTarget target})
Create a regex/glob query.
factory

Properties

crossesBoundaries bool
Whether this query can match across hierarchy boundaries.
final
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether the query is empty / trivial (should return no results).
no setter
rawQuery String
The original user-supplied query string.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
segmentCount int
Number of logical segments in the parsed query.
no setter
target SearchTarget
What this query matches — occurrences, signals, or both.
final

Methods

isComplete(int stateIndex) bool
Whether the query is fully consumed at stateIndex.
matchOccurrence(String occurrenceName, int stateIndex) Set<int>
Try matching an occurrence name at match state stateIndex.
matchSignal(String signalName, int stateIndex) bool
Whether signalName matches the query at state stateIndex.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited