Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2007323006: Resynthesize return types lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 return hasModifier(Modifier.FACTORY); 1675 return hasModifier(Modifier.FACTORY);
1676 } 1676 }
1677 1677
1678 @override 1678 @override
1679 bool get isStatic => false; 1679 bool get isStatic => false;
1680 1680
1681 @override 1681 @override
1682 ElementKind get kind => ElementKind.CONSTRUCTOR; 1682 ElementKind get kind => ElementKind.CONSTRUCTOR;
1683 1683
1684 @override 1684 @override
1685 DartType get returnType => enclosingElement.type;
1686
1687 @override
1685 accept(ElementVisitor visitor) => visitor.visitConstructorElement(this); 1688 accept(ElementVisitor visitor) => visitor.visitConstructorElement(this);
1686 1689
1687 @override 1690 @override
1688 void appendTo(StringBuffer buffer) { 1691 void appendTo(StringBuffer buffer) {
1689 if (enclosingElement == null) { 1692 if (enclosingElement == null) {
1690 String message; 1693 String message;
1691 String name = displayName; 1694 String name = displayName;
1692 if (name != null && !name.isEmpty) { 1695 if (name != null && !name.isEmpty) {
1693 message = 1696 message =
1694 'Found constructor element named $name with no enclosing element'; 1697 'Found constructor element named $name with no enclosing element';
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2799 2802
2800 /** 2803 /**
2801 * A list containing all of the type parameters defined for this executable 2804 * A list containing all of the type parameters defined for this executable
2802 * element. 2805 * element.
2803 */ 2806 */
2804 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; 2807 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST;
2805 2808
2806 /** 2809 /**
2807 * The return type defined by this executable element. 2810 * The return type defined by this executable element.
2808 */ 2811 */
2809 DartType returnType; 2812 DartType _returnType;
2810 2813
2811 /** 2814 /**
2812 * The type of function defined by this executable element. 2815 * The type of function defined by this executable element.
2813 */ 2816 */
2814 FunctionType type; 2817 FunctionType type;
2815 2818
2816 /** 2819 /**
2817 * Initialize a newly created executable element to have the given [name] and 2820 * Initialize a newly created executable element to have the given [name] and
2818 * [offset]. 2821 * [offset].
2819 */ 2822 */
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 * [parameters]. 3036 * [parameters].
3034 */ 3037 */
3035 void set parameters(List<ParameterElement> parameters) { 3038 void set parameters(List<ParameterElement> parameters) {
3036 for (ParameterElement parameter in parameters) { 3039 for (ParameterElement parameter in parameters) {
3037 (parameter as ParameterElementImpl).enclosingElement = this; 3040 (parameter as ParameterElementImpl).enclosingElement = this;
3038 } 3041 }
3039 this._parameters = parameters; 3042 this._parameters = parameters;
3040 } 3043 }
3041 3044
3042 @override 3045 @override
3046 DartType get returnType {
3047 if (serializedExecutable != null && _returnType == null) {
3048 bool isSetter =
3049 serializedExecutable.kind == UnlinkedExecutableKind.setter;
3050 _returnType = enclosingUnit.resynthesizerContext.resolveLinkedType(
3051 serializedExecutable.inferredReturnTypeSlot,
3052 typeParameterContext) ??
3053 enclosingUnit.resynthesizerContext.resolveTypeRef(
3054 serializedExecutable.returnType, typeParameterContext,
3055 defaultVoid: isSetter && context.analysisOptions.strongMode);
3056 }
3057 return _returnType;
3058 }
3059
3060 void set returnType(DartType returnType) {
3061 assert(serializedExecutable == null);
3062 _returnType = returnType;
3063 }
3064
3065 @override
3043 TypeParameterizedElementMixin get typeParameterContext => this; 3066 TypeParameterizedElementMixin get typeParameterContext => this;
3044 3067
3045 @override 3068 @override
3046 List<TypeParameterElement> get typeParameters => _typeParameters; 3069 List<TypeParameterElement> get typeParameters => _typeParameters;
3047 3070
3048 /** 3071 /**
3049 * Set the type parameters defined by this executable element to the given 3072 * Set the type parameters defined by this executable element to the given
3050 * [typeParameters]. 3073 * [typeParameters].
3051 */ 3074 */
3052 void set typeParameters(List<TypeParameterElement> typeParameters) { 3075 void set typeParameters(List<TypeParameterElement> typeParameters) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 final UnlinkedTypedef _unlinkedTypedef; 3647 final UnlinkedTypedef _unlinkedTypedef;
3625 3648
3626 /** 3649 /**
3627 * A list containing all of the parameters defined by this type alias. 3650 * A list containing all of the parameters defined by this type alias.
3628 */ 3651 */
3629 List<ParameterElement> _parameters = ParameterElement.EMPTY_LIST; 3652 List<ParameterElement> _parameters = ParameterElement.EMPTY_LIST;
3630 3653
3631 /** 3654 /**
3632 * The return type defined by this type alias. 3655 * The return type defined by this type alias.
3633 */ 3656 */
3634 DartType returnType; 3657 DartType _returnType;
3635 3658
3636 /** 3659 /**
3637 * The type of function defined by this type alias. 3660 * The type of function defined by this type alias.
3638 */ 3661 */
3639 FunctionType type; 3662 FunctionType type;
3640 3663
3641 /** 3664 /**
3642 * A list containing all of the type parameters defined for this type. 3665 * A list containing all of the type parameters defined for this type.
3643 */ 3666 */
3644 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; 3667 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 void set parameters(List<ParameterElement> parameters) { 3778 void set parameters(List<ParameterElement> parameters) {
3756 if (parameters != null) { 3779 if (parameters != null) {
3757 for (ParameterElement parameter in parameters) { 3780 for (ParameterElement parameter in parameters) {
3758 (parameter as ParameterElementImpl).enclosingElement = this; 3781 (parameter as ParameterElementImpl).enclosingElement = this;
3759 } 3782 }
3760 } 3783 }
3761 this._parameters = parameters; 3784 this._parameters = parameters;
3762 } 3785 }
3763 3786
3764 @override 3787 @override
3788 DartType get returnType {
3789 if (_unlinkedTypedef != null && _returnType == null) {
3790 _returnType = enclosingUnit.resynthesizerContext
3791 .resolveTypeRef(_unlinkedTypedef.returnType, this);
3792 }
3793 return _returnType;
3794 }
3795
3796 void set returnType(DartType returnType) {
3797 assert(_unlinkedTypedef == null);
3798 _returnType = returnType;
3799 }
3800
3801 @override
3765 TypeParameterizedElementMixin get typeParameterContext => this; 3802 TypeParameterizedElementMixin get typeParameterContext => this;
3766 3803
3767 @override 3804 @override
3768 List<TypeParameterElement> get typeParameters { 3805 List<TypeParameterElement> get typeParameters {
3769 if (_unlinkedTypedef != null) { 3806 if (_unlinkedTypedef != null) {
3770 return super.typeParameters; 3807 return super.typeParameters;
3771 } 3808 }
3772 return _typeParameters; 3809 return _typeParameters;
3773 } 3810 }
3774 3811
(...skipping 3279 matching lines...) Expand 10 before | Expand all | Expand 10 after
7054 7091
7055 @override 7092 @override
7056 void visitElement(Element element) { 7093 void visitElement(Element element) {
7057 int offset = element.nameOffset; 7094 int offset = element.nameOffset;
7058 if (offset != -1) { 7095 if (offset != -1) {
7059 map[offset] = element; 7096 map[offset] = element;
7060 } 7097 }
7061 super.visitElement(element); 7098 super.visitElement(element);
7062 } 7099 }
7063 } 7100 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698