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

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

Issue 1140963002: Issue 23444. Use ConstructorMember(s) for super constructor fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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
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 'package:analysis_server/edit/fix/fix_core.dart'; 7 import 'package:analysis_server/edit/fix/fix_core.dart';
8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
9 import 'package:analysis_server/src/services/correction/fix.dart'; 9 import 'package:analysis_server/src/services/correction/fix.dart';
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; 10 import 'package:analysis_server/src/services/correction/fix_internal.dart';
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 class A { 510 class A {
511 A._named(int p); 511 A._named(int p);
512 } 512 }
513 class B extends A { 513 class B extends A {
514 B() {} 514 B() {}
515 } 515 }
516 '''); 516 ''');
517 assertNoFix(DartFixKind.ADD_SUPER_CONSTRUCTOR_INVOCATION); 517 assertNoFix(DartFixKind.ADD_SUPER_CONSTRUCTOR_INVOCATION);
518 } 518 }
519 519
520 void test_createConstructorSuperExplicit_typeArgument() {
521 resolveTestUnit('''
522 class A<T> {
523 A(T p);
524 }
525 class B extends A<int> {
526 B();
527 }
528 ''');
529 assertHasFix(DartFixKind.ADD_SUPER_CONSTRUCTOR_INVOCATION, '''
530 class A<T> {
531 A(T p);
532 }
533 class B extends A<int> {
534 B() : super(0);
535 }
536 ''');
537 }
538
520 void test_createConstructorSuperImplicit() { 539 void test_createConstructorSuperImplicit() {
521 resolveTestUnit(''' 540 resolveTestUnit('''
522 class A { 541 class A {
523 A(p1, int p2, List<String> p3, [int p4]); 542 A(p1, int p2, List<String> p3, [int p4]);
524 } 543 }
525 class B extends A { 544 class B extends A {
526 int existingField; 545 int existingField;
527 546
528 void existingMethod() {} 547 void existingMethod() {}
529 } 548 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 resolveTestUnit(''' 643 resolveTestUnit('''
625 class A { 644 class A {
626 A._named(p); 645 A._named(p);
627 } 646 }
628 class B extends A { 647 class B extends A {
629 } 648 }
630 '''); 649 ''');
631 assertNoFix(DartFixKind.CREATE_CONSTRUCTOR_SUPER); 650 assertNoFix(DartFixKind.CREATE_CONSTRUCTOR_SUPER);
632 } 651 }
633 652
653 void test_createConstructorSuperImplicit_typeArgument() {
654 resolveTestUnit('''
655 class C<T> {
656 final T x;
657 C(this.x);
658 }
659 class D extends C<int> {
660 }''');
661 assertHasFix(DartFixKind.CREATE_CONSTRUCTOR_SUPER, '''
662 class C<T> {
663 final T x;
664 C(this.x);
665 }
666 class D extends C<int> {
667 D(int x) : super(x);
668 }''');
669 }
670
634 void test_createField_BAD_inEnum() { 671 void test_createField_BAD_inEnum() {
635 resolveTestUnit(''' 672 resolveTestUnit('''
636 enum MyEnum { 673 enum MyEnum {
637 AAA, BBB 674 AAA, BBB
638 } 675 }
639 main() { 676 main() {
640 MyEnum.foo; 677 MyEnum.foo;
641 } 678 }
642 '''); 679 ''');
643 assertNoFix(DartFixKind.CREATE_FIELD); 680 assertNoFix(DartFixKind.CREATE_FIELD);
(...skipping 2962 matching lines...) Expand 10 before | Expand all | Expand 10 after
3606 3643
3607 List<Position> _findResultPositions(List<String> searchStrings) { 3644 List<Position> _findResultPositions(List<String> searchStrings) {
3608 List<Position> positions = <Position>[]; 3645 List<Position> positions = <Position>[];
3609 for (String search in searchStrings) { 3646 for (String search in searchStrings) {
3610 int offset = resultCode.indexOf(search); 3647 int offset = resultCode.indexOf(search);
3611 positions.add(new Position(testFile, offset)); 3648 positions.add(new Position(testFile, offset));
3612 } 3649 }
3613 return positions; 3650 return positions;
3614 } 3651 }
3615 } 3652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698