| 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.dart.constant.utilities; | 5 library analyzer.src.dart.constant.utilities; |
| 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/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 */ | 165 */ |
| 166 bool treatFinalInstanceVarAsConst = false; | 166 bool treatFinalInstanceVarAsConst = false; |
| 167 | 167 |
| 168 ConstantFinder(this.context, this.source, this.librarySource); | 168 ConstantFinder(this.context, this.source, this.librarySource); |
| 169 | 169 |
| 170 @override | 170 @override |
| 171 Object visitAnnotation(Annotation node) { | 171 Object visitAnnotation(Annotation node) { |
| 172 super.visitAnnotation(node); | 172 super.visitAnnotation(node); |
| 173 ElementAnnotation elementAnnotation = node.elementAnnotation; | 173 ElementAnnotation elementAnnotation = node.elementAnnotation; |
| 174 if (elementAnnotation == null) { | 174 if (elementAnnotation == null) { |
| 175 // Analyzer ignores annotations on "part of" directives. | 175 // Analyzer ignores annotations on "part of" directives and on enum |
| 176 assert(node.parent is PartOfDirective); | 176 // constant declarations. |
| 177 assert(node.parent is PartOfDirective || |
| 178 node.parent is EnumConstantDeclaration); |
| 177 } else { | 179 } else { |
| 178 constantsToCompute.add(elementAnnotation); | 180 constantsToCompute.add(elementAnnotation); |
| 179 } | 181 } |
| 180 return null; | 182 return null; |
| 181 } | 183 } |
| 182 | 184 |
| 183 @override | 185 @override |
| 184 Object visitClassDeclaration(ClassDeclaration node) { | 186 Object visitClassDeclaration(ClassDeclaration node) { |
| 185 bool prevTreatFinalInstanceVarAsConst = treatFinalInstanceVarAsConst; | 187 bool prevTreatFinalInstanceVarAsConst = treatFinalInstanceVarAsConst; |
| 186 if (node.element.constructors.any((ConstructorElement e) => e.isConst)) { | 188 if (node.element.constructors.any((ConstructorElement e) => e.isConst)) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 @override | 305 @override |
| 304 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 306 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 305 super.visitSuperConstructorInvocation(node); | 307 super.visitSuperConstructorInvocation(node); |
| 306 ConstructorElement constructor = getConstructorImpl(node.staticElement); | 308 ConstructorElement constructor = getConstructorImpl(node.staticElement); |
| 307 if (constructor != null) { | 309 if (constructor != null) { |
| 308 _callback(constructor); | 310 _callback(constructor); |
| 309 } | 311 } |
| 310 return null; | 312 return null; |
| 311 } | 313 } |
| 312 } | 314 } |
| OLD | NEW |