| OLD | NEW |
| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.element_test; | 8 library engine.element_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 runReflectiveTests(ElementLocationImplTest); | 35 runReflectiveTests(ElementLocationImplTest); |
| 36 runReflectiveTests(ElementImplTest); | 36 runReflectiveTests(ElementImplTest); |
| 37 runReflectiveTests(HtmlElementImplTest); | 37 runReflectiveTests(HtmlElementImplTest); |
| 38 runReflectiveTests(LibraryElementImplTest); | 38 runReflectiveTests(LibraryElementImplTest); |
| 39 runReflectiveTests(MultiplyDefinedElementImplTest); | 39 runReflectiveTests(MultiplyDefinedElementImplTest); |
| 40 runReflectiveTests(ParameterElementImplTest); | 40 runReflectiveTests(ParameterElementImplTest); |
| 41 } | 41 } |
| 42 | 42 |
| 43 @reflectiveTest | 43 @reflectiveTest |
| 44 class ClassElementImplTest extends EngineTestCase { | 44 class ClassElementImplTest extends EngineTestCase { |
| 45 void test_computeNode_ClassDeclaration() { |
| 46 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 47 AnalysisContext context = contextHelper.context; |
| 48 Source source = contextHelper.addSource("/test.dart", r''' |
| 49 class A {} |
| 50 class B {} |
| 51 enum C {C1, C2, C3}'''); |
| 52 // prepare CompilationUnitElement |
| 53 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 54 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 55 // A |
| 56 { |
| 57 ClassElement elementA = unitElement.getType("A"); |
| 58 ClassDeclaration nodeA = elementA.computeNode(); |
| 59 expect(nodeA, isNotNull); |
| 60 expect(nodeA.name.name, "A"); |
| 61 expect(nodeA.element, same(elementA)); |
| 62 } |
| 63 // B |
| 64 { |
| 65 ClassElement elementB = unitElement.getType("B"); |
| 66 ClassDeclaration nodeB = elementB.computeNode(); |
| 67 expect(nodeB, isNotNull); |
| 68 expect(nodeB.name.name, "B"); |
| 69 expect(nodeB.element, same(elementB)); |
| 70 } |
| 71 // C |
| 72 { |
| 73 ClassElement elementC = unitElement.getEnum("C"); |
| 74 EnumDeclaration nodeC = elementC.computeNode(); |
| 75 expect(nodeC, isNotNull); |
| 76 expect(nodeC.name.name, "C"); |
| 77 expect(nodeC.element, same(elementC)); |
| 78 } |
| 79 } |
| 80 |
| 81 void test_computeNode_ClassTypeAlias() { |
| 82 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 83 AnalysisContext context = contextHelper.context; |
| 84 Source source = contextHelper.addSource("/test.dart", r''' |
| 85 abstract class A<K, V> = Object with MapMixin<K, V>; |
| 86 '''); |
| 87 // prepare CompilationUnitElement |
| 88 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 89 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 90 // A |
| 91 { |
| 92 ClassElement elementA = unitElement.getType("A"); |
| 93 ClassTypeAlias nodeA = elementA.computeNode(); |
| 94 expect(nodeA, isNotNull); |
| 95 expect(nodeA.name.name, "A"); |
| 96 expect(nodeA.element, same(elementA)); |
| 97 } |
| 98 } |
| 99 |
| 45 void test_getAllSupertypes_interface() { | 100 void test_getAllSupertypes_interface() { |
| 46 ClassElement classA = ElementFactory.classElement2("A"); | 101 ClassElement classA = ElementFactory.classElement2("A"); |
| 47 ClassElement classB = ElementFactory.classElement("B", classA.type); | 102 ClassElement classB = ElementFactory.classElement("B", classA.type); |
| 48 ClassElementImpl elementC = ElementFactory.classElement2("C"); | 103 ClassElementImpl elementC = ElementFactory.classElement2("C"); |
| 49 InterfaceType typeObject = classA.supertype; | 104 InterfaceType typeObject = classA.supertype; |
| 50 InterfaceType typeA = classA.type; | 105 InterfaceType typeA = classA.type; |
| 51 InterfaceType typeB = classB.type; | 106 InterfaceType typeB = classB.type; |
| 52 InterfaceType typeC = elementC.type; | 107 InterfaceType typeC = elementC.type; |
| 53 elementC.interfaces = <InterfaceType>[typeB]; | 108 elementC.interfaces = <InterfaceType>[typeB]; |
| 54 List<InterfaceType> supers = elementC.allSupertypes; | 109 List<InterfaceType> supers = elementC.allSupertypes; |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 // } | 905 // } |
| 851 LibraryElementImpl library = | 906 LibraryElementImpl library = |
| 852 ElementFactory.library(createAnalysisContext(), "lib"); | 907 ElementFactory.library(createAnalysisContext(), "lib"); |
| 853 ClassElementImpl classA = ElementFactory.classElement2("A"); | 908 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 854 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); | 909 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); |
| 855 classA.supertype = classB.type; | 910 classA.supertype = classB.type; |
| 856 (library.definingCompilationUnit as CompilationUnitElementImpl).types = | 911 (library.definingCompilationUnit as CompilationUnitElementImpl).types = |
| 857 <ClassElement>[classA, classB]; | 912 <ClassElement>[classA, classB]; |
| 858 expect(classA.lookUpSetter("s", library), isNull); | 913 expect(classA.lookUpSetter("s", library), isNull); |
| 859 } | 914 } |
| 860 | |
| 861 void test_node_ClassDeclaration() { | |
| 862 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | |
| 863 AnalysisContext context = contextHelper.context; | |
| 864 Source source = contextHelper.addSource("/test.dart", r''' | |
| 865 class A {} | |
| 866 class B {} | |
| 867 enum C {C1, C2, C3}'''); | |
| 868 // prepare CompilationUnitElement | |
| 869 LibraryElement libraryElement = context.computeLibraryElement(source); | |
| 870 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | |
| 871 // A | |
| 872 { | |
| 873 ClassElement elementA = unitElement.getType("A"); | |
| 874 ClassDeclaration nodeA = elementA.node; | |
| 875 expect(nodeA, isNotNull); | |
| 876 expect(nodeA.name.name, "A"); | |
| 877 expect(nodeA.element, same(elementA)); | |
| 878 } | |
| 879 // B | |
| 880 { | |
| 881 ClassElement elementB = unitElement.getType("B"); | |
| 882 ClassDeclaration nodeB = elementB.node; | |
| 883 expect(nodeB, isNotNull); | |
| 884 expect(nodeB.name.name, "B"); | |
| 885 expect(nodeB.element, same(elementB)); | |
| 886 } | |
| 887 // C | |
| 888 { | |
| 889 ClassElement elementC = unitElement.getEnum("C"); | |
| 890 EnumDeclaration nodeC = elementC.node; | |
| 891 expect(nodeC, isNotNull); | |
| 892 expect(nodeC.name.name, "C"); | |
| 893 expect(nodeC.element, same(elementC)); | |
| 894 } | |
| 895 } | |
| 896 | |
| 897 void test_node_ClassTypeAlias() { | |
| 898 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | |
| 899 AnalysisContext context = contextHelper.context; | |
| 900 Source source = contextHelper.addSource("/test.dart", r''' | |
| 901 abstract class A<K, V> = Object with MapMixin<K, V>; | |
| 902 '''); | |
| 903 // prepare CompilationUnitElement | |
| 904 LibraryElement libraryElement = context.computeLibraryElement(source); | |
| 905 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | |
| 906 // A | |
| 907 { | |
| 908 ClassElement elementA = unitElement.getType("A"); | |
| 909 ClassTypeAlias nodeA = elementA.node; | |
| 910 expect(nodeA, isNotNull); | |
| 911 expect(nodeA.name.name, "A"); | |
| 912 expect(nodeA.element, same(elementA)); | |
| 913 } | |
| 914 } | |
| 915 } | 915 } |
| 916 | 916 |
| 917 @reflectiveTest | 917 @reflectiveTest |
| 918 class CompilationUnitElementImplTest extends EngineTestCase { | 918 class CompilationUnitElementImplTest extends EngineTestCase { |
| 919 void test_getElementAt() { | 919 void test_getElementAt() { |
| 920 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 920 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 921 AnalysisContext context = contextHelper.context; | 921 AnalysisContext context = contextHelper.context; |
| 922 String code = r''' | 922 String code = r''' |
| 923 class A { | 923 class A { |
| 924 int field; | 924 int field; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 void test_hashCode_equal() { | 1213 void test_hashCode_equal() { |
| 1214 String encoding = "a;b;c"; | 1214 String encoding = "a;b;c"; |
| 1215 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); | 1215 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); |
| 1216 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); | 1216 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); |
| 1217 expect(first.hashCode == second.hashCode, isTrue); | 1217 expect(first.hashCode == second.hashCode, isTrue); |
| 1218 } | 1218 } |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 @reflectiveTest | 1221 @reflectiveTest |
| 1222 class FieldElementImplTest extends EngineTestCase { | 1222 class FieldElementImplTest extends EngineTestCase { |
| 1223 void test_node() { | 1223 void test_computeNode() { |
| 1224 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 1224 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 1225 AnalysisContext context = contextHelper.context; | 1225 AnalysisContext context = contextHelper.context; |
| 1226 Source source = contextHelper.addSource("/test.dart", r''' | 1226 Source source = contextHelper.addSource("/test.dart", r''' |
| 1227 class A { | 1227 class A { |
| 1228 int a; | 1228 int a; |
| 1229 } | 1229 } |
| 1230 enum B {B1, B2, B3}'''); | 1230 enum B {B1, B2, B3}'''); |
| 1231 // prepare CompilationUnitElement | 1231 // prepare CompilationUnitElement |
| 1232 LibraryElement libraryElement = context.computeLibraryElement(source); | 1232 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 1233 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 1233 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 1234 // A | 1234 // A |
| 1235 { | 1235 { |
| 1236 FieldElement elementA = unitElement.getType("A").getField('a'); | 1236 FieldElement elementA = unitElement.getType("A").getField('a'); |
| 1237 VariableDeclaration nodeA = elementA.node; | 1237 VariableDeclaration nodeA = elementA.computeNode(); |
| 1238 expect(nodeA, isNotNull); | 1238 expect(nodeA, isNotNull); |
| 1239 expect(nodeA.name.name, "a"); | 1239 expect(nodeA.name.name, "a"); |
| 1240 expect(nodeA.element, same(elementA)); | 1240 expect(nodeA.element, same(elementA)); |
| 1241 } | 1241 } |
| 1242 // B | 1242 // B |
| 1243 { | 1243 { |
| 1244 FieldElement elementB = unitElement.getEnum("B").getField('B2'); | 1244 FieldElement elementB = unitElement.getEnum("B").getField('B2'); |
| 1245 EnumConstantDeclaration nodeB = elementB.node; | 1245 EnumConstantDeclaration nodeB = elementB.computeNode(); |
| 1246 expect(nodeB, isNotNull); | 1246 expect(nodeB, isNotNull); |
| 1247 expect(nodeB.name.name, "B2"); | 1247 expect(nodeB.name.name, "B2"); |
| 1248 expect(nodeB.element, same(elementB)); | 1248 expect(nodeB.element, same(elementB)); |
| 1249 } | 1249 } |
| 1250 } | 1250 } |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 @reflectiveTest | 1253 @reflectiveTest |
| 1254 class FunctionTypeImplTest extends EngineTestCase { | 1254 class FunctionTypeImplTest extends EngineTestCase { |
| 1255 void test_creation() { | 1255 void test_creation() { |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2164 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | 2164 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2165 expect(type.accessors.length, 2); | 2165 expect(type.accessors.length, 2); |
| 2166 } | 2166 } |
| 2167 | 2167 |
| 2168 void test_getAccessors_empty() { | 2168 void test_getAccessors_empty() { |
| 2169 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | 2169 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2170 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | 2170 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2171 expect(type.accessors.length, 0); | 2171 expect(type.accessors.length, 0); |
| 2172 } | 2172 } |
| 2173 | 2173 |
| 2174 void test_getConstructors() { |
| 2175 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2176 ConstructorElementImpl constructorOne = |
| 2177 ElementFactory.constructorElement(typeElement, 'one', false); |
| 2178 ConstructorElementImpl constructorTwo = |
| 2179 ElementFactory.constructorElement(typeElement, 'two', false); |
| 2180 typeElement.constructors = <ConstructorElement>[ |
| 2181 constructorOne, |
| 2182 constructorTwo |
| 2183 ]; |
| 2184 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2185 expect(type.constructors, hasLength(2)); |
| 2186 } |
| 2187 |
| 2188 void test_getConstructors_empty() { |
| 2189 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2190 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2191 expect(type.constructors, isEmpty); |
| 2192 } |
| 2193 |
| 2174 void test_getElement() { | 2194 void test_getElement() { |
| 2175 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | 2195 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2176 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | 2196 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2177 expect(type.element, typeElement); | 2197 expect(type.element, typeElement); |
| 2178 } | 2198 } |
| 2179 | 2199 |
| 2180 void test_getGetter_implemented() { | 2200 void test_getGetter_implemented() { |
| 2181 // | 2201 // |
| 2182 // class A { g {} } | 2202 // class A { g {} } |
| 2183 // | 2203 // |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 | 2563 |
| 2544 void test_getMethod_unimplemented() { | 2564 void test_getMethod_unimplemented() { |
| 2545 // | 2565 // |
| 2546 // class A {} | 2566 // class A {} |
| 2547 // | 2567 // |
| 2548 ClassElementImpl classA = ElementFactory.classElement2("A"); | 2568 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 2549 InterfaceType typeA = classA.type; | 2569 InterfaceType typeA = classA.type; |
| 2550 expect(typeA.getMethod("m"), isNull); | 2570 expect(typeA.getMethod("m"), isNull); |
| 2551 } | 2571 } |
| 2552 | 2572 |
| 2553 void test_getConstructors() { | |
| 2554 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | |
| 2555 ConstructorElementImpl constructorOne = | |
| 2556 ElementFactory.constructorElement(typeElement, 'one', false); | |
| 2557 ConstructorElementImpl constructorTwo = | |
| 2558 ElementFactory.constructorElement(typeElement, 'two', false); | |
| 2559 typeElement.constructors = <ConstructorElement>[ | |
| 2560 constructorOne, | |
| 2561 constructorTwo | |
| 2562 ]; | |
| 2563 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | |
| 2564 expect(type.constructors, hasLength(2)); | |
| 2565 } | |
| 2566 | |
| 2567 void test_getMethods() { | 2573 void test_getMethods() { |
| 2568 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | 2574 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2569 MethodElementImpl methodOne = ElementFactory.methodElement("one", null); | 2575 MethodElementImpl methodOne = ElementFactory.methodElement("one", null); |
| 2570 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null); | 2576 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null); |
| 2571 typeElement.methods = <MethodElement>[methodOne, methodTwo]; | 2577 typeElement.methods = <MethodElement>[methodOne, methodTwo]; |
| 2572 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | 2578 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2573 expect(type.methods.length, 2); | 2579 expect(type.methods.length, 2); |
| 2574 } | 2580 } |
| 2575 | 2581 |
| 2576 void test_getMethods_empty() { | 2582 void test_getMethods_empty() { |
| 2577 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | 2583 ClassElementImpl typeElement = ElementFactory.classElement2("A"); |
| 2578 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | 2584 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); |
| 2579 expect(type.methods.length, 0); | 2585 expect(type.methods.length, 0); |
| 2580 } | 2586 } |
| 2581 | 2587 |
| 2582 void test_getConstructors_empty() { | |
| 2583 ClassElementImpl typeElement = ElementFactory.classElement2("A"); | |
| 2584 InterfaceTypeImpl type = new InterfaceTypeImpl(typeElement); | |
| 2585 expect(type.constructors, isEmpty); | |
| 2586 } | |
| 2587 | |
| 2588 void test_getMixins_nonParameterized() { | 2588 void test_getMixins_nonParameterized() { |
| 2589 // | 2589 // |
| 2590 // class C extends Object with A, B | 2590 // class C extends Object with A, B |
| 2591 // | 2591 // |
| 2592 ClassElementImpl classA = ElementFactory.classElement2("A"); | 2592 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 2593 InterfaceType typeA = classA.type; | 2593 InterfaceType typeA = classA.type; |
| 2594 ClassElementImpl classB = ElementFactory.classElement2("B"); | 2594 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 2595 InterfaceType typeB = classB.type; | 2595 InterfaceType typeB = classB.type; |
| 2596 ClassElementImpl classC = ElementFactory.classElement2("C"); | 2596 ClassElementImpl classC = ElementFactory.classElement2("C"); |
| 2597 classC.mixins = <InterfaceType>[typeA, typeB]; | 2597 classC.mixins = <InterfaceType>[typeA, typeB]; |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3725 | 3725 |
| 3726 void test_fromElements_nonConflicting() { | 3726 void test_fromElements_nonConflicting() { |
| 3727 Element element = ElementFactory.localVariableElement2("xx"); | 3727 Element element = ElementFactory.localVariableElement2("xx"); |
| 3728 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), | 3728 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), |
| 3729 same(element)); | 3729 same(element)); |
| 3730 } | 3730 } |
| 3731 } | 3731 } |
| 3732 | 3732 |
| 3733 @reflectiveTest | 3733 @reflectiveTest |
| 3734 class ParameterElementImplTest extends EngineTestCase { | 3734 class ParameterElementImplTest extends EngineTestCase { |
| 3735 void test_node_DefaultFormalParameter() { | 3735 void test_computeNode_DefaultFormalParameter() { |
| 3736 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3736 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3737 AnalysisContext context = contextHelper.context; | 3737 AnalysisContext context = contextHelper.context; |
| 3738 Source source = contextHelper.addSource("/test.dart", r''' | 3738 Source source = contextHelper.addSource("/test.dart", r''' |
| 3739 main([int p = 42]) { | 3739 main([int p = 42]) { |
| 3740 }'''); | 3740 }'''); |
| 3741 // prepare CompilationUnitElement | 3741 // prepare CompilationUnitElement |
| 3742 LibraryElement libraryElement = context.computeLibraryElement(source); | 3742 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3743 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 3743 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3744 // p | 3744 // p |
| 3745 { | 3745 { |
| 3746 ParameterElement element = unitElement.functions[0].parameters[0]; | 3746 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3747 DefaultFormalParameter node = element.node; | 3747 DefaultFormalParameter node = element.computeNode(); |
| 3748 expect(node, isNotNull); | 3748 expect(node, isNotNull); |
| 3749 expect(node.identifier.name, 'p'); | 3749 expect(node.identifier.name, 'p'); |
| 3750 expect(node.element, same(element)); | 3750 expect(node.element, same(element)); |
| 3751 } | 3751 } |
| 3752 } | 3752 } |
| 3753 | 3753 |
| 3754 void test_node_FieldFormalParameter() { | 3754 void test_computeNode_FieldFormalParameter() { |
| 3755 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3755 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3756 AnalysisContext context = contextHelper.context; | 3756 AnalysisContext context = contextHelper.context; |
| 3757 Source source = contextHelper.addSource("/test.dart", r''' | 3757 Source source = contextHelper.addSource("/test.dart", r''' |
| 3758 class A { | 3758 class A { |
| 3759 int p; | 3759 int p; |
| 3760 A(this.p) { | 3760 A(this.p) { |
| 3761 } | 3761 } |
| 3762 }'''); | 3762 }'''); |
| 3763 // prepare CompilationUnitElement | 3763 // prepare CompilationUnitElement |
| 3764 LibraryElement libraryElement = context.computeLibraryElement(source); | 3764 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3765 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 3765 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3766 // p | 3766 // p |
| 3767 { | 3767 { |
| 3768 ClassElement classA = unitElement.types[0]; | 3768 ClassElement classA = unitElement.types[0]; |
| 3769 ConstructorElement constructorA = classA.constructors[0]; | 3769 ConstructorElement constructorA = classA.constructors[0]; |
| 3770 FieldFormalParameterElement element = constructorA.parameters[0]; | 3770 FieldFormalParameterElement element = constructorA.parameters[0]; |
| 3771 FieldFormalParameter node = element.node; | 3771 FieldFormalParameter node = element.computeNode(); |
| 3772 expect(node, isNotNull); | 3772 expect(node, isNotNull); |
| 3773 expect(node.identifier.name, 'p'); | 3773 expect(node.identifier.name, 'p'); |
| 3774 expect(node.element, same(element)); | 3774 expect(node.element, same(element)); |
| 3775 } | 3775 } |
| 3776 } | 3776 } |
| 3777 | 3777 |
| 3778 void test_node_FunctionTypedFormalParameter() { | 3778 void test_computeNode_FunctionTypedFormalParameter() { |
| 3779 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3779 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3780 AnalysisContext context = contextHelper.context; | 3780 AnalysisContext context = contextHelper.context; |
| 3781 Source source = contextHelper.addSource("/test.dart", r''' | 3781 Source source = contextHelper.addSource("/test.dart", r''' |
| 3782 main(p(int a, int b)) { | 3782 main(p(int a, int b)) { |
| 3783 }'''); | 3783 }'''); |
| 3784 // prepare CompilationUnitElement | 3784 // prepare CompilationUnitElement |
| 3785 LibraryElement libraryElement = context.computeLibraryElement(source); | 3785 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3786 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 3786 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3787 // p | 3787 // p |
| 3788 { | 3788 { |
| 3789 ParameterElement element = unitElement.functions[0].parameters[0]; | 3789 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3790 FunctionTypedFormalParameter node = element.node; | 3790 FunctionTypedFormalParameter node = element.computeNode(); |
| 3791 expect(node, isNotNull); | 3791 expect(node, isNotNull); |
| 3792 expect(node.identifier.name, 'p'); | 3792 expect(node.identifier.name, 'p'); |
| 3793 expect(node.element, same(element)); | 3793 expect(node.element, same(element)); |
| 3794 } | 3794 } |
| 3795 } | 3795 } |
| 3796 | 3796 |
| 3797 void test_node_SimpleFormalParameter() { | 3797 void test_computeNode_SimpleFormalParameter() { |
| 3798 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3798 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3799 AnalysisContext context = contextHelper.context; | 3799 AnalysisContext context = contextHelper.context; |
| 3800 Source source = contextHelper.addSource("/test.dart", r''' | 3800 Source source = contextHelper.addSource("/test.dart", r''' |
| 3801 main(int p) { | 3801 main(int p) { |
| 3802 }'''); | 3802 }'''); |
| 3803 // prepare CompilationUnitElement | 3803 // prepare CompilationUnitElement |
| 3804 LibraryElement libraryElement = context.computeLibraryElement(source); | 3804 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3805 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 3805 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3806 // p | 3806 // p |
| 3807 { | 3807 { |
| 3808 ParameterElement element = unitElement.functions[0].parameters[0]; | 3808 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3809 SimpleFormalParameter node = element.node; | 3809 SimpleFormalParameter node = element.computeNode(); |
| 3810 expect(node, isNotNull); | 3810 expect(node, isNotNull); |
| 3811 expect(node.identifier.name, 'p'); | 3811 expect(node.identifier.name, 'p'); |
| 3812 expect(node.element, same(element)); | 3812 expect(node.element, same(element)); |
| 3813 } | 3813 } |
| 3814 } | 3814 } |
| 3815 } | 3815 } |
| 3816 | 3816 |
| 3817 @reflectiveTest | 3817 @reflectiveTest |
| 3818 class TypeParameterTypeImplTest extends EngineTestCase { | 3818 class TypeParameterTypeImplTest extends EngineTestCase { |
| 3819 void test_creation() { | 3819 void test_creation() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3979 } | 3979 } |
| 3980 | 3980 |
| 3981 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 3981 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 3982 extends InterfaceTypeImpl { | 3982 extends InterfaceTypeImpl { |
| 3983 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 3983 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 3984 : super(arg0); | 3984 : super(arg0); |
| 3985 | 3985 |
| 3986 @override | 3986 @override |
| 3987 bool get isDartCoreFunction => true; | 3987 bool get isDartCoreFunction => true; |
| 3988 } | 3988 } |
| OLD | NEW |