| 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.element.element; | 5 library analyzer.src.dart.element.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 EvaluationResultImpl get evaluationResult => _evaluationResult; | 2329 EvaluationResultImpl get evaluationResult => _evaluationResult; |
| 2330 | 2330 |
| 2331 void set evaluationResult(EvaluationResultImpl evaluationResult) { | 2331 void set evaluationResult(EvaluationResultImpl evaluationResult) { |
| 2332 _evaluationResult = evaluationResult; | 2332 _evaluationResult = evaluationResult; |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 /** | 2335 /** |
| 2336 * If this element is resynthesized from the summary, return the unlinked | 2336 * If this element is resynthesized from the summary, return the unlinked |
| 2337 * initializer, otherwise return `null`. | 2337 * initializer, otherwise return `null`. |
| 2338 */ | 2338 */ |
| 2339 UnlinkedConst get _unlinkedConst; | 2339 UnlinkedExpr get _unlinkedConst; |
| 2340 | 2340 |
| 2341 /** | 2341 /** |
| 2342 * Return a representation of the value of this variable, forcing the value | 2342 * Return a representation of the value of this variable, forcing the value |
| 2343 * to be computed if it had not previously been computed, or `null` if either | 2343 * to be computed if it had not previously been computed, or `null` if either |
| 2344 * this variable was not declared with the 'const' modifier or if the value of | 2344 * this variable was not declared with the 'const' modifier or if the value of |
| 2345 * this variable could not be computed because of errors. | 2345 * this variable could not be computed because of errors. |
| 2346 */ | 2346 */ |
| 2347 DartObject computeConstantValue() { | 2347 DartObject computeConstantValue() { |
| 2348 if (evaluationResult == null) { | 2348 if (evaluationResult == null) { |
| 2349 context?.computeResult(this, CONSTANT_VALUE); | 2349 context?.computeResult(this, CONSTANT_VALUE); |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 | 3122 |
| 3123 @override | 3123 @override |
| 3124 void visitChildren(ElementVisitor visitor) { | 3124 void visitChildren(ElementVisitor visitor) { |
| 3125 // There are no children to visit | 3125 // There are no children to visit |
| 3126 } | 3126 } |
| 3127 | 3127 |
| 3128 /** | 3128 /** |
| 3129 * Return annotations for the given [unlinkedConsts] in the [unit]. | 3129 * Return annotations for the given [unlinkedConsts] in the [unit]. |
| 3130 */ | 3130 */ |
| 3131 List<ElementAnnotation> _buildAnnotations( | 3131 List<ElementAnnotation> _buildAnnotations( |
| 3132 CompilationUnitElementImpl unit, List<UnlinkedConst> unlinkedConsts) { | 3132 CompilationUnitElementImpl unit, List<UnlinkedExpr> unlinkedConsts) { |
| 3133 int length = unlinkedConsts.length; | 3133 int length = unlinkedConsts.length; |
| 3134 if (length != 0) { | 3134 if (length != 0) { |
| 3135 List<ElementAnnotation> annotations = new List<ElementAnnotation>(length); | 3135 List<ElementAnnotation> annotations = new List<ElementAnnotation>(length); |
| 3136 ResynthesizerContext context = unit.resynthesizerContext; | 3136 ResynthesizerContext context = unit.resynthesizerContext; |
| 3137 for (int i = 0; i < length; i++) { | 3137 for (int i = 0; i < length; i++) { |
| 3138 annotations[i] = context.buildAnnotation(this, unlinkedConsts[i]); | 3138 annotations[i] = context.buildAnnotation(this, unlinkedConsts[i]); |
| 3139 } | 3139 } |
| 3140 return annotations; | 3140 return annotations; |
| 3141 } else { | 3141 } else { |
| 3142 return const <ElementAnnotation>[]; | 3142 return const <ElementAnnotation>[]; |
| (...skipping 3661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6804 } | 6804 } |
| 6805 | 6805 |
| 6806 void set type(DartType type) { | 6806 void set type(DartType type) { |
| 6807 _assertNotResynthesized(_unlinkedVariable); | 6807 _assertNotResynthesized(_unlinkedVariable); |
| 6808 _type = type; | 6808 _type = type; |
| 6809 } | 6809 } |
| 6810 | 6810 |
| 6811 /** | 6811 /** |
| 6812 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. | 6812 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. |
| 6813 */ | 6813 */ |
| 6814 UnlinkedConst get _unlinkedConst => _unlinkedVariable?.initializer?.bodyExpr; | 6814 UnlinkedExpr get _unlinkedConst => _unlinkedVariable?.initializer?.bodyExpr; |
| 6815 } | 6815 } |
| 6816 | 6816 |
| 6817 /** | 6817 /** |
| 6818 * A concrete implementation of a [ParameterElement]. | 6818 * A concrete implementation of a [ParameterElement]. |
| 6819 */ | 6819 */ |
| 6820 class ParameterElementImpl extends VariableElementImpl | 6820 class ParameterElementImpl extends VariableElementImpl |
| 6821 with ParameterElementMixin | 6821 with ParameterElementMixin |
| 6822 implements ParameterElement { | 6822 implements ParameterElement { |
| 6823 /** | 6823 /** |
| 6824 * The unlinked representation of the parameter in the summary. | 6824 * The unlinked representation of the parameter in the summary. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7171 } | 7171 } |
| 7172 if (_visibleRangeLength < 0) { | 7172 if (_visibleRangeLength < 0) { |
| 7173 return null; | 7173 return null; |
| 7174 } | 7174 } |
| 7175 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 7175 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
| 7176 } | 7176 } |
| 7177 | 7177 |
| 7178 /** | 7178 /** |
| 7179 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. | 7179 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. |
| 7180 */ | 7180 */ |
| 7181 UnlinkedConst get _unlinkedConst => _unlinkedParam?.initializer?.bodyExpr; | 7181 UnlinkedExpr get _unlinkedConst => _unlinkedParam?.initializer?.bodyExpr; |
| 7182 | 7182 |
| 7183 @override | 7183 @override |
| 7184 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); | 7184 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); |
| 7185 | 7185 |
| 7186 @override | 7186 @override |
| 7187 void appendTo(StringBuffer buffer) { | 7187 void appendTo(StringBuffer buffer) { |
| 7188 String left = ""; | 7188 String left = ""; |
| 7189 String right = ""; | 7189 String right = ""; |
| 7190 while (true) { | 7190 while (true) { |
| 7191 if (parameterKind == ParameterKind.NAMED) { | 7191 if (parameterKind == ParameterKind.NAMED) { |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7753 _assertNotResynthesized(_unlinkedVariable); | 7753 _assertNotResynthesized(_unlinkedVariable); |
| 7754 _propagatedType = propagatedType; | 7754 _propagatedType = propagatedType; |
| 7755 } | 7755 } |
| 7756 } | 7756 } |
| 7757 | 7757 |
| 7758 /** | 7758 /** |
| 7759 * The context in which elements are resynthesized. | 7759 * The context in which elements are resynthesized. |
| 7760 */ | 7760 */ |
| 7761 abstract class ResynthesizerContext { | 7761 abstract class ResynthesizerContext { |
| 7762 /** | 7762 /** |
| 7763 * Build [ElementAnnotationImpl] for the given [UnlinkedConst]. | 7763 * Build [ElementAnnotationImpl] for the given [UnlinkedExpr]. |
| 7764 */ | 7764 */ |
| 7765 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedConst uc); | 7765 ElementAnnotationImpl buildAnnotation(ElementImpl context, UnlinkedExpr uc); |
| 7766 | 7766 |
| 7767 /** | 7767 /** |
| 7768 * Build [Expression] for the given [UnlinkedConst]. | 7768 * Build [Expression] for the given [UnlinkedExpr]. |
| 7769 */ | 7769 */ |
| 7770 Expression buildExpression(ElementImpl context, UnlinkedConst uc); | 7770 Expression buildExpression(ElementImpl context, UnlinkedExpr uc); |
| 7771 | 7771 |
| 7772 /** | 7772 /** |
| 7773 * Build explicit top-level property accessors. | 7773 * Build explicit top-level property accessors. |
| 7774 */ | 7774 */ |
| 7775 UnitExplicitTopLevelAccessors buildTopLevelAccessors(); | 7775 UnitExplicitTopLevelAccessors buildTopLevelAccessors(); |
| 7776 | 7776 |
| 7777 /** | 7777 /** |
| 7778 * Build explicit top-level variables. | 7778 * Build explicit top-level variables. |
| 7779 */ | 7779 */ |
| 7780 UnitExplicitTopLevelVariables buildTopLevelVariables(); | 7780 UnitExplicitTopLevelVariables buildTopLevelVariables(); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8487 | 8487 |
| 8488 @override | 8488 @override |
| 8489 void visitElement(Element element) { | 8489 void visitElement(Element element) { |
| 8490 int offset = element.nameOffset; | 8490 int offset = element.nameOffset; |
| 8491 if (offset != -1) { | 8491 if (offset != -1) { |
| 8492 map[offset] = element; | 8492 map[offset] = element; |
| 8493 } | 8493 } |
| 8494 super.visitElement(element); | 8494 super.visitElement(element); |
| 8495 } | 8495 } |
| 8496 } | 8496 } |
| OLD | NEW |