| 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_server.dart' | 10 import 'package:analysis_server/src/protocol_server.dart' |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 /** |
| 65 * Returns a [Future] completing with a [List] of references to [element]. | 65 * Returns a [Future] completing with a [List] of references to [element]. |
| 66 */ | 66 */ |
| 67 Future<List<SearchResult>> _findSingleElementReferences(Element element) { | 67 Future<List<SearchResult>> _findSingleElementReferences( |
| 68 Future<List<SearchMatch>> matchesFuture = | 68 Element element) async { |
| 69 searchEngine.searchReferences(element); | 69 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
| 70 return matchesFuture.then((List<SearchMatch> matches) { | 70 return matches.map(toResult).toList(); |
| 71 return matches.map(toResult).toList(); | |
| 72 }); | |
| 73 } | 71 } |
| 74 | 72 |
| 75 /** | 73 /** |
| 76 * Returns a [Future] completing with [Element]s to search references to. | 74 * Returns a [Future] completing with [Element]s to search references to. |
| 77 * | 75 * |
| 78 * If a [ClassMemberElement] is given, each corresponding [Element] in the | 76 * If a [ClassMemberElement] is given, each corresponding [Element] in the |
| 79 * hierarchy is returned. | 77 * hierarchy is returned. |
| 80 * | 78 * |
| 81 * Otherwise, only references to [element] should be searched. | 79 * Otherwise, only references to [element] should be searched. |
| 82 */ | 80 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 * Adds a [Future] or an [E] value to results. | 145 * Adds a [Future] or an [E] value to results. |
| 148 */ | 146 */ |
| 149 void add(value) { | 147 void add(value) { |
| 150 if (value is Future) { | 148 if (value is Future) { |
| 151 _futures.add(value as Future<List<E>>); | 149 _futures.add(value as Future<List<E>>); |
| 152 } else { | 150 } else { |
| 153 _futures.add(new Future.value(<E>[value as E])); | 151 _futures.add(new Future.value(<E>[value as E])); |
| 154 } | 152 } |
| 155 } | 153 } |
| 156 } | 154 } |
| OLD | NEW |