| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 static ExportElementImpl exportFor(LibraryElement exportedLibrary, | 195 static ExportElementImpl exportFor(LibraryElement exportedLibrary, |
| 196 [List<NamespaceCombinator> combinators = | 196 [List<NamespaceCombinator> combinators = |
| 197 NamespaceCombinator.EMPTY_LIST]) { | 197 NamespaceCombinator.EMPTY_LIST]) { |
| 198 ExportElementImpl spec = new ExportElementImpl(-1); | 198 ExportElementImpl spec = new ExportElementImpl(-1); |
| 199 spec.exportedLibrary = exportedLibrary; | 199 spec.exportedLibrary = exportedLibrary; |
| 200 spec.combinators = combinators; | 200 spec.combinators = combinators; |
| 201 return spec; | 201 return spec; |
| 202 } | 202 } |
| 203 | 203 |
| 204 static FieldElementImpl fieldElement( | 204 static FieldElementImpl fieldElement( |
| 205 String name, bool isStatic, bool isFinal, bool isConst, DartType type) { | 205 String name, bool isStatic, bool isFinal, bool isConst, DartType type, |
| 206 {Expression initializer}) { |
| 206 FieldElementImpl field = isConst | 207 FieldElementImpl field = isConst |
| 207 ? new ConstFieldElementImpl(name, 0) | 208 ? new ConstFieldElementImpl(name, 0) |
| 208 : new FieldElementImpl(name, 0); | 209 : new FieldElementImpl(name, 0); |
| 209 field.const3 = isConst; | 210 field.const3 = isConst; |
| 210 field.final2 = isFinal; | 211 field.final2 = isFinal; |
| 211 field.static = isStatic; | 212 field.static = isStatic; |
| 212 field.type = type; | 213 field.type = type; |
| 214 if (isConst) { |
| 215 (field as ConstFieldElementImpl).constantInitializer = initializer; |
| 216 } |
| 213 PropertyAccessorElementImpl getter = | 217 PropertyAccessorElementImpl getter = |
| 214 new PropertyAccessorElementImpl.forVariable(field); | 218 new PropertyAccessorElementImpl.forVariable(field); |
| 215 getter.getter = true; | 219 getter.getter = true; |
| 216 getter.synthetic = true; | 220 getter.synthetic = true; |
| 217 getter.variable = field; | 221 getter.variable = field; |
| 218 getter.returnType = type; | 222 getter.returnType = type; |
| 219 field.getter = getter; | 223 field.getter = getter; |
| 220 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); | 224 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); |
| 221 getter.type = getterType; | 225 getter.type = getterType; |
| 222 if (!isConst && !isFinal) { | 226 if (!isConst && !isFinal) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 return parameter; | 493 return parameter; |
| 490 } | 494 } |
| 491 | 495 |
| 492 static ParameterElementImpl namedParameter2(String name, DartType type) { | 496 static ParameterElementImpl namedParameter2(String name, DartType type) { |
| 493 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); | 497 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); |
| 494 parameter.parameterKind = ParameterKind.NAMED; | 498 parameter.parameterKind = ParameterKind.NAMED; |
| 495 parameter.type = type; | 499 parameter.type = type; |
| 496 return parameter; | 500 return parameter; |
| 497 } | 501 } |
| 498 | 502 |
| 503 static ParameterElementImpl namedParameter3(String name, |
| 504 {DartType type, Expression initializer}) { |
| 505 DefaultParameterElementImpl parameter = |
| 506 new DefaultParameterElementImpl(name, 0); |
| 507 parameter.parameterKind = ParameterKind.NAMED; |
| 508 parameter.type = type; |
| 509 parameter.constantInitializer = initializer; |
| 510 return parameter; |
| 511 } |
| 512 |
| 499 static ParameterElementImpl positionalParameter(String name) { | 513 static ParameterElementImpl positionalParameter(String name) { |
| 500 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); | 514 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); |
| 501 parameter.parameterKind = ParameterKind.POSITIONAL; | 515 parameter.parameterKind = ParameterKind.POSITIONAL; |
| 502 return parameter; | 516 return parameter; |
| 503 } | 517 } |
| 504 | 518 |
| 505 static ParameterElementImpl positionalParameter2(String name, DartType type) { | 519 static ParameterElementImpl positionalParameter2(String name, DartType type) { |
| 506 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); | 520 ParameterElementImpl parameter = new ParameterElementImpl(name, 0); |
| 507 parameter.parameterKind = ParameterKind.POSITIONAL; | 521 parameter.parameterKind = ParameterKind.POSITIONAL; |
| 508 parameter.type = type; | 522 parameter.type = type; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 642 } |
| 629 | 643 |
| 630 static TypeParameterElementImpl typeParameterWithType(String name, | 644 static TypeParameterElementImpl typeParameterWithType(String name, |
| 631 [DartType bound]) { | 645 [DartType bound]) { |
| 632 TypeParameterElementImpl typeParameter = typeParameterElement(name); | 646 TypeParameterElementImpl typeParameter = typeParameterElement(name); |
| 633 typeParameter.type = new TypeParameterTypeImpl(typeParameter); | 647 typeParameter.type = new TypeParameterTypeImpl(typeParameter); |
| 634 typeParameter.bound = bound; | 648 typeParameter.bound = bound; |
| 635 return typeParameter; | 649 return typeParameter; |
| 636 } | 650 } |
| 637 } | 651 } |
| OLD | NEW |