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

Side by Side Diff: pkg/analyzer_experimental/test/generated/resolver_test.dart

Issue 14205011: Issue 9845. Compare runtime types using ==. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver_test; 4 library engine.resolver_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 7 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 8 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 9 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 10 import 'package:analyzer_experimental/src/generated/source_io.dart';
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 CompilationUnit unit = resolveCompilationUnit(source, library); 242 CompilationUnit unit = resolveCompilationUnit(source, library);
243 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 243 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
244 InterfaceType typeA = classA.element.type; 244 InterfaceType typeA = classA.element.type;
245 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 245 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
246 BlockFunctionBody body21 = function.functionExpression.body as BlockFunction Body; 246 BlockFunctionBody body21 = function.functionExpression.body as BlockFunction Body;
247 ReturnStatement statement = body21.block.statements[1] as ReturnStatement; 247 ReturnStatement statement = body21.block.statements[1] as ReturnStatement;
248 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 248 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
249 JUnitTestCase.assertSame(typeA, variableName.staticType); 249 JUnitTestCase.assertSame(typeA, variableName.staticType);
250 } 250 }
251 void test_query() { 251 void test_query() {
252 addSource("/html.dart", EngineTestCase.createSource(["library dart.dom.html; ", "", "class Element {}", "class AnchorElement extends Element {}", "class Body Element extends Element {}", "class ButtonElement extends Element {}", "class Di vElement extends Element {}", "class Document extends Element {}", "class HtmlDo cument extends Document {", " Element query(String selector) { return null; }", "}", "class InputElement extends Element {}", "class SelectElement extends Elem ent {}", "", "HtmlDocument document = null;", "", "Element query(String selector ) { return null; }"])); 252 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'dart:html';", "", "main() {", " var v1 = query('a');", " var v2 = query('A') ;", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]') ;", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query ('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " r eturn [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
253 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'html.dart';", "", "main() {", " var v1 = query('a');", " var v2 = query('A') ;", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]') ;", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('select#id');", " // invocation of method", " var m1 = document.query ('div');", " // unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " r eturn [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
254 LibraryElement library = resolve(source, []); 253 LibraryElement library = resolve(source, []);
255 assertNoErrors(); 254 assertNoErrors();
256 verify([source]); 255 verify([source]);
257 CompilationUnit unit = resolveCompilationUnit(source, library); 256 CompilationUnit unit = resolveCompilationUnit(source, library);
258 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; 257 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
259 BlockFunctionBody body22 = main.functionExpression.body as BlockFunctionBody ; 258 BlockFunctionBody body22 = main.functionExpression.body as BlockFunctionBody ;
260 ReturnStatement statement = body22.block.statements[11] as ReturnStatement; 259 ReturnStatement statement = body22.block.statements[11] as ReturnStatement;
261 NodeList<Expression> elements3 = ((statement.expression as ListLiteral)).ele ments; 260 NodeList<Expression> elements3 = ((statement.expression as ListLiteral)).ele ments;
262 JUnitTestCase.assertEquals("AnchorElement", elements3[0].staticType.name); 261 JUnitTestCase.assertEquals("AnchorElement", elements3[0].staticType.name);
263 JUnitTestCase.assertEquals("AnchorElement", elements3[1].staticType.name); 262 JUnitTestCase.assertEquals("AnchorElement", elements3[1].staticType.name);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 assertNoErrors(); 515 assertNoErrors();
517 verify([source]); 516 verify([source]);
518 } 517 }
519 void test_importOfNonLibrary_libraryNotDeclared() { 518 void test_importOfNonLibrary_libraryNotDeclared() {
520 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "import 'part.dart';"])); 519 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "import 'part.dart';"]));
521 addSource("/part.dart", EngineTestCase.createSource([""])); 520 addSource("/part.dart", EngineTestCase.createSource([""]));
522 resolve(source, []); 521 resolve(source, []);
523 assertNoErrors(); 522 assertNoErrors();
524 verify([source]); 523 verify([source]);
525 } 524 }
525 void test_inconsistentCaseExpressionTypes() {
526 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 2:", " br eak;", " }", "}"]));
527 resolve(source, []);
528 assertNoErrors();
529 verify([source]);
530 }
526 void test_initializingFormalForNonExistantField() { 531 void test_initializingFormalForNonExistantField() {
527 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"])); 532 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
528 resolve(source, []); 533 resolve(source, []);
529 assertNoErrors(); 534 assertNoErrors();
530 verify([source]); 535 verify([source]);
531 } 536 }
532 void test_invalidAssignment() { 537 void test_invalidAssignment() {
533 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"])); 538 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"]));
534 resolve(source, []); 539 resolve(source, []);
535 assertNoErrors(); 540 assertNoErrors();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 runJUnitTest(__test, __test.test_finalNotInitialized_initializer); 755 runJUnitTest(__test, __test.test_finalNotInitialized_initializer);
751 }); 756 });
752 _ut.test('test_importOfNonLibrary_libraryDeclared', () { 757 _ut.test('test_importOfNonLibrary_libraryDeclared', () {
753 final __test = new NonErrorResolverTest(); 758 final __test = new NonErrorResolverTest();
754 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared); 759 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared);
755 }); 760 });
756 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () { 761 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () {
757 final __test = new NonErrorResolverTest(); 762 final __test = new NonErrorResolverTest();
758 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared); 763 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared);
759 }); 764 });
765 _ut.test('test_inconsistentCaseExpressionTypes', () {
766 final __test = new NonErrorResolverTest();
767 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
768 });
760 _ut.test('test_initializingFormalForNonExistantField', () { 769 _ut.test('test_initializingFormalForNonExistantField', () {
761 final __test = new NonErrorResolverTest(); 770 final __test = new NonErrorResolverTest();
762 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); 771 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
763 }); 772 });
764 _ut.test('test_invalidAssignment', () { 773 _ut.test('test_invalidAssignment', () {
765 final __test = new NonErrorResolverTest(); 774 final __test = new NonErrorResolverTest();
766 runJUnitTest(__test, __test.test_invalidAssignment); 775 runJUnitTest(__test, __test.test_invalidAssignment);
767 }); 776 });
768 _ut.test('test_invalidAssignment_toDynamic', () { 777 _ut.test('test_invalidAssignment_toDynamic', () {
769 final __test = new NonErrorResolverTest(); 778 final __test = new NonErrorResolverTest();
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 verify([source]); 1887 verify([source]);
1879 } 1888 }
1880 void fail_importDuplicatedLibraryName() { 1889 void fail_importDuplicatedLibraryName() {
1881 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y test;", "import 'lib1.dart';", "import 'lib2.dart';"])); 1890 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y test;", "import 'lib1.dart';", "import 'lib2.dart';"]));
1882 addSource("/lib1.dart", EngineTestCase.createSource(["library lib;"])); 1891 addSource("/lib1.dart", EngineTestCase.createSource(["library lib;"]));
1883 addSource("/lib2.dart", EngineTestCase.createSource(["library lib;"])); 1892 addSource("/lib2.dart", EngineTestCase.createSource(["library lib;"]));
1884 resolve(source, []); 1893 resolve(source, []);
1885 assertErrors([CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME]); 1894 assertErrors([CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME]);
1886 verify([source]); 1895 verify([source]);
1887 } 1896 }
1888 void fail_inconsistentCaseExpressionTypes() {
1889 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 3:", " break;", " case 'a':", " break;", " }", "}"]));
1890 resolve(source, []);
1891 assertErrors([CompileTimeErrorCode.INCONSITENT_CASE_EXPRESSION_TYPES]);
1892 verify([source]);
1893 }
1894 void fail_initializerForNonExistant_initializer() { 1897 void fail_initializerForNonExistant_initializer() {
1895 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"])); 1898 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"]));
1896 resolve(source, []); 1899 resolve(source, []);
1897 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]); 1900 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]);
1898 verify([source]); 1901 verify([source]);
1899 } 1902 }
1900 void fail_initializerForStaticField() { 1903 void fail_initializerForStaticField() {
1901 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static x;", " A() : x = 0 {}", "}"])); 1904 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static x;", " A() : x = 0 {}", "}"]));
1902 resolve(source, []); 1905 resolve(source, []);
1903 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); 1906 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 assertErrors([CompileTimeErrorCode.IMPLEMENTS_SELF]); 2658 assertErrors([CompileTimeErrorCode.IMPLEMENTS_SELF]);
2656 verify([source]); 2659 verify([source]);
2657 } 2660 }
2658 void test_importOfNonLibrary() { 2661 void test_importOfNonLibrary() {
2659 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "import 'part.dart';"])); 2662 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "import 'part.dart';"]));
2660 addSource("/part.dart", EngineTestCase.createSource(["part of lib;"])); 2663 addSource("/part.dart", EngineTestCase.createSource(["part of lib;"]));
2661 resolve(source, []); 2664 resolve(source, []);
2662 assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); 2665 assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
2663 verify([source]); 2666 verify([source]);
2664 } 2667 }
2668 void test_inconsistentCaseExpressionTypes() {
2669 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " }", "}"]));
2670 resolve(source, []);
2671 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
2672 verify([source]);
2673 }
2674 void test_inconsistentCaseExpressionTypes_repeated() {
2675 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " switch (p) {", " case 1:", " break;", " case 'a':", " break;", " case 'b':", " break;", " }", "}"]));
2676 resolve(source, []);
2677 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, Compi leTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
2678 verify([source]);
2679 }
2665 void test_initializingFormalForNonExistantField() { 2680 void test_initializingFormalForNonExistantField() {
2666 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(this.x) {}", "}"])); 2681 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " A(this.x) {}", "}"]));
2667 resolve(source, []); 2682 resolve(source, []);
2668 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 2683 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
2669 verify([source]); 2684 verify([source]);
2670 } 2685 }
2671 void test_initializingFormalForNonExistantField_notInEnclosingClass() { 2686 void test_initializingFormalForNonExistantField_notInEnclosingClass() {
2672 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", "int x;", "}", "class B extends A {", " B(this.x) {}", "}"])); 2687 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", "int x;", "}", "class B extends A {", " B(this.x) {}", "}"]));
2673 resolve(source, []); 2688 resolve(source, []);
2674 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 2689 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 runJUnitTest(__test, __test.test_implementsRepeated_3times); 3029 runJUnitTest(__test, __test.test_implementsRepeated_3times);
3015 }); 3030 });
3016 _ut.test('test_implementsSelf', () { 3031 _ut.test('test_implementsSelf', () {
3017 final __test = new CompileTimeErrorCodeTest(); 3032 final __test = new CompileTimeErrorCodeTest();
3018 runJUnitTest(__test, __test.test_implementsSelf); 3033 runJUnitTest(__test, __test.test_implementsSelf);
3019 }); 3034 });
3020 _ut.test('test_importOfNonLibrary', () { 3035 _ut.test('test_importOfNonLibrary', () {
3021 final __test = new CompileTimeErrorCodeTest(); 3036 final __test = new CompileTimeErrorCodeTest();
3022 runJUnitTest(__test, __test.test_importOfNonLibrary); 3037 runJUnitTest(__test, __test.test_importOfNonLibrary);
3023 }); 3038 });
3039 _ut.test('test_inconsistentCaseExpressionTypes', () {
3040 final __test = new CompileTimeErrorCodeTest();
3041 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
3042 });
3043 _ut.test('test_inconsistentCaseExpressionTypes_repeated', () {
3044 final __test = new CompileTimeErrorCodeTest();
3045 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes_repeate d);
3046 });
3024 _ut.test('test_initializingFormalForNonExistantField', () { 3047 _ut.test('test_initializingFormalForNonExistantField', () {
3025 final __test = new CompileTimeErrorCodeTest(); 3048 final __test = new CompileTimeErrorCodeTest();
3026 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); 3049 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
3027 }); 3050 });
3028 _ut.test('test_initializingFormalForNonExistantField_notInEnclosingClass', () { 3051 _ut.test('test_initializingFormalForNonExistantField_notInEnclosingClass', () {
3029 final __test = new CompileTimeErrorCodeTest(); 3052 final __test = new CompileTimeErrorCodeTest();
3030 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass); 3053 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass);
3031 }); 3054 });
3032 _ut.test('test_initializingFormalForNonExistantField_optional', () { 3055 _ut.test('test_initializingFormalForNonExistantField_optional', () {
3033 final __test = new CompileTimeErrorCodeTest(); 3056 final __test = new CompileTimeErrorCodeTest();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3148 int unresolvedTypeCount = _unresolvedTypes.length; 3171 int unresolvedTypeCount = _unresolvedTypes.length;
3149 PrintStringWriter writer = new PrintStringWriter(); 3172 PrintStringWriter writer = new PrintStringWriter();
3150 writer.print("Failed to associate types with nodes: "); 3173 writer.print("Failed to associate types with nodes: ");
3151 writer.print(unresolvedExpressionCount); 3174 writer.print(unresolvedExpressionCount);
3152 writer.print("/"); 3175 writer.print("/");
3153 writer.print(_resolvedExpressionCount + unresolvedExpressionCount); 3176 writer.print(_resolvedExpressionCount + unresolvedExpressionCount);
3154 writer.print(" Expressions and "); 3177 writer.print(" Expressions and ");
3155 writer.print(unresolvedTypeCount); 3178 writer.print(unresolvedTypeCount);
3156 writer.print("/"); 3179 writer.print("/");
3157 writer.print(_resolvedTypeCount + unresolvedTypeCount); 3180 writer.print(_resolvedTypeCount + unresolvedTypeCount);
3158 writer.printlnObject(" TypeNames."); 3181 writer.println(" TypeNames.");
3159 if (unresolvedTypeCount > 0) { 3182 if (unresolvedTypeCount > 0) {
3160 writer.printlnObject("TypeNames:"); 3183 writer.println("TypeNames:");
3161 for (TypeName identifier in _unresolvedTypes) { 3184 for (TypeName identifier in _unresolvedTypes) {
3162 writer.print(" "); 3185 writer.print(" ");
3163 writer.print(identifier.toString()); 3186 writer.print(identifier.toString());
3164 writer.print(" ("); 3187 writer.print(" (");
3165 writer.print(getFileName(identifier)); 3188 writer.print(getFileName(identifier));
3166 writer.print(" : "); 3189 writer.print(" : ");
3167 writer.print(identifier.offset); 3190 writer.print(identifier.offset);
3168 writer.printlnObject(")"); 3191 writer.println(")");
3169 } 3192 }
3170 } 3193 }
3171 if (unresolvedExpressionCount > 0) { 3194 if (unresolvedExpressionCount > 0) {
3172 writer.printlnObject("Expressions:"); 3195 writer.println("Expressions:");
3173 for (Expression identifier in _unresolvedExpressions) { 3196 for (Expression identifier in _unresolvedExpressions) {
3174 writer.print(" "); 3197 writer.print(" ");
3175 writer.print(identifier.toString()); 3198 writer.print(identifier.toString());
3176 writer.print(" ("); 3199 writer.print(" (");
3177 writer.print(getFileName(identifier)); 3200 writer.print(getFileName(identifier));
3178 writer.print(" : "); 3201 writer.print(" : ");
3179 writer.print(identifier.offset); 3202 writer.print(identifier.offset);
3180 writer.printlnObject(")"); 3203 writer.println(")");
3181 } 3204 }
3182 } 3205 }
3183 JUnitTestCase.fail(writer.toString()); 3206 JUnitTestCase.fail(writer.toString());
3184 } 3207 }
3185 } 3208 }
3186 Object visitCommentReference(CommentReference node) => null; 3209 Object visitCommentReference(CommentReference node) => null;
3187 Object visitExpression(Expression node) { 3210 Object visitExpression(Expression node) {
3188 node.visitChildren(this); 3211 node.visitChildren(this);
3189 if (node.staticType == null) { 3212 if (node.staticType == null) {
3190 _unresolvedExpressions.add(node); 3213 _unresolvedExpressions.add(node);
3191 } else { 3214 } else {
3192 _resolvedExpressionCount++; 3215 _resolvedExpressionCount++;
3193 } 3216 }
3194 return null; 3217 return null;
3195 } 3218 }
3196 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 3219 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
3197 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 3220 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
3198 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 3221 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
3199 return null; 3222 return null;
3200 } 3223 }
3201 return super.visitPrefixedIdentifier(node); 3224 return super.visitPrefixedIdentifier(node);
3202 } 3225 }
3203 Object visitSimpleIdentifier(SimpleIdentifier node) { 3226 Object visitSimpleIdentifier(SimpleIdentifier node) {
3204 ASTNode parent20 = node.parent; 3227 ASTNode parent21 = node.parent;
3205 if (parent20 is MethodInvocation && identical(node, ((parent20 as MethodInvo cation)).methodName)) { 3228 if (parent21 is MethodInvocation && identical(node, ((parent21 as MethodInvo cation)).methodName)) {
3206 return null; 3229 return null;
3207 } else if (parent20 is RedirectingConstructorInvocation && identical(node, ( (parent20 as RedirectingConstructorInvocation)).constructorName)) { 3230 } else if (parent21 is RedirectingConstructorInvocation && identical(node, ( (parent21 as RedirectingConstructorInvocation)).constructorName)) {
3208 return null; 3231 return null;
3209 } else if (parent20 is SuperConstructorInvocation && identical(node, ((paren t20 as SuperConstructorInvocation)).constructorName)) { 3232 } else if (parent21 is SuperConstructorInvocation && identical(node, ((paren t21 as SuperConstructorInvocation)).constructorName)) {
3210 return null; 3233 return null;
3211 } else if (parent20 is ConstructorName && identical(node, ((parent20 as Cons tructorName)).name)) { 3234 } else if (parent21 is ConstructorName && identical(node, ((parent21 as Cons tructorName)).name)) {
3212 return null; 3235 return null;
3213 } else if (parent20 is Label && identical(node, ((parent20 as Label)).label) ) { 3236 } else if (parent21 is Label && identical(node, ((parent21 as Label)).label) ) {
3214 return null; 3237 return null;
3215 } else if (parent20 is ImportDirective && identical(node, ((parent20 as Impo rtDirective)).prefix)) { 3238 } else if (parent21 is ImportDirective && identical(node, ((parent21 as Impo rtDirective)).prefix)) {
3216 return null; 3239 return null;
3217 } else if (node.element is PrefixElement) { 3240 } else if (node.element is PrefixElement) {
3218 return null; 3241 return null;
3219 } 3242 }
3220 return super.visitSimpleIdentifier(node); 3243 return super.visitSimpleIdentifier(node);
3221 } 3244 }
3222 Object visitTypeName(TypeName node) { 3245 Object visitTypeName(TypeName node) {
3223 if (node.type == null) { 3246 if (node.type == null) {
3224 _unresolvedTypes.add(node); 3247 _unresolvedTypes.add(node);
3225 } else { 3248 } else {
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
4546 TestTypeProvider provider = new TestTypeProvider(); 4569 TestTypeProvider provider = new TestTypeProvider();
4547 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art"); 4570 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
4548 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 4571 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
4549 coreUnit.source = coreSource; 4572 coreUnit.source = coreSource;
4550 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT ype.element, provider.functionType.element, provider.intType.element, provider.l istType.element, provider.mapType.element, provider.numType.element, provider.ob jectType.element, provider.stackTraceType.element, provider.stringType.element, provider.typeType.element]; 4573 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT ype.element, provider.functionType.element, provider.intType.element, provider.l istType.element, provider.mapType.element, provider.numType.element, provider.ob jectType.element, provider.stackTraceType.element, provider.stringType.element, provider.typeType.element];
4551 LibraryElementImpl coreLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "core"])); 4574 LibraryElementImpl coreLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "core"]));
4552 coreLibrary.definingCompilationUnit = coreUnit; 4575 coreLibrary.definingCompilationUnit = coreUnit;
4553 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart"); 4576 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart");
4554 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 4577 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
4555 htmlUnit.source = htmlSource; 4578 htmlUnit.source = htmlSource;
4579 ClassElementImpl elementElement = ElementFactory.classElement2("Element", [] );
4580 InterfaceType elementType = elementElement.type;
4581 ClassElementImpl documentElement = ElementFactory.classElement("Document", e lementType, []);
4582 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu ment", documentElement.type, []);
4583 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement( "query", elementType, <Type2> [provider.stringType])];
4584 htmlUnit.types = <ClassElement> [ElementFactory.classElement("AnchorElement" , elementType, []), ElementFactory.classElement("BodyElement", elementType, []), ElementFactory.classElement("ButtonElement", elementType, []), ElementFactory.c lassElement("DivElement", elementType, []), documentElement, elementElement, htm lDocumentElement, ElementFactory.classElement("InputElement", elementType, []), ElementFactory.classElement("SelectElement", elementType, [])];
4585 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)];
4586 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t2("document");
4587 document.type = htmlDocumentElement.type;
4588 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
4556 LibraryElementImpl htmlLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "dom", "html"])); 4589 LibraryElementImpl htmlLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "dom", "html"]));
4557 htmlLibrary.definingCompilationUnit = htmlUnit; 4590 htmlLibrary.definingCompilationUnit = htmlUnit;
4558 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); 4591 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
4559 elementMap[coreSource] = coreLibrary; 4592 elementMap[coreSource] = coreLibrary;
4560 elementMap[htmlSource] = htmlLibrary; 4593 elementMap[htmlSource] = htmlLibrary;
4561 context.setContents(coreSource, ""); 4594 context.setContents(coreSource, "");
4562 context.setContents(htmlSource, ""); 4595 context.setContents(htmlSource, "");
4563 context.recordLibraryElements(elementMap); 4596 context.recordLibraryElements(elementMap);
4564 return context; 4597 return context;
4565 } 4598 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 } 4736 }
4704 /** 4737 /**
4705 * Assert that all of the visited identifiers were resolved. 4738 * Assert that all of the visited identifiers were resolved.
4706 */ 4739 */
4707 void assertResolved() { 4740 void assertResolved() {
4708 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) { 4741 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
4709 PrintStringWriter writer = new PrintStringWriter(); 4742 PrintStringWriter writer = new PrintStringWriter();
4710 if (!_unresolvedNodes.isEmpty) { 4743 if (!_unresolvedNodes.isEmpty) {
4711 writer.print("Failed to resolve "); 4744 writer.print("Failed to resolve ");
4712 writer.print(_unresolvedNodes.length); 4745 writer.print(_unresolvedNodes.length);
4713 writer.printlnObject(" nodes:"); 4746 writer.println(" nodes:");
4714 printNodes(writer, _unresolvedNodes); 4747 printNodes(writer, _unresolvedNodes);
4715 } 4748 }
4716 if (!_wrongTypedNodes.isEmpty) { 4749 if (!_wrongTypedNodes.isEmpty) {
4717 writer.print("Resolved "); 4750 writer.print("Resolved ");
4718 writer.print(_wrongTypedNodes.length); 4751 writer.print(_wrongTypedNodes.length);
4719 writer.printlnObject(" to the wrong type of element:"); 4752 writer.println(" to the wrong type of element:");
4720 printNodes(writer, _wrongTypedNodes); 4753 printNodes(writer, _wrongTypedNodes);
4721 } 4754 }
4722 JUnitTestCase.fail(writer.toString()); 4755 JUnitTestCase.fail(writer.toString());
4723 } 4756 }
4724 } 4757 }
4725 Object visitBinaryExpression(BinaryExpression node) { 4758 Object visitBinaryExpression(BinaryExpression node) {
4726 node.visitChildren(this); 4759 node.visitChildren(this);
4727 if (!node.operator.isUserDefinableOperator()) { 4760 if (!node.operator.isUserDefinableOperator()) {
4728 return null; 4761 return null;
4729 } 4762 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4813 return "<unknown file- ASTNode is null>"; 4846 return "<unknown file- ASTNode is null>";
4814 } 4847 }
4815 void printNodes(PrintStringWriter writer, List<ASTNode> nodes) { 4848 void printNodes(PrintStringWriter writer, List<ASTNode> nodes) {
4816 for (ASTNode identifier in nodes) { 4849 for (ASTNode identifier in nodes) {
4817 writer.print(" "); 4850 writer.print(" ");
4818 writer.print(identifier.toString()); 4851 writer.print(identifier.toString());
4819 writer.print(" ("); 4852 writer.print(" (");
4820 writer.print(getFileName(identifier)); 4853 writer.print(getFileName(identifier));
4821 writer.print(" : "); 4854 writer.print(" : ");
4822 writer.print(identifier.offset); 4855 writer.print(identifier.offset);
4823 writer.printlnObject(")"); 4856 writer.println(")");
4824 } 4857 }
4825 } 4858 }
4826 } 4859 }
4827 class LibraryScopeTest extends ResolverTestCase { 4860 class LibraryScopeTest extends ResolverTestCase {
4828 void test_creation_empty() { 4861 void test_creation_empty() {
4829 LibraryElement definingLibrary = createTestLibrary(); 4862 LibraryElement definingLibrary = createTestLibrary();
4830 GatheringErrorListener errorListener = new GatheringErrorListener(); 4863 GatheringErrorListener errorListener = new GatheringErrorListener();
4831 new LibraryScope(definingLibrary, errorListener); 4864 new LibraryScope(definingLibrary, errorListener);
4832 } 4865 }
4833 void test_creation_nonEmpty() { 4866 void test_creation_nonEmpty() {
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 // LibraryScopeTest.dartSuite(); 6392 // LibraryScopeTest.dartSuite();
6360 // ScopeTest.dartSuite(); 6393 // ScopeTest.dartSuite();
6361 // CompileTimeErrorCodeTest.dartSuite(); 6394 // CompileTimeErrorCodeTest.dartSuite();
6362 // ErrorResolverTest.dartSuite(); 6395 // ErrorResolverTest.dartSuite();
6363 // NonErrorResolverTest.dartSuite(); 6396 // NonErrorResolverTest.dartSuite();
6364 // SimpleResolverTest.dartSuite(); 6397 // SimpleResolverTest.dartSuite();
6365 // StaticTypeWarningCodeTest.dartSuite(); 6398 // StaticTypeWarningCodeTest.dartSuite();
6366 // StaticWarningCodeTest.dartSuite(); 6399 // StaticWarningCodeTest.dartSuite();
6367 // TypePropagationTest.dartSuite(); 6400 // TypePropagationTest.dartSuite();
6368 } 6401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698