From 74059becf8bc9fde4eb95f0bc6b2de89c06e5cb3 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Thu, 7 Nov 2024 10:03:31 -0800 Subject: [PATCH] removes logic duplicated in SymbolKit - prefer SymbolKit for this logic --- .../Symbol Graph/SymbolGraphLoader.swift | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift index a7a142e48..c44164a4a 100644 --- a/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift +++ b/Sources/SwiftDocC/Infrastructure/Symbol Graph/SymbolGraphLoader.swift @@ -78,7 +78,7 @@ struct SymbolGraphLoader { symbolGraphTransformer?(&symbolGraph) - let (moduleName, isMainSymbolGraph) = Self.moduleNameFor(symbolGraph, at: symbolGraphURL) + let (moduleName, isMainSymbolGraph) = GraphCollector.moduleNameFor(symbolGraph, at: symbolGraphURL) // If the bundle provides availability defaults add symbol availability data. self.addDefaultAvailability(to: &symbolGraph, moduleName: moduleName) @@ -191,7 +191,7 @@ struct SymbolGraphLoader { private func loadSymbolGraph(at url: URL) throws -> (SymbolGraph, isMainSymbolGraph: Bool) { // This is a private method, the `url` key is known to exist var symbolGraph = symbolGraphs[url]! - let (moduleName, isMainSymbolGraph) = Self.moduleNameFor(symbolGraph, at: url) + let (moduleName, isMainSymbolGraph) = GraphCollector.moduleNameFor(symbolGraph, at: url) if !isMainSymbolGraph && symbolGraph.module.bystanders == nil { // If this is an extending another module, change the module name to match the extended module. @@ -338,30 +338,6 @@ struct SymbolGraphLoader { return fileName.split(separator: "@", maxSplits: 1).last.map({ String($0) }) } - - /// Returns the module name of a symbol graph based on the JSON data and file name. - /// - /// Useful during decoding the symbol graphs to implement the correct name logic starting with the module name in the JSON. - private static func moduleNameFor(_ symbolGraph: SymbolGraph, at url: URL) -> (String, Bool) { - let isMainSymbolGraph = !url.lastPathComponent.contains("@") - - let moduleName: String - if isMainSymbolGraph || symbolGraph.module.bystanders != nil { - // For main symbol graphs, get the module name from the symbol graph's data - - // When bystander modules are present, the symbol graph is a cross-import overlay, and - // we need to preserve the original module name to properly render it. It is still - // kept with the extension symbols, due to the merging behavior of UnifiedSymbolGraph. - moduleName = symbolGraph.module.name - } else { - // For extension symbol graphs, derive the extended module's name from the file name. - // - // The per-symbol `extendedModule` value is the same as the main module for most symbols, so it's not a good way to find the name - // of the module that was extended (rdar://63200368). - moduleName = SymbolGraphLoader.moduleNameFor(url)! - } - return (moduleName, isMainSymbolGraph) - } } extension SymbolGraph.SemanticVersion {