| 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 engine.incremental_resolver_test; | 5 library engine.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| 11 import 'package:analyzer/src/generated/incremental_logger.dart' as log; |
| 11 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 12 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
| 12 import 'package:analyzer/src/generated/incremental_logger.dart' as log; | |
| 13 import 'package:analyzer/src/generated/java_engine.dart'; | 13 import 'package:analyzer/src/generated/java_engine.dart'; |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 14 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
| 16 import 'package:analyzer/src/generated/scanner.dart'; | 16 import 'package:analyzer/src/generated/scanner.dart'; |
| 17 import 'package:analyzer/src/generated/source_io.dart'; | 17 import 'package:analyzer/src/generated/source_io.dart'; |
| 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 19 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 19 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 20 import 'package:unittest/unittest.dart'; | 20 import 'package:unittest/unittest.dart'; |
| 21 | 21 |
| 22 import '../reflective_tests.dart'; | 22 import '../reflective_tests.dart'; |
| (...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 } | 2346 } |
| 2347 '''); | 2347 '''); |
| 2348 _updateAndValidate(r''' | 2348 _updateAndValidate(r''' |
| 2349 /// aaa bbb | 2349 /// aaa bbb |
| 2350 main() { | 2350 main() { |
| 2351 return 2; | 2351 return 2; |
| 2352 } | 2352 } |
| 2353 '''); | 2353 '''); |
| 2354 } | 2354 } |
| 2355 | 2355 |
| 2356 void test_endOfLineComment_add_beforeKeywordToken() { |
| 2357 _resolveUnit(r''' |
| 2358 main() { |
| 2359 var v = 42; |
| 2360 } |
| 2361 '''); |
| 2362 _updateAndValidate(r''' |
| 2363 main() { |
| 2364 // some comment |
| 2365 var v = 42; |
| 2366 } |
| 2367 '''); |
| 2368 } |
| 2369 |
| 2370 void test_endOfLineComment_add_beforeStringToken() { |
| 2371 _resolveUnit(r''' |
| 2372 main() { |
| 2373 print(0); |
| 2374 } |
| 2375 '''); |
| 2376 _updateAndValidate(r''' |
| 2377 main() { |
| 2378 // some comment |
| 2379 print(0); |
| 2380 } |
| 2381 '''); |
| 2382 } |
| 2383 |
| 2384 void test_endOfLineComment_edit() { |
| 2385 _resolveUnit(r''' |
| 2386 main() { |
| 2387 // some comment |
| 2388 print(2); |
| 2389 } |
| 2390 '''); |
| 2391 _updateAndValidate(r''' |
| 2392 main() { |
| 2393 // edited comment text |
| 2394 print(0); |
| 2395 } |
| 2396 '''); |
| 2397 } |
| 2398 |
| 2399 void test_endOfLineComment_remove() { |
| 2400 _resolveUnit(r''' |
| 2401 main() { |
| 2402 // some comment |
| 2403 print(0); |
| 2404 } |
| 2405 '''); |
| 2406 _updateAndValidate(r''' |
| 2407 main() { |
| 2408 print(0); |
| 2409 } |
| 2410 '''); |
| 2411 } |
| 2412 |
| 2356 void test_false_topLevelFunction_name() { | 2413 void test_false_topLevelFunction_name() { |
| 2357 _resolveUnit(r''' | 2414 _resolveUnit(r''' |
| 2358 a() {} | 2415 a() {} |
| 2359 b() {} | 2416 b() {} |
| 2360 '''); | 2417 '''); |
| 2361 _updateAndValidate(r''' | 2418 _updateAndValidate(r''' |
| 2362 a() {} | 2419 a() {} |
| 2363 bb() {} | 2420 bb() {} |
| 2364 ''', expectedSuccess: false); | 2421 ''', expectedSuccess: false); |
| 2365 } | 2422 } |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2829 _assertEqualToken(incrToken, fullToken); | 2886 _assertEqualToken(incrToken, fullToken); |
| 2830 // comments | 2887 // comments |
| 2831 { | 2888 { |
| 2832 Token incrComment = incrToken.precedingComments; | 2889 Token incrComment = incrToken.precedingComments; |
| 2833 Token fullComment = fullToken.precedingComments; | 2890 Token fullComment = fullToken.precedingComments; |
| 2834 while (true) { | 2891 while (true) { |
| 2835 if (fullComment == null) { | 2892 if (fullComment == null) { |
| 2836 expect(incrComment, isNull); | 2893 expect(incrComment, isNull); |
| 2837 break; | 2894 break; |
| 2838 } | 2895 } |
| 2896 expect(incrComment, isNotNull); |
| 2839 _assertEqualToken(incrComment, fullComment); | 2897 _assertEqualToken(incrComment, fullComment); |
| 2840 incrComment = incrComment.next; | 2898 incrComment = incrComment.next; |
| 2841 fullComment = fullComment.next; | 2899 fullComment = fullComment.next; |
| 2842 } | 2900 } |
| 2843 } | 2901 } |
| 2844 // next tokens | 2902 // next tokens |
| 2845 incrToken = incrToken.next; | 2903 incrToken = incrToken.next; |
| 2846 fullToken = fullToken.next; | 2904 fullToken = fullToken.next; |
| 2847 } | 2905 } |
| 2848 } | 2906 } |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3910 _visitList(node.metadata, other.metadata); | 3968 _visitList(node.metadata, other.metadata); |
| 3911 _visitNode(node.identifier, other.identifier); | 3969 _visitNode(node.identifier, other.identifier); |
| 3912 } | 3970 } |
| 3913 | 3971 |
| 3914 static void assertSameResolution(CompilationUnit actual, | 3972 static void assertSameResolution(CompilationUnit actual, |
| 3915 CompilationUnit expected) { | 3973 CompilationUnit expected) { |
| 3916 _SameResolutionValidator validator = new _SameResolutionValidator(expected); | 3974 _SameResolutionValidator validator = new _SameResolutionValidator(expected); |
| 3917 actual.accept(validator); | 3975 actual.accept(validator); |
| 3918 } | 3976 } |
| 3919 } | 3977 } |
| OLD | NEW |