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

Side by Side Diff: pkg/analyzer/lib/src/generated/testing/element_search.dart

Issue 2965133003: Move findElementsByName() into shared analyzer/element_search.dart file. (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 unified diff | Download patch
OLDNEW
(Empty)
1 import 'package:analyzer/dart/ast/ast.dart';
Brian Wilkerson 2017/07/06 18:42:28 Missing copyright.
2 import 'package:analyzer/dart/ast/visitor.dart';
3 import 'package:analyzer/dart/element/element.dart';
4
5 /**
6 * Search the [unit] for the [Element]s with the given [name].
7 */
8 List<Element> findElementsByName(CompilationUnit unit, String name) {
9 var finder = new _ElementsByNameFinder(name);
10 unit.accept(finder);
11 return finder.elements;
12 }
13
14 class _ElementsByNameFinder extends RecursiveAstVisitor<Null> {
15 final String name;
16 final List<Element> elements = [];
17
18 _ElementsByNameFinder(this.name);
19
20 @override
21 visitSimpleIdentifier(SimpleIdentifier node) {
22 if (node.name == name && node.inDeclarationContext()) {
23 elements.add(node.staticElement);
24 }
25 }
26 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/plugin/protocol_dart_test.dart ('k') | pkg/analyzer/test/src/dart/analysis/search_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698