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

Side by Side Diff: pkg/analyzer/test/generated/incremental_resolver_test.dart

Issue 1024553006: Issue 22962. Adding/removing method/accessor body is a declartion mismatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.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 engine.incremental_resolver_test; 5 library engine.incremental_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 void test_false_FunctionTypedFormalParameter_wasSimple() { 903 void test_false_FunctionTypedFormalParameter_wasSimple() {
904 _assertDoesNotMatch(r''' 904 _assertDoesNotMatch(r'''
905 main(int callback) { 905 main(int callback) {
906 } 906 }
907 ''', r''' 907 ''', r'''
908 main(int callback(int a, String b)) { 908 main(int callback(int a, String b)) {
909 } 909 }
910 '''); 910 ''');
911 } 911 }
912 912
913 void test_false_getter_body_add() {
914 _assertDoesNotMatchOK(r'''
915 class A {
916 int get foo;
917 }
918 ''', r'''
919 class A {
920 int get foo => 0;
921 }
922 ''');
923 }
924
925 void test_false_getter_body_remove() {
926 _assertDoesNotMatchOK(r'''
927 class A {
928 int get foo => 0;
929 }
930 ''', r'''
931 class A {
932 int get foo;
933 }
934 ''');
935 }
936
913 void test_false_implementsClause_add() { 937 void test_false_implementsClause_add() {
914 _assertDoesNotMatch(r''' 938 _assertDoesNotMatch(r'''
915 class A {} 939 class A {}
916 class B {} 940 class B {}
917 ''', r''' 941 ''', r'''
918 class A {} 942 class A {}
919 class B implements A {} 943 class B implements A {}
920 '''); 944 ''');
921 } 945 }
922 946
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 class A { 1105 class A {
1082 m() async {} 1106 m() async {}
1083 } 1107 }
1084 ''', r''' 1108 ''', r'''
1085 class A { 1109 class A {
1086 m() {} 1110 m() {}
1087 } 1111 }
1088 '''); 1112 ''');
1089 } 1113 }
1090 1114
1115 void test_false_method_body_add() {
1116 _assertDoesNotMatchOK(r'''
1117 class A {
1118 void foo();
1119 }
1120 ''', r'''
1121 class A {
1122 void foo() {}
1123 }
1124 ''');
1125 }
1126
1127 void test_false_method_body_remove() {
1128 _assertDoesNotMatchOK(r'''
1129 class A {
1130 void foo() {}
1131 }
1132 ''', r'''
1133 class A {
1134 void foo();
1135 }
1136 ''');
1137 }
1138
1091 void test_false_method_generator_add() { 1139 void test_false_method_generator_add() {
1092 _assertDoesNotMatchOK(r''' 1140 _assertDoesNotMatchOK(r'''
1093 class A { 1141 class A {
1094 m() async {} 1142 m() async {}
1095 } 1143 }
1096 ''', r''' 1144 ''', r'''
1097 class A { 1145 class A {
1098 m() async* {} 1146 m() async* {}
1099 } 1147 }
1100 '''); 1148 ''');
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 class M<T> {} 1663 class M<T> {}
1616 class A<T> {} 1664 class A<T> {}
1617 class B<T> = A<T> with M<T>; 1665 class B<T> = A<T> with M<T>;
1618 ''', r''' 1666 ''', r'''
1619 class M<T> {} 1667 class M<T> {}
1620 class A<T> {} 1668 class A<T> {}
1621 class B<T> = A<T> with M<T>; 1669 class B<T> = A<T> with M<T>;
1622 '''); 1670 ''');
1623 } 1671 }
1624 1672
1673 void test_true_constructor_body_add() {
1674 _assertMatches(r'''
1675 class A {
1676 A(int p);
1677 }
1678 ''', r'''
1679 class A {
1680 A(int p) {}
1681 }
1682 ''');
1683 }
1684
1685 void test_true_constructor_body_remove() {
1686 _assertMatches(r'''
1687 class A {
1688 A(int p) {}
1689 }
1690 ''', r'''
1691 class A {
1692 A(int p);
1693 }
1694 ''');
1695 }
1696
1625 void test_true_constructor_named_same() { 1697 void test_true_constructor_named_same() {
1626 _assertMatches(r''' 1698 _assertMatches(r'''
1627 class A { 1699 class A {
1628 A.name(int p); 1700 A.name(int p);
1629 } 1701 }
1630 ''', r''' 1702 ''', r'''
1631 class A { 1703 class A {
1632 A.name(int p); 1704 A.name(int p);
1633 } 1705 }
1634 '''); 1706 ''');
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3831 } 3903 }
3832 3904
3833 ClassDeclaration _createResolvedClassDeclaration() { 3905 ClassDeclaration _createResolvedClassDeclaration() {
3834 CompilationUnit unit = _createResolvedCompilationUnit(); 3906 CompilationUnit unit = _createResolvedCompilationUnit();
3835 String className = "C"; 3907 String className = "C";
3836 ClassDeclaration classNode = AstFactory.classDeclaration( 3908 ClassDeclaration classNode = AstFactory.classDeclaration(
3837 null, className, AstFactory.typeParameterList(), null, null, null); 3909 null, className, AstFactory.typeParameterList(), null, null, null);
3838 unit.declarations.add(classNode); 3910 unit.declarations.add(classNode);
3839 ClassElement classElement = ElementFactory.classElement2(className); 3911 ClassElement classElement = ElementFactory.classElement2(className);
3840 classNode.name.staticElement = classElement; 3912 classNode.name.staticElement = classElement;
3841 (unit.element as CompilationUnitElementImpl).types = <ClassElement>[ 3913 (unit.element as CompilationUnitElementImpl).types =
3842 classElement 3914 <ClassElement>[classElement];
3843 ];
3844 return classNode; 3915 return classNode;
3845 } 3916 }
3846 3917
3847 ClassTypeAlias _createResolvedClassTypeAlias() { 3918 ClassTypeAlias _createResolvedClassTypeAlias() {
3848 CompilationUnit unit = _createResolvedCompilationUnit(); 3919 CompilationUnit unit = _createResolvedCompilationUnit();
3849 String className = "C"; 3920 String className = "C";
3850 ClassTypeAlias classNode = AstFactory.classTypeAlias( 3921 ClassTypeAlias classNode = AstFactory.classTypeAlias(
3851 className, AstFactory.typeParameterList(), null, null, null, null); 3922 className, AstFactory.typeParameterList(), null, null, null, null);
3852 unit.declarations.add(classNode); 3923 unit.declarations.add(classNode);
3853 ClassElement classElement = ElementFactory.classElement2(className); 3924 ClassElement classElement = ElementFactory.classElement2(className);
3854 classNode.name.staticElement = classElement; 3925 classNode.name.staticElement = classElement;
3855 (unit.element as CompilationUnitElementImpl).types = <ClassElement>[ 3926 (unit.element as CompilationUnitElementImpl).types =
3856 classElement 3927 <ClassElement>[classElement];
3857 ];
3858 return classNode; 3928 return classNode;
3859 } 3929 }
3860 3930
3861 CompilationUnit _createResolvedCompilationUnit() { 3931 CompilationUnit _createResolvedCompilationUnit() {
3862 CompilationUnit unit = AstFactory.compilationUnit(); 3932 CompilationUnit unit = AstFactory.compilationUnit();
3863 LibraryElementImpl library = 3933 LibraryElementImpl library =
3864 ElementFactory.library(AnalysisContextFactory.contextWithCore(), "lib"); 3934 ElementFactory.library(AnalysisContextFactory.contextWithCore(), "lib");
3865 unit.element = library.definingCompilationUnit; 3935 unit.element = library.definingCompilationUnit;
3866 return unit; 3936 return unit;
3867 } 3937 }
3868 3938
3869 ConstructorDeclaration _createResolvedConstructorDeclaration() { 3939 ConstructorDeclaration _createResolvedConstructorDeclaration() {
3870 ClassDeclaration classNode = _createResolvedClassDeclaration(); 3940 ClassDeclaration classNode = _createResolvedClassDeclaration();
3871 String constructorName = "f"; 3941 String constructorName = "f";
3872 ConstructorDeclaration constructorNode = AstFactory.constructorDeclaration( 3942 ConstructorDeclaration constructorNode = AstFactory.constructorDeclaration(
3873 AstFactory.identifier3(constructorName), null, 3943 AstFactory.identifier3(constructorName), null,
3874 AstFactory.formalParameterList(), null); 3944 AstFactory.formalParameterList(), null);
3875 classNode.members.add(constructorNode); 3945 classNode.members.add(constructorNode);
3876 ConstructorElement constructorElement = 3946 ConstructorElement constructorElement =
3877 ElementFactory.constructorElement2(classNode.element, null); 3947 ElementFactory.constructorElement2(classNode.element, null);
3878 constructorNode.element = constructorElement; 3948 constructorNode.element = constructorElement;
3879 (classNode.element as ClassElementImpl).constructors = <ConstructorElement>[ 3949 (classNode.element as ClassElementImpl).constructors =
3880 constructorElement 3950 <ConstructorElement>[constructorElement];
3881 ];
3882 return constructorNode; 3951 return constructorNode;
3883 } 3952 }
3884 3953
3885 FunctionDeclaration _createResolvedFunctionDeclaration() { 3954 FunctionDeclaration _createResolvedFunctionDeclaration() {
3886 CompilationUnit unit = _createResolvedCompilationUnit(); 3955 CompilationUnit unit = _createResolvedCompilationUnit();
3887 String functionName = "f"; 3956 String functionName = "f";
3888 FunctionDeclaration functionNode = AstFactory.functionDeclaration( 3957 FunctionDeclaration functionNode = AstFactory.functionDeclaration(
3889 null, null, functionName, AstFactory.functionExpression()); 3958 null, null, functionName, AstFactory.functionExpression());
3890 unit.declarations.add(functionNode); 3959 unit.declarations.add(functionNode);
3891 FunctionElement functionElement = 3960 FunctionElement functionElement =
3892 ElementFactory.functionElement(functionName); 3961 ElementFactory.functionElement(functionName);
3893 functionNode.name.staticElement = functionElement; 3962 functionNode.name.staticElement = functionElement;
3894 (unit.element as CompilationUnitElementImpl).functions = <FunctionElement>[ 3963 (unit.element as CompilationUnitElementImpl).functions =
3895 functionElement 3964 <FunctionElement>[functionElement];
3896 ];
3897 return functionNode; 3965 return functionNode;
3898 } 3966 }
3899 3967
3900 FunctionTypeAlias _createResolvedFunctionTypeAlias() { 3968 FunctionTypeAlias _createResolvedFunctionTypeAlias() {
3901 CompilationUnit unit = _createResolvedCompilationUnit(); 3969 CompilationUnit unit = _createResolvedCompilationUnit();
3902 FunctionTypeAlias aliasNode = AstFactory.typeAlias( 3970 FunctionTypeAlias aliasNode = AstFactory.typeAlias(
3903 AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(), 3971 AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(),
3904 AstFactory.formalParameterList()); 3972 AstFactory.formalParameterList());
3905 unit.declarations.add(aliasNode); 3973 unit.declarations.add(aliasNode);
3906 SimpleIdentifier aliasName = aliasNode.name; 3974 SimpleIdentifier aliasName = aliasNode.name;
3907 FunctionTypeAliasElement aliasElement = 3975 FunctionTypeAliasElement aliasElement =
3908 new FunctionTypeAliasElementImpl.forNode(aliasName); 3976 new FunctionTypeAliasElementImpl.forNode(aliasName);
3909 aliasName.staticElement = aliasElement; 3977 aliasName.staticElement = aliasElement;
3910 (unit.element as CompilationUnitElementImpl).typeAliases = 3978 (unit.element as CompilationUnitElementImpl).typeAliases =
3911 <FunctionTypeAliasElement>[aliasElement]; 3979 <FunctionTypeAliasElement>[aliasElement];
3912 return aliasNode; 3980 return aliasNode;
3913 } 3981 }
3914 3982
3915 MethodDeclaration _createResolvedMethodDeclaration() { 3983 MethodDeclaration _createResolvedMethodDeclaration() {
3916 ClassDeclaration classNode = _createResolvedClassDeclaration(); 3984 ClassDeclaration classNode = _createResolvedClassDeclaration();
3917 String methodName = "f"; 3985 String methodName = "f";
3918 MethodDeclaration methodNode = AstFactory.methodDeclaration(null, null, 3986 MethodDeclaration methodNode = AstFactory.methodDeclaration(null, null,
3919 null, null, AstFactory.identifier3(methodName), 3987 null, null, AstFactory.identifier3(methodName),
3920 AstFactory.formalParameterList()); 3988 AstFactory.formalParameterList());
3921 classNode.members.add(methodNode); 3989 classNode.members.add(methodNode);
3922 MethodElement methodElement = 3990 MethodElement methodElement =
3923 ElementFactory.methodElement(methodName, null); 3991 ElementFactory.methodElement(methodName, null);
3924 methodNode.name.staticElement = methodElement; 3992 methodNode.name.staticElement = methodElement;
3925 (classNode.element as ClassElementImpl).methods = <MethodElement>[ 3993 (classNode.element as ClassElementImpl).methods =
3926 methodElement 3994 <MethodElement>[methodElement];
3927 ];
3928 return methodNode; 3995 return methodNode;
3929 } 3996 }
3930 3997
3931 Scope _scopeFor(AstNode node) { 3998 Scope _scopeFor(AstNode node) {
3932 return ResolutionContextBuilder.contextFor(node, listener).scope; 3999 return ResolutionContextBuilder.contextFor(node, listener).scope;
3933 } 4000 }
3934 } 4001 }
3935 4002
3936 class _Edit { 4003 class _Edit {
3937 final int offset; 4004 final int offset;
3938 final int length; 4005 final int length;
3939 final String replacement; 4006 final String replacement;
3940 _Edit(this.offset, this.length, this.replacement); 4007 _Edit(this.offset, this.length, this.replacement);
3941 } 4008 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698