lookupViaScope method

CommentReferable lookupViaScope(
  1. ReferenceChildrenLookup referenceLookup,
  2. bool allowTree(
    1. CommentReferable
  3. bool filter(
    1. CommentReferable

Looks up references by scope, skipping over results that do not match the given filter.

Override if Scope.lookup may return elements not corresponding to a CommentReferable, but you still want to have an implementation of scope.


CommentReferable lookupViaScope(
    ReferenceChildrenLookup referenceLookup,
    bool Function(CommentReferable) allowTree,
    bool Function(CommentReferable) filter) {
  var resultElement = scope.lookupPreferGetter(referenceLookup.lookup);
  if (resultElement == null) return null;
  var result = modelBuilder.fromElement(resultElement);
  if (result is Accessor) {
    result = (result as Accessor).enclosingCombo;
  if (result?.enclosingElement is Container) {
        '[Container] member detected, support not implemented for analyzer scope inside containers');
    return null;
  if (!allowTree(result)) return null;
  return recurseChildrenAndFilter(referenceLookup, result,
      allowTree: allowTree, filter: filter);