@@ -29,7 +29,6 @@ import 'package:analyzer/src/dart/constant/value.dart';
2929import 'package:analyzer/src/dart/element/display_string_builder.dart' ;
3030import 'package:analyzer/src/dart/element/field_name_non_promotability_info.dart' ;
3131import 'package:analyzer/src/dart/element/inheritance_manager3.dart' ;
32- import 'package:analyzer/src/dart/element/member.dart' ;
3332import 'package:analyzer/src/dart/element/name_union.dart' ;
3433import 'package:analyzer/src/dart/element/scope.dart' ;
3534import 'package:analyzer/src/dart/element/since_sdk_version.dart' ;
@@ -1084,7 +1083,7 @@ class ConstructorFragmentImpl extends ExecutableFragmentImpl
10841083 }
10851084
10861085 @override
1087- int get offset => isSynthetic ? enclosingElement3.offset : _nameOffset ;
1086+ int get offset => isSynthetic ? enclosingElement3.offset : nameOffset ;
10881087
10891088 @override
10901089 InterfaceTypeImpl get returnType {
@@ -2305,7 +2304,7 @@ abstract class ExecutableFragmentImpl extends _ExistingFragmentImpl
23052304 }
23062305
23072306 @override
2308- int get offset => _nameOffset ;
2307+ int get offset => nameOffset ;
23092308
23102309 /// The formal parameters defined by this executable fragment.
23112310 List <FormalParameterFragmentImpl > get parameters {
@@ -2940,7 +2939,7 @@ class FieldFragmentImpl extends PropertyInducingFragmentImpl
29402939 super .nextFragment as FieldFragmentImpl ? ;
29412940
29422941 @override
2943- int get offset => isSynthetic ? enclosingFragment.offset : _nameOffset ;
2942+ int get offset => isSynthetic ? enclosingFragment.offset : nameOffset ;
29442943
29452944 @override
29462945 FieldFragmentImpl ? get previousFragment =>
@@ -3580,10 +3579,10 @@ mixin FragmentedTypeParameterizedElementMixin<
35803579 }
35813580}
35823581
3583- abstract class FragmentImpl implements FragmentOrMember {
3582+ abstract class FragmentImpl implements Fragment {
35843583 static int _NEXT_ID = 0 ;
35853584
3586- @override
3585+ /// The unique integer identifier of this fragment.
35873586 final int id = _NEXT_ID ++ ;
35883587
35893588 /// The element that either physically or logically encloses this element.
@@ -3597,14 +3596,16 @@ abstract class FragmentImpl implements FragmentOrMember {
35973596 FragmentImpl ? enclosingElement3;
35983597
35993598 /// The offset of the name of this element in the file that contains the
3600- /// declaration of this element.
3601- int _nameOffset = 0 ;
3599+ /// declaration of this element, or `-1` if this element is synthetic, does
3600+ /// not have a name, or otherwise does not have an offset.
3601+ int nameOffset = 0 ;
36023602
36033603 /// The modifiers associated with this element.
36043604 EnumSet <Modifier > _modifiers = EnumSet .empty ();
36053605
3606- /// The documentation comment for this element.
3607- String ? _docComment;
3606+ /// The content of the documentation comment (including delimiters) for this
3607+ /// element, or `null` if this element does not or cannot have documentation.
3608+ String ? documentationComment;
36083609
36093610 /// The offset of the beginning of the element's code in the file that
36103611 /// contains the element, or `null` if the element is synthetic.
@@ -3615,7 +3616,7 @@ abstract class FragmentImpl implements FragmentOrMember {
36153616
36163617 /// Initialize a newly created element to have the given [name] at the given
36173618 /// [_nameOffset] .
3618- FragmentImpl ({required int nameOffset}) : _nameOffset = nameOffset ;
3619+ FragmentImpl ({required this . nameOffset});
36193620
36203621 /// The length of the element's code, or `null` if the element is synthetic.
36213622 int ? get codeLength => _codeLength;
@@ -3624,25 +3625,28 @@ abstract class FragmentImpl implements FragmentOrMember {
36243625 /// contains the element, or `null` if the element is synthetic.
36253626 int ? get codeOffset => _codeOffset;
36263627
3627- @override
3628+ /// The analysis context in which this element is defined.
36283629 AnalysisContext get context {
36293630 return library! .context;
36303631 }
36313632
3632- @override
3633+ /// The declaration of this element.
3634+ ///
3635+ /// If the element is a view on an element, e.g. a method from an interface
3636+ /// type, with substituted type parameters, return the corresponding element
3637+ /// from the class, without any substitutions. If this element is already a
3638+ /// declaration (or a synthetic element, e.g. a synthetic property accessor),
3639+ /// return itself.
36333640 FragmentImpl get declaration => this ;
36343641
3635- @override
3642+ /// The display name of this element, possibly the empty string if the
3643+ /// element does not have a name.
3644+ ///
3645+ /// In most cases the name and the display name are the same. Differences
3646+ /// though are cases such as setters where the name of some setter `set f(x)`
3647+ /// is `f=` , instead of `f` .
36363648 String get displayName => name2 ?? '' ;
36373649
3638- @override
3639- String ? get documentationComment => _docComment;
3640-
3641- /// The documentation comment source for this element.
3642- set documentationComment (String ? doc) {
3643- _docComment = doc;
3644- }
3645-
36463650 /// Return the enclosing unit element (which might be the same as `this` ), or
36473651 /// `null` if this element is not contained in any compilation unit.
36483652 LibraryFragmentImpl get enclosingUnit {
@@ -3653,7 +3657,10 @@ abstract class FragmentImpl implements FragmentOrMember {
36533657 return library! .featureSet.isEnabled (Feature .nonfunction_type_aliases);
36543658 }
36553659
3656- @override
3660+ /// Whether the element is private.
3661+ ///
3662+ /// Private elements are visible only within the library in which they are
3663+ /// declared.
36573664 bool get isPrivate {
36583665 var name = name2;
36593666 if (name == null ) {
@@ -3662,10 +3669,17 @@ abstract class FragmentImpl implements FragmentOrMember {
36623669 return Identifier .isPrivateName (name);
36633670 }
36643671
3665- @override
3672+ /// Whether the element is public.
3673+ ///
3674+ /// Public elements are visible within any library that imports the library
3675+ /// in which they are declared.
36663676 bool get isPublic => ! isPrivate;
36673677
3668- @override
3678+ /// Whether the element is synthetic.
3679+ ///
3680+ /// A synthetic element is an element that is not represented in the source
3681+ /// code explicitly, but is implied by the source code, such as the default
3682+ /// constructor for a class that does not explicitly define any constructors.
36693683 bool get isSynthetic {
36703684 return hasModifier (Modifier .SYNTHETIC );
36713685 }
@@ -3675,38 +3689,50 @@ abstract class FragmentImpl implements FragmentOrMember {
36753689 setModifier (Modifier .SYNTHETIC , isSynthetic);
36763690 }
36773691
3692+ /// The kind of element that this is.
3693+ // TODO(scheglov): remove it
3694+ ElementKind get kind;
3695+
36783696 LibraryElementImpl ? get library;
36793697
3680- @override
3698+ /// If this target is associated with a library, return the source of the
3699+ /// library's defining compilation unit; otherwise return `null` .
36813700 Source ? get librarySource => library? .source;
36823701
36833702 String ? get lookupName {
36843703 return name2;
36853704 }
36863705
3687- @override
3706+ /// The length of the name of this element in the file that contains the
3707+ /// declaration of this element, or `0` if this element does not have a name.
36883708 int get nameLength => displayName.length;
36893709
3690- @override
3691- int get nameOffset => _nameOffset;
3692-
3693- /// Sets the offset of the name of this element in the file that contains the
3694- /// declaration of this element.
3695- set nameOffset (int offset) {
3696- _nameOffset = offset;
3697- }
3698-
3699- @override
3710+ /// The analysis session in which this element is defined.
37003711 AnalysisSession ? get session {
37013712 return enclosingElement3? .session;
37023713 }
37033714
3704- @override
3715+ /// The version where this SDK API was added.
3716+ ///
3717+ /// A `@Since()` annotation can be applied to a library declaration,
3718+ /// any public declaration in a library, or in a class, or to an optional
3719+ /// parameter, etc.
3720+ ///
3721+ /// The returned version is "effective", so that if a library is annotated
3722+ /// then all elements of the library inherit it; or if a class is annotated
3723+ /// then all members and constructors of the class inherit it.
3724+ ///
3725+ /// If multiple `@Since()` annotations apply to the same element, the latest
3726+ /// version takes precedence.
3727+ ///
3728+ /// Returns `null` if the element is not declared in SDK, or does not have
3729+ /// a `@Since()` annotation applicable to it.
37053730 Version ? get sinceSdkVersion {
37063731 return asElement2.ifTypeOrNull <HasSinceSdkVersion >()? .sinceSdkVersion;
37073732 }
37083733
3709- @override
3734+ /// Return the source associated with this target, or `null` if this target is
3735+ /// not associated with a source.
37103736 Source ? get source {
37113737 return enclosingElement3? .source;
37123738 }
@@ -3739,7 +3765,22 @@ abstract class FragmentImpl implements FragmentOrMember {
37393765 }
37403766 }
37413767
3742- @override
3768+ /// Returns the presentation of this element as it should appear when
3769+ /// presented to users.
3770+ ///
3771+ /// If [withNullability] is `true` , then [NullabilitySuffix.question] and
3772+ /// [NullabilitySuffix.star] in types will be represented as `?` and `*` .
3773+ /// [NullabilitySuffix.none] does not have any explicit presentation.
3774+ ///
3775+ /// If [withNullability] is `false` , nullability suffixes will not be
3776+ /// included into the presentation.
3777+ ///
3778+ /// If [multiline] is `true` , the string may be wrapped over multiple lines
3779+ /// with newlines to improve formatting. For example function signatures may
3780+ /// be formatted as if they had trailing commas.
3781+ ///
3782+ /// Clients should not depend on the content of the returned value as it will
3783+ /// be changed if doing so would improve the UX.
37433784 String getDisplayString ({
37443785 @Deprecated ('Only non-nullable by default mode is supported' )
37453786 bool withNullability = true ,
@@ -3783,118 +3824,6 @@ abstract class FragmentImpl implements FragmentOrMember {
37833824 }
37843825}
37853826
3786- /// A shared internal interface of `Element` and [Member] .
3787- /// Used during migration to avoid referencing `Element` .
3788- abstract class FragmentOrMember implements Fragment {
3789- /// The analysis context in which this element is defined.
3790- AnalysisContext get context;
3791-
3792- /// The declaration of this element.
3793- ///
3794- /// If the element is a view on an element, e.g. a method from an interface
3795- /// type, with substituted type parameters, return the corresponding element
3796- /// from the class, without any substitutions. If this element is already a
3797- /// declaration (or a synthetic element, e.g. a synthetic property accessor),
3798- /// return itself.
3799- FragmentOrMember ? get declaration;
3800-
3801- /// The display name of this element, possibly the empty string if the
3802- /// element does not have a name.
3803- ///
3804- /// In most cases the name and the display name are the same. Differences
3805- /// though are cases such as setters where the name of some setter `set f(x)`
3806- /// is `f=` , instead of `f` .
3807- String get displayName;
3808-
3809- /// The content of the documentation comment (including delimiters) for this
3810- /// element, or `null` if this element does not or cannot have documentation.
3811- String ? get documentationComment;
3812-
3813- /// The unique integer identifier of this element.
3814- int get id;
3815-
3816- /// Whether the element is private.
3817- ///
3818- /// Private elements are visible only within the library in which they are
3819- /// declared.
3820- bool get isPrivate;
3821-
3822- /// Whether the element is public.
3823- ///
3824- /// Public elements are visible within any library that imports the library
3825- /// in which they are declared.
3826- bool get isPublic;
3827-
3828- /// Whether the element is synthetic.
3829- ///
3830- /// A synthetic element is an element that is not represented in the source
3831- /// code explicitly, but is implied by the source code, such as the default
3832- /// constructor for a class that does not explicitly define any constructors.
3833- bool get isSynthetic;
3834-
3835- /// The kind of element that this is.
3836- ElementKind get kind;
3837-
3838- /// If this target is associated with a library, return the source of the
3839- /// library's defining compilation unit; otherwise return `null` .
3840- Source ? get librarySource;
3841-
3842- /// The length of the name of this element in the file that contains the
3843- /// declaration of this element, or `0` if this element does not have a name.
3844- int get nameLength;
3845-
3846- /// The offset of the name of this element in the file that contains the
3847- /// declaration of this element, or `-1` if this element is synthetic, does
3848- /// not have a name, or otherwise does not have an offset.
3849- int get nameOffset;
3850-
3851- /// The analysis session in which this element is defined.
3852- AnalysisSession ? get session;
3853-
3854- /// The version where this SDK API was added.
3855- ///
3856- /// A `@Since()` annotation can be applied to a library declaration,
3857- /// any public declaration in a library, or in a class, or to an optional
3858- /// parameter, etc.
3859- ///
3860- /// The returned version is "effective", so that if a library is annotated
3861- /// then all elements of the library inherit it; or if a class is annotated
3862- /// then all members and constructors of the class inherit it.
3863- ///
3864- /// If multiple `@Since()` annotations apply to the same element, the latest
3865- /// version takes precedence.
3866- ///
3867- /// Returns `null` if the element is not declared in SDK, or does not have
3868- /// a `@Since()` annotation applicable to it.
3869- Version ? get sinceSdkVersion;
3870-
3871- /// Return the source associated with this target, or `null` if this target is
3872- /// not associated with a source.
3873- Source ? get source;
3874-
3875- /// Returns the presentation of this element as it should appear when
3876- /// presented to users.
3877- ///
3878- /// If [withNullability] is `true` , then [NullabilitySuffix.question] and
3879- /// [NullabilitySuffix.star] in types will be represented as `?` and `*` .
3880- /// [NullabilitySuffix.none] does not have any explicit presentation.
3881- ///
3882- /// If [withNullability] is `false` , nullability suffixes will not be
3883- /// included into the presentation.
3884- ///
3885- /// If [multiline] is `true` , the string may be wrapped over multiple lines
3886- /// with newlines to improve formatting. For example function signatures may
3887- /// be formatted as if they had trailing commas.
3888- ///
3889- /// Clients should not depend on the content of the returned value as it will
3890- /// be changed if doing so would improve the UX.
3891- String getDisplayString ({
3892- @Deprecated ('Only non-nullable by default mode is supported' )
3893- bool withNullability = true ,
3894- bool multiline = false ,
3895- });
3896- }
3897-
38983827sealed class FunctionFragmentImpl extends ExecutableFragmentImpl
38993828 implements FunctionTypedFragmentImpl {
39003829 @override
@@ -4109,7 +4038,7 @@ class GenericFunctionTypeFragmentImpl extends _ExistingFragmentImpl
41094038 GenericFunctionTypeFragmentImpl ? get nextFragment => null ;
41104039
41114040 @override
4112- int get offset => _nameOffset ;
4041+ int get offset => nameOffset ;
41134042
41144043 @override
41154044 List <FormalParameterFragmentImpl > get parameters {
@@ -4855,7 +4784,7 @@ abstract class InstanceFragmentImpl extends _ExistingFragmentImpl
48554784 List <MethodFragment > get methods2 => methods.cast <MethodFragment >();
48564785
48574786 @override
4858- int get offset => _nameOffset ;
4787+ int get offset => nameOffset ;
48594788
48604789 @override
48614790 List <SetterFragmentImpl > get setters {
@@ -5633,7 +5562,7 @@ class LabelFragmentImpl extends FragmentImpl implements LabelFragment {
56335562 LabelFragmentImpl ? get nextFragment => null ;
56345563
56355564 @override
5636- int get offset => _nameOffset ;
5565+ int get offset => nameOffset ;
56375566
56385567 @override
56395568 LabelFragmentImpl ? get previousFragment => null ;
@@ -8582,7 +8511,7 @@ sealed class PropertyAccessorFragmentImpl extends ExecutableFragmentImpl
85828511 }
85838512 return variable.firstFragment.offset;
85848513 }
8585- return _nameOffset ;
8514+ return nameOffset ;
85868515 }
85878516}
85888517
0 commit comments