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

Unified Diff: pkg/analysis_server/lib/src/domain_completion.dart

Issue 424543004: incremental progress aligning code completion api to spec (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments 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 | « no previous file | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/domain_completion.dart
diff --git a/pkg/analysis_server/lib/src/domain_completion.dart b/pkg/analysis_server/lib/src/domain_completion.dart
index 7d000c15bf8e3ebed0af2d0005e5514fc5da1475..2a70a9498800d07746092477dc939e49cfd49fc3 100644
--- a/pkg/analysis_server/lib/src/domain_completion.dart
+++ b/pkg/analysis_server/lib/src/domain_completion.dart
@@ -7,10 +7,11 @@ library domain.completion;
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
-import 'package:analysis_services/completion/completion_suggestion.dart';
import 'package:analysis_services/completion/completion_computer.dart';
+import 'package:analysis_services/completion/completion_suggestion.dart';
import 'package:analysis_services/constants.dart';
-import 'package:analysis_services/search/search_engine.dart';
+import 'package:analyzer/src/generated/java_io.dart';
+import 'package:analyzer/src/generated/source_io.dart';
/**
* Instances of the class [CompletionDomainHandler] implement a [RequestHandler]
@@ -23,11 +24,6 @@ class CompletionDomainHandler implements RequestHandler {
final AnalysisServer server;
/**
- * The [SearchEngine] for this server.
- */
- SearchEngine searchEngine;
-
- /**
* The next completion response id.
*/
int _nextCompletionId = 0;
@@ -59,14 +55,22 @@ class CompletionDomainHandler implements RequestHandler {
int offset = request.getRequiredParameter(OFFSET).asInt();
// schedule completion analysis
String completionId = (_nextCompletionId++).toString();
- CompletionComputer.create(server.searchEngine).then((computers) {
+ Source source = server.getSource(file);
+ CompletionManager manager =
+ CompletionManager.create(source, offset, server.searchEngine);
+ manager.generate().then((List<CompletionComputer> computers) {
int count = computers.length;
List<CompletionSuggestion> results = new List<CompletionSuggestion>();
computers.forEach((CompletionComputer c) {
c.compute().then((List<CompletionSuggestion> partialResults) {
// send aggregate results as we compute them
results.addAll(partialResults);
- sendCompletionNotification(completionId, --count == 0, results);
+ sendCompletionNotification(
+ manager.replacementOffset,
+ manager.replacementLength,
+ completionId,
+ --count == 0,
+ results);
});
});
});
@@ -77,12 +81,14 @@ class CompletionDomainHandler implements RequestHandler {
/**
* Send completion notification results.
*/
- void sendCompletionNotification(String completionId, bool isLast,
- Iterable<CompletionSuggestion> results) {
+ void sendCompletionNotification(int replacementOffset, int replacementLength,
+ String completionId, bool isLast, Iterable<CompletionSuggestion> results) {
Notification notification = new Notification(COMPLETION_RESULTS);
notification.setParameter(ID, completionId);
- notification.setParameter(LAST, isLast);
+ notification.setParameter(REPLACEMENT_OFFSET, replacementOffset);
+ notification.setParameter(REPLACEMENT_LENGTH, replacementLength);
notification.setParameter(RESULTS, results);
+ notification.setParameter(LAST, isLast);
server.sendNotification(notification);
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698