| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Map<IndexRelationKind, SearchResultKind> relationToResultKind) async { | 77 Map<IndexRelationKind, SearchResultKind> relationToResultKind) async { |
| 78 String path = element.source.fullName; | 78 String path = element.source.fullName; |
| 79 | 79 |
| 80 // If the file with the element is not known, then the element is not used. | 80 // If the file with the element is not known, then the element is not used. |
| 81 if (!_driver.knownFiles.contains(path)) { | 81 if (!_driver.knownFiles.contains(path)) { |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // TODO(scheglov) optimize for private elements | 85 // TODO(scheglov) optimize for private elements |
| 86 String name = element.displayName; | 86 String name = element.displayName; |
| 87 if (element is ConstructorElement) { |
| 88 name = element.enclosingElement.displayName; |
| 89 } |
| 87 | 90 |
| 88 // Prepare the list of files that reference the element name. | 91 // Prepare the list of files that reference the element name. |
| 89 List<String> files = await _driver.getFilesReferencingName(name); | 92 List<String> files = await _driver.getFilesReferencingName(name); |
| 90 if (!files.contains(path) && _driver.addedFiles.contains(path)) { | 93 if (!files.contains(path) && _driver.addedFiles.contains(path)) { |
| 91 files.add(path); | 94 files.add(path); |
| 92 } | 95 } |
| 93 | 96 |
| 94 // Check the index of every file that references the element name. | 97 // Check the index of every file that references the element name. |
| 95 for (String file in files) { | 98 for (String file in files) { |
| 96 IndexResult result = await _driver.getIndex(file); | 99 IndexResult result = await _driver.getIndex(file); |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 631 } |
| 629 | 632 |
| 630 void _addResult(AstNode node, SearchResultKind kind) { | 633 void _addResult(AstNode node, SearchResultKind kind) { |
| 631 bool isQualified = node.parent is Label; | 634 bool isQualified = node.parent is Label; |
| 632 Element enclosingElement = | 635 Element enclosingElement = |
| 633 _getEnclosingElement(enclosingUnitElement, node.offset); | 636 _getEnclosingElement(enclosingUnitElement, node.offset); |
| 634 results.add(new SearchResult._(element, enclosingElement, kind, node.offset, | 637 results.add(new SearchResult._(element, enclosingElement, kind, node.offset, |
| 635 node.length, true, isQualified)); | 638 node.length, true, isQualified)); |
| 636 } | 639 } |
| 637 } | 640 } |
| OLD | NEW |