| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return _searchReferences_Parameter(element); | 67 return _searchReferences_Parameter(element); |
| 68 } else if (kind == ElementKind.PREFIX) { | 68 } else if (kind == ElementKind.PREFIX) { |
| 69 return _searchReferences_Prefix(element); | 69 return _searchReferences_Prefix(element); |
| 70 } else if (kind == ElementKind.TYPE_PARAMETER) { | 70 } else if (kind == ElementKind.TYPE_PARAMETER) { |
| 71 return _searchReferences_Local( | 71 return _searchReferences_Local( |
| 72 element, (n) => n.parent is CompilationUnit); | 72 element, (n) => n.parent is CompilationUnit); |
| 73 } | 73 } |
| 74 return const <SearchResult>[]; | 74 return const <SearchResult>[]; |
| 75 } | 75 } |
| 76 | 76 |
| 77 /** |
| 78 * Returns subtypes of the given [type]. |
| 79 */ |
| 80 Future<List<SearchResult>> subTypes(ClassElement type) async { |
| 81 if (type == null) { |
| 82 return const <SearchResult>[]; |
| 83 } |
| 84 List<SearchResult> results = <SearchResult>[]; |
| 85 await _addResults(results, type, { |
| 86 IndexRelationKind.IS_EXTENDED_BY: SearchResultKind.REFERENCE, |
| 87 IndexRelationKind.IS_MIXED_IN_BY: SearchResultKind.REFERENCE, |
| 88 IndexRelationKind.IS_IMPLEMENTED_BY: SearchResultKind.REFERENCE |
| 89 }); |
| 90 return results; |
| 91 } |
| 92 |
| 77 Future<Null> _addResults(List<SearchResult> results, Element element, | 93 Future<Null> _addResults(List<SearchResult> results, Element element, |
| 78 Map<IndexRelationKind, SearchResultKind> relationToResultKind) async { | 94 Map<IndexRelationKind, SearchResultKind> relationToResultKind) async { |
| 79 String path = element.source.fullName; | 95 String path = element.source.fullName; |
| 80 | 96 |
| 81 // If the file with the element is not known, then the element is not used. | 97 // If the file with the element is not known, then the element is not used. |
| 82 if (!_driver.knownFiles.contains(path)) { | 98 if (!_driver.knownFiles.contains(path)) { |
| 83 return; | 99 return; |
| 84 } | 100 } |
| 85 | 101 |
| 86 // Prepare the element name. | 102 // Prepare the element name. |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 } | 700 } |
| 685 | 701 |
| 686 void _addResult(AstNode node, SearchResultKind kind) { | 702 void _addResult(AstNode node, SearchResultKind kind) { |
| 687 bool isQualified = node.parent is Label; | 703 bool isQualified = node.parent is Label; |
| 688 Element enclosingElement = | 704 Element enclosingElement = |
| 689 _getEnclosingElement(enclosingUnitElement, node.offset); | 705 _getEnclosingElement(enclosingUnitElement, node.offset); |
| 690 results.add(new SearchResult._(element, enclosingElement, kind, node.offset, | 706 results.add(new SearchResult._(element, enclosingElement, kind, node.offset, |
| 691 node.length, true, isQualified)); | 707 node.length, true, isQualified)); |
| 692 } | 708 } |
| 693 } | 709 } |
| OLD | NEW |