Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 ElementReferencesComputer(this.searchEngine); | 23 ElementReferencesComputer(this.searchEngine); |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Computes [SearchResult]s for [element] references. | 26 * Computes [SearchResult]s for [element] references. |
| 27 */ | 27 */ |
| 28 Future<List<SearchResult>> compute(Element element, bool withPotential) { | 28 Future<List<SearchResult>> compute(Element element, bool withPotential) { |
| 29 var futureGroup = new _ConcatFutureGroup<SearchResult>(); | 29 var futureGroup = new _ConcatFutureGroup<SearchResult>(); |
| 30 // find element references | 30 // find element references |
| 31 futureGroup.add(_findElementsReferences(element)); | 31 futureGroup.add(_findElementsReferences(element)); |
| 32 // add potential references | 32 // add potential references |
| 33 if (withPotential && _isMemberElement(element)) { | 33 if (withPotential && _isMemberElement(element) && |
| 34 element is! ConstructorElement) { | |
|
scheglov
2014/09/09 20:45:17
Push this into _isMemberElement.
Paul Berry
2014/09/09 21:24:59
Done.
| |
| 34 String name = element.displayName; | 35 String name = element.displayName; |
| 35 var matchesFuture = searchEngine.searchMemberReferences(name); | 36 var matchesFuture = searchEngine.searchMemberReferences(name); |
| 36 var resultsFuture = matchesFuture.then((List<SearchMatch> matches) { | 37 var resultsFuture = matchesFuture.then((List<SearchMatch> matches) { |
| 37 return matches.where((match) => !match.isResolved).map(toResult); | 38 return matches.where((match) => !match.isResolved).map(toResult); |
| 38 }); | 39 }); |
| 39 futureGroup.add(resultsFuture); | 40 futureGroup.add(resultsFuture); |
| 40 } | 41 } |
| 41 // merge results | 42 // merge results |
| 42 return futureGroup.future; | 43 return futureGroup.future; |
| 43 } | 44 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 * Adds a [Future] or an [E] value to results. | 140 * Adds a [Future] or an [E] value to results. |
| 140 */ | 141 */ |
| 141 void add(value) { | 142 void add(value) { |
| 142 if (value is Future) { | 143 if (value is Future) { |
| 143 _futures.add(value); | 144 _futures.add(value); |
| 144 } else { | 145 } else { |
| 145 _futures.add(new Future.value(<E>[value])); | 146 _futures.add(new Future.value(<E>[value])); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 } | 149 } |
| OLD | NEW |