| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library search.top_level_declarations; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:analysis_server/src/search/search_result.dart'; |
| 10 import 'package:analysis_services/search/search_engine.dart'; |
| 11 |
| 12 |
| 13 /** |
| 14 * A computer for `search.findTopLevelDeclarations` request results. |
| 15 */ |
| 16 class TopLevelDeclarationsComputer { |
| 17 final SearchEngine searchEngine; |
| 18 |
| 19 TopLevelDeclarationsComputer(this.searchEngine); |
| 20 |
| 21 /** |
| 22 * Computes [SearchResult]s for top-level [element] declarations. |
| 23 */ |
| 24 Future<List<SearchResult>> compute(String pattern) { |
| 25 var matchesFuture = searchEngine.searchTopLevelDeclarations(pattern); |
| 26 return matchesFuture.then((List<SearchMatch> matches) { |
| 27 return matches.map(toResult).toList(); |
| 28 }); |
| 29 } |
| 30 |
| 31 static SearchResult toResult(SearchMatch match) { |
| 32 return new SearchResult.fromMatch(match); |
| 33 } |
| 34 } |
| OLD | NEW |