| 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/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 552 |
| 553 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => | 553 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => |
| 554 topLevelVariableElement3(name, false, false, null); | 554 topLevelVariableElement3(name, false, false, null); |
| 555 | 555 |
| 556 static TopLevelVariableElementImpl topLevelVariableElement3( | 556 static TopLevelVariableElementImpl topLevelVariableElement3( |
| 557 String name, bool isConst, bool isFinal, DartType type) { | 557 String name, bool isConst, bool isFinal, DartType type) { |
| 558 TopLevelVariableElementImpl variable; | 558 TopLevelVariableElementImpl variable; |
| 559 if (isConst) { | 559 if (isConst) { |
| 560 ConstTopLevelVariableElementImpl constant = | 560 ConstTopLevelVariableElementImpl constant = |
| 561 new ConstTopLevelVariableElementImpl(AstFactory.identifier3(name)); | 561 new ConstTopLevelVariableElementImpl(AstFactory.identifier3(name)); |
| 562 constant.constantInitializer = AstFactory.instanceCreationExpression2( | 562 InstanceCreationExpression initializer = AstFactory.instanceCreationExpres
sion2( |
| 563 Keyword.CONST, AstFactory.typeName(type.element)); | 563 Keyword.CONST, AstFactory.typeName(type.element)); |
| 564 if (type is InterfaceType) { |
| 565 initializer.staticElement = type.element.unnamedConstructor; |
| 566 } |
| 567 constant.constantInitializer = initializer; |
| 564 variable = constant; | 568 variable = constant; |
| 565 } else { | 569 } else { |
| 566 variable = new TopLevelVariableElementImpl(name, -1); | 570 variable = new TopLevelVariableElementImpl(name, -1); |
| 567 } | 571 } |
| 568 variable.const3 = isConst; | 572 variable.const3 = isConst; |
| 569 variable.final2 = isFinal; | 573 variable.final2 = isFinal; |
| 570 variable.synthetic = false; | 574 variable.synthetic = false; |
| 571 variable.type = type; | 575 variable.type = type; |
| 572 PropertyAccessorElementImpl getter = | 576 PropertyAccessorElementImpl getter = |
| 573 new PropertyAccessorElementImpl.forVariable(variable); | 577 new PropertyAccessorElementImpl.forVariable(variable); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 619 } |
| 616 | 620 |
| 617 static TypeParameterElementImpl typeParameterWithType(String name, | 621 static TypeParameterElementImpl typeParameterWithType(String name, |
| 618 [DartType bound]) { | 622 [DartType bound]) { |
| 619 TypeParameterElementImpl typeParameter = typeParameterElement(name); | 623 TypeParameterElementImpl typeParameter = typeParameterElement(name); |
| 620 typeParameter.type = new TypeParameterTypeImpl(typeParameter); | 624 typeParameter.type = new TypeParameterTypeImpl(typeParameter); |
| 621 typeParameter.bound = bound; | 625 typeParameter.bound = bound; |
| 622 return typeParameter; | 626 return typeParameter; |
| 623 } | 627 } |
| 624 } | 628 } |
| OLD | NEW |