matches method
bool
matches(
- ParseTree tree, {
- ParseTreePattern? pattern,
- String? patternStr,
- int? patternRuleIndex,
Does pattern
matched as rule patternRuleIndex match tree? Pass in a
compiled pattern instead of a string representation of a tree pattern.
Implementation
bool matches(
ParseTree tree, {
ParseTreePattern? pattern,
String? patternStr,
int? patternRuleIndex,
}) {
assert(pattern != null || patternStr != null && patternRuleIndex != null);
pattern ??= compile(patternStr!, patternRuleIndex!);
final labels = MultiMap<String, ParseTree>();
final mismatchedNode = matchImpl(tree, pattern.patternTree, labels);
return mismatchedNode == null;
}