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 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3226 | 3226 |
3227 void test_undefinedMethod_create_BAD_inSDK() { | 3227 void test_undefinedMethod_create_BAD_inSDK() { |
3228 resolveTestUnit(''' | 3228 resolveTestUnit(''' |
3229 main() { | 3229 main() { |
3230 List.foo(); | 3230 List.foo(); |
3231 } | 3231 } |
3232 '''); | 3232 '''); |
3233 assertNoFix(DartFixKind.CREATE_METHOD); | 3233 assertNoFix(DartFixKind.CREATE_METHOD); |
3234 } | 3234 } |
3235 | 3235 |
3236 void test_undefinedMethod_create_generic_BAD() { | 3236 void test_undefinedMethod_create_generic_BAD_argumentType() { |
3237 resolveTestUnit(''' | 3237 resolveTestUnit(''' |
3238 class A<T> { | 3238 class A<T> { |
3239 B b; | 3239 B b; |
3240 Map<int, T> items; | 3240 Map<int, T> items; |
3241 main() { | 3241 main() { |
3242 b.process(items); | 3242 b.process(items); |
3243 } | 3243 } |
3244 } | 3244 } |
3245 | 3245 |
3246 class B { | 3246 class B { |
3247 } | 3247 } |
3248 '''); | 3248 '''); |
3249 assertHasFix(DartFixKind.CREATE_METHOD, ''' | 3249 assertHasFix(DartFixKind.CREATE_METHOD, ''' |
3250 class A<T> { | 3250 class A<T> { |
3251 B b; | 3251 B b; |
3252 Map<int, T> items; | 3252 Map<int, T> items; |
3253 main() { | 3253 main() { |
3254 b.process(items); | 3254 b.process(items); |
3255 } | 3255 } |
3256 } | 3256 } |
3257 | 3257 |
3258 class B { | 3258 class B { |
3259 void process(Map items) { | 3259 void process(Map items) { |
3260 } | 3260 } |
3261 } | 3261 } |
3262 '''); | 3262 '''); |
3263 } | 3263 } |
3264 | 3264 |
| 3265 void test_undefinedMethod_create_generic_BAD_returnType() { |
| 3266 resolveTestUnit(''' |
| 3267 class A<T> { |
| 3268 main() { |
| 3269 T t = new B().compute(); |
| 3270 } |
| 3271 } |
| 3272 |
| 3273 class B { |
| 3274 } |
| 3275 '''); |
| 3276 assertHasFix(DartFixKind.CREATE_METHOD, ''' |
| 3277 class A<T> { |
| 3278 main() { |
| 3279 T t = new B().compute(); |
| 3280 } |
| 3281 } |
| 3282 |
| 3283 class B { |
| 3284 dynamic compute() { |
| 3285 } |
| 3286 } |
| 3287 '''); |
| 3288 } |
| 3289 |
3265 void test_undefinedMethod_create_generic_OK_literal() { | 3290 void test_undefinedMethod_create_generic_OK_literal() { |
3266 resolveTestUnit(''' | 3291 resolveTestUnit(''' |
3267 class A { | 3292 class A { |
3268 B b; | 3293 B b; |
3269 List<int> items; | 3294 List<int> items; |
3270 main() { | 3295 main() { |
3271 b.process(items); | 3296 b.process(items); |
3272 } | 3297 } |
3273 } | 3298 } |
3274 | 3299 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3725 | 3750 |
3726 List<Position> _findResultPositions(List<String> searchStrings) { | 3751 List<Position> _findResultPositions(List<String> searchStrings) { |
3727 List<Position> positions = <Position>[]; | 3752 List<Position> positions = <Position>[]; |
3728 for (String search in searchStrings) { | 3753 for (String search in searchStrings) { |
3729 int offset = resultCode.indexOf(search); | 3754 int offset = resultCode.indexOf(search); |
3730 positions.add(new Position(testFile, offset)); | 3755 positions.add(new Position(testFile, offset)); |
3731 } | 3756 } |
3732 return positions; | 3757 return positions; |
3733 } | 3758 } |
3734 } | 3759 } |
OLD | NEW |