| 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/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 String completionId = (_nextCompletionId++).toString(); | 168 String completionId = (_nextCompletionId++).toString(); |
| 169 AnalysisContext context = server.getAnalysisContext(params.file); | 169 AnalysisContext context = server.getAnalysisContext(params.file); |
| 170 Source source = server.getSource(params.file); | 170 Source source = server.getSource(params.file); |
| 171 recordRequest(performance, context, source, params.offset); | 171 recordRequest(performance, context, source, params.offset); |
| 172 CompletionManager manager = completionManagerFor(context, source); | 172 CompletionManager manager = completionManagerFor(context, source); |
| 173 CompletionRequest completionRequest = | 173 CompletionRequest completionRequest = |
| 174 new CompletionRequest(params.offset, performance); | 174 new CompletionRequest(params.offset, performance); |
| 175 int notificationCount = 0; | 175 int notificationCount = 0; |
| 176 manager.results(completionRequest).listen((CompletionResult result) { | 176 manager.results(completionRequest).listen((CompletionResult result) { |
| 177 ++notificationCount; | 177 ++notificationCount; |
| 178 performance.logElapseTime("notification $notificationCount", () { | 178 performance.logElapseTime("notification $notificationCount send", () { |
| 179 sendCompletionNotification( | 179 sendCompletionNotification( |
| 180 completionId, | 180 completionId, |
| 181 result.replacementOffset, | 181 result.replacementOffset, |
| 182 result.replacementLength, | 182 result.replacementLength, |
| 183 result.suggestions, | 183 result.suggestions, |
| 184 result.last); | 184 result.last); |
| 185 }); | 185 }); |
| 186 if (notificationCount == 1) { |
| 187 performance.logFirstNotificationComplete('notification 1 complete'); |
| 188 } |
| 186 if (result.last) { | 189 if (result.last) { |
| 187 performance.notificationCount = notificationCount; | 190 performance.notificationCount = notificationCount; |
| 188 performance.suggestionCount = result.suggestions.length; | 191 performance.suggestionCount = result.suggestions.length; |
| 189 performance.complete(); | 192 performance.complete(); |
| 190 } | 193 } |
| 191 }); | 194 }); |
| 192 // initial response without results | 195 // initial response without results |
| 193 return new CompletionGetSuggestionsResult( | 196 return new CompletionGetSuggestionsResult( |
| 194 completionId).toResponse(request.id); | 197 completionId).toResponse(request.id); |
| 195 } | 198 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (_sourcesChangedSubscription != null) { | 267 if (_sourcesChangedSubscription != null) { |
| 265 _sourcesChangedSubscription.cancel(); | 268 _sourcesChangedSubscription.cancel(); |
| 266 _sourcesChangedSubscription = null; | 269 _sourcesChangedSubscription = null; |
| 267 } | 270 } |
| 268 if (_manager != null) { | 271 if (_manager != null) { |
| 269 _manager.dispose(); | 272 _manager.dispose(); |
| 270 _manager = null; | 273 _manager = null; |
| 271 } | 274 } |
| 272 } | 275 } |
| 273 } | 276 } |
| OLD | NEW |