Chromium Code Reviews| 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.correction.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 8 import 'package:analysis_server/src/services/correction/fix.dart'; | 8 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1729 print(0) | 1729 print(0) |
| 1730 } | 1730 } |
| 1731 '''); | 1731 '''); |
| 1732 assertHasFix(FixKind.INSERT_SEMICOLON, ''' | 1732 assertHasFix(FixKind.INSERT_SEMICOLON, ''' |
| 1733 main() { | 1733 main() { |
| 1734 print(0); | 1734 print(0); |
| 1735 } | 1735 } |
| 1736 '''); | 1736 '''); |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 void test_illegalAsyncReturnType_asyncLibrary_import() { | |
| 1740 errorFilter = (AnalysisError error) { | |
| 1741 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; | |
| 1742 }; | |
| 1743 resolveTestUnit(''' | |
| 1744 library main; | |
| 1745 int main() async { | |
| 1746 } | |
| 1747 '''); | |
| 1748 assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' | |
| 1749 library main; | |
| 1750 import 'dart:async'; | |
| 1751 Future<int> main() async { | |
| 1752 } | |
| 1753 '''); | |
| 1754 } | |
| 1755 | |
| 1756 void test_illegalAsyncReturnType_asyncLibrary_usePrefix() { | |
| 1757 errorFilter = (AnalysisError error) { | |
| 1758 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; | |
| 1759 }; | |
| 1760 resolveTestUnit(''' | |
| 1761 import 'dart:async' as al; | |
| 1762 int main() async { | |
| 1763 } | |
| 1764 '''); | |
| 1765 assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' | |
| 1766 import 'dart:async' as al; | |
| 1767 al.Future<int> main() async { | |
| 1768 } | |
| 1769 '''); | |
| 1770 } | |
| 1771 | |
| 1772 void test_illegalAsyncReturnType_complexTypeName() { | |
| 1773 errorFilter = (AnalysisError error) { | |
| 1774 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; | |
| 1775 }; | |
| 1776 resolveTestUnit(''' | |
| 1777 import 'dart:async'; | |
| 1778 List<int> main() async { | |
| 1779 } | |
| 1780 '''); | |
| 1781 assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' | |
| 1782 import 'dart:async'; | |
| 1783 Future<List<int>> main() async { | |
| 1784 } | |
| 1785 '''); | |
| 1786 } | |
| 1787 | |
| 1788 void test_illegalAsyncReturnType_void() { | |
|
Brian Wilkerson
2015/03/09 21:05:35
Perhaps a test case containing:
import 'dart:asyn
scheglov
2015/03/09 21:34:37
Well, we don't report any error in this case.
So,
| |
| 1789 errorFilter = (AnalysisError error) { | |
| 1790 return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; | |
| 1791 }; | |
| 1792 resolveTestUnit(''' | |
| 1793 import 'dart:async'; | |
| 1794 void main() async { | |
| 1795 } | |
| 1796 '''); | |
| 1797 assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' | |
| 1798 import 'dart:async'; | |
| 1799 Future main() async { | |
| 1800 } | |
| 1801 '''); | |
| 1802 } | |
| 1803 | |
| 1739 void test_importLibraryPackage_withClass() { | 1804 void test_importLibraryPackage_withClass() { |
| 1740 _configureMyPkg(''' | 1805 _configureMyPkg(''' |
| 1741 library my_lib; | 1806 library my_lib; |
| 1742 class Test {} | 1807 class Test {} |
| 1743 '''); | 1808 '''); |
| 1744 // try to find a fix | 1809 // try to find a fix |
| 1745 resolveTestUnit(''' | 1810 resolveTestUnit(''' |
| 1746 main() { | 1811 main() { |
| 1747 Test test = null; | 1812 Test test = null; |
| 1748 } | 1813 } |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3081 | 3146 |
| 3082 List<Position> _findResultPositions(List<String> searchStrings) { | 3147 List<Position> _findResultPositions(List<String> searchStrings) { |
| 3083 List<Position> positions = <Position>[]; | 3148 List<Position> positions = <Position>[]; |
| 3084 for (String search in searchStrings) { | 3149 for (String search in searchStrings) { |
| 3085 int offset = resultCode.indexOf(search); | 3150 int offset = resultCode.indexOf(search); |
| 3086 positions.add(new Position(testFile, offset)); | 3151 positions.add(new Position(testFile, offset)); |
| 3087 } | 3152 } |
| 3088 return positions; | 3153 return positions; |
| 3089 } | 3154 } |
| 3090 } | 3155 } |
| OLD | NEW |