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

Side by Side Diff: pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart

Issue 1520613003: simplify contributors by resolving declarations in scope (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart ('k') | no next file » | 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 test.services.completion.dart.util; 5 library test.services.completion.dart.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // Future.value or Future() constructors use scheduleMicrotask themselves an d 376 // Future.value or Future() constructors use scheduleMicrotask themselves an d
377 // would therefore not wait for microtask callbacks that are scheduled after 377 // would therefore not wait for microtask callbacks that are scheduled after
378 // invoking this method. 378 // invoking this method.
379 return new Future.delayed( 379 return new Future.delayed(
380 Duration.ZERO, () => computeLibrariesContaining(times - 1)); 380 Duration.ZERO, () => computeLibrariesContaining(times - 1));
381 } 381 }
382 382
383 Future computeSuggestions([int times = 200]) async { 383 Future computeSuggestions([int times = 200]) async {
384 CompletionRequestImpl baseRequest = new CompletionRequestImpl( 384 CompletionRequestImpl baseRequest = new CompletionRequestImpl(
385 context, provider, searchEngine, testSource, completionOffset); 385 context, provider, searchEngine, testSource, completionOffset);
386 request = new DartCompletionRequestImpl.forRequest(baseRequest); 386
387 // Build the request
388 Completer<DartCompletionRequest> requestCompleter =
389 new Completer<DartCompletionRequest>();
390 DartCompletionRequestImpl
391 .from(baseRequest)
392 .then((DartCompletionRequest request) {
393 requestCompleter.complete(request);
394 });
395 request = await performAnalysis(times, requestCompleter);
396
387 var range = new ReplacementRange.compute(request.offset, request.target); 397 var range = new ReplacementRange.compute(request.offset, request.target);
388 replacementOffset = range.offset; 398 replacementOffset = range.offset;
389 replacementLength = range.length; 399 replacementLength = range.length;
390 Completer<List<CompletionSuggestion>> completer = 400 Completer<List<CompletionSuggestion>> suggestionCompleter =
391 new Completer<List<CompletionSuggestion>>(); 401 new Completer<List<CompletionSuggestion>>();
392 402
393 // Request completions 403 // Request completions
394 contributor 404 contributor
395 .computeSuggestions(request) 405 .computeSuggestions(request)
396 .then((List<CompletionSuggestion> computedSuggestions) { 406 .then((List<CompletionSuggestion> computedSuggestions) {
397 completer.complete(computedSuggestions); 407 suggestionCompleter.complete(computedSuggestions);
398 }); 408 });
399 409
400 // Perform analysis until the suggestions have been computed 410 // Perform analysis until the suggestions have been computed
401 // or the max analysis cycles ([times]) has been reached 411 // or the max analysis cycles ([times]) has been reached
402 suggestions = await performAnalysis(times, completer); 412 suggestions = await performAnalysis(times, suggestionCompleter);
403 expect(suggestions, isNotNull, reason: 'expected suggestions'); 413 expect(suggestions, isNotNull, reason: 'expected suggestions');
404 } 414 }
405 415
406 DartCompletionContributor createContributor(); 416 DartCompletionContributor createContributor();
407 417
408 void failedCompletion(String message, 418 void failedCompletion(String message,
409 [Iterable<CompletionSuggestion> completions]) { 419 [Iterable<CompletionSuggestion> completions]) {
410 StringBuffer sb = new StringBuffer(message); 420 StringBuffer sb = new StringBuffer(message);
411 if (completions != null) { 421 if (completions != null) {
412 sb.write('\n found'); 422 sb.write('\n found');
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 472 }
463 473
464 @override 474 @override
465 void setUp() { 475 void setUp() {
466 super.setUp(); 476 super.setUp();
467 index = createLocalMemoryIndex(); 477 index = createLocalMemoryIndex();
468 searchEngine = new SearchEngineImpl(index); 478 searchEngine = new SearchEngineImpl(index);
469 contributor = createContributor(); 479 contributor = createContributor();
470 } 480 }
471 } 481 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/inherited_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698