11import Foundation
22
3- fileprivate enum ChangeType {
4- case change( old: String , new: String )
5- case removal( String )
6- case addition( String )
7-
8- var title : String {
9- switch self {
10- case . change: " Changed "
11- case . removal: " Removed "
12- case . addition: " Added "
13- }
14- }
15-
16- static func `for`( oldValue: String ? , newValue: String ? ) -> Self ? {
17- if oldValue == newValue { return nil }
18- if let oldValue, let newValue { return . change( old: oldValue, new: newValue) }
19- if let oldValue { return . removal( oldValue) }
20- if let newValue { return . addition( newValue) }
21- return nil
22- }
23- }
24-
253extension SwiftInterfaceElement {
264
27- func diffDescription( propertyType: String ? , oldValue: String ? , newValue: String ? ) -> [ String ] {
5+ /// Returns a description for a change between an old and new value
6+ /// - Parameters:
7+ /// - propertyType: The (optional) property type name (e.g. "accessor", "modifier", "generic where clause", ...) for additional information
8+ /// - oldValue: The (optional) old value
9+ /// - newValue: The (optional) new value
10+ /// - Returns: A list with a single item that represents a change description caused by a value change
11+ func diffDescription(
12+ propertyType: String ? ,
13+ oldValue: String ? ,
14+ newValue: String ?
15+ ) -> [ String ] {
2816
2917 guard let changeType: ChangeType = . for( oldValue: oldValue, newValue: newValue) else { return [ ] }
3018
@@ -47,6 +35,12 @@ extension SwiftInterfaceElement {
4735 return [ diffDescription]
4836 }
4937
38+ /// Returns a list of change descriptions for changes between the old and new values
39+ /// - Parameters:
40+ /// - propertyType: The (optional) property type name (e.g. "accessor", "modifier", "generic where clause", ...) for additional information
41+ /// - oldValue: The (optional) old values
42+ /// - newValue: The (optional) new values
43+ /// - Returns: A list of change descriptions caused by a value change
5044 func diffDescription( propertyType: String , oldValues: [ String ] ? , newValues: [ String ] ? ) -> [ String ] {
5145
5246 if let oldValues, let newValues {
@@ -68,3 +62,28 @@ extension SwiftInterfaceElement {
6862 return [ ]
6963 }
7064}
65+
66+ // MARK: -
67+
68+ /// File-private helper to produce detailed descriptions
69+ fileprivate enum ChangeType {
70+ case change( old: String , new: String )
71+ case removal( String )
72+ case addition( String )
73+
74+ var title : String {
75+ switch self {
76+ case . change: " Changed "
77+ case . removal: " Removed "
78+ case . addition: " Added "
79+ }
80+ }
81+
82+ static func `for`( oldValue: String ? , newValue: String ? ) -> Self ? {
83+ if oldValue == newValue { return nil }
84+ if let oldValue, let newValue { return . change( old: oldValue, new: newValue) }
85+ if let oldValue { return . removal( oldValue) }
86+ if let newValue { return . addition( newValue) }
87+ return nil
88+ }
89+ }
0 commit comments