| 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 21 matching lines...) Expand all Loading... |
| 32 if (kind == ElementKind.LABEL || kind == ElementKind.LOCAL_VARIABLE) { | 32 if (kind == ElementKind.LABEL || kind == ElementKind.LOCAL_VARIABLE) { |
| 33 return _searchReferences_Local(element, (n) => n is Block); | 33 return _searchReferences_Local(element, (n) => n is Block); |
| 34 } | 34 } |
| 35 // TODO(scheglov) support other kinds | 35 // TODO(scheglov) support other kinds |
| 36 return const <SearchResult>[]; | 36 return const <SearchResult>[]; |
| 37 } | 37 } |
| 38 | 38 |
| 39 Future<List<SearchResult>> _searchReferences_Local( | 39 Future<List<SearchResult>> _searchReferences_Local( |
| 40 Element element, bool isRootNode(AstNode n)) async { | 40 Element element, bool isRootNode(AstNode n)) async { |
| 41 String path = element.source.fullName; | 41 String path = element.source.fullName; |
| 42 if (!_driver.addedFiles.contains(path)) { |
| 43 return const <SearchResult>[]; |
| 44 } |
| 42 | 45 |
| 43 // Prepare the unit. | 46 // Prepare the unit. |
| 44 AnalysisResult analysisResult = await _driver.getResult(path); | 47 AnalysisResult analysisResult = await _driver.getResult(path); |
| 45 CompilationUnit unit = analysisResult.unit; | 48 CompilationUnit unit = analysisResult.unit; |
| 46 if (unit == null) { | 49 if (unit == null) { |
| 47 return const <SearchResult>[]; | 50 return const <SearchResult>[]; |
| 48 } | 51 } |
| 49 | 52 |
| 50 // Prepare the node. | 53 // Prepare the node. |
| 51 AstNode node = new NodeLocator(element.nameOffset).searchWithin(unit); | 54 AstNode node = new NodeLocator(element.nameOffset).searchWithin(unit); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 200 } |
| 198 | 201 |
| 199 void _addResult(AstNode node, SearchResultKind kind) { | 202 void _addResult(AstNode node, SearchResultKind kind) { |
| 200 bool isQualified = node.parent is Label; | 203 bool isQualified = node.parent is Label; |
| 201 var finder = new _ContainingElementFinder(node.offset); | 204 var finder = new _ContainingElementFinder(node.offset); |
| 202 enclosingUnitElement.accept(finder); | 205 enclosingUnitElement.accept(finder); |
| 203 results.add(new SearchResult._(element, finder.containingElement, kind, | 206 results.add(new SearchResult._(element, finder.containingElement, kind, |
| 204 node.offset, node.length, true, isQualified)); | 207 node.offset, node.length, true, isQualified)); |
| 205 } | 208 } |
| 206 } | 209 } |
| OLD | NEW |