| 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.constant; | 5 library analyzer.src.generated.constant; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 @override | 184 @override |
| 185 SuperConstructorInvocation visitSuperConstructorInvocation( | 185 SuperConstructorInvocation visitSuperConstructorInvocation( |
| 186 SuperConstructorInvocation node) { | 186 SuperConstructorInvocation node) { |
| 187 SuperConstructorInvocation invocation = | 187 SuperConstructorInvocation invocation = |
| 188 super.visitSuperConstructorInvocation(node); | 188 super.visitSuperConstructorInvocation(node); |
| 189 invocation.staticElement = node.staticElement; | 189 invocation.staticElement = node.staticElement; |
| 190 return invocation; | 190 return invocation; |
| 191 } | 191 } |
| 192 |
| 193 @override |
| 194 TypeName visitTypeName(TypeName node) { |
| 195 TypeName typeName = super.visitTypeName(node); |
| 196 typeName.type = node.type; |
| 197 return typeName; |
| 198 } |
| 192 } | 199 } |
| 193 | 200 |
| 194 /** | 201 /** |
| 195 * Helper class encapsulating the methods for evaluating constants and | 202 * Helper class encapsulating the methods for evaluating constants and |
| 196 * constant instance creation expressions. | 203 * constant instance creation expressions. |
| 197 */ | 204 */ |
| 198 class ConstantEvaluationEngine { | 205 class ConstantEvaluationEngine { |
| 199 /** | 206 /** |
| 200 * Parameter to "fromEnvironment" methods that denotes the default value. | 207 * Parameter to "fromEnvironment" methods that denotes the default value. |
| 201 */ | 208 */ |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 ConstructorElement element = node.element; | 1284 ConstructorElement element = node.element; |
| 1278 if (element != null) { | 1285 if (element != null) { |
| 1279 constantsToCompute.add(element); | 1286 constantsToCompute.add(element); |
| 1280 constantsToCompute.addAll(element.parameters); | 1287 constantsToCompute.addAll(element.parameters); |
| 1281 } | 1288 } |
| 1282 } | 1289 } |
| 1283 return null; | 1290 return null; |
| 1284 } | 1291 } |
| 1285 | 1292 |
| 1286 @override | 1293 @override |
| 1294 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 1295 super.visitDefaultFormalParameter(node); |
| 1296 Expression defaultValue = node.defaultValue; |
| 1297 if (defaultValue != null && node.element != null) { |
| 1298 constantsToCompute.add(node.element); |
| 1299 } |
| 1300 return null; |
| 1301 } |
| 1302 |
| 1303 @override |
| 1287 Object visitVariableDeclaration(VariableDeclaration node) { | 1304 Object visitVariableDeclaration(VariableDeclaration node) { |
| 1288 super.visitVariableDeclaration(node); | 1305 super.visitVariableDeclaration(node); |
| 1289 Expression initializer = node.initializer; | 1306 Expression initializer = node.initializer; |
| 1290 VariableElement element = node.element; | 1307 VariableElement element = node.element; |
| 1291 if (initializer != null && | 1308 if (initializer != null && |
| 1292 (node.isConst || | 1309 (node.isConst || |
| 1293 treatFinalInstanceVarAsConst && | 1310 treatFinalInstanceVarAsConst && |
| 1294 element is FieldElement && | 1311 element is FieldElement && |
| 1295 node.isFinal && | 1312 node.isFinal && |
| 1296 !element.isStatic)) { | 1313 !element.isStatic)) { |
| (...skipping 4083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5380 return BoolState.from(_element == rightElement); | 5397 return BoolState.from(_element == rightElement); |
| 5381 } else if (rightOperand is DynamicState) { | 5398 } else if (rightOperand is DynamicState) { |
| 5382 return BoolState.UNKNOWN_VALUE; | 5399 return BoolState.UNKNOWN_VALUE; |
| 5383 } | 5400 } |
| 5384 return BoolState.FALSE_STATE; | 5401 return BoolState.FALSE_STATE; |
| 5385 } | 5402 } |
| 5386 | 5403 |
| 5387 @override | 5404 @override |
| 5388 String toString() => _element == null ? "-unknown-" : _element.name; | 5405 String toString() => _element == null ? "-unknown-" : _element.name; |
| 5389 } | 5406 } |
| OLD | NEW |