| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library domain.completion; | 5 library domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 ContextSourcePair contextSource = server.getContextSourcePair(params.file); | 188 ContextSourcePair contextSource = server.getContextSourcePair(params.file); |
| 189 AnalysisContext context = contextSource.context; | 189 AnalysisContext context = contextSource.context; |
| 190 Source source = contextSource.source; | 190 Source source = contextSource.source; |
| 191 if (context == null || !context.exists(source)) { | 191 if (context == null || !context.exists(source)) { |
| 192 return new Response.unknownSource(request); | 192 return new Response.unknownSource(request); |
| 193 } | 193 } |
| 194 recordRequest(performance, context, source, params.offset); | 194 recordRequest(performance, context, source, params.offset); |
| 195 if (manager == null) { | 195 if (manager == null) { |
| 196 manager = completionManagerFor(context, source); | 196 manager = completionManagerFor(context, source); |
| 197 } | 197 } |
| 198 CompletionRequest completionRequest = | 198 CompletionRequest completionRequest = new CompletionRequestImpl(context, |
| 199 new CompletionRequestImpl(server, context, source, params.offset); | 199 server.resourceProvider, server.searchEngine, source, params.offset); |
| 200 int notificationCount = 0; | 200 int notificationCount = 0; |
| 201 manager.results(completionRequest).listen((CompletionResult result) { | 201 manager.results(completionRequest).listen((CompletionResult result) { |
| 202 ++notificationCount; | 202 ++notificationCount; |
| 203 bool isLast = result is CompletionResultImpl ? result.isLast : true; | 203 bool isLast = result is CompletionResultImpl ? result.isLast : true; |
| 204 performance.logElapseTime("notification $notificationCount send", () { | 204 performance.logElapseTime("notification $notificationCount send", () { |
| 205 sendCompletionNotification(completionId, result.replacementOffset, | 205 sendCompletionNotification(completionId, result.replacementOffset, |
| 206 result.replacementLength, result.suggestions, isLast); | 206 result.replacementLength, result.suggestions, isLast); |
| 207 }); | 207 }); |
| 208 if (notificationCount == 1) { | 208 if (notificationCount == 1) { |
| 209 performance.logFirstNotificationComplete('notification 1 complete'); | 209 performance.logFirstNotificationComplete('notification 1 complete'); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 if (_sourcesChangedSubscription != null) { | 285 if (_sourcesChangedSubscription != null) { |
| 286 _sourcesChangedSubscription.cancel(); | 286 _sourcesChangedSubscription.cancel(); |
| 287 _sourcesChangedSubscription = null; | 287 _sourcesChangedSubscription = null; |
| 288 } | 288 } |
| 289 if (_manager != null) { | 289 if (_manager != null) { |
| 290 _manager.dispose(); | 290 _manager.dispose(); |
| 291 _manager = null; | 291 _manager = null; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 } | 294 } |
| OLD | NEW |