Skip to content

Commit d68bede

Browse files
committed
Reorganize declarations of Manifest APIs
1 parent 0d3004c commit d68bede

File tree

1 file changed

+39
-37
lines changed

1 file changed

+39
-37
lines changed

Sources/PackageModel/Manifest.swift

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,6 @@ public final class Manifest: ObjectIdentifierProtocol, CustomStringConvertible,
129129
self._requiredDependencies = [:]
130130
}
131131

132-
public var description: String {
133-
return "<Manifest: \(name)>"
134-
}
135-
136-
/// Coding user info key for dump-package command.
137-
///
138-
/// Presence of this key will hide some keys when encoding the Manifest object.
139-
public static let dumpPackageKey: CodingUserInfoKey = CodingUserInfoKey(rawValue: "dumpPackage")!
140-
}
141-
142-
extension Manifest {
143132
/// Returns the targets required for a particular product filter.
144133
public func targetsRequired(for productFilter: ProductFilter) -> [TargetDescription] {
145134
// If we have already calcualted it, returned the cached value.
@@ -173,32 +162,6 @@ extension Manifest {
173162
}
174163
}
175164

176-
public func encode(to encoder: Encoder) throws {
177-
var container = encoder.container(keyedBy: CodingKeys.self)
178-
try container.encode(name, forKey: .name)
179-
180-
// Hide the keys that users shouldn't see when
181-
// we're encoding for the dump-package command.
182-
if encoder.userInfo[Manifest.dumpPackageKey] == nil {
183-
try container.encode(path, forKey: .path)
184-
try container.encode(url, forKey: .url)
185-
try container.encode(version, forKey: .version)
186-
try container.encode(targetMap, forKey: .targetMap)
187-
}
188-
189-
try container.encode(toolsVersion, forKey: .toolsVersion)
190-
try container.encode(pkgConfig, forKey: .pkgConfig)
191-
try container.encode(providers, forKey: .providers)
192-
try container.encode(cLanguageStandard, forKey: .cLanguageStandard)
193-
try container.encode(cxxLanguageStandard, forKey: .cxxLanguageStandard)
194-
try container.encode(swiftLanguageVersions, forKey: .swiftLanguageVersions)
195-
try container.encode(dependencies, forKey: .dependencies)
196-
try container.encode(products, forKey: .products)
197-
try container.encode(targets, forKey: .targets)
198-
try container.encode(platforms, forKey: .platforms)
199-
try container.encode(packageKind, forKey: .packageKind)
200-
}
201-
202165
/// Returns the targets required for building the provided products.
203166
public func targetsRequired(for products: [ProductDescription]) -> [TargetDescription] {
204167
let targetsByName = Dictionary(targets.map({ ($0.name, $0) }), uniquingKeysWith: { $1 })
@@ -364,6 +327,45 @@ extension Manifest {
364327
return false
365328
}
366329
}
330+
331+
// MARK: - CustomStringConvertible
332+
333+
public var description: String {
334+
return "<Manifest: \(name)>"
335+
}
336+
337+
// MARK: - Codable
338+
339+
/// Coding user info key for dump-package command.
340+
///
341+
/// Presence of this key will hide some keys when encoding the Manifest object.
342+
public static let dumpPackageKey: CodingUserInfoKey = CodingUserInfoKey(rawValue: "dumpPackage")!
343+
344+
public func encode(to encoder: Encoder) throws {
345+
var container = encoder.container(keyedBy: CodingKeys.self)
346+
try container.encode(name, forKey: .name)
347+
348+
// Hide the keys that users shouldn't see when
349+
// we're encoding for the dump-package command.
350+
if encoder.userInfo[Manifest.dumpPackageKey] == nil {
351+
try container.encode(path, forKey: .path)
352+
try container.encode(url, forKey: .url)
353+
try container.encode(version, forKey: .version)
354+
try container.encode(targetMap, forKey: .targetMap)
355+
}
356+
357+
try container.encode(toolsVersion, forKey: .toolsVersion)
358+
try container.encode(pkgConfig, forKey: .pkgConfig)
359+
try container.encode(providers, forKey: .providers)
360+
try container.encode(cLanguageStandard, forKey: .cLanguageStandard)
361+
try container.encode(cxxLanguageStandard, forKey: .cxxLanguageStandard)
362+
try container.encode(swiftLanguageVersions, forKey: .swiftLanguageVersions)
363+
try container.encode(dependencies, forKey: .dependencies)
364+
try container.encode(products, forKey: .products)
365+
try container.encode(targets, forKey: .targets)
366+
try container.encode(platforms, forKey: .platforms)
367+
try container.encode(packageKind, forKey: .packageKind)
368+
}
367369
}
368370

369371
/// The description of an individual target.

0 commit comments

Comments
 (0)