OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 | 1654 |
1655 Future<AnalysisResult> resultFuture = driver.getResult(testFile); | 1655 Future<AnalysisResult> resultFuture = driver.getResult(testFile); |
1656 driver.removeFile(testFile); | 1656 driver.removeFile(testFile); |
1657 | 1657 |
1658 AnalysisResult result = await resultFuture; | 1658 AnalysisResult result = await resultFuture; |
1659 expect(result, isNotNull); | 1659 expect(result, isNotNull); |
1660 expect(result.path, testFile); | 1660 expect(result.path, testFile); |
1661 expect(result.unit, isNotNull); | 1661 expect(result.unit, isNotNull); |
1662 } | 1662 } |
1663 | 1663 |
| 1664 test_getResult_importLibrary_thenRemoveIt() async { |
| 1665 var a = _p('/test/lib/a.dart'); |
| 1666 var b = _p('/test/lib/b.dart'); |
| 1667 provider.newFile(a, 'class A {}'); |
| 1668 provider.newFile( |
| 1669 b, |
| 1670 r''' |
| 1671 import 'a.dart'; |
| 1672 class B extends A {} |
| 1673 '''); |
| 1674 |
| 1675 driver.addFile(a); |
| 1676 driver.addFile(b); |
| 1677 await scheduler.waitForIdle(); |
| 1678 |
| 1679 // No errors in b.dart |
| 1680 { |
| 1681 AnalysisResult result = await driver.getResult(b); |
| 1682 expect(result.errors, isEmpty); |
| 1683 } |
| 1684 |
| 1685 // Remove a.dart and reanalyze. |
| 1686 provider.deleteFile(a); |
| 1687 driver.removeFile(a); |
| 1688 |
| 1689 // The unresolved URI error must be reported. |
| 1690 { |
| 1691 AnalysisResult result = await driver.getResult(b); |
| 1692 expect( |
| 1693 result.errors, |
| 1694 contains(predicate((AnalysisError e) => |
| 1695 e.errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST))); |
| 1696 } |
| 1697 |
| 1698 // Restore a.dart and reanalyze. |
| 1699 provider.newFile(a, 'class A {}'); |
| 1700 driver.addFile(a); |
| 1701 |
| 1702 // No errors in b.dart again. |
| 1703 { |
| 1704 AnalysisResult result = await driver.getResult(b); |
| 1705 expect(result.errors, isEmpty); |
| 1706 } |
| 1707 } |
| 1708 |
1664 test_getResult_twoPendingFutures() async { | 1709 test_getResult_twoPendingFutures() async { |
1665 String content = 'main() {}'; | 1710 String content = 'main() {}'; |
1666 addTestFile(content, priority: true); | 1711 addTestFile(content, priority: true); |
1667 | 1712 |
1668 Future<AnalysisResult> future1 = driver.getResult(testFile); | 1713 Future<AnalysisResult> future1 = driver.getResult(testFile); |
1669 Future<AnalysisResult> future2 = driver.getResult(testFile); | 1714 Future<AnalysisResult> future2 = driver.getResult(testFile); |
1670 | 1715 |
1671 // Both futures complete, with the same result. | 1716 // Both futures complete, with the same result. |
1672 AnalysisResult result1 = await future1; | 1717 AnalysisResult result1 = await future1; |
1673 AnalysisResult result2 = await future2; | 1718 AnalysisResult result2 = await future2; |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 var path = _p('/test.dart'); | 2845 var path = _p('/test.dart'); |
2801 expect(() { | 2846 expect(() { |
2802 driver.removeFile(path); | 2847 driver.removeFile(path); |
2803 }, throwsStateError); | 2848 }, throwsStateError); |
2804 } | 2849 } |
2805 | 2850 |
2806 String _p(String path) => provider.convertPath(path); | 2851 String _p(String path) => provider.convertPath(path); |
2807 } | 2852 } |
2808 | 2853 |
2809 class _SourceMock extends TypedMock implements Source {} | 2854 class _SourceMock extends TypedMock implements Source {} |
OLD | NEW |