| 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/completion/completion_core.dart' | 9 import 'package:analysis_server/completion/completion_core.dart' |
| 10 show CompletionRequest; | 10 show CompletionRequest, CompletionResult; |
| 11 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
| 12 import 'package:analysis_server/src/constants.dart'; | 12 import 'package:analysis_server/src/constants.dart'; |
| 13 import 'package:analysis_server/src/context_manager.dart'; | 13 import 'package:analysis_server/src/context_manager.dart'; |
| 14 import 'package:analysis_server/src/protocol.dart'; | 14 import 'package:analysis_server/src/protocol.dart'; |
| 15 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 15 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 16 import 'package:analysis_server/src/services/search/search_engine.dart'; | 16 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 17 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
| 19 | 19 |
| 20 export 'package:analysis_server/src/services/completion/completion_manager.dart' | 20 export 'package:analysis_server/src/services/completion/completion_manager.dart' |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (manager == null) { | 187 if (manager == null) { |
| 188 manager = completionManagerFor(context, source); | 188 manager = completionManagerFor(context, source); |
| 189 } | 189 } |
| 190 CompletionRequest completionRequest = | 190 CompletionRequest completionRequest = |
| 191 new CompletionRequestImpl(server, context, source, params.offset); | 191 new CompletionRequestImpl(server, context, source, params.offset); |
| 192 int notificationCount = 0; | 192 int notificationCount = 0; |
| 193 manager.results(completionRequest).listen((CompletionResult result) { | 193 manager.results(completionRequest).listen((CompletionResult result) { |
| 194 ++notificationCount; | 194 ++notificationCount; |
| 195 performance.logElapseTime("notification $notificationCount send", () { | 195 performance.logElapseTime("notification $notificationCount send", () { |
| 196 sendCompletionNotification(completionId, result.replacementOffset, | 196 sendCompletionNotification(completionId, result.replacementOffset, |
| 197 result.replacementLength, result.suggestions, result.last); | 197 result.replacementLength, result.suggestions, result.isLast); |
| 198 }); | 198 }); |
| 199 if (notificationCount == 1) { | 199 if (notificationCount == 1) { |
| 200 performance.logFirstNotificationComplete('notification 1 complete'); | 200 performance.logFirstNotificationComplete('notification 1 complete'); |
| 201 performance.suggestionCountFirst = result.suggestions.length; | 201 performance.suggestionCountFirst = result.suggestions.length; |
| 202 } | 202 } |
| 203 if (result.last) { | 203 if (result.isLast) { |
| 204 performance.notificationCount = notificationCount; | 204 performance.notificationCount = notificationCount; |
| 205 performance.suggestionCountLast = result.suggestions.length; | 205 performance.suggestionCountLast = result.suggestions.length; |
| 206 performance.complete(); | 206 performance.complete(); |
| 207 } | 207 } |
| 208 }); | 208 }); |
| 209 // initial response without results | 209 // initial response without results |
| 210 return new CompletionGetSuggestionsResult(completionId) | 210 return new CompletionGetSuggestionsResult(completionId) |
| 211 .toResponse(request.id); | 211 .toResponse(request.id); |
| 212 } | 212 } |
| 213 | 213 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 if (_sourcesChangedSubscription != null) { | 273 if (_sourcesChangedSubscription != null) { |
| 274 _sourcesChangedSubscription.cancel(); | 274 _sourcesChangedSubscription.cancel(); |
| 275 _sourcesChangedSubscription = null; | 275 _sourcesChangedSubscription = null; |
| 276 } | 276 } |
| 277 if (_manager != null) { | 277 if (_manager != null) { |
| 278 _manager.dispose(); | 278 _manager.dispose(); |
| 279 _manager = null; | 279 _manager = null; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 } | 282 } |
| OLD | NEW |