Chromium Code Reviews| 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..59036ab9387a92bf8b4e11aac77330363c5795d8 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 = new FileBasedSource.con1(new JavaFile(file)); |
|
scheglov
2014/07/31 22:28:47
We don't use FileBasedSource in server directly.
W
danrubel
2014/08/01 16:24:31
Good point. Much better that way. Done.
|
| + 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); |
| } |
| } |