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 3543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3554 */ | 3554 */ |
3555 final UnlinkedExecutable serializedExecutable; | 3555 final UnlinkedExecutable serializedExecutable; |
3556 | 3556 |
3557 /** | 3557 /** |
3558 * A list containing all of the functions defined within this executable | 3558 * A list containing all of the functions defined within this executable |
3559 * element. | 3559 * element. |
3560 */ | 3560 */ |
3561 List<FunctionElement> _functions; | 3561 List<FunctionElement> _functions; |
3562 | 3562 |
3563 /** | 3563 /** |
3564 * A list containing all of the labels defined within this executable element. | |
3565 */ | |
3566 List<LabelElement> _labels; | |
3567 | |
3568 /** | |
3569 * A list containing all of the parameters defined by this executable element. | 3564 * A list containing all of the parameters defined by this executable element. |
3570 */ | 3565 */ |
3571 List<ParameterElement> _parameters; | 3566 List<ParameterElement> _parameters; |
3572 | 3567 |
3573 /** | 3568 /** |
3574 * The declared return type of this executable element. | 3569 * The declared return type of this executable element. |
3575 */ | 3570 */ |
3576 DartType _declaredReturnType; | 3571 DartType _declaredReturnType; |
3577 | 3572 |
3578 /** | 3573 /** |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3738 return hasModifier(Modifier.GENERATOR); | 3733 return hasModifier(Modifier.GENERATOR); |
3739 } | 3734 } |
3740 | 3735 |
3741 @override | 3736 @override |
3742 bool get isOperator => false; | 3737 bool get isOperator => false; |
3743 | 3738 |
3744 @override | 3739 @override |
3745 bool get isSynchronous => !isAsynchronous; | 3740 bool get isSynchronous => !isAsynchronous; |
3746 | 3741 |
3747 @override | 3742 @override |
3748 List<LabelElement> get labels { | |
3749 if (serializedExecutable != null) { | |
3750 _labels ??= LabelElementImpl.resynthesizeList( | |
3751 this, serializedExecutable.localLabels); | |
3752 } | |
3753 return _labels ?? const <LabelElement>[]; | |
3754 } | |
3755 | |
3756 /** | |
3757 * Set the labels defined within this executable element to the given | |
3758 * [labels]. | |
3759 */ | |
3760 void set labels(List<LabelElement> labels) { | |
3761 _assertNotResynthesized(serializedExecutable); | |
3762 for (LabelElement label in labels) { | |
3763 (label as LabelElementImpl).enclosingElement = this; | |
3764 } | |
3765 this._labels = labels; | |
3766 } | |
3767 | |
3768 @override | |
3769 List<ElementAnnotation> get metadata { | 3743 List<ElementAnnotation> get metadata { |
3770 if (serializedExecutable != null) { | 3744 if (serializedExecutable != null) { |
3771 return _metadata ??= | 3745 return _metadata ??= |
3772 _buildAnnotations(enclosingUnit, serializedExecutable.annotations); | 3746 _buildAnnotations(enclosingUnit, serializedExecutable.annotations); |
3773 } | 3747 } |
3774 return super.metadata; | 3748 return super.metadata; |
3775 } | 3749 } |
3776 | 3750 |
3777 @override | 3751 @override |
3778 String get name { | 3752 String get name { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3917 } | 3891 } |
3918 | 3892 |
3919 @override | 3893 @override |
3920 ElementImpl getChild(String identifier) { | 3894 ElementImpl getChild(String identifier) { |
3921 for (FunctionElement function in _functions) { | 3895 for (FunctionElement function in _functions) { |
3922 FunctionElementImpl functionImpl = function; | 3896 FunctionElementImpl functionImpl = function; |
3923 if (functionImpl.identifier == identifier) { | 3897 if (functionImpl.identifier == identifier) { |
3924 return functionImpl; | 3898 return functionImpl; |
3925 } | 3899 } |
3926 } | 3900 } |
3927 for (LabelElement label in _labels) { | |
3928 LabelElementImpl labelImpl = label; | |
3929 if (labelImpl.identifier == identifier) { | |
3930 return labelImpl; | |
3931 } | |
3932 } | |
3933 for (ParameterElement parameter in parameters) { | 3901 for (ParameterElement parameter in parameters) { |
3934 ParameterElementImpl parameterImpl = parameter; | 3902 ParameterElementImpl parameterImpl = parameter; |
3935 if (parameterImpl.identifier == identifier) { | 3903 if (parameterImpl.identifier == identifier) { |
3936 return parameterImpl; | 3904 return parameterImpl; |
3937 } | 3905 } |
3938 } | 3906 } |
3939 return null; | 3907 return null; |
3940 } | 3908 } |
3941 | 3909 |
3942 @override | 3910 @override |
3943 void visitChildren(ElementVisitor visitor) { | 3911 void visitChildren(ElementVisitor visitor) { |
3944 super.visitChildren(visitor); | 3912 super.visitChildren(visitor); |
3945 _safelyVisitPossibleChild(returnType, visitor); | 3913 _safelyVisitPossibleChild(returnType, visitor); |
3946 safelyVisitChildren(typeParameters, visitor); | 3914 safelyVisitChildren(typeParameters, visitor); |
3947 safelyVisitChildren(parameters, visitor); | 3915 safelyVisitChildren(parameters, visitor); |
3948 safelyVisitChildren(functions, visitor); | 3916 safelyVisitChildren(functions, visitor); |
3949 safelyVisitChildren(labels, visitor); | |
3950 } | 3917 } |
3951 } | 3918 } |
3952 | 3919 |
3953 /** | 3920 /** |
3954 * A concrete implementation of an [ExportElement]. | 3921 * A concrete implementation of an [ExportElement]. |
3955 */ | 3922 */ |
3956 class ExportElementImpl extends UriReferencedElementImpl | 3923 class ExportElementImpl extends UriReferencedElementImpl |
3957 implements ExportElement { | 3924 implements ExportElement { |
3958 /** | 3925 /** |
3959 * The unlinked representation of the export in the summary. | 3926 * The unlinked representation of the export in the summary. |
(...skipping 5007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8967 | 8934 |
8968 @override | 8935 @override |
8969 DartObject computeConstantValue() => null; | 8936 DartObject computeConstantValue() => null; |
8970 | 8937 |
8971 @override | 8938 @override |
8972 void visitChildren(ElementVisitor visitor) { | 8939 void visitChildren(ElementVisitor visitor) { |
8973 super.visitChildren(visitor); | 8940 super.visitChildren(visitor); |
8974 _initializer?.accept(visitor); | 8941 _initializer?.accept(visitor); |
8975 } | 8942 } |
8976 } | 8943 } |
OLD | NEW |