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

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

Issue 247053004: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 // 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/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1034 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1035 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); 1035 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []);
1036 InterfaceType typeB = classB.type; 1036 InterfaceType typeB = classB.type;
1037 InterfaceType typeC = classC.type; 1037 InterfaceType typeC = classC.type;
1038 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC)); 1038 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC));
1039 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB)); 1039 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB));
1040 } 1040 }
1041 1041
1042 void test_getLeastUpperBound_functionType() { 1042 void test_getLeastUpperBound_functionType() {
1043 DartType interfaceType = ElementFactory.classElement2("A", []).type; 1043 DartType interfaceType = ElementFactory.classElement2("A", []).type;
1044 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(AstFactory.identifier3("f"))); 1044 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.forNode(AstFactory.identifier3("f")));
1045 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType)); 1045 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType));
1046 } 1046 }
1047 1047
1048 void test_getLeastUpperBound_mixinCase() { 1048 void test_getLeastUpperBound_mixinCase() {
1049 // 1049 //
1050 // class A 1050 // class A
1051 // class B extends A 1051 // class B extends A
1052 // class C extends A 1052 // class C extends A
1053 // class D extends B with M, N, O, P 1053 // class D extends B with M, N, O, P
1054 // 1054 //
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 2580
2581 static CompilationUnitElementImpl compilationUnit(String fileName) { 2581 static CompilationUnitElementImpl compilationUnit(String fileName) {
2582 FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile( fileName)); 2582 FileBasedSource source = new FileBasedSource.con1(FileUtilities2.createFile( fileName));
2583 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); 2583 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName);
2584 unit.source = source; 2584 unit.source = source;
2585 return unit; 2585 return unit;
2586 } 2586 }
2587 2587
2588 static ConstructorElementImpl constructorElement(ClassElement definingClass, S tring name, bool isConst, List<DartType> argumentTypes) { 2588 static ConstructorElementImpl constructorElement(ClassElement definingClass, S tring name, bool isConst, List<DartType> argumentTypes) {
2589 DartType type = definingClass.type; 2589 DartType type = definingClass.type;
2590 ConstructorElementImpl constructor = new ConstructorElementImpl.con1(name == null ? null : AstFactory.identifier3(name)); 2590 ConstructorElementImpl constructor = new ConstructorElementImpl.forNode(name == null ? null : AstFactory.identifier3(name));
2591 constructor.const2 = isConst; 2591 constructor.const2 = isConst;
2592 int count = argumentTypes.length; 2592 int count = argumentTypes.length;
2593 List<ParameterElement> parameters = new List<ParameterElement>(count); 2593 List<ParameterElement> parameters = new List<ParameterElement>(count);
2594 for (int i = 0; i < count; i++) { 2594 for (int i = 0; i < count; i++) {
2595 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory. identifier3("a${i}")); 2595 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory. identifier3("a${i}"));
2596 parameter.type = argumentTypes[i]; 2596 parameter.type = argumentTypes[i];
2597 parameter.parameterKind = ParameterKind.REQUIRED; 2597 parameter.parameterKind = ParameterKind.REQUIRED;
2598 parameters[i] = parameter; 2598 parameters[i] = parameter;
2599 } 2599 }
2600 constructor.parameters = parameters; 2600 constructor.parameters = parameters;
(...skipping 11 matching lines...) Expand all
2612 spec.combinators = combinators; 2612 spec.combinators = combinators;
2613 return spec; 2613 return spec;
2614 } 2614 }
2615 2615
2616 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, DartType type) { 2616 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, DartType type) {
2617 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me)); 2617 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me));
2618 field.const3 = isConst; 2618 field.const3 = isConst;
2619 field.final2 = isFinal; 2619 field.final2 = isFinal;
2620 field.static = isStatic; 2620 field.static = isStatic;
2621 field.type = type; 2621 field.type = type;
2622 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 2622 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(field);
2623 getter.getter = true; 2623 getter.getter = true;
2624 getter.static = isStatic; 2624 getter.static = isStatic;
2625 getter.synthetic = true; 2625 getter.synthetic = true;
2626 getter.variable = field; 2626 getter.variable = field;
2627 getter.returnType = type; 2627 getter.returnType = type;
2628 field.getter = getter; 2628 field.getter = getter;
2629 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 2629 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2630 getter.type = getterType; 2630 getter.type = getterType;
2631 if (!isConst && !isFinal) { 2631 if (!isConst && !isFinal) {
2632 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field); 2632 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(field );
2633 setter.setter = true; 2633 setter.setter = true;
2634 setter.static = isStatic; 2634 setter.static = isStatic;
2635 setter.synthetic = true; 2635 setter.synthetic = true;
2636 setter.variable = field; 2636 setter.variable = field;
2637 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)]; 2637 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)];
2638 setter.returnType = VoidTypeImpl.instance; 2638 setter.returnType = VoidTypeImpl.instance;
2639 setter.type = new FunctionTypeImpl.con1(setter); 2639 setter.type = new FunctionTypeImpl.con1(setter);
2640 field.setter = setter; 2640 field.setter = setter;
2641 } 2641 }
2642 return field; 2642 return field;
2643 } 2643 }
2644 2644
2645 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) = > new FieldFormalParameterElementImpl(name); 2645 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) = > new FieldFormalParameterElementImpl(name);
2646 2646
2647 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null); 2647 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null);
2648 2648
2649 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null); 2649 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
2650 2650
2651 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) { 2651 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) {
2652 // We don't create parameter elements because we don't have parameter names 2652 // We don't create parameter elements because we don't have parameter names
2653 FunctionElementImpl functionElement = new FunctionElementImpl.con1(AstFactor y.identifier3(functionName)); 2653 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3(functionName));
2654 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 2654 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2655 functionElement.type = functionType; 2655 functionElement.type = functionType;
2656 // return type 2656 // return type
2657 if (returnElement == null) { 2657 if (returnElement == null) {
2658 functionElement.returnType = VoidTypeImpl.instance; 2658 functionElement.returnType = VoidTypeImpl.instance;
2659 } else { 2659 } else {
2660 functionElement.returnType = returnElement.type; 2660 functionElement.returnType = returnElement.type;
2661 } 2661 }
2662 // parameters 2662 // parameters
2663 int normalCount = normalParameters == null ? 0 : normalParameters.length; 2663 int normalCount = normalParameters == null ? 0 : normalParameters.length;
(...skipping 10 matching lines...) Expand all
2674 parameter.parameterKind = ParameterKind.POSITIONAL; 2674 parameter.parameterKind = ParameterKind.POSITIONAL;
2675 } 2675 }
2676 parameters[i] = parameter; 2676 parameters[i] = parameter;
2677 } 2677 }
2678 functionElement.parameters = parameters; 2678 functionElement.parameters = parameters;
2679 // done 2679 // done
2680 return functionElement; 2680 return functionElement;
2681 } 2681 }
2682 2682
2683 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) { 2683 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) {
2684 FunctionElementImpl functionElement = new FunctionElementImpl.con1(AstFactor y.identifier3(functionName)); 2684 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3(functionName));
2685 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 2685 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2686 functionElement.type = functionType; 2686 functionElement.type = functionType;
2687 // parameters 2687 // parameters
2688 int normalCount = normalParameters == null ? 0 : normalParameters.length; 2688 int normalCount = normalParameters == null ? 0 : normalParameters.length;
2689 int nameCount = names == null ? 0 : names.length; 2689 int nameCount = names == null ? 0 : names.length;
2690 int typeCount = namedParameters == null ? 0 : namedParameters.length; 2690 int typeCount = namedParameters == null ? 0 : namedParameters.length;
2691 if (names != null && nameCount != typeCount) { 2691 if (names != null && nameCount != typeCount) {
2692 throw new IllegalStateException("The passed String[] and ClassElement[] ar rays had different lengths."); 2692 throw new IllegalStateException("The passed String[] and ClassElement[] ar rays had different lengths.");
2693 } 2693 }
2694 int totalCount = normalCount + nameCount; 2694 int totalCount = normalCount + nameCount;
(...skipping 20 matching lines...) Expand all
2715 } 2715 }
2716 return functionElement; 2716 return functionElement;
2717 } 2717 }
2718 2718
2719 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null); 2719 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null);
2720 2720
2721 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters); 2721 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters);
2722 2722
2723 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters ); 2723 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters );
2724 2724
2725 static FunctionElementImpl functionElementWithParameters(String functionName, DartType returnType, List<ParameterElement> parameters) {
2726 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3(functionName));
2727 functionElement.returnType = returnType == null ? VoidTypeImpl.instance : re turnType;
2728 functionElement.parameters = parameters;
2729 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2730 functionElement.type = functionType;
2731 return functionElement;
2732 }
2733
2725 static ClassElementImpl get object { 2734 static ClassElementImpl get object {
2726 if (_objectElement == null) { 2735 if (_objectElement == null) {
2727 _objectElement = classElement("Object", null, []); 2736 _objectElement = classElement("Object", null, []);
2728 } 2737 }
2729 return _objectElement; 2738 return _objectElement;
2730 } 2739 }
2731 2740
2732 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, D artType type) { 2741 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, D artType type) {
2733 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me)); 2742 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me));
2734 field.static = isStatic; 2743 field.static = isStatic;
2735 field.synthetic = true; 2744 field.synthetic = true;
2736 field.type = type; 2745 field.type = type;
2737 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 2746 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(field);
2738 getter.getter = true; 2747 getter.getter = true;
2739 getter.static = isStatic; 2748 getter.static = isStatic;
2740 getter.variable = field; 2749 getter.variable = field;
2741 getter.returnType = type; 2750 getter.returnType = type;
2742 field.getter = getter; 2751 field.getter = getter;
2743 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 2752 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2744 getter.type = getterType; 2753 getter.type = getterType;
2745 return getter; 2754 return getter;
2746 } 2755 }
2747 2756
(...skipping 18 matching lines...) Expand all
2766 LibraryElementImpl library = new LibraryElementImpl(context, AstFactory.libr aryIdentifier2([libraryName])); 2775 LibraryElementImpl library = new LibraryElementImpl(context, AstFactory.libr aryIdentifier2([libraryName]));
2767 library.definingCompilationUnit = unit; 2776 library.definingCompilationUnit = unit;
2768 return library; 2777 return library;
2769 } 2778 }
2770 2779
2771 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name); 2780 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name);
2772 2781
2773 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(AstFactory.identifier3(name)); 2782 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(AstFactory.identifier3(name));
2774 2783
2775 static MethodElementImpl methodElement(String methodName, DartType returnType, List<DartType> argumentTypes) { 2784 static MethodElementImpl methodElement(String methodName, DartType returnType, List<DartType> argumentTypes) {
2776 MethodElementImpl method = new MethodElementImpl.con1(AstFactory.identifier3 (methodName)); 2785 MethodElementImpl method = new MethodElementImpl.forNode(AstFactory.identifi er3(methodName));
2777 int count = argumentTypes.length; 2786 int count = argumentTypes.length;
2778 List<ParameterElement> parameters = new List<ParameterElement>(count); 2787 List<ParameterElement> parameters = new List<ParameterElement>(count);
2779 for (int i = 0; i < count; i++) { 2788 for (int i = 0; i < count; i++) {
2780 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory. identifier3("a${i}")); 2789 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory. identifier3("a${i}"));
2781 parameter.type = argumentTypes[i]; 2790 parameter.type = argumentTypes[i];
2782 parameter.parameterKind = ParameterKind.REQUIRED; 2791 parameter.parameterKind = ParameterKind.REQUIRED;
2783 parameters[i] = parameter; 2792 parameters[i] = parameter;
2784 } 2793 }
2785 method.parameters = parameters; 2794 method.parameters = parameters;
2786 method.returnType = returnType; 2795 method.returnType = returnType;
2787 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method); 2796 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method);
2788 method.type = methodType; 2797 method.type = methodType;
2789 return method; 2798 return method;
2790 } 2799 }
2791 2800
2801 static MethodElementImpl methodElementWithParameters(String methodName, List<D artType> typeArguments, DartType returnType, List<ParameterElement> parameters) {
2802 MethodElementImpl method = new MethodElementImpl.forNode(AstFactory.identifi er3(methodName));
2803 method.parameters = parameters;
2804 method.returnType = returnType;
2805 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method);
2806 methodType.typeArguments = typeArguments;
2807 method.type = methodType;
2808 return method;
2809 }
2810
2792 static ParameterElementImpl namedParameter(String name) { 2811 static ParameterElementImpl namedParameter(String name) {
2793 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory.id entifier3(name)); 2812 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory.id entifier3(name));
2794 parameter.parameterKind = ParameterKind.NAMED; 2813 parameter.parameterKind = ParameterKind.NAMED;
2795 return parameter; 2814 return parameter;
2796 } 2815 }
2797 2816
2798 static ParameterElementImpl namedParameter2(String name, DartType type) { 2817 static ParameterElementImpl namedParameter2(String name, DartType type) {
2799 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory.id entifier3(name)); 2818 ParameterElementImpl parameter = new ParameterElementImpl.con1(AstFactory.id entifier3(name));
2800 parameter.parameterKind = ParameterKind.NAMED; 2819 parameter.parameterKind = ParameterKind.NAMED;
2801 parameter.type = type; 2820 parameter.type = type;
(...skipping 26 matching lines...) Expand all
2828 parameter.parameterKind = ParameterKind.REQUIRED; 2847 parameter.parameterKind = ParameterKind.REQUIRED;
2829 parameter.type = type; 2848 parameter.type = type;
2830 return parameter; 2849 return parameter;
2831 } 2850 }
2832 2851
2833 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, D artType type) { 2852 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, D artType type) {
2834 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me)); 2853 FieldElementImpl field = new FieldElementImpl.con1(AstFactory.identifier3(na me));
2835 field.static = isStatic; 2854 field.static = isStatic;
2836 field.synthetic = true; 2855 field.synthetic = true;
2837 field.type = type; 2856 field.type = type;
2838 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 2857 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(field);
2839 getter.getter = true; 2858 getter.getter = true;
2840 getter.static = isStatic; 2859 getter.static = isStatic;
2841 getter.variable = field; 2860 getter.variable = field;
2842 getter.returnType = type; 2861 getter.returnType = type;
2843 field.getter = getter; 2862 field.getter = getter;
2844 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 2863 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2845 getter.type = getterType; 2864 getter.type = getterType;
2846 ParameterElementImpl parameter = requiredParameter2("a", type); 2865 ParameterElementImpl parameter = requiredParameter2("a", type);
2847 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld); 2866 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(field);
2848 setter.setter = true; 2867 setter.setter = true;
2849 setter.static = isStatic; 2868 setter.static = isStatic;
2850 setter.synthetic = true; 2869 setter.synthetic = true;
2851 setter.variable = field; 2870 setter.variable = field;
2852 setter.parameters = <ParameterElement> [parameter]; 2871 setter.parameters = <ParameterElement> [parameter];
2853 setter.returnType = VoidTypeImpl.instance; 2872 setter.returnType = VoidTypeImpl.instance;
2854 setter.type = new FunctionTypeImpl.con1(setter); 2873 setter.type = new FunctionTypeImpl.con1(setter);
2855 field.setter = setter; 2874 field.setter = setter;
2856 return setter; 2875 return setter;
2857 } 2876 }
2858 2877
2859 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name); 2878 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name);
2860 2879
2861 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name); 2880 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name);
2862 2881
2863 static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isConst, bool isFinal, DartType type) { 2882 static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isConst, bool isFinal, DartType type) {
2864 TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl.con2( name); 2883 TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl.con2( name);
2865 variable.const3 = isConst; 2884 variable.const3 = isConst;
2866 variable.final2 = isFinal; 2885 variable.final2 = isFinal;
2867 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(va riable); 2886 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(variabl e);
2868 getter.getter = true; 2887 getter.getter = true;
2869 getter.static = true; 2888 getter.static = true;
2870 getter.synthetic = true; 2889 getter.synthetic = true;
2871 getter.variable = variable; 2890 getter.variable = variable;
2872 getter.returnType = type; 2891 getter.returnType = type;
2873 variable.getter = getter; 2892 variable.getter = getter;
2874 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 2893 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2875 getter.type = getterType; 2894 getter.type = getterType;
2876 if (!isFinal) { 2895 if (!isFinal) {
2877 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( variable); 2896 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(varia ble);
2878 setter.setter = true; 2897 setter.setter = true;
2879 setter.static = true; 2898 setter.static = true;
2880 setter.synthetic = true; 2899 setter.synthetic = true;
2881 setter.variable = variable; 2900 setter.variable = variable;
2882 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)]; 2901 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)];
2883 setter.returnType = VoidTypeImpl.instance; 2902 setter.returnType = VoidTypeImpl.instance;
2884 setter.type = new FunctionTypeImpl.con1(setter); 2903 setter.type = new FunctionTypeImpl.con1(setter);
2885 variable.setter = setter; 2904 variable.setter = setter;
2886 } 2905 }
2887 return variable; 2906 return variable;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 _ut.test('test_isPublic_true', () { 3533 _ut.test('test_isPublic_true', () {
3515 final __test = new ElementImplTest(); 3534 final __test = new ElementImplTest();
3516 runJUnitTest(__test, __test.test_isPublic_true); 3535 runJUnitTest(__test, __test.test_isPublic_true);
3517 }); 3536 });
3518 }); 3537 });
3519 } 3538 }
3520 } 3539 }
3521 3540
3522 class FunctionTypeImplTest extends EngineTestCase { 3541 class FunctionTypeImplTest extends EngineTestCase {
3523 void test_creation() { 3542 void test_creation() {
3524 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.con1(AstFactory.identifier3("f")))); 3543 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.forNode(AstFactory.identifier3("f"))));
3525 } 3544 }
3526 3545
3527 void test_getElement() { 3546 void test_getElement() {
3528 FunctionElementImpl typeElement = new FunctionElementImpl.con1(AstFactory.id entifier3("f")); 3547 FunctionElementImpl typeElement = new FunctionElementImpl.forNode(AstFactory .identifier3("f"));
3529 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement); 3548 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
3530 JUnitTestCase.assertEquals(typeElement, type.element); 3549 JUnitTestCase.assertEquals(typeElement, type.element);
3531 } 3550 }
3532 3551
3533 void test_getNamedParameterTypes() { 3552 void test_getNamedParameterTypes() {
3534 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(AstFactory.identifier3("f"))); 3553 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
3535 Map<String, DartType> types = type.namedParameterTypes; 3554 Map<String, DartType> types = type.namedParameterTypes;
3536 EngineTestCase.assertSizeOfMap(0, types); 3555 EngineTestCase.assertSizeOfMap(0, types);
3537 } 3556 }
3538 3557
3539 void test_getNormalParameterTypes() { 3558 void test_getNormalParameterTypes() {
3540 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(AstFactory.identifier3("f"))); 3559 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
3541 List<DartType> types = type.normalParameterTypes; 3560 List<DartType> types = type.normalParameterTypes;
3542 EngineTestCase.assertLength(0, types); 3561 EngineTestCase.assertLength(0, types);
3543 } 3562 }
3544 3563
3545 void test_getReturnType() { 3564 void test_getReturnType() {
3546 DartType expectedReturnType = VoidTypeImpl.instance; 3565 DartType expectedReturnType = VoidTypeImpl.instance;
3547 FunctionElementImpl functionElement = new FunctionElementImpl.con1(AstFactor y.identifier3("f")); 3566 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
3548 functionElement.returnType = expectedReturnType; 3567 functionElement.returnType = expectedReturnType;
3549 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement); 3568 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
3550 DartType returnType = type.returnType; 3569 DartType returnType = type.returnType;
3551 JUnitTestCase.assertEquals(expectedReturnType, returnType); 3570 JUnitTestCase.assertEquals(expectedReturnType, returnType);
3552 } 3571 }
3553 3572
3554 void test_getTypeArguments() { 3573 void test_getTypeArguments() {
3555 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(AstFactory.identifier3("f"))); 3574 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
3556 List<DartType> types = type.typeArguments; 3575 List<DartType> types = type.typeArguments;
3557 EngineTestCase.assertLength(0, types); 3576 EngineTestCase.assertLength(0, types);
3558 } 3577 }
3559 3578
3560 void test_hashCode_element() { 3579 void test_hashCode_element() {
3561 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(AstFactory.identifier3("f"))); 3580 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
3562 type.hashCode; 3581 type.hashCode;
3563 } 3582 }
3564 3583
3565 void test_hashCode_noElement() { 3584 void test_hashCode_noElement() {
3566 FunctionTypeImpl type = new FunctionTypeImpl.con1(null); 3585 FunctionTypeImpl type = new FunctionTypeImpl.con1(null);
3567 type.hashCode; 3586 type.hashCode;
3568 } 3587 }
3569 3588
3570 void test_isAssignableTo_normalAndPositionalArgs() { 3589 void test_isAssignableTo_normalAndPositionalArgs() {
3571 // ([a]) -> void <: (a) -> void 3590 // ([a]) -> void <: (a) -> void
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 void test_isSubtypeOf_typeParameters_matchesBounds() { 3867 void test_isSubtypeOf_typeParameters_matchesBounds() {
3849 TestTypeProvider provider = new TestTypeProvider(); 3868 TestTypeProvider provider = new TestTypeProvider();
3850 InterfaceType boolType = provider.boolType; 3869 InterfaceType boolType = provider.boolType;
3851 InterfaceType stringType = provider.stringType; 3870 InterfaceType stringType = provider.stringType;
3852 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(AstFactor y.identifier3("B")); 3871 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(AstFactor y.identifier3("B"));
3853 parameterB.bound = boolType; 3872 parameterB.bound = boolType;
3854 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); 3873 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
3855 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(AstFactor y.identifier3("S")); 3874 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(AstFactor y.identifier3("S"));
3856 parameterS.bound = stringType; 3875 parameterS.bound = stringType;
3857 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS); 3876 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS);
3858 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(AstF actory.identifier3("func")); 3877 FunctionElementImpl functionAliasElement = new FunctionElementImpl.forNode(A stFactory.identifier3("func"));
3859 functionAliasElement.parameters = <ParameterElement> [ 3878 functionAliasElement.parameters = <ParameterElement> [
3860 ElementFactory.requiredParameter2("a", typeB), 3879 ElementFactory.requiredParameter2("a", typeB),
3861 ElementFactory.positionalParameter2("b", typeS)]; 3880 ElementFactory.positionalParameter2("b", typeS)];
3862 functionAliasElement.returnType = stringType; 3881 functionAliasElement.returnType = stringType;
3863 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element); 3882 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element);
3864 functionAliasElement.type = functionAliasType; 3883 functionAliasElement.type = functionAliasType;
3865 FunctionElementImpl functionElement = new FunctionElementImpl.con1(AstFactor y.identifier3("f")); 3884 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
3866 functionElement.parameters = <ParameterElement> [ 3885 functionElement.parameters = <ParameterElement> [
3867 ElementFactory.requiredParameter2("c", boolType), 3886 ElementFactory.requiredParameter2("c", boolType),
3868 ElementFactory.positionalParameter2("d", stringType)]; 3887 ElementFactory.positionalParameter2("d", stringType)];
3869 functionElement.returnType = provider.dynamicType; 3888 functionElement.returnType = provider.dynamicType;
3870 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 3889 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
3871 functionElement.type = functionType; 3890 functionElement.type = functionType;
3872 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType)); 3891 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType));
3873 } 3892 }
3874 3893
3875 void test_isSubtypeOf_wrongFunctionType_normal_named() { 3894 void test_isSubtypeOf_wrongFunctionType_normal_named() {
(...skipping 11 matching lines...) Expand all
3887 // ! ({name: A}) -> void <: ([a]) -> void 3906 // ! ({name: A}) -> void <: ([a]) -> void
3888 ClassElement a = ElementFactory.classElement2("A", []); 3907 ClassElement a = ElementFactory.classElement2("A", []);
3889 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type; 3908 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
3890 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type; 3909 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
3891 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); 3910 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
3892 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); 3911 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
3893 } 3912 }
3894 3913
3895 void test_setTypeArguments() { 3914 void test_setTypeArguments() {
3896 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); 3915 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
3897 MethodElementImpl methodElement = new MethodElementImpl.con1(AstFactory.iden tifier3("m")); 3916 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i dentifier3("m"));
3898 enclosingClass.methods = <MethodElement> [methodElement]; 3917 enclosingClass.methods = <MethodElement> [methodElement];
3899 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement); 3918 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement);
3900 DartType expectedType = enclosingClass.typeParameters[0].type; 3919 DartType expectedType = enclosingClass.typeParameters[0].type;
3901 type.typeArguments = <DartType> [expectedType]; 3920 type.typeArguments = <DartType> [expectedType];
3902 List<DartType> arguments = type.typeArguments; 3921 List<DartType> arguments = type.typeArguments;
3903 EngineTestCase.assertLength(1, arguments); 3922 EngineTestCase.assertLength(1, arguments);
3904 JUnitTestCase.assertEquals(expectedType, arguments[0]); 3923 JUnitTestCase.assertEquals(expectedType, arguments[0]);
3905 } 3924 }
3906 3925
3907 void test_substitute2_equal() { 3926 void test_substitute2_equal() {
3908 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); 3927 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
3909 TypeParameterType parameterType = definingClass.typeParameters[0].type; 3928 TypeParameterType parameterType = definingClass.typeParameters[0].type;
3910 MethodElementImpl functionElement = new MethodElementImpl.con1(AstFactory.id entifier3("m")); 3929 MethodElementImpl functionElement = new MethodElementImpl.forNode(AstFactory .identifier3("m"));
3911 String namedParameterName = "c"; 3930 String namedParameterName = "c";
3912 functionElement.parameters = <ParameterElement> [ 3931 functionElement.parameters = <ParameterElement> [
3913 ElementFactory.requiredParameter2("a", parameterType), 3932 ElementFactory.requiredParameter2("a", parameterType),
3914 ElementFactory.positionalParameter2("b", parameterType), 3933 ElementFactory.positionalParameter2("b", parameterType),
3915 ElementFactory.namedParameter2(namedParameterName, parameterType)]; 3934 ElementFactory.namedParameter2(namedParameterName, parameterType)];
3916 functionElement.returnType = parameterType; 3935 functionElement.returnType = parameterType;
3917 definingClass.methods = <MethodElement> [functionElement]; 3936 definingClass.methods = <MethodElement> [functionElement];
3918 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 3937 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
3919 functionType.typeArguments = <DartType> [parameterType]; 3938 functionType.typeArguments = <DartType> [parameterType];
3920 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D"))); 3939 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
3921 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]); 3940 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
3922 JUnitTestCase.assertEquals(argumentType, result.returnType); 3941 JUnitTestCase.assertEquals(argumentType, result.returnType);
3923 List<DartType> normalParameters = result.normalParameterTypes; 3942 List<DartType> normalParameters = result.normalParameterTypes;
3924 EngineTestCase.assertLength(1, normalParameters); 3943 EngineTestCase.assertLength(1, normalParameters);
3925 JUnitTestCase.assertEquals(argumentType, normalParameters[0]); 3944 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
3926 List<DartType> optionalParameters = result.optionalParameterTypes; 3945 List<DartType> optionalParameters = result.optionalParameterTypes;
3927 EngineTestCase.assertLength(1, optionalParameters); 3946 EngineTestCase.assertLength(1, optionalParameters);
3928 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]); 3947 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
3929 Map<String, DartType> namedParameters = result.namedParameterTypes; 3948 Map<String, DartType> namedParameters = result.namedParameterTypes;
3930 EngineTestCase.assertSizeOfMap(1, namedParameters); 3949 EngineTestCase.assertSizeOfMap(1, namedParameters);
3931 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] ); 3950 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
3932 } 3951 }
3933 3952
3934 void test_substitute2_notEqual() { 3953 void test_substitute2_notEqual() {
3935 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(AstFac tory.identifier3("R"))); 3954 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(AstFac tory.identifier3("R")));
3936 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm pl(AstFactory.identifier3("A"))); 3955 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm pl(AstFactory.identifier3("A")));
3937 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("B"))); 3956 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("B")));
3938 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(AstFactory.identifier3("C"))); 3957 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(AstFactory.identifier3("C")));
3939 FunctionElementImpl functionElement = new FunctionElementImpl.con1(AstFactor y.identifier3("f")); 3958 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
3940 String namedParameterName = "c"; 3959 String namedParameterName = "c";
3941 functionElement.parameters = <ParameterElement> [ 3960 functionElement.parameters = <ParameterElement> [
3942 ElementFactory.requiredParameter2("a", normalParameterType), 3961 ElementFactory.requiredParameter2("a", normalParameterType),
3943 ElementFactory.positionalParameter2("b", optionalParameterType), 3962 ElementFactory.positionalParameter2("b", optionalParameterType),
3944 ElementFactory.namedParameter2(namedParameterName, namedParameterType)]; 3963 ElementFactory.namedParameter2(namedParameterName, namedParameterType)];
3945 functionElement.returnType = returnType; 3964 functionElement.returnType = returnType;
3946 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 3965 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
3947 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D"))); 3966 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
3948 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(AstFactory.identifier3("E"))); 3967 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(AstFactory.identifier3("E")));
3949 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]); 3968 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4151 InterfaceTypeImplTest.dartSuite(); 4170 InterfaceTypeImplTest.dartSuite();
4152 TypeParameterTypeImplTest.dartSuite(); 4171 TypeParameterTypeImplTest.dartSuite();
4153 VoidTypeImplTest.dartSuite(); 4172 VoidTypeImplTest.dartSuite();
4154 ClassElementImplTest.dartSuite(); 4173 ClassElementImplTest.dartSuite();
4155 ElementLocationImplTest.dartSuite(); 4174 ElementLocationImplTest.dartSuite();
4156 ElementImplTest.dartSuite(); 4175 ElementImplTest.dartSuite();
4157 HtmlElementImplTest.dartSuite(); 4176 HtmlElementImplTest.dartSuite();
4158 LibraryElementImplTest.dartSuite(); 4177 LibraryElementImplTest.dartSuite();
4159 MultiplyDefinedElementImplTest.dartSuite(); 4178 MultiplyDefinedElementImplTest.dartSuite();
4160 } 4179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698