Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/constant.dart |
| diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart |
| index 5b400a8c3b8acb86427b9ad31d85976e40cad061..a1a51fe7067723340ad2111ff4c6c792402c2a70 100644 |
| --- a/pkg/analyzer/lib/src/generated/constant.dart |
| +++ b/pkg/analyzer/lib/src/generated/constant.dart |
| @@ -144,6 +144,51 @@ class BoolState extends InstanceState { |
| } |
| /** |
| + * An [AstCloner] that copies the necessary information from the AST to allow |
| + * const constructor initializers to be evaluated. |
| + */ |
| +class ConstantAstCloner extends AstCloner { |
| + // TODO(brianwilkerson) Investigate replacing uses of this class with uses of |
|
Brian Wilkerson
2015/04/01 16:39:21
I think we can remove the TODO: having one visitor
Paul Berry
2015/04/01 18:12:07
Done.
|
| + // AstCloner and ResolutionCopier. |
| + |
| + ConstantAstCloner() : super(true); |
| + |
| + @override |
| + InstanceCreationExpression visitInstanceCreationExpression( |
| + InstanceCreationExpression node) { |
| + InstanceCreationExpression expression = |
| + super.visitInstanceCreationExpression(node); |
| + expression.evaluationResult = node.evaluationResult; |
| + return expression; |
| + } |
| + |
| + @override |
| + RedirectingConstructorInvocation visitRedirectingConstructorInvocation( |
| + RedirectingConstructorInvocation node) { |
| + RedirectingConstructorInvocation invocation = |
| + super.visitRedirectingConstructorInvocation(node); |
| + invocation.staticElement = node.staticElement; |
| + return invocation; |
| + } |
| + |
| + @override |
| + SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) { |
| + SimpleIdentifier identifier = super.visitSimpleIdentifier(node); |
| + identifier.staticElement = node.staticElement; |
| + return identifier; |
| + } |
| + |
| + @override |
| + SuperConstructorInvocation visitSuperConstructorInvocation( |
| + SuperConstructorInvocation node) { |
| + SuperConstructorInvocation invocation = |
| + super.visitSuperConstructorInvocation(node); |
| + invocation.staticElement = node.staticElement; |
| + return invocation; |
| + } |
| +} |
| + |
| +/** |
| * Instances of the class `ConstantEvaluator` evaluate constant expressions to |
| * produce their compile-time value. According to the Dart Language |
| * Specification: |
| @@ -652,8 +697,7 @@ class ConstantValueComputer { |
| ConstructorElementImpl constructor = |
| declaration.element as ConstructorElementImpl; |
| constructor.constantInitializers = |
| - new ConstantValueComputer_InitializerCloner() |
| - .cloneNodeList(initializers); |
| + new ConstantAstCloner().cloneNodeList(initializers); |
| } else if (constNode is FormalParameter) { |
| if (constNode is DefaultFormalParameter) { |
| DefaultFormalParameter parameter = constNode; |
| @@ -1089,51 +1133,6 @@ class ConstantValueComputer { |
| } |
| /** |
| - * An [AstCloner] that copies the necessary information from the AST to allow |
| - * const constructor initializers to be evaluated. |
| - */ |
| -class ConstantValueComputer_InitializerCloner extends AstCloner { |
| - // TODO(brianwilkerson) Investigate replacing uses of this class with uses of |
| - // AstCloner and ResolutionCopier. |
| - |
| - ConstantValueComputer_InitializerCloner() : super(true); |
| - |
| - @override |
| - InstanceCreationExpression visitInstanceCreationExpression( |
| - InstanceCreationExpression node) { |
| - InstanceCreationExpression expression = |
| - super.visitInstanceCreationExpression(node); |
| - expression.evaluationResult = node.evaluationResult; |
| - return expression; |
| - } |
| - |
| - @override |
| - RedirectingConstructorInvocation visitRedirectingConstructorInvocation( |
| - RedirectingConstructorInvocation node) { |
| - RedirectingConstructorInvocation invocation = |
| - super.visitRedirectingConstructorInvocation(node); |
| - invocation.staticElement = node.staticElement; |
| - return invocation; |
| - } |
| - |
| - @override |
| - SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) { |
| - SimpleIdentifier identifier = super.visitSimpleIdentifier(node); |
| - identifier.staticElement = node.staticElement; |
| - return identifier; |
| - } |
| - |
| - @override |
| - SuperConstructorInvocation visitSuperConstructorInvocation( |
| - SuperConstructorInvocation node) { |
| - SuperConstructorInvocation invocation = |
| - super.visitSuperConstructorInvocation(node); |
| - invocation.staticElement = node.staticElement; |
| - return invocation; |
| - } |
| -} |
| - |
| -/** |
| * A visitor used to evaluate constant expressions to produce their compile-time |
| * value. According to the Dart Language Specification: <blockquote> A constant |
| * expression is one of the following: |