Index: pkg/analyzer/test/utils.dart |
diff --git a/pkg/analyzer/test/utils.dart b/pkg/analyzer/test/utils.dart |
index ed733b81e5c6fc9e707cdae9701ebf78c5bec4d0..72c71cd8db44a7885cacc7246b120333477e17fe 100644 |
--- a/pkg/analyzer/test/utils.dart |
+++ b/pkg/analyzer/test/utils.dart |
@@ -17,6 +17,18 @@ import 'package:test/test.dart'; |
* Search the [unit] for the [LocalVariableElement] with the given [name]. |
* Fail if there is not exactly one such variable. |
*/ |
+FunctionElement findLocalFunction(CompilationUnit unit, String name) { |
+ List<Element> elements = findElementsByName(unit, name); |
+ List<Element> functions = |
+ elements.where((e) => e is FunctionElement).toList(); |
+ expect(functions, hasLength(1)); |
+ return functions[0]; |
+} |
+ |
+/** |
+ * Search the [unit] for the [LocalVariableElement] with the given [name]. |
+ * Fail if there is not exactly one such variable. |
+ */ |
LocalVariableElement findLocalVariable(CompilationUnit unit, String name) { |
List<Element> elements = findElementsByName(unit, name); |
List<Element> localVariables = |