elementsWithNestedQueries method

List<FoundElement> elementsWithNestedQueries()

Returns all found elements, from this query an all nested queries. The elements returned by this method are in no particular order, thus they can only be used to determine the method parameters.

This method makes some effort to remove duplicated parameters. But only by comparing the dart name.

Implementation

List<FoundElement> elementsWithNestedQueries() {
  final elements = List.of(this.elements);

  final subQueries = resultSet?.nestedResults.whereType<NestedResultQuery>();
  for (final subQuery in subQueries ?? const <NestedResultQuery>[]) {
    for (final subElement in subQuery.query.elementsWithNestedQueries()) {
      if (elements
          .none((e) => e.dartParameterName == subElement.dartParameterName)) {
        elements.add(subElement);
      }
    }
  }

  return elements;
}