@@ -701,6 +701,10 @@ class ConstructorElementImpl extends ExecutableElementImpl
701701 @trackedIncludedInId
702702 bool get isConst => _firstFragment.isConst;
703703
704+ @override
705+ @trackedIncludedInId
706+ bool get isDeclaring => _firstFragment.isDeclaring;
707+
704708 @override
705709 @trackedIndirectly
706710 bool get isDefaultConstructor => _firstFragment.isDefaultConstructor;
@@ -713,6 +717,10 @@ class ConstructorElementImpl extends ExecutableElementImpl
713717 @trackedIndirectly
714718 bool get isGenerative => ! isFactory;
715719
720+ @override
721+ @trackedIncludedInId
722+ bool get isPrimary => _firstFragment.isPrimary;
723+
716724 @override
717725 @trackedIncludedInId
718726 ElementKind get kind => ElementKind .CONSTRUCTOR ;
@@ -2627,6 +2635,22 @@ class FieldElementImpl extends PropertyInducingElementImpl
26272635 @trackedIncludedInId
26282636 FieldElementImpl get baseElement => this ;
26292637
2638+ @override
2639+ @trackedIndirectly
2640+ FieldFormalParameterElementImpl ? get declaringFormalParameter {
2641+ if (enclosingElement case InterfaceElementImpl enclosingElement) {
2642+ var declaringConstructor = enclosingElement.constructors.firstWhereOrNull (
2643+ (constructor) => constructor.isDeclaring,
2644+ );
2645+ return declaringConstructor? .formalParameters
2646+ .whereType <FieldFormalParameterElementImpl >()
2647+ .firstWhereOrNull ((f) {
2648+ return f.isDeclaring && f.field == this ;
2649+ });
2650+ }
2651+ return null ;
2652+ }
2653+
26302654 @override
26312655 @trackedIncludedInId
26322656 InstanceElementImpl get enclosingElement {
@@ -2828,12 +2852,17 @@ class FieldFormalParameterElementImpl extends FormalParameterElementImpl
28282852 ];
28292853 }
28302854
2855+ @override
2856+ bool get isDeclaring => _firstFragment.isDeclaring;
2857+
28312858 @override
28322859 FieldFormalParameterFragmentImpl get _firstFragment =>
28332860 super ._firstFragment as FieldFormalParameterFragmentImpl ;
28342861}
28352862
2863+ @GenerateFragmentImpl (modifiers: _FieldFormalParameterFragmentModifiers .values)
28362864class FieldFormalParameterFragmentImpl extends FormalParameterFragmentImpl
2865+ with _FieldFormalParameterFragmentImplMixin
28372866 implements FieldFormalParameterFragment {
28382867 /// Initialize a newly created parameter element to have the given [name] and
28392868 /// [nameOffset] .
@@ -7754,7 +7783,12 @@ enum Modifier {
77547783 /// Indicates that the class is `Object` from `dart:core` .
77557784 DART_CORE_OBJECT ,
77567785
7757- /// Indicates that the import element represents a deferred library.
7786+ /// Indicates that the element is either:
7787+ /// 1. Declaring formal parameters.
7788+ /// 2. Declaring constructor.
7789+ DECLARING ,
7790+
7791+ /// Indicates that the element is a declaring formal parameter.
77587792 DEFERRED ,
77597793
77607794 /// Indicates that a class element was defined by an enum declaration.
@@ -7822,6 +7856,10 @@ enum Modifier {
78227856 /// enclosing element. This includes not only explicitly specified type
78237857 /// annotations, but also inferred types.
78247858 NO_ENCLOSING_TYPE_PARAMETER_REFERENCE ,
7859+
7860+ /// Whether the constructor is primary.
7861+ PRIMARY ,
7862+
78257863 PROMOTABLE ,
78267864
78277865 /// Indicates whether the type of a [PropertyInducingFragmentImpl] should be
@@ -10053,7 +10091,12 @@ enum _ClassFragmentImplModifiers {
1005310091 isSealed,
1005410092}
1005510093
10056- enum _ConstructorFragmentImplModifiers { isConst, isFactory }
10094+ enum _ConstructorFragmentImplModifiers {
10095+ isConst,
10096+ isDeclaring,
10097+ isFactory,
10098+ isPrimary,
10099+ }
1005710100
1005810101enum _ExecutableFragmentImplModifiers {
1005910102 hasImplicitReturnType,
@@ -10073,6 +10116,8 @@ enum _ExecutableFragmentImplModifiers {
1007310116 isStatic,
1007410117}
1007510118
10119+ enum _FieldFormalParameterFragmentModifiers { isDeclaring }
10120+
1007610121enum _FieldFragmentImplModifiers {
1007710122 /// Whether the field was explicitly marked as being covariant.
1007810123 isExplicitlyCovariant,
0 commit comments