| 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 29 matching lines...) Expand all Loading... |
| 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(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); | |
| 51 element.type = type; | |
| 52 if (parameterNames != null) { | 50 if (parameterNames != null) { |
| 53 int count = parameterNames.length; | 51 element.typeParameters = typeParameters(parameterNames); |
| 54 if (count > 0) { | |
| 55 element.typeParameters = typeParameters(parameterNames); | |
| 56 type.typeArguments = new List<DartType>.from( | |
| 57 element.typeParameters.map((p) => p.type), | |
| 58 growable: false); | |
| 59 } | |
| 60 } | 52 } |
| 61 return element; | 53 return element; |
| 62 } | 54 } |
| 63 | 55 |
| 64 static ClassElementImpl classElement2(String typeName, | 56 static ClassElementImpl classElement2(String typeName, |
| 65 [List<String> parameterNames]) => | 57 [List<String> parameterNames]) => |
| 66 classElement(typeName, objectType, parameterNames); | 58 classElement(typeName, objectType, parameterNames); |
| 67 | 59 |
| 68 static classTypeAlias(String typeName, InterfaceType superclassType, | 60 static classTypeAlias(String typeName, InterfaceType superclassType, |
| 69 [List<String> parameterNames]) { | 61 [List<String> parameterNames]) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 ClassElement definingClass, String name, | 125 ClassElement definingClass, String name, |
| 134 [List<DartType> argumentTypes]) => | 126 [List<DartType> argumentTypes]) => |
| 135 constructorElement(definingClass, name, false, argumentTypes); | 127 constructorElement(definingClass, name, false, argumentTypes); |
| 136 | 128 |
| 137 static EnumElementImpl enumElement(TypeProvider typeProvider, String enumName, | 129 static EnumElementImpl enumElement(TypeProvider typeProvider, String enumName, |
| 138 [List<String> constantNames]) { | 130 [List<String> constantNames]) { |
| 139 // | 131 // |
| 140 // Build the enum. | 132 // Build the enum. |
| 141 // | 133 // |
| 142 EnumElementImpl enumElement = new EnumElementImpl(enumName, -1); | 134 EnumElementImpl enumElement = new EnumElementImpl(enumName, -1); |
| 143 InterfaceTypeImpl enumType = new InterfaceTypeImpl(enumElement); | 135 InterfaceTypeImpl enumType = enumElement.type; |
| 144 enumElement.type = enumType; | |
| 145 // | 136 // |
| 146 // Populate the fields. | 137 // Populate the fields. |
| 147 // | 138 // |
| 148 List<FieldElement> fields = new List<FieldElement>(); | 139 List<FieldElement> fields = new List<FieldElement>(); |
| 149 InterfaceType intType = typeProvider.intType; | 140 InterfaceType intType = typeProvider.intType; |
| 150 InterfaceType stringType = typeProvider.stringType; | 141 InterfaceType stringType = typeProvider.stringType; |
| 151 String indexFieldName = "index"; | 142 String indexFieldName = "index"; |
| 152 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); | 143 FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1); |
| 153 indexField.final2 = true; | 144 indexField.final2 = true; |
| 154 indexField.type = intType; | 145 indexField.type = intType; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 608 } |
| 618 | 609 |
| 619 static TypeParameterElementImpl typeParameterWithType(String name, | 610 static TypeParameterElementImpl typeParameterWithType(String name, |
| 620 [DartType bound]) { | 611 [DartType bound]) { |
| 621 TypeParameterElementImpl typeParameter = typeParameterElement(name); | 612 TypeParameterElementImpl typeParameter = typeParameterElement(name); |
| 622 typeParameter.type = new TypeParameterTypeImpl(typeParameter); | 613 typeParameter.type = new TypeParameterTypeImpl(typeParameter); |
| 623 typeParameter.bound = bound; | 614 typeParameter.bound = bound; |
| 624 return typeParameter; | 615 return typeParameter; |
| 625 } | 616 } |
| 626 } | 617 } |
| OLD | NEW |