| 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 engine.testing.element_factory; | 5 library engine.testing.element_factory; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/constant.dart'; | 10 import 'package:analyzer/src/generated/constant.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 return _objectElement; | 36 return _objectElement; |
| 37 } | 37 } |
| 38 | 38 |
| 39 static InterfaceType get objectType => object.type; | 39 static InterfaceType get objectType => object.type; |
| 40 | 40 |
| 41 static ClassElementImpl classElement( | 41 static ClassElementImpl classElement( |
| 42 String typeName, InterfaceType superclassType, | 42 String typeName, InterfaceType superclassType, |
| 43 [List<String> parameterNames]) { | 43 [List<String> parameterNames]) { |
| 44 ClassElementImpl element = new ClassElementImpl(typeName, 0); | 44 ClassElementImpl element = new ClassElementImpl(typeName, 0); |
| 45 element.constructors = const <ConstructorElement>[]; |
| 45 element.supertype = superclassType; | 46 element.supertype = superclassType; |
| 46 InterfaceTypeImpl type = new InterfaceTypeImpl(element); | 47 InterfaceTypeImpl type = new InterfaceTypeImpl(element); |
| 47 element.type = type; | 48 element.type = type; |
| 48 if (parameterNames != null) { | 49 if (parameterNames != null) { |
| 49 int count = parameterNames.length; | 50 int count = parameterNames.length; |
| 50 if (count > 0) { | 51 if (count > 0) { |
| 51 List<TypeParameterElementImpl> typeParameters = | 52 List<TypeParameterElementImpl> typeParameters = |
| 52 new List<TypeParameterElementImpl>(count); | 53 new List<TypeParameterElementImpl>(count); |
| 53 List<TypeParameterTypeImpl> typeParameterTypes = | 54 List<TypeParameterTypeImpl> typeParameterTypes = |
| 54 new List<TypeParameterTypeImpl>(count); | 55 new List<TypeParameterTypeImpl>(count); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 ConstTopLevelVariableElementImpl constant = | 572 ConstTopLevelVariableElementImpl constant = |
| 572 new ConstTopLevelVariableElementImpl(AstFactory.identifier3(name)); | 573 new ConstTopLevelVariableElementImpl(AstFactory.identifier3(name)); |
| 573 constant.constantInitializer = AstFactory.instanceCreationExpression2( | 574 constant.constantInitializer = AstFactory.instanceCreationExpression2( |
| 574 Keyword.CONST, AstFactory.typeName(type.element)); | 575 Keyword.CONST, AstFactory.typeName(type.element)); |
| 575 variable = constant; | 576 variable = constant; |
| 576 } else { | 577 } else { |
| 577 variable = new TopLevelVariableElementImpl(name, -1); | 578 variable = new TopLevelVariableElementImpl(name, -1); |
| 578 } | 579 } |
| 579 variable.const3 = isConst; | 580 variable.const3 = isConst; |
| 580 variable.final2 = isFinal; | 581 variable.final2 = isFinal; |
| 581 variable.synthetic = true; | 582 variable.synthetic = false; |
| 583 variable.type = type; |
| 582 PropertyAccessorElementImpl getter = | 584 PropertyAccessorElementImpl getter = |
| 583 new PropertyAccessorElementImpl.forVariable(variable); | 585 new PropertyAccessorElementImpl.forVariable(variable); |
| 584 getter.getter = true; | 586 getter.getter = true; |
| 585 getter.synthetic = true; | 587 getter.synthetic = true; |
| 586 getter.variable = variable; | 588 getter.variable = variable; |
| 587 getter.returnType = type; | 589 getter.returnType = type; |
| 588 variable.getter = getter; | 590 variable.getter = getter; |
| 589 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); | 591 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); |
| 590 getter.type = getterType; | 592 getter.type = getterType; |
| 591 if (!isConst && !isFinal) { | 593 if (!isConst && !isFinal) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 604 } | 606 } |
| 605 return variable; | 607 return variable; |
| 606 } | 608 } |
| 607 | 609 |
| 608 static TypeParameterElementImpl typeParameterElement(String name) { | 610 static TypeParameterElementImpl typeParameterElement(String name) { |
| 609 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); | 611 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); |
| 610 element.type = new TypeParameterTypeImpl(element); | 612 element.type = new TypeParameterTypeImpl(element); |
| 611 return element; | 613 return element; |
| 612 } | 614 } |
| 613 } | 615 } |
| OLD | NEW |