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/plugin/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
8 import 'package:analysis_server/plugin/protocol/protocol.dart' | 8 import 'package:analysis_server/plugin/protocol/protocol.dart' |
9 hide AnalysisError; | 9 hide AnalysisError; |
10 import 'package:analysis_server/src/services/correction/fix.dart'; | 10 import 'package:analysis_server/src/services/correction/fix.dart'; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 '''); | 391 '''); |
392 assertHasFix( | 392 assertHasFix( |
393 DartFixKind.REPLACE_BOOLEAN_WITH_BOOL, | 393 DartFixKind.REPLACE_BOOLEAN_WITH_BOOL, |
394 ''' | 394 ''' |
395 main() { | 395 main() { |
396 bool v; | 396 bool v; |
397 } | 397 } |
398 '''); | 398 '''); |
399 } | 399 } |
400 | 400 |
| 401 void test_canBeNullAfterNullAware_chain() { |
| 402 resolveTestUnit(''' |
| 403 main(x) { |
| 404 x?.a.b.c; |
| 405 } |
| 406 '''); |
| 407 assertHasFix( |
| 408 DartFixKind.REPLACE_WITH_NULL_AWARE, |
| 409 ''' |
| 410 main(x) { |
| 411 x?.a?.b?.c; |
| 412 } |
| 413 '''); |
| 414 } |
| 415 |
| 416 void test_canBeNullAfterNullAware_methodInvocation() { |
| 417 resolveTestUnit(''' |
| 418 main(x) { |
| 419 x?.a.b(); |
| 420 } |
| 421 '''); |
| 422 assertHasFix( |
| 423 DartFixKind.REPLACE_WITH_NULL_AWARE, |
| 424 ''' |
| 425 main(x) { |
| 426 x?.a?.b(); |
| 427 } |
| 428 '''); |
| 429 } |
| 430 |
| 431 void test_canBeNullAfterNullAware_propertyAccess() { |
| 432 resolveTestUnit(''' |
| 433 main(x) { |
| 434 x?.a().b; |
| 435 } |
| 436 '''); |
| 437 assertHasFix( |
| 438 DartFixKind.REPLACE_WITH_NULL_AWARE, |
| 439 ''' |
| 440 main(x) { |
| 441 x?.a()?.b; |
| 442 } |
| 443 '''); |
| 444 } |
| 445 |
401 void test_changeToStaticAccess_method() { | 446 void test_changeToStaticAccess_method() { |
402 resolveTestUnit(''' | 447 resolveTestUnit(''' |
403 class A { | 448 class A { |
404 static foo() {} | 449 static foo() {} |
405 } | 450 } |
406 main(A a) { | 451 main(A a) { |
407 a.foo(); | 452 a.foo(); |
408 } | 453 } |
409 '''); | 454 '''); |
410 assertHasFix( | 455 assertHasFix( |
(...skipping 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 int offset = resultCode.indexOf(search); | 4613 int offset = resultCode.indexOf(search); |
4569 positions.add(new Position(testFile, offset)); | 4614 positions.add(new Position(testFile, offset)); |
4570 } | 4615 } |
4571 return positions; | 4616 return positions; |
4572 } | 4617 } |
4573 | 4618 |
4574 void _performAnalysis() { | 4619 void _performAnalysis() { |
4575 while (context.performAnalysisTask().hasMoreWork); | 4620 while (context.performAnalysisTask().hasMoreWork); |
4576 } | 4621 } |
4577 } | 4622 } |
OLD | NEW |