| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 /** | 167 /** |
| 168 * Process a `completion.getSuggestions` request. | 168 * Process a `completion.getSuggestions` request. |
| 169 */ | 169 */ |
| 170 Response processRequest(Request request, [CompletionManager manager]) { | 170 Response processRequest(Request request, [CompletionManager manager]) { |
| 171 performance = new CompletionPerformance(); | 171 performance = new CompletionPerformance(); |
| 172 // extract params | 172 // extract params |
| 173 CompletionGetSuggestionsParams params = | 173 CompletionGetSuggestionsParams params = |
| 174 new CompletionGetSuggestionsParams.fromRequest(request); | 174 new CompletionGetSuggestionsParams.fromRequest(request); |
| 175 // schedule completion analysis | 175 // schedule completion analysis |
| 176 String completionId = (_nextCompletionId++).toString(); | 176 String completionId = (_nextCompletionId++).toString(); |
| 177 AnalysisContext context = server.getAnalysisContext(params.file); | 177 ContextSourcePair contextSource = server.getContextSourcePair(params.file); |
| 178 Source source = server.getSource(params.file); | 178 AnalysisContext context = contextSource.context; |
| 179 Source source = contextSource.source; |
| 179 recordRequest(performance, context, source, params.offset); | 180 recordRequest(performance, context, source, params.offset); |
| 180 if (manager == null) { | 181 if (manager == null) { |
| 181 manager = completionManagerFor(context, source); | 182 manager = completionManagerFor(context, source); |
| 182 } | 183 } |
| 183 CompletionRequest completionRequest = | 184 CompletionRequest completionRequest = |
| 184 new CompletionRequest(params.offset, performance); | 185 new CompletionRequest(params.offset, performance); |
| 185 int notificationCount = 0; | 186 int notificationCount = 0; |
| 186 manager.results(completionRequest).listen((CompletionResult result) { | 187 manager.results(completionRequest).listen((CompletionResult result) { |
| 187 ++notificationCount; | 188 ++notificationCount; |
| 188 performance.logElapseTime("notification $notificationCount send", () { | 189 performance.logElapseTime("notification $notificationCount send", () { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (_sourcesChangedSubscription != null) { | 267 if (_sourcesChangedSubscription != null) { |
| 267 _sourcesChangedSubscription.cancel(); | 268 _sourcesChangedSubscription.cancel(); |
| 268 _sourcesChangedSubscription = null; | 269 _sourcesChangedSubscription = null; |
| 269 } | 270 } |
| 270 if (_manager != null) { | 271 if (_manager != null) { |
| 271 _manager.dispose(); | 272 _manager.dispose(); |
| 272 _manager = null; | 273 _manager = null; |
| 273 } | 274 } |
| 274 } | 275 } |
| 275 } | 276 } |
| OLD | NEW |