@@ -13,19 +13,32 @@ public func buildTreeContent(context: Context) -> String {
13
13
return content
14
14
}
15
15
public func buildHeader( context: Context ) -> String {
16
- return context. exclusiveConstraints. compactMap { constraint in
16
+ var shouldShowErrorMessage = false
17
+ let validate : ( [ HasDisplayName ] ) -> Bool = { !$0. allSatisfy ( \. isValid) }
18
+ let content = context. exclusiveConstraints. compactMap { constraint in
17
19
let address = addres ( of: constraint)
18
20
switch ( constraint. firstItem, constraint. secondItem) {
19
21
case ( . none, . none) :
20
22
return " NSLayoutConstraint: \( address) Unknown case. \( constraint. displayIdentifier) "
21
23
case ( . some( let lhs) , . some( let rhs) ) :
22
- let ( lAttribute, rAttribute) = ( constraint. firstAttribute. displayName , constraint. secondAttribute. displayName )
24
+ let ( lAttribute, rAttribute) = ( constraint. firstAttribute, constraint. secondAttribute)
23
25
let relation = constraint. relation
24
- return " NSLayoutConstraint: \( address) \( itemType ( of: lhs) ) . \( lAttribute) \( relation. displayName) \( itemType ( of: rhs) ) . \( rAttribute) \( constraint. displayIdentifier) "
26
+ shouldShowErrorMessage = shouldShowErrorMessage || validate ( [ lAttribute, rAttribute, relation] )
27
+ return " NSLayoutConstraint: \( address) \( itemType ( of: lhs) ) . \( lAttribute. displayName) \( relation. displayName) \( itemType ( of: rhs) ) . \( rAttribute. displayName) \( constraint. displayIdentifier) "
25
28
case ( . some( let item) , . none) :
29
+ shouldShowErrorMessage = shouldShowErrorMessage || validate ( [ constraint. firstAttribute, constraint. relation] )
26
30
return " NSLayoutConstraint: \( address) \( itemType ( of: item) ) . \( constraint. firstAttribute. displayName) \( constraint. relation. displayName) \( constraint. constant) \( constraint. displayIdentifier) "
27
31
case ( . none, . some( let item) ) :
32
+ shouldShowErrorMessage = shouldShowErrorMessage || validate ( [ constraint. secondAttribute, constraint. relation] )
28
33
return " NSLayoutConstraint: \( address) \( itemType ( of: item) ) . \( constraint. secondAttribute. displayName) \( constraint. relation. displayName) \( constraint. constant) \( constraint. displayIdentifier) "
29
34
}
30
35
} . joined ( separator: " \n " )
36
+ if shouldShowErrorMessage {
37
+ return """
38
+ Gedatsu catch unknown attribute or relation pattern. See issues for a solution to this problem. If that doesn't solve, please create a new issue. "
39
+ https://github.com/bannzai/gedatsu/issues
40
+ \( content)
41
+ """
42
+ }
43
+ return content
31
44
}
0 commit comments