| 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 services.completion.manager; | 5 library services.completion.manager; |
| 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'; | |
| 11 import 'package:analysis_server/src/plugin/server_plugin.dart'; | |
| 12 import 'package:analysis_server/src/provisional/completion/completion_core.dart' | 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' |
| 13 show CompletionRequest, CompletionResult; | 11 show CompletionRequest, CompletionResult; |
| 14 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 12 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 15 import 'package:analysis_server/src/services/search/search_engine.dart'; | 13 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 16 import 'package:analyzer/file_system/file_system.dart'; | |
| 17 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 19 | 16 |
| 20 /** | 17 /** |
| 21 * [CompletionCache] contains information about the prior code completion | 18 * [CompletionCache] contains information about the prior code completion |
| 22 * for use in the next code completion. | 19 * for use in the next code completion. |
| 23 */ | 20 */ |
| 24 abstract class CompletionCache { | 21 abstract class CompletionCache { |
| 25 /** | 22 /** |
| 26 * The context in which the completion was computed. | 23 * The context in which the completion was computed. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 208 } |
| 212 ++end; | 209 ++end; |
| 213 } | 210 } |
| 214 String prefix = contents.substring(start, offset); | 211 String prefix = contents.substring(start, offset); |
| 215 String suffix = contents.substring(offset, end); | 212 String suffix = contents.substring(offset, end); |
| 216 return '$prefix^$suffix'; | 213 return '$prefix^$suffix'; |
| 217 } | 214 } |
| 218 } | 215 } |
| 219 | 216 |
| 220 /** | 217 /** |
| 221 * Encapsulates information specific to a particular completion request. | |
| 222 */ | |
| 223 class CompletionRequestImpl implements CompletionRequest { | |
| 224 /** | |
| 225 * The underlying analysis server for this completion request. | |
| 226 */ | |
| 227 final AnalysisServer server; | |
| 228 | |
| 229 @override | |
| 230 final AnalysisContext context; | |
| 231 | |
| 232 @override | |
| 233 final Source source; | |
| 234 | |
| 235 @override | |
| 236 final int offset; | |
| 237 | |
| 238 CompletionRequestImpl(this.server, this.context, this.source, this.offset); | |
| 239 | |
| 240 @override | |
| 241 ResourceProvider get resourceProvider => server.resourceProvider; | |
| 242 | |
| 243 @override | |
| 244 ServerPlugin get serverPlugin => server.serverPlugin; | |
| 245 } | |
| 246 | |
| 247 /** | |
| 248 * Code completion result generated by an [CompletionManager]. | 218 * Code completion result generated by an [CompletionManager]. |
| 249 */ | 219 */ |
| 250 class CompletionResultImpl implements CompletionResult { | 220 class CompletionResultImpl implements CompletionResult { |
| 251 /** | 221 /** |
| 252 * The length of the text to be replaced if the remainder of the identifier | 222 * The length of the text to be replaced if the remainder of the identifier |
| 253 * containing the cursor is to be replaced when the suggestion is applied | 223 * containing the cursor is to be replaced when the suggestion is applied |
| 254 * (that is, the number of characters in the existing identifier). | 224 * (that is, the number of characters in the existing identifier). |
| 255 */ | 225 */ |
| 256 final int replacementLength; | 226 final int replacementLength; |
| 257 | 227 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 */ | 271 */ |
| 302 final String name; | 272 final String name; |
| 303 | 273 |
| 304 /** | 274 /** |
| 305 * The elapse time or `null` if undefined. | 275 * The elapse time or `null` if undefined. |
| 306 */ | 276 */ |
| 307 final Duration elapsed; | 277 final Duration elapsed; |
| 308 | 278 |
| 309 OperationPerformance(this.name, this.elapsed); | 279 OperationPerformance(this.name, this.elapsed); |
| 310 } | 280 } |
| OLD | NEW |