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/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/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
14 import 'package:analysis_server/src/services/search/search_engine.dart'; | 14 import 'package:analysis_server/src/services/search/search_engine.dart'; |
15 import 'package:analyzer/file_system/file_system.dart'; | 15 import 'package:analyzer/file_system/file_system.dart'; |
16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
18 | 18 |
19 /** | 19 /** |
20 * [CompletionCache] contains information about the prior code completion | 20 * [CompletionCache] contains information about the prior code completion |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 CompletionRequestImpl(this.server, this.context, this.source, this.offset); | 240 CompletionRequestImpl(this.server, this.context, this.source, this.offset); |
241 | 241 |
242 @override | 242 @override |
243 ResourceProvider get resourceProvider => server.resourceProvider; | 243 ResourceProvider get resourceProvider => server.resourceProvider; |
244 } | 244 } |
245 | 245 |
246 /** | 246 /** |
247 * Code completion result generated by an [CompletionManager]. | 247 * Code completion result generated by an [CompletionManager]. |
248 */ | 248 */ |
249 class CompletionResult { | 249 class CompletionResultImpl implements CompletionResult { |
250 | 250 |
251 /** | 251 /** |
252 * The length of the text to be replaced if the remainder of the identifier | 252 * 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 | 253 * containing the cursor is to be replaced when the suggestion is applied |
254 * (that is, the number of characters in the existing identifier). | 254 * (that is, the number of characters in the existing identifier). |
255 */ | 255 */ |
256 final int replacementLength; | 256 final int replacementLength; |
257 | 257 |
258 /** | 258 /** |
259 * The offset of the start of the text to be replaced. This will be different | 259 * The offset of the start of the text to be replaced. This will be different |
260 * than the offset used to request the completion suggestions if there was a | 260 * than the offset used to request the completion suggestions if there was a |
261 * portion of an identifier before the original offset. In particular, the | 261 * portion of an identifier before the original offset. In particular, the |
262 * replacementOffset will be the offset of the beginning of said identifier. | 262 * replacementOffset will be the offset of the beginning of said identifier. |
263 */ | 263 */ |
264 final int replacementOffset; | 264 final int replacementOffset; |
265 | 265 |
266 /** | 266 /** |
267 * The suggested completions. | 267 * The suggested completions. |
268 */ | 268 */ |
269 final List<CompletionSuggestion> suggestions; | 269 final List<CompletionSuggestion> suggestions; |
270 | 270 |
271 /** | 271 /** |
272 * `true` if this is that last set of results that will be returned | 272 * `true` if this is that last set of results that will be returned |
273 * for the indicated completion. | 273 * for the indicated completion. |
274 */ | 274 */ |
275 final bool last; | 275 final bool last; |
276 | 276 |
277 CompletionResult(this.replacementOffset, this.replacementLength, | 277 CompletionResultImpl(this.replacementOffset, this.replacementLength, |
278 this.suggestions, this.last); | 278 this.suggestions, this.last); |
| 279 |
| 280 @override |
| 281 // TODO(brianwilkerson) Figure out whether this is correct. |
| 282 bool get hasNewSuggestions => suggestions.isNotEmpty; |
| 283 |
| 284 @override |
| 285 bool get isLast => last; |
279 } | 286 } |
280 | 287 |
281 class NoOpCompletionManager extends CompletionManager { | 288 class NoOpCompletionManager extends CompletionManager { |
282 NoOpCompletionManager(Source source) : super(null, source); | 289 NoOpCompletionManager(Source source) : super(null, source); |
283 | 290 |
284 @override | 291 @override |
285 void computeSuggestions(CompletionRequest request) { | 292 void computeSuggestions(CompletionRequest request) { |
286 controller.add(new CompletionResult(request.offset, 0, [], true)); | 293 controller.add(new CompletionResultImpl(request.offset, 0, [], true)); |
287 } | 294 } |
288 } | 295 } |
289 | 296 |
290 /** | 297 /** |
291 * The performance of an operation when computing code completion. | 298 * The performance of an operation when computing code completion. |
292 */ | 299 */ |
293 class OperationPerformance { | 300 class OperationPerformance { |
294 | 301 |
295 /** | 302 /** |
296 * The name of the operation | 303 * The name of the operation |
297 */ | 304 */ |
298 final String name; | 305 final String name; |
299 | 306 |
300 /** | 307 /** |
301 * The elapse time or `null` if undefined. | 308 * The elapse time or `null` if undefined. |
302 */ | 309 */ |
303 final Duration elapsed; | 310 final Duration elapsed; |
304 | 311 |
305 OperationPerformance(this.name, this.elapsed); | 312 OperationPerformance(this.name, this.elapsed); |
306 } | 313 } |
OLD | NEW |