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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 /** | 90 /** |
91 * A list containing all of the fields contained in this class. | 91 * A list containing all of the fields contained in this class. |
92 */ | 92 */ |
93 List<FieldElement> _fields = FieldElement.EMPTY_LIST; | 93 List<FieldElement> _fields = FieldElement.EMPTY_LIST; |
94 | 94 |
95 /** | 95 /** |
96 * A list containing all of the mixins that are applied to the class being | 96 * A list containing all of the mixins that are applied to the class being |
97 * extended in order to derive the superclass of this class. | 97 * extended in order to derive the superclass of this class. |
98 */ | 98 */ |
99 @override | 99 List<InterfaceType> _mixins; |
100 List<InterfaceType> mixins = InterfaceType.EMPTY_LIST; | |
101 | 100 |
102 /** | 101 /** |
103 * A list containing all of the interfaces that are implemented by this class. | 102 * A list containing all of the interfaces that are implemented by this class. |
104 */ | 103 */ |
105 @override | 104 List<InterfaceType> _interfaces; |
106 List<InterfaceType> interfaces = InterfaceType.EMPTY_LIST; | |
107 | 105 |
108 /** | 106 /** |
109 * A list containing all of the methods contained in this class. | 107 * A list containing all of the methods contained in this class. |
110 */ | 108 */ |
111 List<MethodElement> _methods = MethodElement.EMPTY_LIST; | 109 List<MethodElement> _methods = MethodElement.EMPTY_LIST; |
112 | 110 |
113 /** | 111 /** |
114 * The superclass of the class, or `null` if the class does not have an | 112 * The superclass of the class, or `null` if the class does not have an |
115 * explicit superclass. | 113 * explicit superclass. |
116 */ | 114 */ |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 365 } |
368 for (PropertyAccessorElement accessor in _accessors) { | 366 for (PropertyAccessorElement accessor in _accessors) { |
369 if (accessor.isStatic) { | 367 if (accessor.isStatic) { |
370 return true; | 368 return true; |
371 } | 369 } |
372 } | 370 } |
373 return false; | 371 return false; |
374 } | 372 } |
375 | 373 |
376 @override | 374 @override |
| 375 List<InterfaceType> get interfaces { |
| 376 if (_unlinkedClass != null && _interfaces == null) { |
| 377 ResynthesizerContext context = enclosingUnit.resynthesizerContext; |
| 378 _interfaces = _unlinkedClass.interfaces |
| 379 .map((EntityRef t) => context.resolveTypeRef(t, this)) |
| 380 .toList(); |
| 381 } |
| 382 return _interfaces ?? const <InterfaceType>[]; |
| 383 } |
| 384 |
| 385 void set interfaces(List<InterfaceType> interfaces) { |
| 386 assert(_unlinkedClass == null); |
| 387 _interfaces = interfaces; |
| 388 } |
| 389 |
| 390 @override |
377 bool get isAbstract { | 391 bool get isAbstract { |
378 if (_unlinkedClass != null) { | 392 if (_unlinkedClass != null) { |
379 return _unlinkedClass.isAbstract; | 393 return _unlinkedClass.isAbstract; |
380 } | 394 } |
381 return hasModifier(Modifier.ABSTRACT); | 395 return hasModifier(Modifier.ABSTRACT); |
382 } | 396 } |
383 | 397 |
384 @override | 398 @override |
385 bool get isEnum => hasModifier(Modifier.ENUM); | 399 bool get isEnum => hasModifier(Modifier.ENUM); |
386 | 400 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 465 |
452 /** | 466 /** |
453 * Set whether this class is a mixin application. | 467 * Set whether this class is a mixin application. |
454 */ | 468 */ |
455 void set mixinApplication(bool isMixinApplication) { | 469 void set mixinApplication(bool isMixinApplication) { |
456 assert(_unlinkedClass == null); | 470 assert(_unlinkedClass == null); |
457 setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication); | 471 setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication); |
458 } | 472 } |
459 | 473 |
460 @override | 474 @override |
| 475 List<InterfaceType> get mixins { |
| 476 if (_unlinkedClass != null && _mixins == null) { |
| 477 ResynthesizerContext context = enclosingUnit.resynthesizerContext; |
| 478 _mixins = _unlinkedClass.mixins |
| 479 .map((EntityRef t) => context.resolveTypeRef(t, this)) |
| 480 .toList(); |
| 481 } |
| 482 return _mixins ?? const <InterfaceType>[]; |
| 483 } |
| 484 |
| 485 void set mixins(List<InterfaceType> mixins) { |
| 486 assert(_unlinkedClass == null); |
| 487 _mixins = mixins; |
| 488 } |
| 489 |
| 490 @override |
461 String get name { | 491 String get name { |
462 if (_unlinkedClass != null) { | 492 if (_unlinkedClass != null) { |
463 return _unlinkedClass.name; | 493 return _unlinkedClass.name; |
464 } | 494 } |
465 return super.name; | 495 return super.name; |
466 } | 496 } |
467 | 497 |
468 @override | 498 @override |
469 int get nameOffset { | 499 int get nameOffset { |
470 if (_unlinkedClass != null) { | 500 if (_unlinkedClass != null) { |
(...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3652 List<ParameterElement> _parameters = ParameterElement.EMPTY_LIST; | 3682 List<ParameterElement> _parameters = ParameterElement.EMPTY_LIST; |
3653 | 3683 |
3654 /** | 3684 /** |
3655 * The return type defined by this type alias. | 3685 * The return type defined by this type alias. |
3656 */ | 3686 */ |
3657 DartType _returnType; | 3687 DartType _returnType; |
3658 | 3688 |
3659 /** | 3689 /** |
3660 * The type of function defined by this type alias. | 3690 * The type of function defined by this type alias. |
3661 */ | 3691 */ |
3662 FunctionType type; | 3692 FunctionType _type; |
3663 | 3693 |
3664 /** | 3694 /** |
3665 * A list containing all of the type parameters defined for this type. | 3695 * A list containing all of the type parameters defined for this type. |
3666 */ | 3696 */ |
3667 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; | 3697 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; |
3668 | 3698 |
3669 /** | 3699 /** |
3670 * Initialize a newly created type alias element to have the given name. | 3700 * Initialize a newly created type alias element to have the given name. |
3671 * | 3701 * |
3672 * [name] the name of this element | 3702 * [name] the name of this element |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3792 } | 3822 } |
3793 return _returnType; | 3823 return _returnType; |
3794 } | 3824 } |
3795 | 3825 |
3796 void set returnType(DartType returnType) { | 3826 void set returnType(DartType returnType) { |
3797 assert(_unlinkedTypedef == null); | 3827 assert(_unlinkedTypedef == null); |
3798 _returnType = returnType; | 3828 _returnType = returnType; |
3799 } | 3829 } |
3800 | 3830 |
3801 @override | 3831 @override |
| 3832 FunctionType get type { |
| 3833 if (_unlinkedTypedef != null && _type == null) { |
| 3834 _type = new FunctionTypeImpl.forTypedef(this); |
| 3835 } |
| 3836 return _type; |
| 3837 } |
| 3838 |
| 3839 void set type(FunctionType type) { |
| 3840 assert(_unlinkedTypedef == null); |
| 3841 _type = type; |
| 3842 } |
| 3843 |
| 3844 @override |
3802 TypeParameterizedElementMixin get typeParameterContext => this; | 3845 TypeParameterizedElementMixin get typeParameterContext => this; |
3803 | 3846 |
3804 @override | 3847 @override |
3805 List<TypeParameterElement> get typeParameters { | 3848 List<TypeParameterElement> get typeParameters { |
3806 if (_unlinkedTypedef != null) { | 3849 if (_unlinkedTypedef != null) { |
3807 return super.typeParameters; | 3850 return super.typeParameters; |
3808 } | 3851 } |
3809 return _typeParameters; | 3852 return _typeParameters; |
3810 } | 3853 } |
3811 | 3854 |
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5778 return super.name; | 5821 return super.name; |
5779 } | 5822 } |
5780 | 5823 |
5781 @override | 5824 @override |
5782 int get nameOffset { | 5825 int get nameOffset { |
5783 if (_unlinkedVariable != null) { | 5826 if (_unlinkedVariable != null) { |
5784 return _unlinkedVariable.nameOffset; | 5827 return _unlinkedVariable.nameOffset; |
5785 } | 5828 } |
5786 return super.nameOffset; | 5829 return super.nameOffset; |
5787 } | 5830 } |
| 5831 |
| 5832 @override |
| 5833 DartType get type { |
| 5834 if (_unlinkedVariable != null && _type == null) { |
| 5835 _type = enclosingUnit.resynthesizerContext.resolveLinkedType( |
| 5836 _unlinkedVariable.inferredTypeSlot, typeParameterContext) ?? |
| 5837 enclosingUnit.resynthesizerContext |
| 5838 .resolveTypeRef(_unlinkedVariable.type, typeParameterContext); |
| 5839 } |
| 5840 return super.type; |
| 5841 } |
| 5842 |
| 5843 void set type(DartType type) { |
| 5844 assert(_unlinkedVariable == null); |
| 5845 _type = type; |
| 5846 } |
5788 } | 5847 } |
5789 | 5848 |
5790 /** | 5849 /** |
5791 * A concrete implementation of a [ParameterElement]. | 5850 * A concrete implementation of a [ParameterElement]. |
5792 */ | 5851 */ |
5793 class ParameterElementImpl extends VariableElementImpl | 5852 class ParameterElementImpl extends VariableElementImpl |
5794 with ParameterElementMixin | 5853 with ParameterElementMixin |
5795 implements ParameterElement { | 5854 implements ParameterElement { |
5796 /** | 5855 /** |
5797 * The unlinked representation of the parameter in the summary. | 5856 * The unlinked representation of the parameter in the summary. |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7114 | 7173 |
7115 @override | 7174 @override |
7116 void visitElement(Element element) { | 7175 void visitElement(Element element) { |
7117 int offset = element.nameOffset; | 7176 int offset = element.nameOffset; |
7118 if (offset != -1) { | 7177 if (offset != -1) { |
7119 map[offset] = element; | 7178 map[offset] = element; |
7120 } | 7179 } |
7121 super.visitElement(element); | 7180 super.visitElement(element); |
7122 } | 7181 } |
7123 } | 7182 } |
OLD | NEW |