Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ extension UnifiedSymbolGraph: Encodable {
case moduleData
case metadata
case symbols
case relationships
case relationshipsByLanguage
case orphanRelationships
}

private struct EncodableModuleData: Encodable {
Expand All @@ -29,6 +30,11 @@ extension UnifiedSymbolGraph: Encodable {
var metadata: SymbolGraph.Metadata
}

private struct EncodableRelationships: Encodable {
var selector: Selector
var relationships: [SymbolGraph.Relationship]
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)

Expand All @@ -41,6 +47,10 @@ extension UnifiedSymbolGraph: Encodable {
try container.encode(encodableMetadata, forKey: .metadata)

try container.encode(Array(symbols.values), forKey: .symbols)
try container.encode(relationships, forKey: .relationships)

let encodableRelationships = relationshipsByLanguage.map({ EncodableRelationships(selector: $0.key, relationships: $0.value) })
try container.encode(encodableRelationships, forKey: .relationshipsByLanguage)

try container.encode(orphanRelationships, forKey: .orphanRelationships)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UnifiedSymbolGraph {
public var symbols: [String: UnifiedSymbolGraph.Symbol]

/// The relationships between symbols.
@available(*, deprecated, message: "Use unifiedRelationships and orphanRelationships instead")
@available(*, deprecated, message: "Use relationshipsByLanguage and orphanRelationships instead")
public var relationships: [SymbolGraph.Relationship] {
var allRelations = mergeRelationships(Array(relationshipsByLanguage.values.joined()))
allRelations.append(contentsOf: self.orphanRelationships)
Expand Down