Skip to content

Commit

Permalink
Tidy up Parameter.htmlId (#3723)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins committed Mar 18, 2024
1 parent d599364 commit 67f72d5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/src/model/parameter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,22 @@ class Parameter extends ModelElement with HasNoPage {
@override
String get htmlId {
final enclosingElement = element.enclosingElement;
if (enclosingElement != null) {
var enclosingName = enclosingElement.name;
if (enclosingElement is GenericFunctionTypeElement) {
// TODO(jcollins-g): Drop when GenericFunctionTypeElement populates
// name. Also, allowing null here is allowed as a workaround for
// dart-lang/sdk#32005.
for (Element e = enclosingElement;
e.enclosingElement != null;
e = e.enclosingElement!) {
enclosingName = e.name;
if (enclosingName != null && enclosingName.isNotEmpty) break;
}
}
return '$enclosingName-param-$name';
} else {
if (enclosingElement == null) {
return 'param-$name';
}
var enclosingName = enclosingElement.name;
if (enclosingElement is GenericFunctionTypeElement) {
// TODO(jcollins-g): Drop when GenericFunctionTypeElement populates
// name. Also, allowing null here is allowed as a workaround for
// dart-lang/sdk#32005.
for (Element e = enclosingElement;
e.enclosingElement != null;
e = e.enclosingElement!) {
enclosingName = e.name;
if (enclosingName != null && enclosingName.isNotEmpty) break;
}
}
return '$enclosingName-param-$name';
}

@override
Expand Down

0 comments on commit 67f72d5

Please sign in to comment.