| 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.refactoring.extract_method; | 5 library test.services.refactoring.extract_method; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; | 10 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; |
| (...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 | 2271 |
| 2272 int res() { | 2272 int res() { |
| 2273 localFunction() { | 2273 localFunction() { |
| 2274 return 'abc'; | 2274 return 'abc'; |
| 2275 } | 2275 } |
| 2276 return 42; | 2276 return 42; |
| 2277 } | 2277 } |
| 2278 '''); | 2278 '''); |
| 2279 } | 2279 } |
| 2280 | 2280 |
| 2281 test_statements_return_multiple_sameElementDifferentTypeArgs() { |
| 2282 indexTestUnit(''' |
| 2283 main(bool b) { |
| 2284 // start |
| 2285 if (b) { |
| 2286 return <int>[]; |
| 2287 } else { |
| 2288 return <String>[]; |
| 2289 } |
| 2290 // end |
| 2291 } |
| 2292 '''); |
| 2293 _createRefactoringForStartEndComments(); |
| 2294 // apply refactoring |
| 2295 return _assertSuccessfulRefactoring(''' |
| 2296 main(bool b) { |
| 2297 // start |
| 2298 return res(b); |
| 2299 // end |
| 2300 } |
| 2301 |
| 2302 List res(bool b) { |
| 2303 if (b) { |
| 2304 return <int>[]; |
| 2305 } else { |
| 2306 return <String>[]; |
| 2307 } |
| 2308 } |
| 2309 '''); |
| 2310 } |
| 2311 |
| 2281 test_statements_return_single() { | 2312 test_statements_return_single() { |
| 2282 indexTestUnit(''' | 2313 indexTestUnit(''' |
| 2283 main() { | 2314 main() { |
| 2284 // start | 2315 // start |
| 2285 return 42; | 2316 return 42; |
| 2286 // end | 2317 // end |
| 2287 } | 2318 } |
| 2288 '''); | 2319 '''); |
| 2289 _createRefactoringForStartEndComments(); | 2320 _createRefactoringForStartEndComments(); |
| 2290 // apply refactoring | 2321 // apply refactoring |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 * Returns a deep copy of [refactoring] parameters. | 2447 * Returns a deep copy of [refactoring] parameters. |
| 2417 * There was a bug masked by updating parameter instances shared between the | 2448 * There was a bug masked by updating parameter instances shared between the |
| 2418 * refactoring and the test. | 2449 * refactoring and the test. |
| 2419 */ | 2450 */ |
| 2420 List<RefactoringMethodParameter> _getParametersCopy() { | 2451 List<RefactoringMethodParameter> _getParametersCopy() { |
| 2421 return refactoring.parameters.map((p) { | 2452 return refactoring.parameters.map((p) { |
| 2422 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); | 2453 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); |
| 2423 }).toList(); | 2454 }).toList(); |
| 2424 } | 2455 } |
| 2425 } | 2456 } |
| OLD | NEW |