Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.

Commit 411f06e

Browse files
author
Jeff Verkoeyen
committed
Don't overwrite previously-existing usr info unless it's unstructured.
Some Swift usrs can appear twice in the sourcekitten output.
1 parent 2bd2ff5 commit 411f06e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apple/diffreport/diffreportlib/diffreport.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,14 @@ func apiNodeIsOrderedBefore(prev: APINode, next: APINode) -> Bool {
160160
return false
161161
}
162162

163-
/** Union two dictionaries. */
164-
func += <K, V> (left: inout [K:V], right: [K:V]) {
163+
/** Union two dictionaries, preferring existing values if they possess a parent.usr key. */
164+
func += (left: inout ApiNameNodeMap, right: ApiNameNodeMap) {
165165
for (k, v) in right {
166-
left.updateValue(v, forKey: k)
166+
if left[k] == nil {
167+
left.updateValue(v, forKey: k)
168+
} else if let object = left[k], object["parent.usr"] == nil {
169+
left.updateValue(v, forKey: k)
170+
}
167171
}
168172
}
169173

0 commit comments

Comments
 (0)