| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/visitor.dart'; | 10 import 'package:analyzer/dart/element/visitor.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Search support for an [AnalysisDriver]. | 29 * Search support for an [AnalysisDriver]. |
| 30 */ | 30 */ |
| 31 class Search { | 31 class Search { |
| 32 final AnalysisDriver _driver; | 32 final AnalysisDriver _driver; |
| 33 | 33 |
| 34 Search(this._driver); | 34 Search(this._driver); |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Returns class members with names matching the given [regExp]. | 37 * Returns class members with the given [name]. |
| 38 */ | 38 */ |
| 39 Future<List<Element>> classMembers(RegExp regExp) async { | 39 Future<List<Element>> classMembers(String name) async { |
| 40 List<Element> elements = <Element>[]; | 40 List<Element> elements = <Element>[]; |
| 41 | 41 |
| 42 void addElement(Element element) { | 42 void addElement(Element element) { |
| 43 if (!element.isSynthetic && regExp.hasMatch(element.displayName)) { | 43 if (!element.isSynthetic && element.displayName == name) { |
| 44 elements.add(element); | 44 elements.add(element); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 for (FileState file in _driver.fsState.knownFiles) { | 48 List<String> files = await _driver.getFilesDefiningClassMemberName(name); |
| 49 CompilationUnitElement unitElement = | 49 for (String file in files) { |
| 50 await _driver.getUnitElement(file.path); | 50 CompilationUnitElement unitElement = await _driver.getUnitElement(file); |
| 51 if (unitElement != null) { | 51 if (unitElement != null) { |
| 52 for (ClassElement clazz in unitElement.types) { | 52 for (ClassElement clazz in unitElement.types) { |
| 53 clazz.accessors.forEach(addElement); | 53 clazz.accessors.forEach(addElement); |
| 54 clazz.fields.forEach(addElement); | 54 clazz.fields.forEach(addElement); |
| 55 clazz.methods.forEach(addElement); | 55 clazz.methods.forEach(addElement); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 return elements; | 59 return elements; |
| 60 } | 60 } |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 } | 857 } |
| 858 | 858 |
| 859 void _addResult(AstNode node, SearchResultKind kind) { | 859 void _addResult(AstNode node, SearchResultKind kind) { |
| 860 bool isQualified = node.parent is Label; | 860 bool isQualified = node.parent is Label; |
| 861 Element enclosingElement = | 861 Element enclosingElement = |
| 862 _getEnclosingElement(enclosingUnitElement, node.offset); | 862 _getEnclosingElement(enclosingUnitElement, node.offset); |
| 863 results.add(new SearchResult._( | 863 results.add(new SearchResult._( |
| 864 enclosingElement, kind, node.offset, node.length, true, isQualified)); | 864 enclosingElement, kind, node.offset, node.length, true, isQualified)); |
| 865 } | 865 } |
| 866 } | 866 } |
| OLD | NEW |