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/completion/completion_core.dart' | 9 import 'package:analysis_server/completion/completion_core.dart' |
10 show CompletionRequest; | 10 show CompletionRequest; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 /** | 316 /** |
317 * The set of completions used to prevent duplicates | 317 * The set of completions used to prevent duplicates |
318 */ | 318 */ |
319 final Set<String> _completions = new Set<String>(); | 319 final Set<String> _completions = new Set<String>(); |
320 | 320 |
321 DartCompletionRequest(AnalysisServer server, AnalysisContext context, | 321 DartCompletionRequest(AnalysisServer server, AnalysisContext context, |
322 Source source, int offset, this.cache) | 322 Source source, int offset, this.cache) |
323 : super(server, context, source, offset); | 323 : super(server, context, source, offset); |
324 | 324 |
325 factory DartCompletionRequest.from(CompletionRequestImpl request, | 325 factory DartCompletionRequest.from( |
326 DartCompletionCache cache) => new DartCompletionRequest( | 326 CompletionRequestImpl request, DartCompletionCache cache) => |
327 request.server, request.context, request.source, request.offset, cache); | 327 new DartCompletionRequest(request.server, request.context, request.source, |
| 328 request.offset, cache); |
328 | 329 |
329 /** | 330 /** |
330 * Return the original text from the [replacementOffset] to the [offset] | 331 * Return the original text from the [replacementOffset] to the [offset] |
331 * that can be used to filter the suggestions on the server side. | 332 * that can be used to filter the suggestions on the server side. |
332 */ | 333 */ |
333 String get filterText { | 334 String get filterText { |
334 return context.getContents(source).data.substring( | 335 return context |
335 replacementOffset, offset); | 336 .getContents(source) |
| 337 .data |
| 338 .substring(replacementOffset, offset); |
336 } | 339 } |
337 | 340 |
338 /** | 341 /** |
339 * Information about the types of suggestions that should be included. | 342 * Information about the types of suggestions that should be included. |
340 * The [target] must be set first. | 343 * The [target] must be set first. |
341 */ | 344 */ |
342 OpType get optype { | 345 OpType get optype { |
343 if (_optype == null) { | 346 if (_optype == null) { |
344 _optype = new OpType.forCompletion(target, offset); | 347 _optype = new OpType.forCompletion(target, offset); |
345 } | 348 } |
(...skipping 25 matching lines...) Expand all Loading... |
371 * to [CompletionSuggestionKind.IDENTIFIER] suggestions. | 374 * to [CompletionSuggestionKind.IDENTIFIER] suggestions. |
372 */ | 375 */ |
373 void convertInvocationsToIdentifiers() { | 376 void convertInvocationsToIdentifiers() { |
374 for (int index = _suggestions.length - 1; index >= 0; --index) { | 377 for (int index = _suggestions.length - 1; index >= 0; --index) { |
375 CompletionSuggestion suggestion = _suggestions[index]; | 378 CompletionSuggestion suggestion = _suggestions[index]; |
376 if (suggestion.kind == CompletionSuggestionKind.INVOCATION) { | 379 if (suggestion.kind == CompletionSuggestionKind.INVOCATION) { |
377 // Create a copy rather than just modifying the existing suggestion | 380 // Create a copy rather than just modifying the existing suggestion |
378 // because [DartCompletionCache] may be caching that suggestion | 381 // because [DartCompletionCache] may be caching that suggestion |
379 // for future completion requests | 382 // for future completion requests |
380 _suggestions[index] = new CompletionSuggestion( | 383 _suggestions[index] = new CompletionSuggestion( |
381 CompletionSuggestionKind.IDENTIFIER, suggestion.relevance, | 384 CompletionSuggestionKind.IDENTIFIER, |
382 suggestion.completion, suggestion.selectionOffset, | 385 suggestion.relevance, |
383 suggestion.selectionLength, suggestion.isDeprecated, | 386 suggestion.completion, |
| 387 suggestion.selectionOffset, |
| 388 suggestion.selectionLength, |
| 389 suggestion.isDeprecated, |
384 suggestion.isPotential, | 390 suggestion.isPotential, |
385 declaringType: suggestion.declaringType, | 391 declaringType: suggestion.declaringType, |
386 parameterNames: suggestion.parameterNames, | 392 parameterNames: suggestion.parameterNames, |
387 parameterTypes: suggestion.parameterTypes, | 393 parameterTypes: suggestion.parameterTypes, |
388 requiredParameterCount: suggestion.requiredParameterCount, | 394 requiredParameterCount: suggestion.requiredParameterCount, |
389 hasNamedParameters: suggestion.hasNamedParameters, | 395 hasNamedParameters: suggestion.hasNamedParameters, |
390 returnType: suggestion.returnType, | 396 returnType: suggestion.returnType, |
391 element: suggestion.element); | 397 element: suggestion.element); |
392 } | 398 } |
393 } | 399 } |
394 } | 400 } |
395 } | 401 } |
OLD | NEW |