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

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

Issue 1347283005: refactor ContributionSorter to use new API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge 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/completion/completion_dart.dart' as newApi;
12 import 'package:analysis_server/completion/dart/completion_target.dart';
12 import 'package:analysis_server/src/analysis_server.dart'; 13 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/protocol.dart'; 14 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/services/completion/arglist_contributor.dart '; 15 import 'package:analysis_server/src/services/completion/arglist_contributor.dart ';
15 import 'package:analysis_server/src/services/completion/combinator_contributor.d art'; 16 import 'package:analysis_server/src/services/completion/combinator_contributor.d art';
16 import 'package:analysis_server/src/services/completion/common_usage_computer.da rt'; 17 import 'package:analysis_server/src/services/completion/common_usage_computer.da rt';
17 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 18 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
18 import 'package:analysis_server/src/services/completion/completion_target.dart';
19 import 'package:analysis_server/src/services/completion/contribution_sorter.dart '; 19 import 'package:analysis_server/src/services/completion/contribution_sorter.dart ';
20 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 20 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
21 import 'package:analysis_server/src/services/completion/imported_reference_contr ibutor.dart'; 21 import 'package:analysis_server/src/services/completion/imported_reference_contr ibutor.dart';
22 import 'package:analysis_server/src/services/completion/keyword_contributor.dart '; 22 import 'package:analysis_server/src/services/completion/keyword_contributor.dart ';
23 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';
24 import 'package:analysis_server/src/services/completion/optype.dart'; 24 import 'package:analysis_server/src/services/completion/optype.dart';
25 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'; 26 import 'package:analysis_server/src/services/completion/uri_contributor.dart';
27 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'; 28 import 'package:analyzer/file_system/file_system.dart';
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 List<DartCompletionContributor> todo = new List.from(contributors); 177 List<DartCompletionContributor> todo = new List.from(contributors);
178 todo.removeWhere((DartCompletionContributor c) { 178 todo.removeWhere((DartCompletionContributor c) {
179 return performance.logElapseTime('computeFast ${c.runtimeType}', () { 179 return performance.logElapseTime('computeFast ${c.runtimeType}', () {
180 return c.computeFast(request); 180 return c.computeFast(request);
181 }); 181 });
182 }); 182 });
183 contributionSorter.sort(request); 183 contributionSorter.sort(
184 new OldRequestWrapper(request), request.suggestions);
184 sendResults(request, todo.isEmpty); 185 sendResults(request, todo.isEmpty);
185 return todo; 186 return todo;
186 }); 187 });
187 } 188 }
188 189
189 /** 190 /**
190 * If there is remaining work to be done, then wait for the unit to be 191 * If there is remaining work to be done, then wait for the unit to be
191 * resolved and request that each remaining contributor finish their work. 192 * resolved and request that each remaining contributor finish their work.
192 * Return a [Future] that completes when the last notification has been sent. 193 * Return a [Future] that completes when the last notification has been sent.
193 */ 194 */
(...skipping 17 matching lines...) Expand all
211 int count = todo.length; 212 int count = todo.length;
212 todo.forEach((DartCompletionContributor c) { 213 todo.forEach((DartCompletionContributor c) {
213 String name = c.runtimeType.toString(); 214 String name = c.runtimeType.toString();
214 String completeTag = 'computeFull $name complete'; 215 String completeTag = 'computeFull $name complete';
215 performance.logStartTime(completeTag); 216 performance.logStartTime(completeTag);
216 performance.logElapseTime('computeFull $name', () { 217 performance.logElapseTime('computeFull $name', () {
217 c.computeFull(request).then((bool changed) { 218 c.computeFull(request).then((bool changed) {
218 performance.logElapseTime(completeTag); 219 performance.logElapseTime(completeTag);
219 bool last = --count == 0; 220 bool last = --count == 0;
220 if (changed || last) { 221 if (changed || last) {
221 contributionSorter.sort(request); 222 contributionSorter.sort(
223 new OldRequestWrapper(request), request.suggestions);
222 sendResults(request, last); 224 sendResults(request, last);
223 } 225 }
224 }); 226 });
225 }); 227 });
226 }); 228 });
227 }); 229 });
228 }); 230 });
229 } 231 }
230 232
231 @override 233 @override
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 @override 478 @override
477 int get offset => request.offset; 479 int get offset => request.offset;
478 480
479 @override 481 @override
480 ResourceProvider get resourceProvider => request.resourceProvider; 482 ResourceProvider get resourceProvider => request.resourceProvider;
481 483
482 @override 484 @override
483 Source get source => request.source; 485 Source get source => request.source;
484 486
485 @override 487 @override
488 CompletionTarget get target => request.target;
489
490 @override
486 CompilationUnit get unit => request.unit; 491 CompilationUnit get unit => request.unit;
487 492
488 @override 493 @override
489 String toString() => 'wrapped $request'; 494 String toString() => 'wrapped $request';
490 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698