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

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 1468913004: Issue 25021. Fix for adding new required parameters when optional exist. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.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.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ''' 168 '''
169 class Test { 169 class Test {
170 final int a; 170 final int a;
171 final int b; 171 final int b;
172 final int c; 172 final int c;
173 Test(this.a, this.b, [this.c]); 173 Test(this.a, this.b, [this.c]);
174 } 174 }
175 '''); 175 ''');
176 } 176 }
177 177
178 test_addMissingParameter_function_positional_hasNamed() async {
179 resolveTestUnit('''
180 test({int a}) {}
181 main() {
182 test(1);
183 }
184 ''');
185 await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL);
186 }
187
178 test_addMissingParameter_function_positional_hasZero() async { 188 test_addMissingParameter_function_positional_hasZero() async {
179 resolveTestUnit(''' 189 resolveTestUnit('''
180 test() {} 190 test() {}
181 main() { 191 main() {
182 test(1); 192 test(1);
183 } 193 }
184 '''); 194 ''');
185 await assertHasFix( 195 await assertHasFix(
186 DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL, 196 DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL,
187 ''' 197 '''
188 test([int i]) {} 198 test([int i]) {}
189 main() { 199 main() {
190 test(1); 200 test(1);
191 } 201 }
192 '''); 202 ''');
193 } 203 }
194 204
205 test_addMissingParameter_function_required_hasNamed() async {
206 resolveTestUnit('''
207 test({int a}) {}
208 main() {
209 test(1);
210 }
211 ''');
212 await assertHasFix(
213 DartFixKind.ADD_MISSING_PARAMETER_REQUIRED,
214 '''
215 test(int i, {int a}) {}
216 main() {
217 test(1);
218 }
219 ''');
220 }
221
195 test_addMissingParameter_function_required_hasOne() async { 222 test_addMissingParameter_function_required_hasOne() async {
196 resolveTestUnit(''' 223 resolveTestUnit('''
197 test(int a) {} 224 test(int a) {}
198 main() { 225 main() {
199 test(1, 2.0); 226 test(1, 2.0);
200 } 227 }
201 '''); 228 ''');
202 await assertHasFix( 229 await assertHasFix(
203 DartFixKind.ADD_MISSING_PARAMETER_REQUIRED, 230 DartFixKind.ADD_MISSING_PARAMETER_REQUIRED,
204 ''' 231 '''
(...skipping 4414 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 int offset = resultCode.indexOf(search); 4646 int offset = resultCode.indexOf(search);
4620 positions.add(new Position(testFile, offset)); 4647 positions.add(new Position(testFile, offset));
4621 } 4648 }
4622 return positions; 4649 return positions;
4623 } 4650 }
4624 4651
4625 void _performAnalysis() { 4652 void _performAnalysis() {
4626 while (context.performAnalysisTask().hasMoreWork); 4653 while (context.performAnalysisTask().hasMoreWork);
4627 } 4654 }
4628 } 4655 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698