Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: pkg/analysis_server/test/services/refactoring/extract_method_test.dart

Issue 956393002: Issue 20827. Import required type in 'Extract Method' refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 return _assertSuccessfulRefactoring(''' 1366 return _assertSuccessfulRefactoring('''
1367 typedef R Foo<S, R>(S s); 1367 typedef R Foo<S, R>(S s);
1368 void main(Foo<String, int> foo, String s) { 1368 void main(Foo<String, int> foo, String s) {
1369 int a = res(foo, s); 1369 int a = res(foo, s);
1370 } 1370 }
1371 1371
1372 int res(Foo<String, int> foo, String s) => foo(s); 1372 int res(Foo<String, int> foo, String s) => foo(s);
1373 '''); 1373 ''');
1374 } 1374 }
1375 1375
1376 test_singleExpression_returnType_importLibrary() async {
1377 _addLibraryReturningAsync();
1378 indexTestUnit('''
1379 import 'asyncLib.dart';
1380 main() {
1381 var a = newFuture();
1382 }
1383 ''');
1384 _createRefactoringForString('newFuture()');
1385 // apply refactoring
1386 return _assertSuccessfulRefactoring('''
1387 import 'asyncLib.dart';
1388 import 'dart:async';
1389 main() {
1390 var a = res();
1391 }
1392
1393 Future<int> res() => newFuture();
1394 ''');
1395 }
1396
1376 test_singleExpression_returnTypeGeneric() { 1397 test_singleExpression_returnTypeGeneric() {
1377 indexTestUnit(''' 1398 indexTestUnit('''
1378 main() { 1399 main() {
1379 var v = new List<String>(); 1400 var v = new List<String>();
1380 } 1401 }
1381 '''); 1402 ''');
1382 _createRefactoringForString('new List<String>()'); 1403 _createRefactoringForString('new List<String>()');
1383 // apply refactoring 1404 // apply refactoring
1384 return _assertSuccessfulRefactoring(''' 1405 return _assertSuccessfulRefactoring('''
1385 main() { 1406 main() {
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 res(a); 2217 res(a);
2197 // end 2218 // end
2198 } 2219 }
2199 2220
2200 void res(int a) { 2221 void res(int a) {
2201 print(a); 2222 print(a);
2202 } 2223 }
2203 '''); 2224 ''');
2204 } 2225 }
2205 2226
2227 test_statements_parameters_importType() {
2228 _addLibraryReturningAsync();
2229 indexTestUnit('''
2230 import 'asyncLib.dart';
2231 main() {
2232 var v = newFuture();
2233 // start
2234 print(v);
2235 // end
2236 }
2237 ''');
2238 _createRefactoringForStartEndComments();
2239 // apply refactoring
2240 return _assertSuccessfulRefactoring('''
2241 import 'asyncLib.dart';
2242 import 'dart:async';
2243 main() {
2244 var v = newFuture();
2245 // start
2246 res(v);
2247 // end
2248 }
2249
2250 void res(Future<int> v) {
2251 print(v);
2252 }
2253 ''');
2254 }
2255
2206 test_statements_return_last() { 2256 test_statements_return_last() {
2207 indexTestUnit(''' 2257 indexTestUnit('''
2208 main() { 2258 main() {
2209 // start 2259 // start
2210 int v = 5; 2260 int v = 5;
2211 return v + 1; 2261 return v + 1;
2212 // end 2262 // end
2213 } 2263 }
2214 '''); 2264 ''');
2215 _createRefactoringForStartEndComments(); 2265 _createRefactoringForStartEndComments();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 print(0); 2449 print(0);
2400 } 2450 }
2401 2451
2402 void res() { 2452 void res() {
2403 print(0); 2453 print(0);
2404 print(0); 2454 print(0);
2405 } 2455 }
2406 '''); 2456 ''');
2407 } 2457 }
2408 2458
2459 void _addLibraryReturningAsync() {
2460 addSource('/asyncLib.dart', r'''
2461 library asyncLib;
2462 import 'dart:async';
2463 Future<int> newFuture() => null;
2464 ''');
2465 }
2466
2409 Future _assertConditionsError(String message) async { 2467 Future _assertConditionsError(String message) async {
2410 RefactoringStatus status = await refactoring.checkAllConditions(); 2468 RefactoringStatus status = await refactoring.checkAllConditions();
2411 assertRefactoringStatus( 2469 assertRefactoringStatus(
2412 status, 2470 status,
2413 RefactoringProblemSeverity.ERROR, 2471 RefactoringProblemSeverity.ERROR,
2414 expectedMessage: message); 2472 expectedMessage: message);
2415 } 2473 }
2416 2474
2417 Future _assertConditionsFatal(String message) async { 2475 Future _assertConditionsFatal(String message) async {
2418 RefactoringStatus status = await refactoring.checkAllConditions(); 2476 RefactoringStatus status = await refactoring.checkAllConditions();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 * Returns a deep copy of [refactoring] parameters. 2543 * Returns a deep copy of [refactoring] parameters.
2486 * There was a bug masked by updating parameter instances shared between the 2544 * There was a bug masked by updating parameter instances shared between the
2487 * refactoring and the test. 2545 * refactoring and the test.
2488 */ 2546 */
2489 List<RefactoringMethodParameter> _getParametersCopy() { 2547 List<RefactoringMethodParameter> _getParametersCopy() {
2490 return refactoring.parameters.map((p) { 2548 return refactoring.parameters.map((p) {
2491 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); 2549 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id);
2492 }).toList(); 2550 }).toList();
2493 } 2551 }
2494 } 2552 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698