| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 summary_resynthesizer; | 5 library summary_resynthesizer; |
| 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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 serializedLabel.nameOffset, | 1999 serializedLabel.nameOffset, |
| 2000 serializedLabel.isOnSwitchStatement, | 2000 serializedLabel.isOnSwitchStatement, |
| 2001 serializedLabel.isOnSwitchMember); | 2001 serializedLabel.isOnSwitchMember); |
| 2002 } | 2002 } |
| 2003 | 2003 |
| 2004 /** | 2004 /** |
| 2005 * Resynthesize a [LocalVariableElement]. | 2005 * Resynthesize a [LocalVariableElement]. |
| 2006 */ | 2006 */ |
| 2007 LocalVariableElement buildLocalVariable(UnlinkedVariable serializedVariable) { | 2007 LocalVariableElement buildLocalVariable(UnlinkedVariable serializedVariable) { |
| 2008 LocalVariableElementImpl element; | 2008 LocalVariableElementImpl element; |
| 2009 if (serializedVariable.constExpr != null) { | 2009 if (serializedVariable.constExpr != null && serializedVariable.isConst) { |
| 2010 ConstLocalVariableElementImpl constElement = | 2010 ConstLocalVariableElementImpl constElement = |
| 2011 new ConstLocalVariableElementImpl( | 2011 new ConstLocalVariableElementImpl( |
| 2012 serializedVariable.name, serializedVariable.nameOffset); | 2012 serializedVariable.name, serializedVariable.nameOffset); |
| 2013 element = constElement; | 2013 element = constElement; |
| 2014 constElement.constantInitializer = | 2014 constElement.constantInitializer = |
| 2015 _buildConstExpression(serializedVariable.constExpr); | 2015 _buildConstExpression(serializedVariable.constExpr); |
| 2016 } else { | 2016 } else { |
| 2017 element = new LocalVariableElementImpl( | 2017 element = new LocalVariableElementImpl( |
| 2018 serializedVariable.name, serializedVariable.nameOffset); | 2018 serializedVariable.name, serializedVariable.nameOffset); |
| 2019 } | 2019 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 return typeParameters; | 2226 return typeParameters; |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 /** | 2229 /** |
| 2230 * Resynthesize a [TopLevelVariableElement] or [FieldElement]. | 2230 * Resynthesize a [TopLevelVariableElement] or [FieldElement]. |
| 2231 */ | 2231 */ |
| 2232 void buildVariable(UnlinkedVariable serializedVariable, | 2232 void buildVariable(UnlinkedVariable serializedVariable, |
| 2233 [ElementHolder holder]) { | 2233 [ElementHolder holder]) { |
| 2234 if (holder == null) { | 2234 if (holder == null) { |
| 2235 TopLevelVariableElementImpl element; | 2235 TopLevelVariableElementImpl element; |
| 2236 if (serializedVariable.constExpr != null) { | 2236 if (serializedVariable.constExpr != null && serializedVariable.isConst) { |
| 2237 ConstTopLevelVariableElementImpl constElement = | 2237 ConstTopLevelVariableElementImpl constElement = |
| 2238 new ConstTopLevelVariableElementImpl( | 2238 new ConstTopLevelVariableElementImpl( |
| 2239 serializedVariable.name, serializedVariable.nameOffset); | 2239 serializedVariable.name, serializedVariable.nameOffset); |
| 2240 element = constElement; | 2240 element = constElement; |
| 2241 constElement.constantInitializer = | 2241 constElement.constantInitializer = |
| 2242 _buildConstExpression(serializedVariable.constExpr); | 2242 _buildConstExpression(serializedVariable.constExpr); |
| 2243 } else { | 2243 } else { |
| 2244 element = new TopLevelVariableElementImpl( | 2244 element = new TopLevelVariableElementImpl( |
| 2245 serializedVariable.name, serializedVariable.nameOffset); | 2245 serializedVariable.name, serializedVariable.nameOffset); |
| 2246 } | 2246 } |
| 2247 buildPropertyIntroducingElementCommonParts(element, serializedVariable); | 2247 buildPropertyIntroducingElementCommonParts(element, serializedVariable); |
| 2248 unitHolder.addTopLevelVariable(element); | 2248 unitHolder.addTopLevelVariable(element); |
| 2249 buildImplicitAccessors(element, unitHolder); | 2249 buildImplicitAccessors(element, unitHolder); |
| 2250 } else { | 2250 } else { |
| 2251 FieldElementImpl element; | 2251 FieldElementImpl element; |
| 2252 if (serializedVariable.constExpr != null) { | 2252 if (serializedVariable.constExpr != null && |
| 2253 (serializedVariable.isConst || |
| 2254 serializedVariable.isFinal && !serializedVariable.isStatic)) { |
| 2253 ConstFieldElementImpl constElement = new ConstFieldElementImpl( | 2255 ConstFieldElementImpl constElement = new ConstFieldElementImpl( |
| 2254 serializedVariable.name, serializedVariable.nameOffset); | 2256 serializedVariable.name, serializedVariable.nameOffset); |
| 2255 element = constElement; | 2257 element = constElement; |
| 2256 constElement.constantInitializer = | 2258 constElement.constantInitializer = |
| 2257 _buildConstExpression(serializedVariable.constExpr); | 2259 _buildConstExpression(serializedVariable.constExpr); |
| 2258 } else { | 2260 } else { |
| 2259 element = new FieldElementImpl( | 2261 element = new FieldElementImpl( |
| 2260 serializedVariable.name, serializedVariable.nameOffset); | 2262 serializedVariable.name, serializedVariable.nameOffset); |
| 2261 } | 2263 } |
| 2262 buildPropertyIntroducingElementCommonParts(element, serializedVariable); | 2264 buildPropertyIntroducingElementCommonParts(element, serializedVariable); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 static String _getElementIdentifier(String name, ReferenceKind kind) { | 2594 static String _getElementIdentifier(String name, ReferenceKind kind) { |
| 2593 if (kind == ReferenceKind.topLevelPropertyAccessor || | 2595 if (kind == ReferenceKind.topLevelPropertyAccessor || |
| 2594 kind == ReferenceKind.propertyAccessor) { | 2596 kind == ReferenceKind.propertyAccessor) { |
| 2595 if (!name.endsWith('=')) { | 2597 if (!name.endsWith('=')) { |
| 2596 return name + '?'; | 2598 return name + '?'; |
| 2597 } | 2599 } |
| 2598 } | 2600 } |
| 2599 return name; | 2601 return name; |
| 2600 } | 2602 } |
| 2601 } | 2603 } |
| OLD | NEW |