Skip to content

Commit

Permalink
Make ParameterMember implement FormalParameterElement
Browse files Browse the repository at this point in the history
Change-Id: Ibaa74894099e0c8f9e71409f19b8372362c5d728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393045
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
bwilkerson authored and Commit Queue committed Nov 1, 2024
1 parent b675b9f commit 06207a7
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion pkg/analyzer/lib/src/dart/element/member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ class MethodMember extends ExecutableMember
/// type parameters are known.
class ParameterMember extends VariableMember
with ParameterElementMixin
implements ParameterElement {
implements ParameterElement, FormalParameterElement {
@override
final List<TypeParameterElement> typeParameters;

Expand Down Expand Up @@ -1076,9 +1076,16 @@ class ParameterMember extends VariableMember
this.typeParameters,
);

@override
FormalParameterElement get baseElement => _element2;

@override
List<Element> get children => parameters;

@override
List<Element2> get children2 =>
children.map((fragment) => fragment.asElement2).nonNulls.toList();

@override
ParameterElement get declaration => super.declaration as ParameterElement;

Expand All @@ -1089,9 +1096,20 @@ class ParameterMember extends VariableMember
// TODO(scheglov): we lose types
FormalParameterElement get element => declaration.element;

@override
Element2? get enclosingElement2 => _element2.enclosingElement2;

@override
Element? get enclosingElement3 => declaration.enclosingElement3;

@override
FormalParameterFragment get firstFragment => _element2.firstFragment;

@override
// TODO(brianwilkerson): This loses type information.
List<FormalParameterElement> get formalParameters =>
_element2.formalParameters;

@override
bool get hasDefaultValue => declaration.hasDefaultValue;

Expand All @@ -1104,9 +1122,18 @@ class ParameterMember extends VariableMember
@override
bool get isSuperFormal => declaration.isSuperFormal;

@override
LibraryElement2? get library2 => _element2.library2;

@override
String get name => declaration.name;

@override
String? get name3 => _element2.name3;

@override
Element2 get nonSynthetic2 => _element2;

@deprecated
@override
ParameterKind get parameterKind {
Expand All @@ -1125,15 +1152,57 @@ class ParameterMember extends VariableMember
@override
Source? get source => _declaration.source;

@override
List<TypeParameterElement2> get typeParameters2 => _element2.typeParameters2;

FormalParameterElement get _element2 =>
declaration.asElement2 as FormalParameterElement;

@override
T? accept<T>(ElementVisitor<T> visitor) =>
visitor.visitParameterElement(this);

@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitFormalParameterElement(this);
}

@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeFormalParameter(this);
}

@override
void appendToWithoutDelimiters2(StringBuffer buffer) {
_element2.appendToWithoutDelimiters2(buffer);
}

@override
String displayString2(
{bool multiline = false, bool preferTypeAlias = false}) {
return _element2.displayString2(
multiline: multiline, preferTypeAlias: preferTypeAlias);
}

@override
bool isAccessibleIn2(LibraryElement2 library) =>
_element2.isAccessibleIn2(library);

@override
Element2? thisOrAncestorMatching2(bool Function(Element2 p1) predicate) {
return _element2.thisOrAncestorMatching2(predicate);
}

@override
E? thisOrAncestorOfType2<E extends Element2>() {
return _element2.thisOrAncestorOfType2();
}

@override
void visitChildren2<T>(ElementVisitor2<T> visitor) {
_element2.visitChildren2(visitor);
}

static ParameterElement from(
ParameterElement element, MapSubstitution substitution) {
var combined = substitution;
Expand Down

0 comments on commit 06207a7

Please sign in to comment.