Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart

Issue 1004343002: Completion should not show overridden inherited methods (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 /** 310 /**
311 * The length of the text to be replaced if the remainder of the identifier 311 * The length of the text to be replaced if the remainder of the identifier
312 * containing the cursor is to be replaced when the suggestion is applied 312 * containing the cursor is to be replaced when the suggestion is applied
313 * (that is, the number of characters in the existing identifier). 313 * (that is, the number of characters in the existing identifier).
314 */ 314 */
315 int replacementLength; 315 int replacementLength;
316 316
317 /** 317 /**
318 * The list of suggestions to be sent to the client. 318 * The list of suggestions to be sent to the client.
319 */ 319 */
320 final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; 320 final List<CompletionSuggestion> _suggestions = <CompletionSuggestion>[];
321
322 /**
323 * The set of completions used to prevent duplicates
324 */
325 final Set<String> _completions = new Set<String>();
321 326
322 DartCompletionRequest(this.context, this.searchEngine, this.source, 327 DartCompletionRequest(this.context, this.searchEngine, this.source,
323 int offset, this.cache, CompletionPerformance performance) 328 int offset, this.cache, CompletionPerformance performance)
324 : super(offset, performance); 329 : super(offset, performance);
325 330
326 /** 331 /**
327 * Return the original text from the [replacementOffset] to the [offset] 332 * Return the original text from the [replacementOffset] to the [offset]
328 * that can be used to filter the suggestions on the server side. 333 * that can be used to filter the suggestions on the server side.
329 */ 334 */
330 String get filterText { 335 String get filterText {
331 return context.getContents(source).data.substring( 336 return context.getContents(source).data.substring(
332 replacementOffset, offset); 337 replacementOffset, offset);
333 } 338 }
334 339
335 /** 340 /**
336 * Information about the types of suggestions that should be included. 341 * Information about the types of suggestions that should be included.
337 * The [target] must be set first. 342 * The [target] must be set first.
338 */ 343 */
339 OpType get optype { 344 OpType get optype {
340 if (_optype == null) { 345 if (_optype == null) {
341 _optype = new OpType.forCompletion(target, offset); 346 _optype = new OpType.forCompletion(target, offset);
342 } 347 }
343 return _optype; 348 return _optype;
344 } 349 }
345 350
346 /** 351 /**
352 * The list of suggestions to be sent to the client.
353 */
354 Iterable<CompletionSuggestion> get suggestions => _suggestions;
355
356 /**
357 * Add the given suggestion to the list that is returned to the client as long
358 * as a suggestion with an identical completion has not already been added.
359 */
360 void addSuggestion(CompletionSuggestion suggestion) {
361 if (_completions.add(suggestion.completion)) {
362 _suggestions.add(suggestion);
363 }
364 }
365
366 /**
347 * Convert all [CompletionSuggestionKind.INVOCATION] suggestions 367 * Convert all [CompletionSuggestionKind.INVOCATION] suggestions
348 * to [CompletionSuggestionKind.IDENTIFIER] suggestions. 368 * to [CompletionSuggestionKind.IDENTIFIER] suggestions.
349 */ 369 */
350 void convertInvocationsToIdentifiers() { 370 void convertInvocationsToIdentifiers() {
351 for (int index = suggestions.length - 1; index >= 0; --index) { 371 for (int index = _suggestions.length - 1; index >= 0; --index) {
352 CompletionSuggestion suggestion = suggestions[index]; 372 CompletionSuggestion suggestion = _suggestions[index];
353 if (suggestion.kind == CompletionSuggestionKind.INVOCATION) { 373 if (suggestion.kind == CompletionSuggestionKind.INVOCATION) {
354 // Create a copy rather than just modifying the existing suggestion 374 // Create a copy rather than just modifying the existing suggestion
355 // because [DartCompletionCache] may be caching that suggestion 375 // because [DartCompletionCache] may be caching that suggestion
356 // for future completion requests 376 // for future completion requests
357 suggestions[index] = new CompletionSuggestion( 377 _suggestions[index] = new CompletionSuggestion(
358 CompletionSuggestionKind.IDENTIFIER, suggestion.relevance, 378 CompletionSuggestionKind.IDENTIFIER, suggestion.relevance,
359 suggestion.completion, suggestion.selectionOffset, 379 suggestion.completion, suggestion.selectionOffset,
360 suggestion.selectionLength, suggestion.isDeprecated, 380 suggestion.selectionLength, suggestion.isDeprecated,
361 suggestion.isPotential, 381 suggestion.isPotential,
362 declaringType: suggestion.declaringType, 382 declaringType: suggestion.declaringType,
363 parameterNames: suggestion.parameterNames, 383 parameterNames: suggestion.parameterNames,
364 parameterTypes: suggestion.parameterTypes, 384 parameterTypes: suggestion.parameterTypes,
365 requiredParameterCount: suggestion.requiredParameterCount, 385 requiredParameterCount: suggestion.requiredParameterCount,
366 hasNamedParameters: suggestion.hasNamedParameters, 386 hasNamedParameters: suggestion.hasNamedParameters,
367 returnType: suggestion.returnType, 387 returnType: suggestion.returnType,
368 element: suggestion.element); 388 element: suggestion.element);
369 } 389 }
370 } 390 }
371 } 391 }
372 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698