OLD | NEW |
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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 /** | 362 /** |
363 * Return a [Future] that completes with the containing library information | 363 * Return a [Future] that completes with the containing library information |
364 * after it is accessible via [context.getLibrariesContaining]. | 364 * after it is accessible via [context.getLibrariesContaining]. |
365 */ | 365 */ |
366 Future computeLibrariesContaining([int times = 200]) { | 366 Future computeLibrariesContaining([int times = 200]) { |
367 List<Source> libraries = context.getLibrariesContaining(testSource); | 367 List<Source> libraries = context.getLibrariesContaining(testSource); |
368 if (libraries.isNotEmpty) { | 368 if (libraries.isNotEmpty) { |
369 return new Future.value(libraries); | 369 return new Future.value(libraries); |
370 } | 370 } |
| 371 if (times == 0) { |
| 372 fail('failed to determine libraries containing $testSource'); |
| 373 } |
371 context.performAnalysisTask(); | 374 context.performAnalysisTask(); |
372 // We use a delayed future to allow microtask events to finish. The | 375 // We use a delayed future to allow microtask events to finish. The |
373 // Future.value or Future() constructors use scheduleMicrotask themselves an
d | 376 // Future.value or Future() constructors use scheduleMicrotask themselves an
d |
374 // would therefore not wait for microtask callbacks that are scheduled after | 377 // would therefore not wait for microtask callbacks that are scheduled after |
375 // invoking this method. | 378 // invoking this method. |
376 return new Future.delayed( | 379 return new Future.delayed( |
377 Duration.ZERO, () => computeLibrariesContaining(times - 1)); | 380 Duration.ZERO, () => computeLibrariesContaining(times - 1)); |
378 } | 381 } |
379 | 382 |
380 Future computeSuggestions([int times = 200]) async { | 383 Future computeSuggestions([int times = 200]) async { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 462 } |
460 | 463 |
461 @override | 464 @override |
462 void setUp() { | 465 void setUp() { |
463 super.setUp(); | 466 super.setUp(); |
464 index = createLocalMemoryIndex(); | 467 index = createLocalMemoryIndex(); |
465 searchEngine = new SearchEngineImpl(index); | 468 searchEngine = new SearchEngineImpl(index); |
466 contributor = createContributor(); | 469 contributor = createContributor(); |
467 } | 470 } |
468 } | 471 } |
OLD | NEW |