| Index: pkg/analyzer/test/src/dart/analysis/base.dart
|
| diff --git a/pkg/analyzer/test/src/dart/analysis/base.dart b/pkg/analyzer/test/src/dart/analysis/base.dart
|
| index 796b9b8b42469e16ed10bc3cfb243d4ced94acb2..bb716cf041acf6913f206d31fb9be646f8c766af 100644
|
| --- a/pkg/analyzer/test/src/dart/analysis/base.dart
|
| +++ b/pkg/analyzer/test/src/dart/analysis/base.dart
|
| @@ -4,6 +4,8 @@
|
|
|
| import 'dart:async';
|
|
|
| +import 'package:analyzer/dart/element/element.dart';
|
| +import 'package:analyzer/dart/element/visitor.dart';
|
| import 'package:analyzer/file_system/file_system.dart';
|
| import 'package:analyzer/file_system/memory_file_system.dart';
|
| import 'package:analyzer/source/package_map_resolver.dart';
|
| @@ -17,6 +19,30 @@ import 'package:test/test.dart';
|
|
|
| import '../../context/mock_sdk.dart';
|
|
|
| +/**
|
| + * Finds an [Element] with the given [name].
|
| + */
|
| +Element findChildElement(Element root, String name, [ElementKind kind]) {
|
| + Element result = null;
|
| + root.accept(new _ElementVisitorFunctionWrapper((Element element) {
|
| + if (element.name != name) {
|
| + return;
|
| + }
|
| + if (kind != null && element.kind != kind) {
|
| + return;
|
| + }
|
| + result = element;
|
| + }));
|
| + return result;
|
| +}
|
| +
|
| +typedef bool Predicate<E>(E argument);
|
| +
|
| +/**
|
| + * A function to be called for every [Element].
|
| + */
|
| +typedef void _ElementVisitorFunction(Element element);
|
| +
|
| class BaseAnalysisDriverTest {
|
| static final MockSdk sdk = new MockSdk();
|
|
|
| @@ -108,6 +134,20 @@ class BaseAnalysisDriverTest {
|
| String _p(String path) => provider.convertPath(path);
|
| }
|
|
|
| +/**
|
| + * Wraps an [_ElementVisitorFunction] into a [GeneralizingElementVisitor].
|
| + */
|
| +class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
|
| + final _ElementVisitorFunction function;
|
| +
|
| + _ElementVisitorFunctionWrapper(this.function);
|
| +
|
| + visitElement(Element element) {
|
| + function(element);
|
| + super.visitElement(element);
|
| + }
|
| +}
|
| +
|
| class _Monitor {
|
| Completer<Null> _completer = new Completer<Null>();
|
|
|
|
|