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

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

Issue 134533007: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 'package:analyzer/src/generated/java_core.dart'; 6 import 'package:analyzer/src/generated/java_core.dart';
7 import 'package:analyzer/src/generated/java_junit.dart'; 7 import 'package:analyzer/src/generated/java_junit.dart';
8 import 'package:analyzer/src/generated/source_io.dart'; 8 import 'package:analyzer/src/generated/source_io.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 14424 matching lines...) Expand 10 before | Expand all | Expand 10 after
14435 14435
14436 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 14436 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
14437 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 14437 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
14438 return null; 14438 return null;
14439 } 14439 }
14440 return super.visitPrefixedIdentifier(node); 14440 return super.visitPrefixedIdentifier(node);
14441 } 14441 }
14442 14442
14443 Object visitSimpleIdentifier(SimpleIdentifier node) { 14443 Object visitSimpleIdentifier(SimpleIdentifier node) {
14444 ASTNode parent = node.parent; 14444 ASTNode parent = node.parent;
14445 if (parent is MethodInvocation && identical(node, (parent as MethodInvocatio n).methodName)) { 14445 if (parent is MethodInvocation && identical(node, parent.methodName)) {
14446 return null; 14446 return null;
14447 } else if (parent is RedirectingConstructorInvocation && identical(node, (pa rent as RedirectingConstructorInvocation).constructorName)) { 14447 } else if (parent is RedirectingConstructorInvocation && identical(node, par ent.constructorName)) {
14448 return null; 14448 return null;
14449 } else if (parent is SuperConstructorInvocation && identical(node, (parent a s SuperConstructorInvocation).constructorName)) { 14449 } else if (parent is SuperConstructorInvocation && identical(node, parent.co nstructorName)) {
14450 return null; 14450 return null;
14451 } else if (parent is ConstructorName && identical(node, (parent as Construct orName).name)) { 14451 } else if (parent is ConstructorName && identical(node, parent.name)) {
14452 return null; 14452 return null;
14453 } else if (parent is ConstructorFieldInitializer && identical(node, (parent as ConstructorFieldInitializer).fieldName)) { 14453 } else if (parent is ConstructorFieldInitializer && identical(node, parent.f ieldName)) {
14454 return null; 14454 return null;
14455 } else if (node.staticElement is PrefixElement) { 14455 } else if (node.staticElement is PrefixElement) {
14456 return null; 14456 return null;
14457 } 14457 }
14458 return super.visitSimpleIdentifier(node); 14458 return super.visitSimpleIdentifier(node);
14459 } 14459 }
14460 14460
14461 Object visitTypeName(TypeName node) { 14461 Object visitTypeName(TypeName node) {
14462 if (node.type == null) { 14462 if (node.type == null) {
14463 _unresolvedTypes.add(node); 14463 _unresolvedTypes.add(node);
14464 } else { 14464 } else {
14465 _resolvedTypeCount++; 14465 _resolvedTypeCount++;
14466 } 14466 }
14467 return null; 14467 return null;
14468 } 14468 }
14469 14469
14470 String getFileName(ASTNode node) { 14470 String getFileName(ASTNode node) {
14471 if (node != null) { 14471 if (node != null) {
14472 ASTNode root = node.root; 14472 ASTNode root = node.root;
14473 if (root is CompilationUnit) { 14473 if (root is CompilationUnit) {
14474 CompilationUnit rootCU = root as CompilationUnit; 14474 CompilationUnit rootCU = root;
14475 if (rootCU.element != null) { 14475 if (rootCU.element != null) {
14476 return rootCU.element.source.fullName; 14476 return rootCU.element.source.fullName;
14477 } else { 14477 } else {
14478 return "<unknown file- CompilationUnit.getElement() returned null>"; 14478 return "<unknown file- CompilationUnit.getElement() returned null>";
14479 } 14479 }
14480 } else { 14480 } else {
14481 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 14481 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
14482 } 14482 }
14483 } 14483 }
14484 return "<unknown file- ASTNode is null>"; 14484 return "<unknown file- ASTNode is null>";
(...skipping 5141 matching lines...) Expand 10 before | Expand all | Expand 10 after
19626 } 19626 }
19627 return node.propertyName.accept(this); 19627 return node.propertyName.accept(this);
19628 } 19628 }
19629 19629
19630 Object visitSimpleIdentifier(SimpleIdentifier node) { 19630 Object visitSimpleIdentifier(SimpleIdentifier node) {
19631 if (node.name == "void") { 19631 if (node.name == "void") {
19632 return null; 19632 return null;
19633 } 19633 }
19634 ASTNode parent = node.parent; 19634 ASTNode parent = node.parent;
19635 if (parent is MethodInvocation) { 19635 if (parent is MethodInvocation) {
19636 MethodInvocation invocation = parent as MethodInvocation; 19636 MethodInvocation invocation = parent;
19637 if (identical(invocation.methodName, node)) { 19637 if (identical(invocation.methodName, node)) {
19638 Expression target = invocation.realTarget; 19638 Expression target = invocation.realTarget;
19639 Type2 targetType = target == null ? null : target.staticType; 19639 Type2 targetType = target == null ? null : target.staticType;
19640 if (targetType == null || targetType.isDynamic) { 19640 if (targetType == null || targetType.isDynamic) {
19641 return null; 19641 return null;
19642 } 19642 }
19643 } 19643 }
19644 } 19644 }
19645 return checkResolved(node, node.staticElement); 19645 return checkResolved(node, node.staticElement);
19646 } 19646 }
(...skipping 10 matching lines...) Expand all
19657 _wrongTypedNodes.add(node); 19657 _wrongTypedNodes.add(node);
19658 } 19658 }
19659 } 19659 }
19660 return null; 19660 return null;
19661 } 19661 }
19662 19662
19663 String getFileName(ASTNode node) { 19663 String getFileName(ASTNode node) {
19664 if (node != null) { 19664 if (node != null) {
19665 ASTNode root = node.root; 19665 ASTNode root = node.root;
19666 if (root is CompilationUnit) { 19666 if (root is CompilationUnit) {
19667 CompilationUnit rootCU = root as CompilationUnit; 19667 CompilationUnit rootCU = root;
19668 if (rootCU.element != null) { 19668 if (rootCU.element != null) {
19669 return rootCU.element.source.fullName; 19669 return rootCU.element.source.fullName;
19670 } else { 19670 } else {
19671 return "<unknown file- CompilationUnit.getElement() returned null>"; 19671 return "<unknown file- CompilationUnit.getElement() returned null>";
19672 } 19672 }
19673 } else { 19673 } else {
19674 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 19674 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
19675 } 19675 }
19676 } 19676 }
19677 return "<unknown file- ASTNode is null>"; 19677 return "<unknown file- ASTNode is null>";
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
20522 List<Type2> actualArguments = actualType.typeArguments; 20522 List<Type2> actualArguments = actualType.typeArguments;
20523 EngineTestCase.assertLength(length, actualArguments); 20523 EngineTestCase.assertLength(length, actualArguments);
20524 for (int i = 0; i < length; i++) { 20524 for (int i = 0; i < length; i++) {
20525 assertType2(expectedArguments[i], actualArguments[i]); 20525 assertType2(expectedArguments[i], actualArguments[i]);
20526 } 20526 }
20527 } 20527 }
20528 20528
20529 void assertType2(Type2 expectedType, Type2 actualType) { 20529 void assertType2(Type2 expectedType, Type2 actualType) {
20530 if (expectedType is InterfaceTypeImpl) { 20530 if (expectedType is InterfaceTypeImpl) {
20531 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); 20531 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
20532 assertType(expectedType as InterfaceTypeImpl, actualType as InterfaceTypeI mpl); 20532 assertType(expectedType, actualType as InterfaceTypeImpl);
20533 } 20533 }
20534 } 20534 }
20535 20535
20536 /** 20536 /**
20537 * Create the analyzer used by the tests. 20537 * Create the analyzer used by the tests.
20538 * 20538 *
20539 * @return the analyzer to be used by the tests 20539 * @return the analyzer to be used by the tests
20540 */ 20540 */
20541 StaticTypeAnalyzer createAnalyzer() { 20541 StaticTypeAnalyzer createAnalyzer() {
20542 AnalysisContextImpl context = new AnalysisContextImpl(); 20542 AnalysisContextImpl context = new AnalysisContextImpl();
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
21666 final __test = new NonHintCodeTest(); 21666 final __test = new NonHintCodeTest();
21667 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); 21667 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction);
21668 }); 21668 });
21669 }); 21669 });
21670 } 21670 }
21671 } 21671 }
21672 21672
21673 class EnclosedScopeTest extends ResolverTestCase { 21673 class EnclosedScopeTest extends ResolverTestCase {
21674 void test_define_duplicate() { 21674 void test_define_duplicate() {
21675 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 21675 GatheringErrorListener errorListener2 = new GatheringErrorListener();
21676 Scope rootScope = new Scope_27(errorListener2); 21676 Scope rootScope = new Scope_29(errorListener2);
21677 EnclosedScope scope = new EnclosedScope(rootScope); 21677 EnclosedScope scope = new EnclosedScope(rootScope);
21678 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21678 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21679 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21679 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21680 scope.define(element1); 21680 scope.define(element1);
21681 scope.define(element2); 21681 scope.define(element2);
21682 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 21682 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
21683 } 21683 }
21684 21684
21685 void test_define_normal() { 21685 void test_define_normal() {
21686 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 21686 GatheringErrorListener errorListener3 = new GatheringErrorListener();
21687 Scope rootScope = new Scope_28(errorListener3); 21687 Scope rootScope = new Scope_30(errorListener3);
21688 EnclosedScope outerScope = new EnclosedScope(rootScope); 21688 EnclosedScope outerScope = new EnclosedScope(rootScope);
21689 EnclosedScope innerScope = new EnclosedScope(outerScope); 21689 EnclosedScope innerScope = new EnclosedScope(outerScope);
21690 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21690 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21691 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 21691 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
21692 outerScope.define(element1); 21692 outerScope.define(element1);
21693 innerScope.define(element2); 21693 innerScope.define(element2);
21694 errorListener3.assertNoErrors(); 21694 errorListener3.assertNoErrors();
21695 } 21695 }
21696 21696
21697 static dartSuite() { 21697 static dartSuite() {
21698 _ut.group('EnclosedScopeTest', () { 21698 _ut.group('EnclosedScopeTest', () {
21699 _ut.test('test_define_duplicate', () { 21699 _ut.test('test_define_duplicate', () {
21700 final __test = new EnclosedScopeTest(); 21700 final __test = new EnclosedScopeTest();
21701 runJUnitTest(__test, __test.test_define_duplicate); 21701 runJUnitTest(__test, __test.test_define_duplicate);
21702 }); 21702 });
21703 _ut.test('test_define_normal', () { 21703 _ut.test('test_define_normal', () {
21704 final __test = new EnclosedScopeTest(); 21704 final __test = new EnclosedScopeTest();
21705 runJUnitTest(__test, __test.test_define_normal); 21705 runJUnitTest(__test, __test.test_define_normal);
21706 }); 21706 });
21707 }); 21707 });
21708 } 21708 }
21709 } 21709 }
21710 21710
21711 class Scope_27 extends Scope { 21711 class Scope_29 extends Scope {
21712 GatheringErrorListener errorListener2; 21712 GatheringErrorListener errorListener2;
21713 21713
21714 Scope_27(this.errorListener2) : super(); 21714 Scope_29(this.errorListener2) : super();
21715 21715
21716 AnalysisErrorListener get errorListener => errorListener2; 21716 AnalysisErrorListener get errorListener => errorListener2;
21717 21717
21718 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 21718 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
21719 } 21719 }
21720 21720
21721 class Scope_28 extends Scope { 21721 class Scope_30 extends Scope {
21722 GatheringErrorListener errorListener3; 21722 GatheringErrorListener errorListener3;
21723 21723
21724 Scope_28(this.errorListener3) : super(); 21724 Scope_30(this.errorListener3) : super();
21725 21725
21726 AnalysisErrorListener get errorListener => errorListener3; 21726 AnalysisErrorListener get errorListener => errorListener3;
21727 21727
21728 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 21728 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
21729 } 21729 }
21730 21730
21731 class LibraryElementBuilderTest extends EngineTestCase { 21731 class LibraryElementBuilderTest extends EngineTestCase {
21732 /** 21732 /**
21733 * The source factory used to create [Source]. 21733 * The source factory used to create [Source].
21734 */ 21734 */
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
21875 * @return the element model that was built for the library 21875 * @return the element model that was built for the library
21876 * @throws Exception if the element model could not be built 21876 * @throws Exception if the element model could not be built
21877 */ 21877 */
21878 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) { 21878 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) {
21879 AnalysisContextImpl context = new AnalysisContextImpl(); 21879 AnalysisContextImpl context = new AnalysisContextImpl();
21880 context.sourceFactory = new SourceFactory.con2([ 21880 context.sourceFactory = new SourceFactory.con2([
21881 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), 21881 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk),
21882 new FileUriResolver()]); 21882 new FileUriResolver()]);
21883 LibraryResolver resolver = new LibraryResolver(context); 21883 LibraryResolver resolver = new LibraryResolver(context);
21884 LibraryElementBuilder builder = new LibraryElementBuilder(resolver); 21884 LibraryElementBuilder builder = new LibraryElementBuilder(resolver);
21885 Library library = resolver.createLibrary(librarySource) as Library; 21885 Library library = resolver.createLibrary(librarySource);
21886 LibraryElement element = builder.buildLibrary(library); 21886 LibraryElement element = builder.buildLibrary(library);
21887 GatheringErrorListener listener = new GatheringErrorListener(); 21887 GatheringErrorListener listener = new GatheringErrorListener();
21888 listener.addAll(resolver.errorListener); 21888 listener.addAll(resolver.errorListener);
21889 listener.assertErrors2(expectedErrorCodes); 21889 listener.assertErrors2(expectedErrorCodes);
21890 return element; 21890 return element;
21891 } 21891 }
21892 21892
21893 static dartSuite() { 21893 static dartSuite() {
21894 _ut.group('LibraryElementBuilderTest', () { 21894 _ut.group('LibraryElementBuilderTest', () {
21895 _ut.test('test_accessorsAcrossFiles', () { 21895 _ut.test('test_accessorsAcrossFiles', () {
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
22446 "main() {", 22446 "main() {",
22447 " var myVar = (int p) => 'foo';", 22447 " var myVar = (int p) => 'foo';",
22448 " myVar(42);", 22448 " myVar(42);",
22449 "}"])); 22449 "}"]));
22450 LibraryElement library = resolve(source); 22450 LibraryElement library = resolve(source);
22451 JUnitTestCase.assertNotNull(library); 22451 JUnitTestCase.assertNotNull(library);
22452 CompilationUnit unit = analysisContext.getResolvedCompilationUnit(source, li brary); 22452 CompilationUnit unit = analysisContext.getResolvedCompilationUnit(source, li brary);
22453 JUnitTestCase.assertNotNull(unit); 22453 JUnitTestCase.assertNotNull(unit);
22454 List<bool> found = [false]; 22454 List<bool> found = [false];
22455 List<AnalysisException> thrownException = new List<AnalysisException>(1); 22455 List<AnalysisException> thrownException = new List<AnalysisException>(1);
22456 unit.accept(new RecursiveASTVisitor_31(this, found, thrownException)); 22456 unit.accept(new RecursiveASTVisitor_33(this, found, thrownException));
22457 if (thrownException[0] != null) { 22457 if (thrownException[0] != null) {
22458 throw new AnalysisException.con3(thrownException[0]); 22458 throw new AnalysisException.con3(thrownException[0]);
22459 } 22459 }
22460 JUnitTestCase.assertTrue(found[0]); 22460 JUnitTestCase.assertTrue(found[0]);
22461 } 22461 }
22462 22462
22463 void test_metadata_class() { 22463 void test_metadata_class() {
22464 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"])); 22464 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"]));
22465 LibraryElement library = resolve(source); 22465 LibraryElement library = resolve(source);
22466 JUnitTestCase.assertNotNull(library); 22466 JUnitTestCase.assertNotNull(library);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
22842 runJUnitTest(__test, __test.test_setter_inherited); 22842 runJUnitTest(__test, __test.test_setter_inherited);
22843 }); 22843 });
22844 _ut.test('test_setter_static', () { 22844 _ut.test('test_setter_static', () {
22845 final __test = new SimpleResolverTest(); 22845 final __test = new SimpleResolverTest();
22846 runJUnitTest(__test, __test.test_setter_static); 22846 runJUnitTest(__test, __test.test_setter_static);
22847 }); 22847 });
22848 }); 22848 });
22849 } 22849 }
22850 } 22850 }
22851 22851
22852 class RecursiveASTVisitor_31 extends RecursiveASTVisitor<Object> { 22852 class RecursiveASTVisitor_33 extends RecursiveASTVisitor<Object> {
22853 final SimpleResolverTest SimpleResolverTest_this; 22853 final SimpleResolverTest SimpleResolverTest_this;
22854 22854
22855 List<bool> found; 22855 List<bool> found;
22856 22856
22857 List<AnalysisException> thrownException; 22857 List<AnalysisException> thrownException;
22858 22858
22859 RecursiveASTVisitor_31(this.SimpleResolverTest_this, this.found, this.thrownEx ception) : super(); 22859 RecursiveASTVisitor_33(this.SimpleResolverTest_this, this.found, this.thrownEx ception) : super();
22860 22860
22861 Object visitSimpleIdentifier(SimpleIdentifier node) { 22861 Object visitSimpleIdentifier(SimpleIdentifier node) {
22862 if (node.name == "myVar" && node.parent is MethodInvocation) { 22862 if (node.name == "myVar" && node.parent is MethodInvocation) {
22863 try { 22863 try {
22864 found[0] = true; 22864 found[0] = true;
22865 Type2 staticType = node.staticType; 22865 Type2 staticType = node.staticType;
22866 JUnitTestCase.assertSame(SimpleResolverTest_this.typeProvider.dynamicTyp e, staticType); 22866 JUnitTestCase.assertSame(SimpleResolverTest_this.typeProvider.dynamicTyp e, staticType);
22867 FunctionType propagatedType = node.propagatedType as FunctionType; 22867 FunctionType propagatedType = node.propagatedType as FunctionType;
22868 JUnitTestCase.assertEquals(SimpleResolverTest_this.typeProvider.stringTy pe, propagatedType.returnType); 22868 JUnitTestCase.assertEquals(SimpleResolverTest_this.typeProvider.stringTy pe, propagatedType.returnType);
22869 } on AnalysisException catch (e) { 22869 } on AnalysisException catch (e) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
23214 // HintCodeTest.dartSuite(); 23214 // HintCodeTest.dartSuite();
23215 // MemberMapTest.dartSuite(); 23215 // MemberMapTest.dartSuite();
23216 // NonHintCodeTest.dartSuite(); 23216 // NonHintCodeTest.dartSuite();
23217 // NonErrorResolverTest.dartSuite(); 23217 // NonErrorResolverTest.dartSuite();
23218 // SimpleResolverTest.dartSuite(); 23218 // SimpleResolverTest.dartSuite();
23219 // StaticTypeWarningCodeTest.dartSuite(); 23219 // StaticTypeWarningCodeTest.dartSuite();
23220 // StaticWarningCodeTest.dartSuite(); 23220 // StaticWarningCodeTest.dartSuite();
23221 // StrictModeTest.dartSuite(); 23221 // StrictModeTest.dartSuite();
23222 // TypePropagationTest.dartSuite(); 23222 // TypePropagationTest.dartSuite();
23223 } 23223 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_test.dart ('k') | pkg/analyzer/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698