Skip to content

Commit 2f05f9d

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Support type aliases in API file
Change-Id: I37114d18fb5e4cb9d6706dc1a0ee4aaf761409cb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423424 Reviewed-by: Paul Berry <[email protected]> Auto-Submit: Samuel Rawlins <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent b29e23e commit 2f05f9d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/analyzer/tool/api/generate.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ class ApiDescription {
249249
}
250250
var parentheticals = <List<Object?>>[];
251251
switch (element) {
252+
case TypeAliasElement2(:var aliasedType, :var typeParameters2):
253+
List<Object?> description = ['type alias'];
254+
if (typeParameters2.isNotEmpty) {
255+
description.addAll(typeParameters2
256+
.map(_describeTypeParameter)
257+
.separate(prefix: '<', suffix: '>'));
258+
}
259+
description.addAll([' for ', ..._describeType(aliasedType)]);
260+
parentheticals.add(description);
252261
case InstanceElement2():
253262
switch (element) {
254263
case InterfaceElement2(
@@ -464,7 +473,8 @@ enum MemberCategory {
464473
propertyAccessor,
465474
topLevelFunctionOrMethod,
466475
interface,
467-
extension
476+
extension,
477+
typeAlias
468478
}
469479

470480
/// Sort key used to sort elements in the output.
@@ -498,6 +508,7 @@ class MemberSortKey implements Comparable<MemberSortKey> {
498508
MethodElement2() => MemberCategory.topLevelFunctionOrMethod,
499509
InterfaceElement2() => MemberCategory.interface,
500510
ExtensionElement2() => MemberCategory.extension,
511+
TypeAliasElement2() => MemberCategory.typeAlias,
501512
dynamic(:var runtimeType) =>
502513
throw UnimplementedError('Unexpected element: $runtimeType')
503514
};

0 commit comments

Comments
 (0)