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

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

Issue 694373002: Support for inlining methods when some arguments are missing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/inline_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.inline_method; 5 library test.services.refactoring.inline_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' hide Element; 9 import 'package:analysis_server/src/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/refactoring/inline_method.dart'; 10 import 'package:analysis_server/src/services/refactoring/inline_method.dart';
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 _createRefactoring('test({'); 991 _createRefactoring('test({');
992 // validate change 992 // validate change
993 return _assertSuccessfulRefactoring(r''' 993 return _assertSuccessfulRefactoring(r'''
994 main() { 994 main() {
995 print(10 + 20); 995 print(10 + 20);
996 print(10 + 20); 996 print(10 + 20);
997 } 997 }
998 '''); 998 ''');
999 } 999 }
1000 1000
1001 test_noArgument_named_hasDefault() {
1002 verifyNoTestUnitErrors = false;
1003 indexTestUnit(r'''
1004 test({a: 42}) {
1005 print(a);
1006 }
1007 main() {
1008 test();
1009 }
1010 ''');
1011 _createRefactoring('test(');
1012 // validate change
1013 return _assertSuccessfulRefactoring(r'''
1014 main() {
1015 print(42);
1016 }
1017 ''');
1018 }
1019
1020 test_noArgument_positional_hasDefault() {
1021 verifyNoTestUnitErrors = false;
1022 indexTestUnit(r'''
1023 test([a = 42]) {
1024 print(a);
1025 }
1026 main() {
1027 test();
1028 }
1029 ''');
1030 _createRefactoring('test(');
1031 // validate change
1032 return _assertSuccessfulRefactoring(r'''
1033 main() {
1034 print(42);
1035 }
1036 ''');
1037 }
1038
1039 test_noArgument_positional_noDefault() {
1040 verifyNoTestUnitErrors = false;
1041 indexTestUnit(r'''
1042 test([a]) {
1043 print(a);
1044 }
1045 main() {
1046 test();
1047 }
1048 ''');
1049 _createRefactoring('test(');
1050 // validate change
1051 return _assertSuccessfulRefactoring(r'''
1052 main() {
1053 print(null);
1054 }
1055 ''');
1056 }
1057
1058 test_noArgument_required() {
1059 verifyNoTestUnitErrors = false;
1060 indexTestUnit(r'''
1061 test(a) {
1062 print(a);
1063 }
1064 main() {
1065 test();
1066 }
1067 ''');
1068 _createRefactoring('test();');
1069 // error
1070 return refactoring.checkAllConditions().then((status) {
1071 var location = new SourceRange(findOffset('test();'), 'test()'.length);
1072 assertRefactoringStatus(
1073 status,
1074 RefactoringProblemSeverity.ERROR,
1075 expectedMessage: 'No argument for the parameter "a".',
1076 expectedContextRange: location);
1077 });
1078 }
1079
1001 test_reference_expressionBody() { 1080 test_reference_expressionBody() {
1002 indexTestUnit(r''' 1081 indexTestUnit(r'''
1003 String message() => 'Hello, World!'; 1082 String message() => 'Hello, World!';
1004 main() { 1083 main() {
1005 print(message); 1084 print(message);
1006 } 1085 }
1007 '''); 1086 ''');
1008 _createRefactoring('message()'); 1087 _createRefactoring('message()');
1009 // validate change 1088 // validate change
1010 return _assertSuccessfulRefactoring(r''' 1089 return _assertSuccessfulRefactoring(r'''
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 }); 1384 });
1306 }); 1385 });
1307 }); 1386 });
1308 } 1387 }
1309 1388
1310 void _createRefactoring(String search) { 1389 void _createRefactoring(String search) {
1311 int offset = findOffset(search); 1390 int offset = findOffset(search);
1312 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset); 1391 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset);
1313 } 1392 }
1314 } 1393 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698