| 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/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 9 import 'package:analysis_server/src/services/correction/fix.dart'; | 9 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| (...skipping 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 resolveTestUnit(''' | 3090 resolveTestUnit(''' |
| 3091 main(p) { | 3091 main(p) { |
| 3092 p i s Null; | 3092 p i s Null; |
| 3093 }'''); | 3093 }'''); |
| 3094 List<AnalysisError> errors = context.computeErrors(testSource); | 3094 List<AnalysisError> errors = context.computeErrors(testSource); |
| 3095 for (var error in errors) { | 3095 for (var error in errors) { |
| 3096 _computeFixes(error); | 3096 _computeFixes(error); |
| 3097 } | 3097 } |
| 3098 } | 3098 } |
| 3099 | 3099 |
| 3100 void test_nonBoolCondition_addNotNull() { |
| 3101 resolveTestUnit(''' |
| 3102 main(String p) { |
| 3103 if (p) { |
| 3104 print(p); |
| 3105 } |
| 3106 } |
| 3107 '''); |
| 3108 assertHasFix( |
| 3109 DartFixKind.ADD_NE_NULL, |
| 3110 ''' |
| 3111 main(String p) { |
| 3112 if (p != null) { |
| 3113 print(p); |
| 3114 } |
| 3115 } |
| 3116 '''); |
| 3117 } |
| 3118 |
| 3100 void test_removeDeadCode_condition() { | 3119 void test_removeDeadCode_condition() { |
| 3101 resolveTestUnit(''' | 3120 resolveTestUnit(''' |
| 3102 main(int p) { | 3121 main(int p) { |
| 3103 if (true || p > 5) { | 3122 if (true || p > 5) { |
| 3104 print(1); | 3123 print(1); |
| 3105 } | 3124 } |
| 3106 } | 3125 } |
| 3107 '''); | 3126 '''); |
| 3108 assertHasFix( | 3127 assertHasFix( |
| 3109 DartFixKind.REMOVE_DEAD_CODE, | 3128 DartFixKind.REMOVE_DEAD_CODE, |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4513 int offset = resultCode.indexOf(search); | 4532 int offset = resultCode.indexOf(search); |
| 4514 positions.add(new Position(testFile, offset)); | 4533 positions.add(new Position(testFile, offset)); |
| 4515 } | 4534 } |
| 4516 return positions; | 4535 return positions; |
| 4517 } | 4536 } |
| 4518 | 4537 |
| 4519 void _performAnalysis() { | 4538 void _performAnalysis() { |
| 4520 while (context.performAnalysisTask().hasMoreWork); | 4539 while (context.performAnalysisTask().hasMoreWork); |
| 4521 } | 4540 } |
| 4522 } | 4541 } |
| OLD | NEW |