| 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.dart' show SearchResult; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Returns a [Future] completing with a [List] of references to [element] or | 46 * Returns a [Future] completing with a [List] of references to [element] or |
| 47 * to the corresponding hierarchy [Element]s. | 47 * to the corresponding hierarchy [Element]s. |
| 48 */ | 48 */ |
| 49 Future<List<SearchResult>> _findElementsReferences(Element element) { | 49 Future<List<SearchResult>> _findElementsReferences(Element element) { |
| 50 return _getRefElements(element).then((Iterable<Element> refElements) { | 50 return _getRefElements(element).then((Iterable<Element> refElements) { |
| 51 var futureGroup = new _ConcatFutureGroup<SearchResult>(); | 51 var futureGroup = new _ConcatFutureGroup<SearchResult>(); |
| 52 for (Element refElement in refElements) { | 52 for (Element refElement in refElements) { |
| 53 // add variable declaration | 53 // add declaration |
| 54 if (_isVariableLikeElement(refElement)) { | 54 if (_isDeclarationInteresting(refElement)) { |
| 55 SearchResult searchResult = _newDeclarationResult(refElement); | 55 SearchResult searchResult = _newDeclarationResult(refElement); |
| 56 futureGroup.add(searchResult); | 56 futureGroup.add(searchResult); |
| 57 } | 57 } |
| 58 // do search | 58 // do search |
| 59 futureGroup.add(_findSingleElementReferences(refElement)); | 59 futureGroup.add(_findSingleElementReferences(refElement)); |
| 60 } | 60 } |
| 61 return futureGroup.future; | 61 return futureGroup.future; |
| 62 }); | 62 }); |
| 63 } | 63 } |
| 64 | 64 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return new SearchResult.fromMatch(match); | 105 return new SearchResult.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 _isVariableLikeElement(Element element) { | 115 static bool _isDeclarationInteresting(Element element) { |
| 116 if (element is LabelElement) { |
| 117 return true; |
| 118 } |
| 116 if (element is LocalVariableElement) { | 119 if (element is LocalVariableElement) { |
| 117 return true; | 120 return true; |
| 118 } | 121 } |
| 119 if (element is ParameterElement) { | 122 if (element is ParameterElement) { |
| 120 return true; | 123 return true; |
| 121 } | 124 } |
| 122 if (element is PropertyInducingElement) { | 125 if (element is PropertyInducingElement) { |
| 123 return !element.isSynthetic; | 126 return !element.isSynthetic; |
| 124 } | 127 } |
| 125 return false; | 128 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 142 * Adds a [Future] or an [E] value to results. | 145 * Adds a [Future] or an [E] value to results. |
| 143 */ | 146 */ |
| 144 void add(value) { | 147 void add(value) { |
| 145 if (value is Future) { | 148 if (value is Future) { |
| 146 _futures.add(value); | 149 _futures.add(value); |
| 147 } else { | 150 } else { |
| 148 _futures.add(new Future.value(<E>[value])); | 151 _futures.add(new Future.value(<E>[value])); |
| 149 } | 152 } |
| 150 } | 153 } |
| 151 } | 154 } |
| OLD | NEW |