| 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.dart; | 5 library services.completion.dart; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/arglist_computer.dart'; | 10 import 'package:analysis_server/src/services/completion/arglist_computer.dart'; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 * containing the cursor is to be replaced when the suggestion is applied | 258 * containing the cursor is to be replaced when the suggestion is applied |
| 259 * (that is, the number of characters in the existing identifier). | 259 * (that is, the number of characters in the existing identifier). |
| 260 */ | 260 */ |
| 261 int replacementLength; | 261 int replacementLength; |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * The list of suggestions to be sent to the client. | 264 * The list of suggestions to be sent to the client. |
| 265 */ | 265 */ |
| 266 final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; | 266 final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; |
| 267 | 267 |
| 268 /** |
| 269 * Return the original text from the [replacementOffset] to the [offset] |
| 270 * that can be used to filter the suggestions on the server side. |
| 271 */ |
| 272 String get filterText { |
| 273 return context.getContents(source).data.substring(replacementOffset, offset)
; |
| 274 } |
| 275 |
| 268 DartCompletionRequest(this.context, this.searchEngine, this.source, | 276 DartCompletionRequest(this.context, this.searchEngine, this.source, |
| 269 int offset, this.cache, CompletionPerformance performance) | 277 int offset, this.cache, CompletionPerformance performance) |
| 270 : super(offset, performance); | 278 : super(offset, performance); |
| 271 } | 279 } |
| 272 | 280 |
| 273 /** | 281 /** |
| 274 * Visitor used to determine the replacement offset and length | 282 * Visitor used to determine the replacement offset and length |
| 275 * based upon the cursor location. | 283 * based upon the cursor location. |
| 276 */ | 284 */ |
| 277 class _ReplacementOffsetBuilder extends SimpleAstVisitor { | 285 class _ReplacementOffsetBuilder extends SimpleAstVisitor { |
| 278 final DartCompletionRequest request; | 286 final DartCompletionRequest request; |
| 279 | 287 |
| 280 _ReplacementOffsetBuilder(this.request) { | 288 _ReplacementOffsetBuilder(this.request) { |
| 281 request.replacementOffset = request.offset; | 289 request.replacementOffset = request.offset; |
| 282 request.replacementLength = 0; | 290 request.replacementLength = 0; |
| 283 } | 291 } |
| 284 | 292 |
| 285 visitSimpleIdentifier(SimpleIdentifier node) { | 293 visitSimpleIdentifier(SimpleIdentifier node) { |
| 286 request.replacementOffset = node.offset; | 294 request.replacementOffset = node.offset; |
| 287 request.replacementLength = node.length; | 295 request.replacementLength = node.length; |
| 288 } | 296 } |
| 289 } | 297 } |
| OLD | NEW |