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

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

Issue 2692983003: Add fix for missing @required params. (Closed)
Patch Set: Removed unneeded async. Created 3 years, 10 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
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 test_addMissingParameter_function_positional_hasNamed() async { 289 test_addMissingParameter_function_positional_hasNamed() async {
290 await resolveTestUnit(''' 290 await resolveTestUnit('''
291 test({int a}) {} 291 test({int a}) {}
292 main() { 292 main() {
293 test(1); 293 test(1);
294 } 294 }
295 '''); 295 ''');
296 await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL); 296 await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL);
297 } 297 }
298 298
299 void _addMetaPackageSource() {
scheglov 2017/02/14 22:06:07 Please format and sort and files that you change i
pquitslund 2017/02/14 23:41:38 Whoops! I got confused by the "Rearrange Code" ac
300 addPackageSource('meta', 'meta.dart', r'''
301 library meta;
302
303 const Required required = const Required();
304
305 class Required {
306 final String reason;
307 const Required([this.reason]);
308 }
309 ''');
310 }
311
312 test_addMissingRequiredParam_single() async {
313 _addMetaPackageSource();
314
315 await resolveTestUnit('''
316 import 'package:meta/meta.dart';
317
318 test({@required int a}) {}
319 main() {
320 test();
321 }
322 ''');
323 await assertHasFix(
324 DartFixKind.ADD_MISSING_REQUIRED_PARAMETER,
325 '''
326 import 'package:meta/meta.dart';
327
328 test({@required int a}) {}
329 main() {
330 test(a: null);
331 }
332 ''');
333 }
334
335 test_addMissingRequiredParam_multiple() async {
scheglov 2017/02/14 22:06:07 This looks like "_hasOtherArgument" test. But yes,
pquitslund 2017/02/14 23:41:38 Acknowledged.
336 _addMetaPackageSource();
337
338 await resolveTestUnit('''
339 import 'package:meta/meta.dart';
340
341 test({@required int a, @required int b}) {}
342 main() {
343 test(a: 3);
344 }
345 ''');
346 await assertHasFix(
347 DartFixKind.ADD_MISSING_REQUIRED_PARAMETER,
348 '''
349 import 'package:meta/meta.dart';
350
351 test({@required int a, @required int b}) {}
352 main() {
353 test(a: 3, b: null);
354 }
355 ''');
356 }
357
299 test_addMissingParameter_function_positional_hasZero() async { 358 test_addMissingParameter_function_positional_hasZero() async {
300 await resolveTestUnit(''' 359 await resolveTestUnit('''
301 test() {} 360 test() {}
302 main() { 361 main() {
303 test(1); 362 test(1);
304 } 363 }
305 '''); 364 ''');
306 await assertHasFix( 365 await assertHasFix(
307 DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL, 366 DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL,
308 ''' 367 '''
(...skipping 5345 matching lines...) Expand 10 before | Expand all | Expand 10 after
5654 5713
5655 @override 5714 @override
5656 final CompilationUnit unit; 5715 final CompilationUnit unit;
5657 5716
5658 @override 5717 @override
5659 final AnalysisError error; 5718 final AnalysisError error;
5660 5719
5661 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, 5720 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations,
5662 this.analysisContext, this.astProvider, this.unit, this.error); 5721 this.analysisContext, this.astProvider, this.unit, this.error);
5663 } 5722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698