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

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

Issue 1338173002: Add a completion for inherited methods (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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/completion/completion_core.dart' 9 import 'package:analysis_server/completion/completion_core.dart'
10 show CompletionRequest; 10 show CompletionRequest;
11 import 'package:analysis_server/completion/completion_dart.dart' as newApi;
11 import 'package:analysis_server/src/analysis_server.dart'; 12 import 'package:analysis_server/src/analysis_server.dart';
12 import 'package:analysis_server/src/protocol.dart'; 13 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analysis_server/src/services/completion/arglist_contributor.dart '; 14 import 'package:analysis_server/src/services/completion/arglist_contributor.dart ';
14 import 'package:analysis_server/src/services/completion/combinator_contributor.d art'; 15 import 'package:analysis_server/src/services/completion/combinator_contributor.d art';
15 import 'package:analysis_server/src/services/completion/common_usage_computer.da rt'; 16 import 'package:analysis_server/src/services/completion/common_usage_computer.da rt';
16 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 17 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
17 import 'package:analysis_server/src/services/completion/completion_target.dart'; 18 import 'package:analysis_server/src/services/completion/completion_target.dart';
18 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 19 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
19 import 'package:analysis_server/src/services/completion/uri_contributor.dart';
20 import 'package:analysis_server/src/services/completion/imported_reference_contr ibutor.dart'; 20 import 'package:analysis_server/src/services/completion/imported_reference_contr ibutor.dart';
21 import 'package:analysis_server/src/services/completion/inherited_computer.dart' ;
21 import 'package:analysis_server/src/services/completion/keyword_contributor.dart '; 22 import 'package:analysis_server/src/services/completion/keyword_contributor.dart ';
22 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart'; 23 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart';
23 import 'package:analysis_server/src/services/completion/optype.dart'; 24 import 'package:analysis_server/src/services/completion/optype.dart';
24 import 'package:analysis_server/src/services/completion/prefixed_element_contrib utor.dart'; 25 import 'package:analysis_server/src/services/completion/prefixed_element_contrib utor.dart';
26 import 'package:analysis_server/src/services/completion/uri_contributor.dart';
25 import 'package:analysis_server/src/services/search/search_engine.dart'; 27 import 'package:analysis_server/src/services/search/search_engine.dart';
28 import 'package:analyzer/file_system/file_system.dart';
26 import 'package:analyzer/src/generated/ast.dart'; 29 import 'package:analyzer/src/generated/ast.dart';
27 import 'package:analyzer/src/generated/engine.dart'; 30 import 'package:analyzer/src/generated/engine.dart';
28 import 'package:analyzer/src/generated/scanner.dart'; 31 import 'package:analyzer/src/generated/scanner.dart';
29 import 'package:analyzer/src/generated/source.dart'; 32 import 'package:analyzer/src/generated/source.dart';
30 33
31 const int DART_RELEVANCE_COMMON_USAGE = 1200; 34 const int DART_RELEVANCE_COMMON_USAGE = 1200;
32 const int DART_RELEVANCE_DEFAULT = 1000; 35 const int DART_RELEVANCE_DEFAULT = 1000;
33 const int DART_RELEVANCE_HIGH = 2000; 36 const int DART_RELEVANCE_HIGH = 2000;
34 const int DART_RELEVANCE_INHERITED_ACCESSOR = 1057; 37 const int DART_RELEVANCE_INHERITED_ACCESSOR = 1057;
35 const int DART_RELEVANCE_INHERITED_FIELD = 1058; 38 const int DART_RELEVANCE_INHERITED_FIELD = 1058;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // LocalReferenceContributor before ImportedReferenceContributor 89 // LocalReferenceContributor before ImportedReferenceContributor
87 // because local suggestions take precedence 90 // because local suggestions take precedence
88 // and can hide other suggestions with the same name 91 // and can hide other suggestions with the same name
89 new LocalReferenceContributor(), 92 new LocalReferenceContributor(),
90 new ImportedReferenceContributor(), 93 new ImportedReferenceContributor(),
91 new KeywordContributor(), 94 new KeywordContributor(),
92 new ArgListContributor(), 95 new ArgListContributor(),
93 new CombinatorContributor(), 96 new CombinatorContributor(),
94 new PrefixedElementContributor(), 97 new PrefixedElementContributor(),
95 new UriContributor(), 98 new UriContributor(),
99 // TODO(brianwilkerson) Use the completion contributor extension point
100 // to add the contributor below (and eventually, all the contributors).
101 new NewCompletionWrapper(new InheritedContributor())
danrubel 2015/09/18 00:30:54 Please comment this line out for now and commit th
Brian Wilkerson 2015/09/18 15:59:26 Done
96 ]; 102 ];
97 } 103 }
98 if (commonUsageComputer == null) { 104 if (commonUsageComputer == null) {
99 commonUsageComputer = new CommonUsageComputer(); 105 commonUsageComputer = new CommonUsageComputer();
100 } 106 }
101 } 107 }
102 108
103 /** 109 /**
104 * Create a new initialized Dart source completion manager 110 * Create a new initialized Dart source completion manager
105 */ 111 */
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 parameterNames: suggestion.parameterNames, 398 parameterNames: suggestion.parameterNames,
393 parameterTypes: suggestion.parameterTypes, 399 parameterTypes: suggestion.parameterTypes,
394 requiredParameterCount: suggestion.requiredParameterCount, 400 requiredParameterCount: suggestion.requiredParameterCount,
395 hasNamedParameters: suggestion.hasNamedParameters, 401 hasNamedParameters: suggestion.hasNamedParameters,
396 returnType: suggestion.returnType, 402 returnType: suggestion.returnType,
397 element: suggestion.element); 403 element: suggestion.element);
398 } 404 }
399 } 405 }
400 } 406 }
401 } 407 }
408
409 /**
410 * A wrapper around a new dart completion contributor that makes it usable where
411 * an old dart completion contributor is expected.
412 */
413 class NewCompletionWrapper implements DartCompletionContributor {
414 /**
415 * The new-style contributor that is being wrapped.
416 */
417 final newApi.DartCompletionContributor contributor;
418
419 /**
420 * Initialize a newly created wrapper for the given [contributor].
421 */
422 NewCompletionWrapper(this.contributor);
423
424 @override
425 bool computeFast(DartCompletionRequest request) {
426 List<CompletionSuggestion> suggestions =
427 contributor.computeSuggestions(new OldRequestWrapper(request));
428 if (suggestions == null) {
429 return false;
430 }
431 for (CompletionSuggestion suggestion in suggestions) {
432 request.addSuggestion(suggestion);
433 }
434 return true;
435 }
436
437 @override
438 Future<bool> computeFull(DartCompletionRequest request) async {
439 List<CompletionSuggestion> suggestions =
440 contributor.computeSuggestions(new OldRequestWrapper(request));
441 if (suggestions != null) {
442 for (CompletionSuggestion suggestion in suggestions) {
443 request.addSuggestion(suggestion);
444 }
danrubel 2015/09/18 00:30:54 return true after this for loop
Brian Wilkerson 2015/09/18 15:59:26 Done
445 }
446 return true;
danrubel 2015/09/18 00:30:54 return false here
Brian Wilkerson 2015/09/18 15:59:26 Done
447 }
448
449 @override
450 String toString() => 'wrapped $contributor';
451 }
452
453 /**
454 * A wrapper around an old dart completion request that makes it usable where a
455 * new dart completion request is expected.
456 */
457 class OldRequestWrapper implements newApi.DartCompletionRequest {
458 final DartCompletionRequest request;
459
460 OldRequestWrapper(this.request);
461
462 @override
463 AnalysisContext get context => request.context;
464
465 @override
466 bool get isResolved => request.unit.element != null;
467
468 @override
469 int get offset => request.offset;
470
471 @override
472 ResourceProvider get resourceProvider => request.resourceProvider;
473
474 @override
475 Source get source => request.source;
476
477 @override
478 CompilationUnit get unit => request.unit;
479
480 @override
481 String toString() => 'wrapped $request';
482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698