Skip to content

Commit 6d1b09a

Browse files
committed
Remove available check below macOS 10.15.4
Since the Package.swift declare the minimal target for macOS is 10.15.4, we can remove the uncessary available check code
1 parent 4d8555d commit 6d1b09a

File tree

6 files changed

+27
-67
lines changed

6 files changed

+27
-67
lines changed

Sources/LSPLogging/Logging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public final class Logger {
182182

183183
var usedOSLog = false
184184
#if canImport(os)
185-
if !disableOSLog, #available(OSX 10.12, *) {
185+
if !disableOSLog {
186186
// If os_log is available, we call it unconditionally since it has its own log-level handling that we respect.
187187
os_log("%@", type: level.osLogType, message)
188188
usedOSLog = true

Sources/LSPTestSupport/CheckCoding.swift

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import XCTest
2020
public func checkCoding<T>(_ value: T, json: String, file: StaticString = #filePath, line: UInt = #line) where T: Codable & Equatable {
2121
let encoder = JSONEncoder()
2222
encoder.outputFormatting.insert(.prettyPrinted)
23-
if #available(macOS 10.13, *) {
24-
encoder.outputFormatting.insert(.sortedKeys)
25-
}
23+
encoder.outputFormatting.insert(.sortedKeys)
24+
2625
let data = try! encoder.encode(WrapFragment(value: value))
2726
let wrappedStr = String(data: data, encoding: .utf8)!
2827

@@ -36,11 +35,7 @@ public func checkCoding<T>(_ value: T, json: String, file: StaticString = #fileP
3635
.replacingOccurrences(of: "\n ", with: "\n")
3736
// Remove trailing whitespace to normalize between corelibs and Apple Foundation.
3837
.trimmingTrailingWhitespace()
39-
40-
// Requires sortedKeys. Silently drop the check if it's not available.
41-
if #available(macOS 10.13, *) {
42-
XCTAssertEqual(json, str, file: file, line: line)
43-
}
38+
XCTAssertEqual(json, str, file: file, line: line)
4439

4540
let decoder = JSONDecoder()
4641
let decodedValue = try! decoder.decode(WrapFragment<T>.self, from: data).value
@@ -70,19 +65,13 @@ public func checkDecoding<T>(json: String, expected value: T, file: StaticString
7065
public func checkCoding<T>(_ value: T, json: String, userInfo: [CodingUserInfoKey: Any] = [:], file: StaticString = #filePath, line: UInt = #line, body: (T) -> Void) where T: Codable {
7166
let encoder = JSONEncoder()
7267
encoder.outputFormatting.insert(.prettyPrinted)
73-
if #available(macOS 10.13, *) {
74-
encoder.outputFormatting.insert(.sortedKeys)
75-
}
68+
encoder.outputFormatting.insert(.sortedKeys)
7669
let data = try! encoder.encode(value)
7770
let str = String(data: data, encoding: .utf8)!
7871
// Remove trailing whitespace to normalize between corelibs and Apple Foundation.
7972
.trimmingTrailingWhitespace()
80-
81-
// Requires sortedKeys. Silently drop the check if it's not available.
82-
if #available(macOS 10.13, *) {
83-
XCTAssertEqual(json, str, file: file, line: line)
84-
}
85-
73+
XCTAssertEqual(json, str, file: file, line: line)
74+
8675
let decoder = JSONDecoder()
8776
decoder.userInfo = userInfo
8877
let decodedValue = try! decoder.decode(T.self, from: data)

Sources/SKCore/BuildServerBuildSystem.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,14 @@ private func makeJSONRPCBuildServer(client: MessageHandler, serverPath: Absolute
260260
withExtendedLifetime((clientToServer, serverToClient)) {}
261261
}
262262
let process = Foundation.Process()
263-
264-
if #available(OSX 10.13, *) {
265-
process.executableURL = serverPath.asURL
266-
} else {
267-
process.launchPath = serverPath.pathString
268-
}
269-
263+
process.executableURL = serverPath.asURL
270264
process.arguments = serverFlags
271265
process.standardOutput = serverToClient
272266
process.standardInput = clientToServer
273267
process.terminationHandler = { process in
274268
log("build server exited: \(process.terminationReason) \(process.terminationStatus)")
275269
connection.close()
276270
}
277-
278-
if #available(OSX 10.13, *) {
279-
try process.run()
280-
} else {
281-
process.launch()
282-
}
283-
271+
try process.run()
284272
return connection
285273
}

Sources/SourceKitLSP/Clang/ClangLanguageServer.swift

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ final class ClangLanguageServerShim: LanguageServer, ToolchainLanguageServer {
5252
/// Changing the property automatically notified the state change handlers.
5353
private var state: LanguageServerState {
5454
didSet {
55-
if #available(OSX 10.12, *) {
56-
// `state` must only be set from `queue`.
57-
dispatchPrecondition(condition: .onQueue(queue))
58-
}
55+
// `state` must only be set from `queue`.
56+
dispatchPrecondition(condition: .onQueue(queue))
5957
for handler in stateChangeHandlers {
6058
handler(oldValue, state)
6159
}
@@ -131,13 +129,7 @@ final class ClangLanguageServerShim: LanguageServer, ToolchainLanguageServer {
131129
}
132130

133131
let process = Foundation.Process()
134-
135-
if #available(OSX 10.13, *) {
136-
process.executableURL = clangdPath.asURL
137-
} else {
138-
process.launchPath = clangdPath.pathString
139-
}
140-
132+
process.executableURL = clangdPath.asURL
141133
process.arguments = [
142134
"-compile_args_from=lsp", // Provide compiler args programmatically.
143135
"-background-index=false", // Disable clangd indexing, we use the build
@@ -162,12 +154,7 @@ final class ClangLanguageServerShim: LanguageServer, ToolchainLanguageServer {
162154
}
163155
}
164156
}
165-
166-
if #available(OSX 10.13, *) {
167-
try process.run()
168-
} else {
169-
process.launch()
170-
}
157+
try process.run()
171158
#if os(Windows)
172159
self.hClangd = process.processHandle
173160
#else

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ public final class SwiftLanguageServer: ToolchainLanguageServer {
120120

121121
private var state: LanguageServerState {
122122
didSet {
123-
if #available(OSX 10.12, *) {
124-
// `state` must only be set from `queue`.
125-
dispatchPrecondition(condition: .onQueue(queue))
126-
}
123+
// `state` must only be set from `queue`.
124+
dispatchPrecondition(condition: .onQueue(queue))
127125
for handler in stateChangeHandlers {
128126
handler(oldValue, state)
129127
}

Tests/SKCoreTests/CompilationDatabaseTests.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,19 @@ final class CompilationDatabaseTests: XCTestCase {
6060

6161
func testEncodeCompDBCommand() {
6262
// Requires JSONEncoder.OutputFormatting.sortedKeys
63-
if #available(macOS 10.13, *) {
64-
func check(_ cmd: CompilationDatabase.Command, _ expected: String, file: StaticString = #filePath, line: UInt = #line) {
65-
let encoder = JSONEncoder()
66-
encoder.outputFormatting.insert(.sortedKeys)
67-
let encodedString = try! String(data: encoder.encode(cmd), encoding: .utf8)
68-
XCTAssertEqual(encodedString, expected, file: file, line: line)
69-
}
70-
71-
check(.init(directory: "a", filename: "b", commandLine: [], output: "c"), """
72-
{"arguments":[],"directory":"a","file":"b","output":"c"}
73-
""")
74-
check(.init(directory: "a", filename: "b", commandLine: ["c", "d"], output: nil), """
75-
{"arguments":["c","d"],"directory":"a","file":"b"}
76-
""")
63+
func check(_ cmd: CompilationDatabase.Command, _ expected: String, file: StaticString = #filePath, line: UInt = #line) {
64+
let encoder = JSONEncoder()
65+
encoder.outputFormatting.insert(.sortedKeys)
66+
let encodedString = try! String(data: encoder.encode(cmd), encoding: .utf8)
67+
XCTAssertEqual(encodedString, expected, file: file, line: line)
7768
}
69+
70+
check(.init(directory: "a", filename: "b", commandLine: [], output: "c"), """
71+
{"arguments":[],"directory":"a","file":"b","output":"c"}
72+
""")
73+
check(.init(directory: "a", filename: "b", commandLine: ["c", "d"], output: nil), """
74+
{"arguments":["c","d"],"directory":"a","file":"b"}
75+
""")
7876
}
7977

8078
func testDecodeCompDBCommand() {

0 commit comments

Comments
 (0)