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

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

Issue 1664423002: Issue 25650. Generate unique parameter names when create a method or function. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« 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 3764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 await assertHasFix( 3775 await assertHasFix(
3776 DartFixKind.CHANGE_TO, 3776 DartFixKind.CHANGE_TO,
3777 ''' 3777 '''
3778 class MyClass {} 3778 class MyClass {}
3779 main() { 3779 main() {
3780 MyClass v = null; 3780 MyClass v = null;
3781 } 3781 }
3782 '''); 3782 ''');
3783 } 3783 }
3784 3784
3785 test_undefinedFunction_create_duplicateArgumentNames() async {
3786 resolveTestUnit('''
3787 class C {
3788 int x;
3789 }
3790
3791 foo(C c1, C c2) {
3792 bar(c1.x, c2.x);
3793 }
3794 ''');
3795 await assertHasFix(
3796 DartFixKind.CREATE_FUNCTION,
3797 '''
3798 class C {
3799 int x;
3800 }
3801
3802 foo(C c1, C c2) {
3803 bar(c1.x, c2.x);
3804 }
3805
3806 void bar(int x, int x2) {
3807 }
3808 ''');
3809 }
3810
3785 test_undefinedFunction_create_dynamicArgument() async { 3811 test_undefinedFunction_create_dynamicArgument() async {
3786 resolveTestUnit(''' 3812 resolveTestUnit('''
3787 main() { 3813 main() {
3788 dynamic v; 3814 dynamic v;
3789 test(v); 3815 test(v);
3790 } 3816 }
3791 '''); 3817 ''');
3792 await assertHasFix( 3818 await assertHasFix(
3793 DartFixKind.CREATE_FUNCTION, 3819 DartFixKind.CREATE_FUNCTION,
3794 ''' 3820 '''
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
4426 4452
4427 test_undefinedMethod_createQualified_targetIsUnresolved() async { 4453 test_undefinedMethod_createQualified_targetIsUnresolved() async {
4428 resolveTestUnit(''' 4454 resolveTestUnit('''
4429 main() { 4455 main() {
4430 NoSuchClass.myUndefinedMethod(); 4456 NoSuchClass.myUndefinedMethod();
4431 } 4457 }
4432 '''); 4458 ''');
4433 await assertNoFix(DartFixKind.CREATE_METHOD); 4459 await assertNoFix(DartFixKind.CREATE_METHOD);
4434 } 4460 }
4435 4461
4462 test_undefinedMethod_createUnqualified_duplicateArgumentNames() async {
4463 resolveTestUnit('''
4464 class C {
4465 int x;
4466 }
4467
4468 class D {
4469 foo(C c1, C c2) {
4470 bar(c1.x, c2.x);
4471 }
4472 }''');
4473 await assertHasFix(
4474 DartFixKind.CREATE_METHOD,
4475 '''
4476 class C {
4477 int x;
4478 }
4479
4480 class D {
4481 foo(C c1, C c2) {
4482 bar(c1.x, c2.x);
4483 }
4484
4485 void bar(int x, int x2) {
4486 }
4487 }''');
4488 }
4489
4436 test_undefinedMethod_createUnqualified_parameters() async { 4490 test_undefinedMethod_createUnqualified_parameters() async {
4437 resolveTestUnit(''' 4491 resolveTestUnit('''
4438 class A { 4492 class A {
4439 main() { 4493 main() {
4440 myUndefinedMethod(0, 1.0, '3'); 4494 myUndefinedMethod(0, 1.0, '3');
4441 } 4495 }
4442 } 4496 }
4443 '''); 4497 ''');
4444 await assertHasFix( 4498 await assertHasFix(
4445 DartFixKind.CREATE_METHOD, 4499 DartFixKind.CREATE_METHOD,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 int offset = resultCode.indexOf(search); 5008 int offset = resultCode.indexOf(search);
4955 positions.add(new Position(testFile, offset)); 5009 positions.add(new Position(testFile, offset));
4956 } 5010 }
4957 return positions; 5011 return positions;
4958 } 5012 }
4959 5013
4960 void _performAnalysis() { 5014 void _performAnalysis() {
4961 while (context.performAnalysisTask().hasMoreWork); 5015 while (context.performAnalysisTask().hasMoreWork);
4962 } 5016 }
4963 } 5017 }
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