| 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 analyzer.test.generated.incremental_resolver_test; | 5 library analyzer.test.generated.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| (...skipping 4757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4768 } | 4768 } |
| 4769 f2() { | 4769 f2() { |
| 4770 print(22); | 4770 print(22); |
| 4771 } | 4771 } |
| 4772 f3() { | 4772 f3() { |
| 4773 print(333) | 4773 print(333) |
| 4774 } | 4774 } |
| 4775 '''); | 4775 '''); |
| 4776 } | 4776 } |
| 4777 | 4777 |
| 4778 void test_updateFunctionToForLoop() { |
| 4779 _resolveUnit(r''' |
| 4780 class PlayDrag { |
| 4781 final List<num> times = new List<num>(); |
| 4782 |
| 4783 PlayDrag.start() {} |
| 4784 |
| 4785 void update(num pos) { |
| 4786 fo (int i = times.length - 2; i >= 0; i--) {} |
| 4787 } |
| 4788 } |
| 4789 '''); |
| 4790 |
| 4791 _updateAndValidate( |
| 4792 r''' |
| 4793 class PlayDrag { |
| 4794 final List<num> times = new List<num>(); |
| 4795 |
| 4796 PlayDrag.start() {} |
| 4797 |
| 4798 void update(num pos) { |
| 4799 for (int i = times.length - 2; i >= 0; i--) {} |
| 4800 } |
| 4801 } |
| 4802 ''', |
| 4803 expectLibraryUnchanged: false); |
| 4804 } |
| 4805 |
| 4778 void test_visibleRange() { | 4806 void test_visibleRange() { |
| 4779 _resolveUnit(r''' | 4807 _resolveUnit(r''' |
| 4780 class Test { | 4808 class Test { |
| 4781 method1(p1) { | 4809 method1(p1) { |
| 4782 var v1; | 4810 var v1; |
| 4783 f1() {} | 4811 f1() {} |
| 4784 return 1; | 4812 return 1; |
| 4785 } | 4813 } |
| 4786 method2(p2) { | 4814 method2(p2) { |
| 4787 var v2; | 4815 var v2; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4839 { | 4867 { |
| 4840 ClassElement typeA = oldUnitElement.getType('A'); | 4868 ClassElement typeA = oldUnitElement.getType('A'); |
| 4841 expect(oldUnitElement.getElementAt(typeA.nameOffset), typeA); | 4869 expect(oldUnitElement.getElementAt(typeA.nameOffset), typeA); |
| 4842 } | 4870 } |
| 4843 { | 4871 { |
| 4844 ClassElement typeB = oldUnitElement.getType('B'); | 4872 ClassElement typeB = oldUnitElement.getType('B'); |
| 4845 expect(oldUnitElement.getElementAt(typeB.nameOffset), typeB); | 4873 expect(oldUnitElement.getElementAt(typeB.nameOffset), typeB); |
| 4846 } | 4874 } |
| 4847 } | 4875 } |
| 4848 | 4876 |
| 4849 void test_updateFunctionToForLoop() { | |
| 4850 _resolveUnit(r''' | |
| 4851 class PlayDrag { | |
| 4852 final List<num> times = new List<num>(); | |
| 4853 | |
| 4854 PlayDrag.start() {} | |
| 4855 | |
| 4856 void update(num pos) { | |
| 4857 fo (int i = times.length - 2; i >= 0; i--) {} | |
| 4858 } | |
| 4859 } | |
| 4860 '''); | |
| 4861 | |
| 4862 _updateAndValidate( | |
| 4863 r''' | |
| 4864 class PlayDrag { | |
| 4865 final List<num> times = new List<num>(); | |
| 4866 | |
| 4867 PlayDrag.start() {} | |
| 4868 | |
| 4869 void update(num pos) { | |
| 4870 for (int i = times.length - 2; i >= 0; i--) {} | |
| 4871 } | |
| 4872 } | |
| 4873 ''', | |
| 4874 expectLibraryUnchanged: false); | |
| 4875 } | |
| 4876 | |
| 4877 void _assertCacheResults( | 4877 void _assertCacheResults( |
| 4878 {bool expectLibraryUnchanged: true, | 4878 {bool expectLibraryUnchanged: true, |
| 4879 bool expectCachePostConstantsValid: true}) { | 4879 bool expectCachePostConstantsValid: true}) { |
| 4880 _assertCacheSourceResult(TOKEN_STREAM); | 4880 _assertCacheSourceResult(TOKEN_STREAM); |
| 4881 _assertCacheSourceResult(SCAN_ERRORS); | 4881 _assertCacheSourceResult(SCAN_ERRORS); |
| 4882 _assertCacheSourceResult(PARSED_UNIT); | 4882 _assertCacheSourceResult(PARSED_UNIT); |
| 4883 _assertCacheSourceResult(PARSE_ERRORS); | 4883 _assertCacheSourceResult(PARSE_ERRORS); |
| 4884 if (!expectLibraryUnchanged) { | 4884 if (!expectLibraryUnchanged) { |
| 4885 return; | 4885 return; |
| 4886 } | 4886 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5283 final int offset; | 5283 final int offset; |
| 5284 final int length; | 5284 final int length; |
| 5285 final String replacement; | 5285 final String replacement; |
| 5286 _Edit(this.offset, this.length, this.replacement); | 5286 _Edit(this.offset, this.length, this.replacement); |
| 5287 } | 5287 } |
| 5288 | 5288 |
| 5289 class _TestLogger implements logging.Logger { | 5289 class _TestLogger implements logging.Logger { |
| 5290 Object lastException; | 5290 Object lastException; |
| 5291 Object lastStackTrace; | 5291 Object lastStackTrace; |
| 5292 | 5292 |
| 5293 @override |
| 5294 void enter(String name) {} |
| 5295 |
| 5296 @override |
| 5297 void exit() {} |
| 5298 |
| 5293 void expectNoErrors() { | 5299 void expectNoErrors() { |
| 5294 if (lastException != null) { | 5300 if (lastException != null) { |
| 5295 fail("logged an exception:\n$lastException\n$lastStackTrace\n"); | 5301 fail("logged an exception:\n$lastException\n$lastStackTrace\n"); |
| 5296 } | 5302 } |
| 5297 } | 5303 } |
| 5298 | 5304 |
| 5299 @override | 5305 @override |
| 5300 void enter(String name) {} | |
| 5301 | |
| 5302 @override | |
| 5303 void exit() {} | |
| 5304 | |
| 5305 @override | |
| 5306 void log(Object obj) {} | 5306 void log(Object obj) {} |
| 5307 | 5307 |
| 5308 @override | 5308 @override |
| 5309 void logException(Object exception, [Object stackTrace]) { | 5309 void logException(Object exception, [Object stackTrace]) { |
| 5310 lastException = exception; | 5310 lastException = exception; |
| 5311 lastStackTrace = stackTrace; | 5311 lastStackTrace = stackTrace; |
| 5312 } | 5312 } |
| 5313 | 5313 |
| 5314 @override | 5314 @override |
| 5315 logging.LoggingTimer startTimer() { | 5315 logging.LoggingTimer startTimer() { |
| 5316 return new logging.LoggingTimer(this); | 5316 return new logging.LoggingTimer(this); |
| 5317 } | 5317 } |
| 5318 } | 5318 } |
| OLD | NEW |