         }
         set {
             if newValue {
-                let value: [String: SourceKitRepresentable]? = nil
-                responseCache.values[cacheKey] = value
+                responseCache.set(key: cacheKey, value: nil)
             } else {
-                responseCache.values.removeValue(forKey: cacheKey)
+                responseCache.unset(key: cacheKey)
             }
         }
     }

internal typealias AssertHandler = () -> Void
private var assertHandlers = [String: AssertHandler]()

private var _allDeclarationsByType = [String: [String]]()
private var queueForRebuild = [Structure]()

private struct Cache<T> {
    fileprivate var values = [String: T]()
    fileprivate var factory: (File) -> T

    fileprivate init(_ factory: @escaping (File) -> T) {
        self.factory = factory


    fileprivate mutating func get(_ file: File) -> T {
        let key = file.cacheKey
        lock.lock()
        if let cachedValue = values[key] {
            lock.unlock()
            return cachedValue
        }
        lock.unlock()
        let value = factory(file)
        set(key: key, value: value)
        return value
    }

    fileprivate mutating func invalidate(_ file: File) {
        if let key = file.path {
            doLocked { values.removeValue(forKey: key) }
        }
    }

    fileprivate mutating func clear() {
        doLocked { values.removeAll(keepingCapacity: false) }
    }

    fileprivate mutating func set(key: String, value: T) {
        doLocked { values[key] = value }
    }

    fileprivate mutating func unset(key: String) {
        doLocked { values.removeValue(forKey: key) }
    }

    private func doLocked(block: () -> Void) {
        lock.lock()
        block()
        lock.unlock()
    }
}

