recurseChildrenAndFilter method

CommentReferable recurseChildrenAndFilter(
  1. ReferenceChildrenLookup referenceLookup,
  2. CommentReferable result,
  3. {bool allowTree(
    1. CommentReferable
    ),
  4. bool filter(
    1. CommentReferable
    )}
)
inherited

Given a result found in an implementation of lookupViaScope or _lookupViaReferenceChildren, recurse through children, skipping over results that do not match the filter.

Implementation

CommentReferable recurseChildrenAndFilter(
    ReferenceChildrenLookup referenceLookup, CommentReferable result,
    {bool Function(CommentReferable) allowTree,
    bool Function(CommentReferable) filter}) {
  assert(result != null);
  if (referenceLookup.remaining.isNotEmpty) {
    if (allowTree(result)) {
      result = result.referenceBy(referenceLookup.remaining,
          tryParents: false, allowTree: allowTree, filter: filter);
    } else {
      result = null;
    }
  } else if (!filter(result)) {
    result = result.referenceBy([referenceLookup.lookup],
        tryParents: false, allowTree: allowTree, filter: filter);
  }
  if (!filter(result)) {
    result = null;
  }
  return result;
}