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

Commit a256d94

Browse files
committed
Add declarations in public protocols as public declarations
1 parent 97b2347 commit a256d94

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Sources/swift-api-inventory/Inventory.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,24 @@ 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.isPublic }
7-
.sorted()
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
22+
.sorted
823
.compactMap { representation(of: $0, in: module) }
924
}
1025

0 commit comments

Comments
 (0)