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

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

Issue 1500723002: hookup new CompletionContributorFactory (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix comment Created 5 years 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/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart'
11 show AnalysisRequest, CompletionContributor, CompletionRequest; 11 show AnalysisRequest, CompletionContributor, CompletionRequest;
12 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; 12 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart';
13 import 'package:analysis_server/src/services/completion/arglist_contributor.dart '; 13 import 'package:analysis_server/src/services/completion/arglist_contributor.dart ';
14 import 'package:analysis_server/src/services/completion/combinator_contributor.d art'; 14 import 'package:analysis_server/src/services/completion/combinator_contributor.d art';
15 import 'package:analysis_server/src/services/completion/completion_core.dart'; 15 import 'package:analysis_server/src/services/completion/completion_core.dart';
16 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 16 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
17 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter .dart'; 17 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter .dart';
18 import 'package:analysis_server/src/services/completion/dart/completion_manager. dart'
19 as newImpl;
20 import 'package:analysis_server/src/services/completion/dart/contribution_sorter .dart'; 18 import 'package:analysis_server/src/services/completion/dart/contribution_sorter .dart';
21 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';
22 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';
23 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart'; 21 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart';
24 import 'package:analysis_server/src/services/completion/optype.dart'; 22 import 'package:analysis_server/src/services/completion/optype.dart';
25 import 'package:analysis_server/src/services/completion/prefixed_element_contrib utor.dart'; 23 import 'package:analysis_server/src/services/completion/prefixed_element_contrib utor.dart';
26 import 'package:analysis_server/src/services/completion/uri_contributor.dart'; 24 import 'package:analysis_server/src/services/completion/uri_contributor.dart';
27 import 'package:analysis_server/src/services/search/search_engine.dart'; 25 import 'package:analysis_server/src/services/search/search_engine.dart';
28 import 'package:analyzer/file_system/file_system.dart'; 26 import 'package:analyzer/file_system/file_system.dart';
29 import 'package:analyzer/src/generated/ast.dart'; 27 import 'package:analyzer/src/generated/ast.dart';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 /** 78 /**
81 * The [defaultContributionSorter] is a long-lived object that isn't allowed 79 * The [defaultContributionSorter] is a long-lived object that isn't allowed
82 * to maintain state between calls to [ContributionSorter#sort(...)]. 80 * to maintain state between calls to [ContributionSorter#sort(...)].
83 */ 81 */
84 static DartContributionSorter defaultContributionSorter = 82 static DartContributionSorter defaultContributionSorter =
85 new CommonUsageSorter(); 83 new CommonUsageSorter();
86 84
87 final SearchEngine searchEngine; 85 final SearchEngine searchEngine;
88 final DartCompletionCache cache; 86 final DartCompletionCache cache;
89 List<DartCompletionContributor> contributors; 87 List<DartCompletionContributor> contributors;
90 List<CompletionContributor> newContributors; 88 Iterable<CompletionContributor> newContributors;
91 DartContributionSorter contributionSorter; 89 DartContributionSorter contributionSorter;
92 90
93 DartCompletionManager( 91 DartCompletionManager(
94 AnalysisContext context, this.searchEngine, Source source, this.cache, 92 AnalysisContext context, this.searchEngine, Source source, this.cache,
95 [this.contributors, this.newContributors, this.contributionSorter]) 93 [this.contributors, this.newContributors, this.contributionSorter])
96 : super(context, source) { 94 : super(context, source) {
97 if (contributors == null) { 95 if (contributors == null) {
98 contributors = [ 96 contributors = [
99 // LocalReferenceContributor before ImportedReferenceContributor 97 // LocalReferenceContributor before ImportedReferenceContributor
100 // because local suggestions take precedence 98 // because local suggestions take precedence
101 // and can hide other suggestions with the same name 99 // and can hide other suggestions with the same name
102 new LocalReferenceContributor(), 100 new LocalReferenceContributor(),
103 new ImportedReferenceContributor(), 101 new ImportedReferenceContributor(),
104 //new KeywordContributor(), 102 //new KeywordContributor(),
105 new ArgListContributor(), 103 new ArgListContributor(),
106 new CombinatorContributor(), 104 new CombinatorContributor(),
107 new PrefixedElementContributor(), 105 new PrefixedElementContributor(),
108 new UriContributor(), 106 new UriContributor(),
109 // TODO(brianwilkerson) Use the completion contributor extension point 107 // TODO(brianwilkerson) Use the completion contributor extension point
110 // to add the contributor below (and eventually, all the contributors). 108 // to add the contributor below (and eventually, all the contributors).
111 // new NewCompletionWrapper(new InheritedContributor()) 109 // new NewCompletionWrapper(new InheritedContributor())
112 ]; 110 ];
113 } 111 }
114 if (newContributors == null) { 112 if (newContributors == null) {
115 newContributors = <CompletionContributor>[ 113 newContributors = <CompletionContributor>[
116 // TODO(danrubel) initialize using plugin API 114 // TODO(danrubel) initialize using plugin API
117 new newImpl.DartCompletionManager(), 115 //new newImpl.DartCompletionManager(),
118 ]; 116 ];
119 } 117 }
120 if (contributionSorter == null) { 118 if (contributionSorter == null) {
121 contributionSorter = defaultContributionSorter; 119 contributionSorter = defaultContributionSorter;
122 } 120 }
123 } 121 }
124 122
125 /** 123 /**
126 * Create a new initialized Dart source completion manager 124 * Create a new initialized Dart source completion manager
127 */ 125 */
128 factory DartCompletionManager.create( 126 factory DartCompletionManager.create(
129 AnalysisContext context, SearchEngine searchEngine, Source source) { 127 AnalysisContext context,
128 SearchEngine searchEngine,
129 Source source,
130 Iterable<CompletionContributor> newContributors) {
130 return new DartCompletionManager(context, searchEngine, source, 131 return new DartCompletionManager(context, searchEngine, source,
131 new DartCompletionCache(context, source)); 132 new DartCompletionCache(context, source), null, newContributors);
132 } 133 }
133 134
134 @override 135 @override
135 Future<bool> computeCache() { 136 Future<bool> computeCache() {
136 return waitForAnalysis().then((CompilationUnit unit) { 137 return waitForAnalysis().then((CompilationUnit unit) {
137 if (unit != null && !cache.isImportInfoCached(unit)) { 138 if (unit != null && !cache.isImportInfoCached(unit)) {
138 return cache.computeImportInfo(unit, searchEngine, true); 139 return cache.computeImportInfo(unit, searchEngine, true);
139 } else { 140 } else {
140 return new Future.value(false); 141 return new Future.value(false);
141 } 142 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 parameterNames: suggestion.parameterNames, 448 parameterNames: suggestion.parameterNames,
448 parameterTypes: suggestion.parameterTypes, 449 parameterTypes: suggestion.parameterTypes,
449 requiredParameterCount: suggestion.requiredParameterCount, 450 requiredParameterCount: suggestion.requiredParameterCount,
450 hasNamedParameters: suggestion.hasNamedParameters, 451 hasNamedParameters: suggestion.hasNamedParameters,
451 returnType: suggestion.returnType, 452 returnType: suggestion.returnType,
452 element: suggestion.element); 453 element: suggestion.element);
453 } 454 }
454 } 455 }
455 } 456 }
456 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698