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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_services/lib/completion/top_level_computer.dart
diff --git a/pkg/analysis_services/lib/completion/top_level_computer.dart b/pkg/analysis_services/lib/completion/top_level_computer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5416e17631f155b00b5aa2207729aabcebffffb1
--- /dev/null
+++ b/pkg/analysis_services/lib/completion/top_level_computer.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library services.completion.computer.toplevel;
+
+import 'dart:async';
+
+import 'package:analysis_services/completion/completion_suggestion.dart';
+import 'package:analysis_services/search/search_engine.dart';
+import 'package:analyzer/src/generated/element.dart';
+
+/**
+ * A computer for `completion.getSuggestions` request results.
+ */
+class TopLevelComputer {
+ final SearchEngine searchEngine;
+
+ TopLevelComputer(this.searchEngine);
+
+ /**
+ * Computes [CompletionSuggestion]s for the specified position in the source.
+ */
+ Future<List<CompletionSuggestion>> compute() {
+ var future = searchEngine.searchTopLevelDeclarations('');
+ return future.then((List<SearchMatch> matches) {
+ return matches.map((SearchMatch match) {
+ Element element = match.element;
+ String completion = element.displayName;
+ return new CompletionSuggestion(
+ CompletionSuggestionKind.fromElementKind(element.kind),
+ CompletionRelevance.DEFAULT,
+ completion,
+ completion.length,
+ 0,
+ element.isDeprecated,
+ false // isPotential
+ );
+ }).toList();
+ });
+ }
+}
« 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