Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: pkg/analysis_services/lib/completion/top_level_computer.dart

Issue 422423003: incremental step moving completion into services and adding tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 services.completion.computer.toplevel;
6
7 import 'dart:async';
8
9 import 'package:analysis_services/completion/completion_suggestion.dart';
10 import 'package:analysis_services/search/search_engine.dart';
11 import 'package:analyzer/src/generated/element.dart';
12
13 /**
14 * A computer for `completion.getSuggestions` request results.
15 */
16 class TopLevelComputer {
17 final SearchEngine searchEngine;
18
19 TopLevelComputer(this.searchEngine);
20
21 /**
22 * Computes [CompletionSuggestion]s for the specified position in the source.
23 */
24 Future<List<CompletionSuggestion>> compute() {
25 var future = searchEngine.searchTopLevelDeclarations('');
26 return future.then((List<SearchMatch> matches) {
27 return matches.map((SearchMatch match) {
28 Element element = match.element;
29 String completion = element.displayName;
30 return new CompletionSuggestion(
31 CompletionSuggestionKind.fromElementKind(element.kind),
32 CompletionRelevance.DEFAULT,
33 completion,
34 completion.length,
35 0,
36 element.isDeprecated,
37 false // isPotential
38 );
39 }).toList();
40 });
41 }
42 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | pkg/analysis_services/test/completion/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698