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 library analyzer.src.generated.testing.element_factory; | 5 library analyzer.src.generated.testing.element_factory; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 26 matching lines...) Expand all Loading... |
37 _objectElement = classElement("Object", null); | 37 _objectElement = classElement("Object", null); |
38 } | 38 } |
39 return _objectElement; | 39 return _objectElement; |
40 } | 40 } |
41 | 41 |
42 static InterfaceType get objectType => object.type; | 42 static InterfaceType get objectType => object.type; |
43 | 43 |
44 static ClassElementImpl classElement( | 44 static ClassElementImpl classElement( |
45 String typeName, InterfaceType superclassType, | 45 String typeName, InterfaceType superclassType, |
46 [List<String> parameterNames]) { | 46 [List<String> parameterNames]) { |
47 ClassElementImpl element = new ClassElementImpl(typeName, 0); | 47 ClassElementImpl element = new ClassElementImpl_Class(typeName, 0); |
48 element.constructors = const <ConstructorElement>[]; | 48 element.constructors = const <ConstructorElement>[]; |
49 element.supertype = superclassType; | 49 element.supertype = superclassType; |
50 InterfaceTypeImpl type = new InterfaceTypeImpl(element); | 50 InterfaceTypeImpl type = new InterfaceTypeImpl(element); |
51 element.type = type; | 51 element.type = type; |
52 if (parameterNames != null) { | 52 if (parameterNames != null) { |
53 int count = parameterNames.length; | 53 int count = parameterNames.length; |
54 if (count > 0) { | 54 if (count > 0) { |
55 element.typeParameters = typeParameters(parameterNames); | 55 element.typeParameters = typeParameters(parameterNames); |
56 type.typeArguments = new List<DartType>.from( | 56 type.typeArguments = new List<DartType>.from( |
57 element.typeParameters.map((p) => p.type), | 57 element.typeParameters.map((p) => p.type), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ClassElement definingClass, String name, | 136 ClassElement definingClass, String name, |
137 [List<DartType> argumentTypes]) => | 137 [List<DartType> argumentTypes]) => |
138 constructorElement(definingClass, name, false, argumentTypes); | 138 constructorElement(definingClass, name, false, argumentTypes); |
139 | 139 |
140 static ClassElementImpl enumElement( | 140 static ClassElementImpl enumElement( |
141 TypeProvider typeProvider, String enumName, | 141 TypeProvider typeProvider, String enumName, |
142 [List<String> constantNames]) { | 142 [List<String> constantNames]) { |
143 // | 143 // |
144 // Build the enum. | 144 // Build the enum. |
145 // | 145 // |
146 ClassElementImpl enumElement = new ClassElementImpl(enumName, -1); | 146 ClassElementImpl enumElement = new ClassElementImpl_Enum(enumName, -1); |
147 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement); | 147 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement); |
148 enumElement.type = enumType; | 148 enumElement.type = enumType; |
149 enumElement.supertype = objectType; | 149 enumElement.supertype = objectType; |
150 enumElement.enum2 = true; | |
151 // | 150 // |
152 // Populate the fields. | 151 // Populate the fields. |
153 // | 152 // |
154 List<FieldElement> fields = new List<FieldElement>(); | 153 List<FieldElement> fields = new List<FieldElement>(); |
155 InterfaceType intType = typeProvider.intType; | 154 InterfaceType intType = typeProvider.intType; |
156 InterfaceType stringType = typeProvider.stringType; | 155 InterfaceType stringType = typeProvider.stringType; |
157 String indexFieldName = "index"; | 156 String indexFieldName = "index"; |
158 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); | 157 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); |
159 indexField.final2 = true; | 158 indexField.final2 = true; |
160 indexField.type = intType; | 159 indexField.type = intType; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 622 } |
624 | 623 |
625 static TypeParameterElementImpl typeParameterWithType(String name, | 624 static TypeParameterElementImpl typeParameterWithType(String name, |
626 [DartType bound]) { | 625 [DartType bound]) { |
627 TypeParameterElementImpl typeParameter = typeParameterElement(name); | 626 TypeParameterElementImpl typeParameter = typeParameterElement(name); |
628 typeParameter.type = new TypeParameterTypeImpl(typeParameter); | 627 typeParameter.type = new TypeParameterTypeImpl(typeParameter); |
629 typeParameter.bound = bound; | 628 typeParameter.bound = bound; |
630 return typeParameter; | 629 return typeParameter; |
631 } | 630 } |
632 } | 631 } |
OLD | NEW |