| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 /** | 51 /** |
| 52 * A list of code completion peformance measurements for the latest | 52 * A list of code completion peformance measurements for the latest |
| 53 * completion operation up to [performanceListMaxLength] measurements. | 53 * completion operation up to [performanceListMaxLength] measurements. |
| 54 */ | 54 */ |
| 55 final List<CompletionPerformance> performanceList = | 55 final List<CompletionPerformance> performanceList = |
| 56 new List<CompletionPerformance>(); | 56 new List<CompletionPerformance>(); |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * The maximum number of performance measurements to keep. | 59 * The maximum number of performance measurements to keep. |
| 60 */ | 60 */ |
| 61 static const int performanceListMaxLength = 0; | 61 static const int performanceListMaxLength = 50; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Performance for the last priority change event. | 64 * Performance for the last priority change event. |
| 65 */ | 65 */ |
| 66 CompletionPerformance priorityChangedPerformance; | 66 CompletionPerformance priorityChangedPerformance; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Initialize a new request handler for the given [server]. | 69 * Initialize a new request handler for the given [server]. |
| 70 */ | 70 */ |
| 71 CompletionDomainHandler(this.server) { | 71 CompletionDomainHandler(this.server) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 completionId).toResponse(request.id); | 197 completionId).toResponse(request.id); |
| 198 } | 198 } |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * If tracking code completion performance over time, then | 201 * If tracking code completion performance over time, then |
| 202 * record addition information about the request in the performance record. | 202 * record addition information about the request in the performance record. |
| 203 */ | 203 */ |
| 204 void recordRequest(CompletionPerformance performance, AnalysisContext context, | 204 void recordRequest(CompletionPerformance performance, AnalysisContext context, |
| 205 Source source, int offset) { | 205 Source source, int offset) { |
| 206 performance.source = source; | 206 performance.source = source; |
| 207 performance.offset = offset; | |
| 208 if (priorityChangedPerformance != null && | 207 if (priorityChangedPerformance != null && |
| 209 priorityChangedPerformance.source != source) { | 208 priorityChangedPerformance.source != source) { |
| 210 priorityChangedPerformance = null; | 209 priorityChangedPerformance = null; |
| 211 } | 210 } |
| 212 if (performanceListMaxLength == 0 || context == null || source == null) { | 211 if (performanceListMaxLength == 0 || context == null || source == null) { |
| 213 return; | 212 return; |
| 214 } | 213 } |
| 215 TimestampedData<String> data = context.getContents(source); | 214 TimestampedData<String> data = context.getContents(source); |
| 216 if (data == null) { | 215 if (data == null) { |
| 217 return; | 216 return; |
| 218 } | 217 } |
| 219 performance.contents = data.data; | 218 performance.setContentsAndOffset(data.data, offset); |
| 220 while (performanceList.length >= performanceListMaxLength) { | 219 while (performanceList.length >= performanceListMaxLength) { |
| 221 performanceList.removeAt(0); | 220 performanceList.removeAt(0); |
| 222 } | 221 } |
| 223 performanceList.add(performance); | 222 performanceList.add(performance); |
| 224 } | 223 } |
| 225 | 224 |
| 226 /** | 225 /** |
| 227 * Send completion notification results. | 226 * Send completion notification results. |
| 228 */ | 227 */ |
| 229 void sendCompletionNotification(String completionId, int replacementOffset, | 228 void sendCompletionNotification(String completionId, int replacementOffset, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (_sourcesChangedSubscription != null) { | 266 if (_sourcesChangedSubscription != null) { |
| 268 _sourcesChangedSubscription.cancel(); | 267 _sourcesChangedSubscription.cancel(); |
| 269 _sourcesChangedSubscription = null; | 268 _sourcesChangedSubscription = null; |
| 270 } | 269 } |
| 271 if (_manager != null) { | 270 if (_manager != null) { |
| 272 _manager.dispose(); | 271 _manager.dispose(); |
| 273 _manager = null; | 272 _manager = null; |
| 274 } | 273 } |
| 275 } | 274 } |
| 276 } | 275 } |
| OLD | NEW |