OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/analysis/results.dart'; | 7 import 'package:analyzer/dart/analysis/results.dart'; |
8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
9 import 'package:analyzer/source/package_map_resolver.dart'; | 9 import 'package:analyzer/source/package_map_resolver.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 cs = s; | 535 cs = s; |
536 } else { | 536 } else { |
537 failedCompletion('expected exactly one $cs', | 537 failedCompletion('expected exactly one $cs', |
538 suggestions.where((s) => s.completion == completion)); | 538 suggestions.where((s) => s.completion == completion)); |
539 } | 539 } |
540 }); | 540 }); |
541 } | 541 } |
542 return cs; | 542 return cs; |
543 } | 543 } |
544 | 544 |
545 Future/*<E>*/ performAnalysis/*<E>*/( | 545 Future<E> performAnalysis<E>(int times, Completer<E> completer) async { |
546 int times, Completer/*<E>*/ completer) async { | |
547 if (completer.isCompleted) { | 546 if (completer.isCompleted) { |
548 return completer.future; | 547 return completer.future; |
549 } | 548 } |
550 // We use a delayed future to allow microtask events to finish. The | 549 // We use a delayed future to allow microtask events to finish. The |
551 // Future.value or Future() constructors use scheduleMicrotask themselves an
d | 550 // Future.value or Future() constructors use scheduleMicrotask themselves an
d |
552 // would therefore not wait for microtask callbacks that are scheduled after | 551 // would therefore not wait for microtask callbacks that are scheduled after |
553 // invoking this method. | 552 // invoking this method. |
554 return new Future.delayed( | 553 return new Future.delayed( |
555 Duration.ZERO, () => performAnalysis(times - 1, completer)); | 554 Duration.ZERO, () => performAnalysis(times - 1, completer)); |
556 } | 555 } |
557 | 556 |
558 void resolveSource(String path, String content) { | 557 void resolveSource(String path, String content) { |
559 addSource(path, content); | 558 addSource(path, content); |
560 } | 559 } |
561 | 560 |
562 @override | 561 @override |
563 void setUp() { | 562 void setUp() { |
564 super.setUp(); | 563 super.setUp(); |
565 testFile = provider.convertPath('/completionTest.dart'); | 564 testFile = provider.convertPath('/completionTest.dart'); |
566 contributor = createContributor(); | 565 contributor = createContributor(); |
567 } | 566 } |
568 } | 567 } |
OLD | NEW |