Skip to content

Commit 06207a7

Browse files
bwilkersonCommit Queue
authored andcommitted
Make ParameterMember implement FormalParameterElement
Change-Id: Ibaa74894099e0c8f9e71409f19b8372362c5d728 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393045 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent b675b9f commit 06207a7

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

pkg/analyzer/lib/src/dart/element/member.dart

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ class MethodMember extends ExecutableMember
10461046
/// type parameters are known.
10471047
class ParameterMember extends VariableMember
10481048
with ParameterElementMixin
1049-
implements ParameterElement {
1049+
implements ParameterElement, FormalParameterElement {
10501050
@override
10511051
final List<TypeParameterElement> typeParameters;
10521052

@@ -1076,9 +1076,16 @@ class ParameterMember extends VariableMember
10761076
this.typeParameters,
10771077
);
10781078

1079+
@override
1080+
FormalParameterElement get baseElement => _element2;
1081+
10791082
@override
10801083
List<Element> get children => parameters;
10811084

1085+
@override
1086+
List<Element2> get children2 =>
1087+
children.map((fragment) => fragment.asElement2).nonNulls.toList();
1088+
10821089
@override
10831090
ParameterElement get declaration => super.declaration as ParameterElement;
10841091

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

1099+
@override
1100+
Element2? get enclosingElement2 => _element2.enclosingElement2;
1101+
10921102
@override
10931103
Element? get enclosingElement3 => declaration.enclosingElement3;
10941104

1105+
@override
1106+
FormalParameterFragment get firstFragment => _element2.firstFragment;
1107+
1108+
@override
1109+
// TODO(brianwilkerson): This loses type information.
1110+
List<FormalParameterElement> get formalParameters =>
1111+
_element2.formalParameters;
1112+
10951113
@override
10961114
bool get hasDefaultValue => declaration.hasDefaultValue;
10971115

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

1125+
@override
1126+
LibraryElement2? get library2 => _element2.library2;
1127+
11071128
@override
11081129
String get name => declaration.name;
11091130

1131+
@override
1132+
String? get name3 => _element2.name3;
1133+
1134+
@override
1135+
Element2 get nonSynthetic2 => _element2;
1136+
11101137
@deprecated
11111138
@override
11121139
ParameterKind get parameterKind {
@@ -1125,15 +1152,57 @@ class ParameterMember extends VariableMember
11251152
@override
11261153
Source? get source => _declaration.source;
11271154

1155+
@override
1156+
List<TypeParameterElement2> get typeParameters2 => _element2.typeParameters2;
1157+
1158+
FormalParameterElement get _element2 =>
1159+
declaration.asElement2 as FormalParameterElement;
1160+
11281161
@override
11291162
T? accept<T>(ElementVisitor<T> visitor) =>
11301163
visitor.visitParameterElement(this);
11311164

1165+
@override
1166+
T? accept2<T>(ElementVisitor2<T> visitor) {
1167+
return visitor.visitFormalParameterElement(this);
1168+
}
1169+
11321170
@override
11331171
void appendTo(ElementDisplayStringBuilder builder) {
11341172
builder.writeFormalParameter(this);
11351173
}
11361174

1175+
@override
1176+
void appendToWithoutDelimiters2(StringBuffer buffer) {
1177+
_element2.appendToWithoutDelimiters2(buffer);
1178+
}
1179+
1180+
@override
1181+
String displayString2(
1182+
{bool multiline = false, bool preferTypeAlias = false}) {
1183+
return _element2.displayString2(
1184+
multiline: multiline, preferTypeAlias: preferTypeAlias);
1185+
}
1186+
1187+
@override
1188+
bool isAccessibleIn2(LibraryElement2 library) =>
1189+
_element2.isAccessibleIn2(library);
1190+
1191+
@override
1192+
Element2? thisOrAncestorMatching2(bool Function(Element2 p1) predicate) {
1193+
return _element2.thisOrAncestorMatching2(predicate);
1194+
}
1195+
1196+
@override
1197+
E? thisOrAncestorOfType2<E extends Element2>() {
1198+
return _element2.thisOrAncestorOfType2();
1199+
}
1200+
1201+
@override
1202+
void visitChildren2<T>(ElementVisitor2<T> visitor) {
1203+
_element2.visitChildren2(visitor);
1204+
}
1205+
11371206
static ParameterElement from(
11381207
ParameterElement element, MapSubstitution substitution) {
11391208
var combined = substitution;

0 commit comments

Comments
 (0)