Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit a43044f

Browse files
committed
Add declarations in public protocols as public declarations
1 parent 0abd89f commit a43044f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/swift-api-inventory/Inventory.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@ import SwiftSemantics
22
import SwiftDoc
33

44
func inventory(of module: Module) -> [String] {
5-
return module.symbols
5+
let publicSymbols = module.symbols
66
.filter { $0.declaration.isPublic }
7+
8+
let publicProtocolNames = Set(publicSymbols
9+
.filter { $0.declaration is Protocol }
10+
.map { $0.declaration.qualifiedName })
11+
12+
13+
let symbolsForPublicProtocols = module.symbols
14+
.filter { symbol -> Bool in
15+
guard let context = symbol.declaration.context else { return false }
16+
return publicProtocolNames.contains(context)
17+
}
18+
19+
let inventory = publicSymbols + symbolsForPublicProtocols
20+
21+
return inventory
722
.sorted { $0.declaration.qualifiedName < $1.declaration.qualifiedName }
823
.compactMap { representation(of: $0, in: module) }
924
}

0 commit comments

Comments
 (0)