| 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 library analyzer.test.driver; | 5 library analyzer.test.driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 { | 741 { |
| 742 AnalysisError error = result.errors[0]; | 742 AnalysisError error = result.errors[0]; |
| 743 expect(error.offset, 13); | 743 expect(error.offset, 13); |
| 744 expect(error.length, 2); | 744 expect(error.length, 2); |
| 745 expect(error.errorCode, HintCode.UNUSED_LOCAL_VARIABLE); | 745 expect(error.errorCode, HintCode.UNUSED_LOCAL_VARIABLE); |
| 746 expect(error.message, "The value of the local variable 'vv' isn't used."); | 746 expect(error.message, "The value of the local variable 'vv' isn't used."); |
| 747 expect(error.correction, "Try removing the variable, or using it."); | 747 expect(error.correction, "Try removing the variable, or using it."); |
| 748 } | 748 } |
| 749 } | 749 } |
| 750 | 750 |
| 751 test_getResult_fileContentOverlay_throughAnalysisContext() async { |
| 752 var a = _p('/test/bin/a.dart'); |
| 753 var b = _p('/test/bin/b.dart'); |
| 754 |
| 755 provider.newFile(a, 'import "b.dart";'); |
| 756 provider.newFile(b, 'var v = 1;'); |
| 757 contentOverlay[b] = 'var v = 2;'; |
| 758 |
| 759 var result = await driver.getResult(a); |
| 760 |
| 761 // The content that was set into the overlay for "b" should be visible |
| 762 // through the AnalysisContext that was used to analyze "a". |
| 763 CompilationUnitElement unitA = result.unit.element; |
| 764 Source sourceB = unitA.library.imports[0].importedLibrary.source; |
| 765 expect(unitA.context.getContents(sourceB).data, 'var v = 2;'); |
| 766 } |
| 767 |
| 751 test_getResult_inferTypes_finalField() async { | 768 test_getResult_inferTypes_finalField() async { |
| 752 addTestFile( | 769 addTestFile( |
| 753 r''' | 770 r''' |
| 754 class C { | 771 class C { |
| 755 final f = 42; | 772 final f = 42; |
| 756 } | 773 } |
| 757 ''', | 774 ''', |
| 758 priority: true); | 775 priority: true); |
| 759 await _waitForIdle(); | 776 await _waitForIdle(); |
| 760 | 777 |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 String _p(String path) => provider.convertPath(path); | 1794 String _p(String path) => provider.convertPath(path); |
| 1778 | 1795 |
| 1779 Future<Null> _waitForIdle() async { | 1796 Future<Null> _waitForIdle() async { |
| 1780 await idleStatusMonitor.signal; | 1797 await idleStatusMonitor.signal; |
| 1781 } | 1798 } |
| 1782 | 1799 |
| 1783 static String _md5(String content) { | 1800 static String _md5(String content) { |
| 1784 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 1801 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 1785 } | 1802 } |
| 1786 } | 1803 } |
| OLD | NEW |