| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library search.element_references; | 5 library search.element_references; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/collections.dart'; | 9 import 'package:analysis_server/src/collections.dart'; |
| 10 import 'package:analysis_server/src/protocol.dart' show SearchResult; | 10 import 'package:analysis_server/src/protocol_server.dart' show SearchResult, |
| 11 newSearchResult_fromMatch; |
| 11 import 'package:analysis_server/src/services/search/hierarchy.dart'; | 12 import 'package:analysis_server/src/services/search/hierarchy.dart'; |
| 12 import 'package:analysis_server/src/services/search/search_engine.dart'; | 13 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 13 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 15 | 16 |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * A computer for `search.findElementReferences` request results. | 19 * A computer for `search.findElementReferences` request results. |
| 19 */ | 20 */ |
| 20 class ElementReferencesComputer { | 21 class ElementReferencesComputer { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Future<Iterable<Element>> _getRefElements(Element element) { | 85 Future<Iterable<Element>> _getRefElements(Element element) { |
| 85 if (element is ClassMemberElement) { | 86 if (element is ClassMemberElement) { |
| 86 return getHierarchyMembers(searchEngine, element); | 87 return getHierarchyMembers(searchEngine, element); |
| 87 } | 88 } |
| 88 return new Future.value([element]); | 89 return new Future.value([element]); |
| 89 } | 90 } |
| 90 | 91 |
| 91 SearchResult _newDeclarationResult(Element refElement) { | 92 SearchResult _newDeclarationResult(Element refElement) { |
| 92 int nameOffset = refElement.nameOffset; | 93 int nameOffset = refElement.nameOffset; |
| 93 int nameLength = refElement.name.length; | 94 int nameLength = refElement.name.length; |
| 94 SearchMatch searchMatch = | 95 SearchMatch searchMatch = new SearchMatch( |
| 95 new SearchMatch( | 96 MatchKind.DECLARATION, |
| 96 MatchKind.DECLARATION, | 97 refElement, |
| 97 refElement, | 98 new SourceRange(nameOffset, nameLength), |
| 98 new SourceRange(nameOffset, nameLength), | 99 true, |
| 99 true, | 100 false); |
| 100 false); | 101 return newSearchResult_fromMatch(searchMatch); |
| 101 return new SearchResult.fromMatch(searchMatch); | |
| 102 } | 102 } |
| 103 | 103 |
| 104 static SearchResult toResult(SearchMatch match) { | 104 static SearchResult toResult(SearchMatch match) { |
| 105 return new SearchResult.fromMatch(match); | 105 return newSearchResult_fromMatch(match); |
| 106 } | 106 } |
| 107 | 107 |
| 108 static bool _isMemberElement(Element element) { | 108 static bool _isMemberElement(Element element) { |
| 109 if (element is ConstructorElement) { | 109 if (element is ConstructorElement) { |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 return element.enclosingElement is ClassElement; | 112 return element.enclosingElement is ClassElement; |
| 113 } | 113 } |
| 114 | 114 |
| 115 static bool _isDeclarationInteresting(Element element) { | 115 static bool _isDeclarationInteresting(Element element) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 * Adds a [Future] or an [E] value to results. | 148 * Adds a [Future] or an [E] value to results. |
| 149 */ | 149 */ |
| 150 void add(value) { | 150 void add(value) { |
| 151 if (value is Future) { | 151 if (value is Future) { |
| 152 _futures.add(value); | 152 _futures.add(value); |
| 153 } else { | 153 } else { |
| 154 _futures.add(new Future.value(<E>[value])); | 154 _futures.add(new Future.value(<E>[value])); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |