Skip to content

Commit

Permalink
fixes equality
Browse files Browse the repository at this point in the history
  • Loading branch information
yonaskolb committed Jan 30, 2018
1 parent a74233a commit b9d025a
Show file tree
Hide file tree
Showing 24 changed files with 142 additions and 46 deletions.
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXBuildFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ final public class PBXBuildFile: PBXObject {

// MARK: - Hashable

public static func == (lhs: PBXBuildFile,
rhs: PBXBuildFile) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXBuildFile else {
return false
}
let lhs = self
let settingsAreEqual: Bool = {
switch (lhs.settings, rhs.settings) {
case (.none, .none):
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ public class PBXBuildPhase: PBXObject {
try super.init(from: decoder)
}

public static func == (lhs: PBXBuildPhase,
rhs: PBXBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXBuildPhase else {
return false
}
let lhs = self
return lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXBuildRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ final public class PBXBuildRule: PBXObject {

// MARK: - Equatable

public static func == (lhs: PBXBuildRule,
rhs: PBXBuildRule) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXBuildRule else {
return false
}
let lhs = self
let outputFilesCompilerFlagsAreEqual: Bool = {
switch (lhs.outputFilesCompilerFlags, rhs.outputFilesCompilerFlags) {
case (.none, .none):
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXContainerItemProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ final public class PBXContainerItemProxy: PBXObject {
super.init()
}

public static func == (lhs: PBXContainerItemProxy,
rhs: PBXContainerItemProxy) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXContainerItemProxy else {
return false
}
let lhs = self
return lhs.proxyType == rhs.proxyType &&
lhs.containerPortal == rhs.containerPortal &&
lhs.remoteGlobalIDString == rhs.remoteGlobalIDString &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXCopyFilesBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ final public class PBXCopyFilesBuildPhase: PBXBuildPhase {
runOnlyForDeploymentPostprocessing)
}

public static func == (lhs: PBXCopyFilesBuildPhase,
rhs: PBXCopyFilesBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXCopyFilesBuildPhase else {
return false
}
let lhs = self
return lhs.dstPath == rhs.dstPath &&
lhs.name == rhs.name &&
lhs.buildActionMask == rhs.buildActionMask &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXFileElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public class PBXFileElement: PBXObject, PlistSerializable {
super.init()
}

public static func == (lhs: PBXFileElement,
rhs: PBXFileElement) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXFileElement else {
return false
}
let lhs = self
return lhs.sourceTree == rhs.sourceTree &&
lhs.path == rhs.path &&
lhs.name == rhs.name
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXFileReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ final public class PBXFileReference: PBXFileElement {
super.init(sourceTree: sourceTree, path: path, name: name)
}

public static func == (lhs: PBXFileReference,
rhs: PBXFileReference) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXFileReference else {
return false
}
let lhs = self
return lhs.fileEncoding == rhs.fileEncoding &&
lhs.explicitFileType == rhs.explicitFileType &&
lhs.lastKnownFileType == rhs.lastKnownFileType &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXFrameworksBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ final public class PBXFrameworksBuildPhase: PBXBuildPhase {
return .frameworks
}

public static func == (lhs: PBXFrameworksBuildPhase,
rhs: PBXFrameworksBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXFrameworksBuildPhase else {
return false
}
let lhs = self
return lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ final public class PBXGroup: PBXFileElement {
super.init(sourceTree: sourceTree, path: path, name: name)
}

public static func == (lhs: PBXGroup,
rhs: PBXGroup) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXGroup else {
return false
}
let lhs = self
return lhs.children == rhs.children &&
lhs.name == rhs.name &&
lhs.sourceTree == rhs.sourceTree &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXHeadersBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ final public class PBXHeadersBuildPhase: PBXBuildPhase {
return .headers
}

public static func == (lhs: PBXHeadersBuildPhase,
rhs: PBXHeadersBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXHeadersBuildPhase else {
return false
}
let lhs = self
return lhs.buildActionMask == rhs.buildActionMask &&
lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXLegacyTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ final public class PBXLegacyTarget: PBXTarget {
try super.init(from: decoder)
}

public static func == (lhs: PBXLegacyTarget,
rhs: PBXLegacyTarget) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXLegacyTarget else {
return false
}
let lhs = self
return (lhs as PBXTarget) == (rhs as PBXTarget) &&
lhs.buildToolPath == rhs.buildToolPath &&
lhs.buildArgumentsString == rhs.buildArgumentsString &&
Expand Down
4 changes: 4 additions & 0 deletions Sources/xcproj/PBXObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class PBXObject: Decodable, Equatable {

public static func == (lhs: PBXObject,
rhs: PBXObject) -> Bool {
return lhs.isEqual(to: rhs)
}

func isEqual(to object: PBXObject) -> Bool {
return true
}

Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ final public class PBXProject: PBXObject {

// MARK: - Hashable

public static func == (lhs: PBXProject,
rhs: PBXProject) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXProject else {
return false
}
let lhs = self
let equalRegion = lhs.developmentRegion == rhs.developmentRegion
let equalHasScannedForEncodings = lhs.hasScannedForEncodings == rhs.hasScannedForEncodings
let equalProductRefGroup = lhs.productRefGroup == rhs.productRefGroup
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXReferenceProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ final public class PBXReferenceProxy: PBXObject {

// MARK: - Hashable

public static func == (lhs: PBXReferenceProxy,
rhs: PBXReferenceProxy) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXReferenceProxy else {
return false
}
let lhs = self
return lhs.fileType == rhs.fileType &&
lhs.path == rhs.path &&
lhs.remoteRef == rhs.remoteRef &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXResourcesBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ final public class PBXResourcesBuildPhase: PBXBuildPhase {
return .resources
}

public static func == (lhs: PBXResourcesBuildPhase,
rhs: PBXResourcesBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXResourcesBuildPhase else {
return false
}
let lhs = self
return lhs.buildActionMask == rhs.buildActionMask &&
lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXRezBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ final public class PBXRezBuildPhase: PBXBuildPhase {
return .carbonResources
}

public static func == (lhs: PBXRezBuildPhase,
rhs: PBXRezBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXRezBuildPhase else {
return false
}
let lhs = self
return lhs.buildActionMask == rhs.buildActionMask &&
lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXShellScriptBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ final public class PBXShellScriptBuildPhase: PBXBuildPhase {
try super.init(from: decoder)
}

public static func == (lhs: PBXShellScriptBuildPhase,
rhs: PBXShellScriptBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXShellScriptBuildPhase else {
return false
}
let lhs = self
return lhs.buildActionMask == rhs.buildActionMask &&
lhs.files == rhs.files &&
lhs.name == rhs.name &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXSourcesBuildPhase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ final public class PBXSourcesBuildPhase: PBXBuildPhase {

// MARK: - Hashable

public static func == (lhs: PBXSourcesBuildPhase,
rhs: PBXSourcesBuildPhase) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXSourcesBuildPhase else {
return false
}
let lhs = self
return lhs.buildActionMask == rhs.buildActionMask &&
lhs.files == rhs.files &&
lhs.runOnlyForDeploymentPostprocessing == rhs.runOnlyForDeploymentPostprocessing
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ public class PBXTarget: PBXObject {
try super.init(from: decoder)
}

public static func == (lhs: PBXTarget,
rhs: PBXTarget) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXTarget else {
return false
}
let lhs = self
return lhs.buildConfigurationList == rhs.buildConfigurationList &&
lhs.buildPhases == rhs.buildPhases &&
lhs.buildRules == rhs.buildRules &&
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXTargetDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ final public class PBXTargetDependency: PBXObject {

// MARK: - Hashable

public static func == (lhs: PBXTargetDependency,
rhs: PBXTargetDependency) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXTargetDependency else {
return false
}
let lhs = self
return lhs.target == rhs.target &&
lhs.targetProxy == rhs.targetProxy
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/PBXVariantGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ final public class PBXVariantGroup: PBXFileElement {

// MARK: - Hashable

public static func == (lhs: PBXVariantGroup,
rhs: PBXVariantGroup) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? PBXVariantGroup else {
return false
}
let lhs = self
return lhs.children == rhs.children &&
lhs.name == rhs.name &&
lhs.sourceTree == rhs.sourceTree
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/XCBuildConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ final public class XCBuildConfiguration: PBXObject {
super.init()
}

public static func == (lhs: XCBuildConfiguration,
rhs: XCBuildConfiguration) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? XCBuildConfiguration else {
return false
}
let lhs = self
return lhs.baseConfigurationReference == rhs.baseConfigurationReference &&
lhs.name == rhs.name &&
NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings)
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/XCConfigurationList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ final public class XCConfigurationList: PBXObject {
super.init()
}

public static func == (lhs: XCConfigurationList,
rhs: XCConfigurationList) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? XCConfigurationList else {
return false
}
let lhs = self
return lhs.buildConfigurations == rhs.buildConfigurations &&
lhs.defaultConfigurationIsVisible == rhs.defaultConfigurationIsVisible
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/xcproj/XCVersionGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ final public class XCVersionGroup: PBXFileElement {
super.init(sourceTree: sourceTree, path: path, name: name)
}

public static func == (lhs: XCVersionGroup,
rhs: XCVersionGroup) -> Bool {
public override func isEqual(to object: PBXObject) -> Bool {
guard super.isEqual(to: self),
let rhs = object as? XCVersionGroup else {
return false
}
let lhs = self
return lhs.currentVersion == rhs.currentVersion &&
lhs.versionGroupType == rhs.versionGroupType &&
lhs.children == rhs.children
Expand Down

0 comments on commit b9d025a

Please sign in to comment.