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

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

Issue 1369033002: Completions with exact prefix should be prioritized - fixes #23099 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/completion_test_util.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.contributor.dart.local; 5 library services.completion.contributor.dart.local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 344 }
345 } 345 }
346 346
347 /** 347 /**
348 * A visitor for collecting suggestions from the most specific child [AstNode] 348 * A visitor for collecting suggestions from the most specific child [AstNode]
349 * that contains the completion offset to the [CompilationUnit]. 349 * that contains the completion offset to the [CompilationUnit].
350 */ 350 */
351 class _LocalVisitor extends LocalDeclarationVisitor { 351 class _LocalVisitor extends LocalDeclarationVisitor {
352 final DartCompletionRequest request; 352 final DartCompletionRequest request;
353 final OpType optype; 353 final OpType optype;
354 int privateMemberRelevance = DART_RELEVANCE_DEFAULT;
354 355
355 _LocalVisitor(this.request, int offset, this.optype) : super(offset) { 356 _LocalVisitor(this.request, int offset, this.optype) : super(offset) {
356 includeLocalInheritedTypes = !optype.inStaticMethodBody; 357 includeLocalInheritedTypes = !optype.inStaticMethodBody;
358 if (request.replacementLength > 0) {
359 var contents = request.source.contents;
360 if (contents != null &&
361 contents.data != null &&
362 contents.data.startsWith('_', request.replacementOffset)) {
363 // If user typed identifier starting with '_'
364 // then do not suppress the relevance of private members
365 privateMemberRelevance = null;
366 }
367 }
357 } 368 }
358 369
359 @override 370 @override
360 void declaredClass(ClassDeclaration declaration) { 371 void declaredClass(ClassDeclaration declaration) {
361 if (optype.includeTypeNameSuggestions) { 372 if (optype.includeTypeNameSuggestions) {
362 _addSuggestion( 373 _addSuggestion(
363 declaration.name, NO_RETURN_TYPE, protocol.ElementKind.CLASS, 374 declaration.name, NO_RETURN_TYPE, protocol.ElementKind.CLASS,
364 isAbstract: declaration.isAbstract, 375 isAbstract: declaration.isAbstract,
365 isDeprecated: isDeprecated(declaration)); 376 isDeprecated: isDeprecated(declaration));
366 } 377 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 SimpleIdentifier id, TypeName typeName, protocol.ElementKind elemKind, 558 SimpleIdentifier id, TypeName typeName, protocol.ElementKind elemKind,
548 {bool isAbstract: false, 559 {bool isAbstract: false,
549 bool isDeprecated: false, 560 bool isDeprecated: false,
550 ClassDeclaration classDecl, 561 ClassDeclaration classDecl,
551 FormalParameterList param, 562 FormalParameterList param,
552 int relevance: DART_RELEVANCE_DEFAULT}) { 563 int relevance: DART_RELEVANCE_DEFAULT}) {
553 CompletionSuggestion suggestion = createSuggestion( 564 CompletionSuggestion suggestion = createSuggestion(
554 id, isDeprecated, relevance, typeName, 565 id, isDeprecated, relevance, typeName,
555 classDecl: classDecl); 566 classDecl: classDecl);
556 if (suggestion != null) { 567 if (suggestion != null) {
568 if (privateMemberRelevance != null &&
569 suggestion.completion.startsWith('_')) {
570 suggestion.relevance = privateMemberRelevance;
571 }
557 request.addSuggestion(suggestion); 572 request.addSuggestion(suggestion);
558 suggestion.element = createElement(request.source, elemKind, id, 573 suggestion.element = createElement(request.source, elemKind, id,
559 isAbstract: isAbstract, 574 isAbstract: isAbstract,
560 isDeprecated: isDeprecated, 575 isDeprecated: isDeprecated,
561 parameters: param != null ? param.toSource() : null, 576 parameters: param != null ? param.toSource() : null,
562 returnType: typeName); 577 returnType: typeName);
563 if ((elemKind == protocol.ElementKind.METHOD || 578 if ((elemKind == protocol.ElementKind.METHOD ||
564 elemKind == protocol.ElementKind.FUNCTION) && 579 elemKind == protocol.ElementKind.FUNCTION) &&
565 param != null) { 580 param != null) {
566 _addParameterInfo(suggestion, param); 581 _addParameterInfo(suggestion, param);
567 } 582 }
568 } 583 }
569 } 584 }
570 585
571 bool _isVoid(TypeName returnType) { 586 bool _isVoid(TypeName returnType) {
572 if (returnType != null) { 587 if (returnType != null) {
573 Identifier id = returnType.name; 588 Identifier id = returnType.name;
574 if (id != null && id.name == 'void') { 589 if (id != null && id.name == 'void') {
575 return true; 590 return true;
576 } 591 }
577 } 592 }
578 return false; 593 return false;
579 } 594 }
580 } 595 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/completion_test_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698