Files
sourcekit-lsp/Sources/SKCore/FileBuildSettingsChange.swift
David Goldman 5977d611aa Withhold diagnostics when fallback arguments are being used (#281)
While fallback arguments are being used (either from the fallback build system or fallback settings from the primary build system), withhold semantic diagnostics from sourcekitd and all diagnostics from clangd. This helps prevent user confusion from spurious errors.

- Also remove the DocumentURI standardization in favor of proper equality + hash checks to work around the %40 --> @ encoding issue seen on CI.
2020-06-11 11:38:50 -04:00

58 lines
1.7 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
/// Denotes a change in build settings for a single file.
public enum FileBuildSettingsChange {
/// The `BuildSystem` has no `FileBuildSettings` for the file.
case removedOrUnavailable
/// The `FileBuildSettings` have been modified or are newly available.
case modified(FileBuildSettings)
/// The `BuildSystem` is providing fallback arguments which may not be correct.
case fallback(FileBuildSettings)
}
extension FileBuildSettingsChange {
public var newSettings: FileBuildSettings? {
switch self {
case .removedOrUnavailable:
return nil
case .modified(let settings):
return settings
case .fallback(let settings):
return settings
}
}
/// Whether the change represents fallback arguments.
public var isFallback: Bool {
switch self {
case .removedOrUnavailable:
return false
case .modified(_):
return false
case .fallback(_):
return true
}
}
public init(_ settings: FileBuildSettings?, fallback: Bool = false) {
if let settings = settings {
self = fallback ? .fallback(settings) : .modified(settings)
} else {
self = .removedOrUnavailable
}
}
}