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

swift-api-declarations: Add declarations in public protocols as public declarations #12

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Sources/swift-api-inventory/Inventory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ import SwiftSemantics
import SwiftDoc

func inventory(of module: Module) -> [String] {
return module.symbols
let publicSymbols = module.symbols
.filter { $0.isPublic }
.sorted()

let publicProtocolNames = Set(publicSymbols
.filter { $0.declaration is Protocol }
.map { $0.declaration.qualifiedName })


let symbolsForPublicProtocols = module.symbols
.filter { symbol -> Bool in
guard let context = symbol.declaration.context else { return false }
return publicProtocolNames.contains(context)
}

let inventory = publicSymbols + symbolsForPublicProtocols

return inventory
.sorted
.compactMap { representation(of: $0, in: module) }
}

Expand Down