Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: pkg/analyzer/lib/src/generated/testing/node_search.dart

Issue 2965423002: Stop using ExecutableElement.functions in tests. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/dart/element/builder_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/testing/node_search.dart
diff --git a/pkg/analyzer/lib/src/generated/testing/node_search.dart b/pkg/analyzer/lib/src/generated/testing/node_search.dart
new file mode 100644
index 0000000000000000000000000000000000000000..39889eea19c4f6889fe6415504542bb8791b65c7
--- /dev/null
+++ b/pkg/analyzer/lib/src/generated/testing/node_search.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
+
+/**
+ * Search the [unit] for declared [SimpleIdentifier]s with the given [name].
+ */
+List<SimpleIdentifier> findDeclaredIdentifiersByName(
+ CompilationUnit unit, String name) {
+ var finder = new _DeclaredIdentifiersByNameFinder(name);
+ unit.accept(finder);
+ return finder.identifiers;
+}
+
+class _DeclaredIdentifiersByNameFinder extends RecursiveAstVisitor<Null> {
+ final String name;
+ final List<SimpleIdentifier> identifiers = [];
+
+ _DeclaredIdentifiersByNameFinder(this.name);
+
+ @override
+ visitSimpleIdentifier(SimpleIdentifier node) {
+ if (node.name == name && node.inDeclarationContext()) {
+ identifiers.add(node);
+ }
+ }
+}
« no previous file with comments | « no previous file | pkg/analyzer/test/dart/element/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698