diff --git a/SourceKitLSPDevUtils/Package.swift b/SourceKitLSPDevUtils/Package.swift index 83868576f..59456953c 100644 --- a/SourceKitLSPDevUtils/Package.swift +++ b/SourceKitLSPDevUtils/Package.swift @@ -1,11 +1,11 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.2 import Foundation import PackageDescription let package = Package( name: "SourceKitLSPDevUtils", - platforms: [.macOS(.v10_15)], + platforms: [.macOS(.v14)], products: [ .executable(name: "sourcekit-lsp-dev-utils", targets: ["SourceKitLSPDevUtils"]) ], @@ -24,7 +24,8 @@ let package = Package( .product(name: "SwiftParser", package: "swift-syntax"), ] ), - ] + ], + swiftLanguageModes: [.v6] ) let dependencies: [(url: String, path: String, fromVersion: Version)] = [ diff --git a/SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift b/SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift index b08ed2f6b..48c51ef6c 100644 --- a/SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift +++ b/SourceKitLSPDevUtils/Sources/ConfigSchemaGen/ConfigSchemaGen.swift @@ -36,15 +36,13 @@ package struct ConfigSchemaGen { .deletingLastPathComponent() private static let sourceDir = projectRoot - .appendingPathComponent("Sources") - .appendingPathComponent("SKOptions") + .appending(components: "Sources", "SKOptions") private static let configSchemaJSONPath = projectRoot - .appendingPathComponent("config.schema.json") + .appending(component: "config.schema.json") private static let configSchemaDocPath = projectRoot - .appendingPathComponent("Documentation") - .appendingPathComponent("Configuration File.md") + .appending(components: "Documentation", "Configuration File.md") /// Generates and writes the JSON schema and documentation for the SourceKit-LSP configuration file format. package static func generate() throws { diff --git a/Sources/BuildServerIntegration/CompilationDatabase.swift b/Sources/BuildServerIntegration/CompilationDatabase.swift index 55903a9f9..99bd1314c 100644 --- a/Sources/BuildServerIntegration/CompilationDatabase.swift +++ b/Sources/BuildServerIntegration/CompilationDatabase.swift @@ -86,7 +86,7 @@ package struct CompilationDatabaseCompileCommand: Equatable, Codable { if filename.isAbsolutePath || !directory.isAbsolutePath { return DocumentURI(filePath: filename, isDirectory: false) } else { - return DocumentURI(URL(fileURLWithPath: directory).appendingPathComponent(filename, isDirectory: false)) + return DocumentURI(URL(fileURLWithPath: directory).appending(component: filename, directoryHint: .notDirectory)) } } } @@ -127,7 +127,7 @@ package struct JSONCompilationDatabase: Equatable, Codable { /// /// - Returns: `nil` if `compile_commands.json` was not found package init(directory: URL) throws { - let path = directory.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + let path = directory.appending(component: JSONCompilationDatabaseBuildServer.dbName) try self.init(file: path) } diff --git a/Sources/BuildServerIntegration/DetermineBuildServer.swift b/Sources/BuildServerIntegration/DetermineBuildServer.swift index 75c7c26a3..725433aea 100644 --- a/Sources/BuildServerIntegration/DetermineBuildServer.swift +++ b/Sources/BuildServerIntegration/DetermineBuildServer.swift @@ -40,12 +40,12 @@ private func searchForCompilationDatabaseConfig( .compactMap { searchPath in let path = workspaceFolder.appending(searchPath) - let jsonPath = path.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + let jsonPath = path.appending(component: JSONCompilationDatabaseBuildServer.dbName) if FileManager.default.isFile(at: jsonPath) { return BuildServerSpec(kind: .jsonCompilationDatabase, projectRoot: workspaceFolder, configPath: jsonPath) } - let fixedPath = path.appendingPathComponent(FixedCompilationDatabaseBuildServer.dbName) + let fixedPath = path.appending(component: FixedCompilationDatabaseBuildServer.dbName) if FileManager.default.isFile(at: fixedPath) { return BuildServerSpec(kind: .fixedCompilationDatabase, projectRoot: workspaceFolder, configPath: fixedPath) } diff --git a/Sources/BuildServerIntegration/ExternalBuildServerAdapter.swift b/Sources/BuildServerIntegration/ExternalBuildServerAdapter.swift index 481bffa72..3f507f8d8 100644 --- a/Sources/BuildServerIntegration/ExternalBuildServerAdapter.swift +++ b/Sources/BuildServerIntegration/ExternalBuildServerAdapter.swift @@ -205,34 +205,34 @@ actor ExternalBuildServerAdapter { private static func getConfigPath(for workspaceFolder: URL? = nil, onlyConsiderRoot: Bool = false) -> URL? { var buildServerConfigLocations: [URL?] = [] if let workspaceFolder = workspaceFolder { - buildServerConfigLocations.append(workspaceFolder.appendingPathComponent(".bsp")) + buildServerConfigLocations.append(workspaceFolder.appending(component: ".bsp")) } if !onlyConsiderRoot { #if os(Windows) if let localAppData = ProcessInfo.processInfo.environment["LOCALAPPDATA"] { - buildServerConfigLocations.append(URL(fileURLWithPath: localAppData).appendingPathComponent("bsp")) + buildServerConfigLocations.append(URL(fileURLWithPath: localAppData).appending(component: "bsp")) } if let programData = ProcessInfo.processInfo.environment["PROGRAMDATA"] { - buildServerConfigLocations.append(URL(fileURLWithPath: programData).appendingPathComponent("bsp")) + buildServerConfigLocations.append(URL(fileURLWithPath: programData).appending(component: "bsp")) } #else if let xdgDataHome = ProcessInfo.processInfo.environment["XDG_DATA_HOME"] { - buildServerConfigLocations.append(URL(fileURLWithPath: xdgDataHome).appendingPathComponent("bsp")) + buildServerConfigLocations.append(URL(fileURLWithPath: xdgDataHome).appending(component: "bsp")) } if let libraryUrl = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first { - buildServerConfigLocations.append(libraryUrl.appendingPathComponent("bsp")) + buildServerConfigLocations.append(libraryUrl.appending(component: "bsp")) } if let xdgDataDirs = ProcessInfo.processInfo.environment["XDG_DATA_DIRS"] { buildServerConfigLocations += xdgDataDirs.split(separator: ":").map { xdgDataDir in - URL(fileURLWithPath: String(xdgDataDir)).appendingPathComponent("bsp") + URL(fileURLWithPath: String(xdgDataDir)).appending(component: "bsp") } } if let libraryUrl = FileManager.default.urls(for: .applicationSupportDirectory, in: .systemDomainMask).first { - buildServerConfigLocations.append(libraryUrl.appendingPathComponent("bsp")) + buildServerConfigLocations.append(libraryUrl.appending(component: "bsp")) } #endif } @@ -255,7 +255,7 @@ actor ExternalBuildServerAdapter { // Pre Swift 6.1 SourceKit-LSP looked for `buildServer.json` in the project root. Maintain this search location for // compatibility even though it's not a standard BSP search location. - if let buildServerPath = workspaceFolder?.appendingPathComponent("buildServer.json"), + if let buildServerPath = workspaceFolder?.appending(component: "buildServer.json"), FileManager.default.isFile(at: buildServerPath) { return buildServerPath diff --git a/Sources/BuildServerIntegration/FixedCompilationDatabaseBuildServer.swift b/Sources/BuildServerIntegration/FixedCompilationDatabaseBuildServer.swift index ef084482a..672111a1d 100644 --- a/Sources/BuildServerIntegration/FixedCompilationDatabaseBuildServer.swift +++ b/Sources/BuildServerIntegration/FixedCompilationDatabaseBuildServer.swift @@ -56,7 +56,7 @@ package actor FixedCompilationDatabaseBuildServer: BuiltInBuildServer { } package var indexDatabasePath: URL? { - indexStorePath?.deletingLastPathComponent().appendingPathComponent("IndexDatabase") + indexStorePath?.deletingLastPathComponent().appending(component: "IndexDatabase") } package nonisolated var supportsPreparationAndOutputPaths: Bool { false } diff --git a/Sources/BuildServerIntegration/JSONCompilationDatabaseBuildServer.swift b/Sources/BuildServerIntegration/JSONCompilationDatabaseBuildServer.swift index abd8e5196..f6e9a619b 100644 --- a/Sources/BuildServerIntegration/JSONCompilationDatabaseBuildServer.swift +++ b/Sources/BuildServerIntegration/JSONCompilationDatabaseBuildServer.swift @@ -93,7 +93,7 @@ package actor JSONCompilationDatabaseBuildServer: BuiltInBuildServer { } package var indexDatabasePath: URL? { - indexStorePath?.deletingLastPathComponent().appendingPathComponent("IndexDatabase") + indexStorePath?.deletingLastPathComponent().appending(component: "IndexDatabase") } package nonisolated var supportsPreparationAndOutputPaths: Bool { false } diff --git a/Sources/BuildServerIntegration/SwiftPMBuildServer.swift b/Sources/BuildServerIntegration/SwiftPMBuildServer.swift index e357d9b25..fcf5e4d81 100644 --- a/Sources/BuildServerIntegration/SwiftPMBuildServer.swift +++ b/Sources/BuildServerIntegration/SwiftPMBuildServer.swift @@ -144,7 +144,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer { } static package func searchForConfig(in path: URL, options: SourceKitLSPOptions) -> BuildServerSpec? { - let packagePath = path.appendingPathComponent("Package.swift") + let packagePath = path.appending(component: "Package.swift") if (try? String(contentsOf: packagePath, encoding: .utf8))?.contains("PackageDescription") ?? false { return BuildServerSpec(kind: .swiftPM, projectRoot: path, configPath: packagePath) } @@ -494,7 +494,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer { } package var indexDatabasePath: URL? { - return buildPath.appendingPathComponent("index").appendingPathComponent("db") + return buildPath.appending(components: "index", "db") } private func indexUnitOutputPath(forSwiftFile uri: DocumentURI) -> String { @@ -583,7 +583,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer { ) } let packageManifest = SourceItem( - uri: DocumentURI(projectRoot.appendingPathComponent("Package.swift")), + uri: DocumentURI(projectRoot.appending(component: "Package.swift")), kind: .file, generated: false ) diff --git a/Sources/CompletionScoringTestSupport/RepeatableRandomNumberGenerator.swift b/Sources/CompletionScoringTestSupport/RepeatableRandomNumberGenerator.swift index 4b37cf7c0..c4c0d8c93 100644 --- a/Sources/CompletionScoringTestSupport/RepeatableRandomNumberGenerator.swift +++ b/Sources/CompletionScoringTestSupport/RepeatableRandomNumberGenerator.swift @@ -129,9 +129,7 @@ private let skTestSupportInputsDirectory: URL = { #if os(macOS) var resources = productsDirectory - .appendingPathComponent("SourceKitLSP_CompletionScoringTestSupport.bundle") - .appendingPathComponent("Contents") - .appendingPathComponent("Resources") + .appending(components: "SourceKitLSP_CompletionScoringTestSupport.bundle", "Contents", "Resources") if !FileManager.default.fileExists(at: resources) { // Xcode and command-line swiftpm differ about the path. resources.deleteLastPathComponent() @@ -140,18 +138,18 @@ private let skTestSupportInputsDirectory: URL = { #else let resources = productsDirectory - .appendingPathComponent("SourceKitLSP_CompletionScoringTestSupport.resources") + .appending(component: "SourceKitLSP_CompletionScoringTestSupport.resources") #endif guard FileManager.default.fileExists(at: resources) else { fatalError("missing resources \(resources)") } - return resources.appendingPathComponent("INPUTS", isDirectory: true).standardizedFileURL + return resources.appending(component: "INPUTS", directoryHint: .isDirectory).standardizedFileURL }() func loadTestResource(name: String, withExtension ext: String) throws -> Data { let file = skTestSupportInputsDirectory - .appendingPathComponent("\(name).\(ext)") + .appending(component: "\(name).\(ext)") return try Data(contentsOf: file) } diff --git a/Sources/Diagnose/DiagnoseCommand.swift b/Sources/Diagnose/DiagnoseCommand.swift index 76bcc4309..5a251f23d 100644 --- a/Sources/Diagnose/DiagnoseCommand.swift +++ b/Sources/Diagnose/DiagnoseCommand.swift @@ -124,7 +124,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { try await reduce( requestInfo: requestInfo, toolchain: toolchain, - bundlePath: bundlePath.appendingPathComponent("sourcekitd-crash"), + bundlePath: bundlePath.appending(component: "sourcekitd-crash"), progressUpdate: { (progress, message) in reportProgress( .reproducingSourcekitdCrash(progress: progress), @@ -192,7 +192,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { } ) - let bundleDirectory = bundlePath.appendingPathComponent("swift-frontend-crash") + let bundleDirectory = bundlePath.appending(component: "swift-frontend-crash") try makeReproducerBundle(for: reducedRequesInfo, toolchain: toolchain, bundlePath: bundleDirectory) // If reduce didn't throw, we have found a reproducer. Stop. @@ -218,7 +218,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { private func addOsLog(toBundle bundlePath: URL) async throws { #if os(macOS) reportProgress(.collectingLogMessages(progress: 0), message: "Collecting log messages") - let outputFileUrl = bundlePath.appendingPathComponent("log.txt") + let outputFileUrl = bundlePath.appending(component: "log.txt") try FileManager.default.createFile(at: outputFileUrl, contents: nil) let fileHandle = try FileHandle(forWritingTo: outputFileUrl) let bytesCollected = AtomicInt32(initialValue: 0) @@ -265,12 +265,11 @@ package struct DiagnoseCommand: AsyncParsableCommand { private func addNonDarwinLogs(toBundle bundlePath: URL) async throws { reportProgress(.collectingLogMessages(progress: 0), message: "Collecting log files") - let destinationDir = bundlePath.appendingPathComponent("logs") + let destinationDir = bundlePath.appending(component: "logs") try FileManager.default.createDirectory(at: destinationDir, withIntermediateDirectories: true) let logFileDirectoryURL = FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent(".sourcekit-lsp") - .appendingPathComponent("logs") + .appending(components: ".sourcekit-lsp", "logs") let enumerator = FileManager.default.enumerator(at: logFileDirectoryURL, includingPropertiesForKeys: nil) while let fileUrl = enumerator?.nextObject() as? URL { guard fileUrl.lastPathComponent.hasPrefix("sourcekit-lsp") else { @@ -278,7 +277,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { } try? FileManager.default.copyItem( at: fileUrl, - to: destinationDir.appendingPathComponent(fileUrl.lastPathComponent) + to: destinationDir.appending(component: fileUrl.lastPathComponent) ) } } @@ -294,7 +293,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { #if os(macOS) reportProgress(.collectingCrashReports, message: "Collecting crash reports") - let destinationDir = bundlePath.appendingPathComponent("crashes") + let destinationDir = bundlePath.appending(component: "crashes") try FileManager.default.createDirectory(at: destinationDir, withIntermediateDirectories: true) let processesToIncludeCrashReportsOf = ["SourceKitService", "sourcekit-lsp", "swift-frontend"] @@ -308,7 +307,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { } try? FileManager.default.copyItem( at: fileUrl, - to: destinationDir.appendingPathComponent(fileUrl.lastPathComponent) + to: destinationDir.appending(component: fileUrl.lastPathComponent) ) } } @@ -317,7 +316,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { @MainActor private func addSwiftVersion(toBundle bundlePath: URL) async throws { - let outputFileUrl = bundlePath.appendingPathComponent("swift-versions.txt") + let outputFileUrl = bundlePath.appending(component: "swift-versions.txt") try FileManager.default.createFile(at: outputFileUrl, contents: nil) let fileHandle = try FileHandle(forWritingTo: outputFileUrl) @@ -388,8 +387,7 @@ package struct DiagnoseCommand: AsyncParsableCommand { URL(fileURLWithPath: bundleOutputPath) } else { FileManager.default.temporaryDirectory - .appendingPathComponent("sourcekit-lsp-diagnose") - .appendingPathComponent("sourcekit-lsp-diagnose-\(date)") + .appending(components: "sourcekit-lsp-diagnose", "sourcekit-lsp-diagnose-\(date)") } try FileManager.default.createDirectory(at: bundlePath, withIntermediateDirectories: true) diff --git a/Sources/Diagnose/ReduceCommand.swift b/Sources/Diagnose/ReduceCommand.swift index 80ce597cc..0f1c14ab2 100644 --- a/Sources/Diagnose/ReduceCommand.swift +++ b/Sources/Diagnose/ReduceCommand.swift @@ -98,7 +98,7 @@ package struct ReduceCommand: AsyncParsableCommand { progressBar.complete(success: true) - let reducedSourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduced.swift") + let reducedSourceFile = FileManager.default.temporaryDirectory.appending(component: "reduced.swift") try reduceRequestInfo.fileContents.write(to: reducedSourceFile, atomically: true, encoding: .utf8) print("Reduced Request:") diff --git a/Sources/Diagnose/ReproducerBundle.swift b/Sources/Diagnose/ReproducerBundle.swift index 8fdccb917..9b2e3d10f 100644 --- a/Sources/Diagnose/ReproducerBundle.swift +++ b/Sources/Diagnose/ReproducerBundle.swift @@ -24,13 +24,13 @@ import struct TSCBasic.AbsolutePath func makeReproducerBundle(for requestInfo: RequestInfo, toolchain: Toolchain, bundlePath: URL) throws { try FileManager.default.createDirectory(at: bundlePath, withIntermediateDirectories: true) try requestInfo.fileContents.write( - to: bundlePath.appendingPathComponent("input.swift"), + to: bundlePath.appending(component: "input.swift"), atomically: true, encoding: .utf8 ) try toolchain.path.realpath.filePath .write( - to: bundlePath.appendingPathComponent("toolchain.txt"), + to: bundlePath.appending(component: "toolchain.txt"), atomically: true, encoding: .utf8 ) @@ -38,12 +38,12 @@ func makeReproducerBundle(for requestInfo: RequestInfo, toolchain: Toolchain, bu let command = "swift-frontend \\\n" + requestInfo.compilerArgs.replacing(["$FILE"], with: ["./input.swift"]).joined(separator: " \\\n") - try command.write(to: bundlePath.appendingPathComponent("command.sh"), atomically: true, encoding: .utf8) + try command.write(to: bundlePath.appending(component: "command.sh"), atomically: true, encoding: .utf8) } else { - let requests = try requestInfo.requests(for: bundlePath.appendingPathComponent("input.swift")) + let requests = try requestInfo.requests(for: bundlePath.appending(component: "input.swift")) for (index, request) in requests.enumerated() { try request.write( - to: bundlePath.appendingPathComponent("request-\(index).yml"), + to: bundlePath.appending(component: "request-\(index).yml"), atomically: true, encoding: .utf8 ) diff --git a/Sources/Diagnose/SourceKitDRequestExecutor.swift b/Sources/Diagnose/SourceKitDRequestExecutor.swift index da5cafddb..a63380a2c 100644 --- a/Sources/Diagnose/SourceKitDRequestExecutor.swift +++ b/Sources/Diagnose/SourceKitDRequestExecutor.swift @@ -74,7 +74,7 @@ package class OutOfProcessSourceKitRequestExecutor: SourceKitRequestExecutor { /// The file to which we write the reduce source file. private var temporarySourceFile: URL { - temporaryDirectory.appendingPathComponent("reduce.swift") + temporaryDirectory.appending(component: "reduce.swift") } /// If this predicate evaluates to true on the sourcekitd response, the request is @@ -86,7 +86,7 @@ package class OutOfProcessSourceKitRequestExecutor: SourceKitRequestExecutor { self.pluginPaths = pluginPaths self.swiftFrontend = swiftFrontend self.reproducerPredicate = reproducerPredicate - temporaryDirectory = FileManager.default.temporaryDirectory.appendingPathComponent("sourcekitd-execute-\(UUID())") + temporaryDirectory = FileManager.default.temporaryDirectory.appending(component: "sourcekitd-execute-\(UUID())") try? FileManager.default.createDirectory(at: temporaryDirectory, withIntermediateDirectories: true) } @@ -171,7 +171,7 @@ package class OutOfProcessSourceKitRequestExecutor: SourceKitRequestExecutor { try request.fileContents.write(to: temporarySourceFile, atomically: true, encoding: .utf8) let requestStrings = try request.requests(for: temporarySourceFile) for (index, requestString) in requestStrings.enumerated() { - let temporaryRequestFile = temporaryDirectory.appendingPathComponent("request-\(index).yml") + let temporaryRequestFile = temporaryDirectory.appending(component: "request-\(index).yml") try requestString.write( to: temporaryRequestFile, atomically: true, diff --git a/Sources/Diagnose/Toolchain+SwiftFrontend.swift b/Sources/Diagnose/Toolchain+SwiftFrontend.swift index f8c091018..bb7e1bb0b 100644 --- a/Sources/Diagnose/Toolchain+SwiftFrontend.swift +++ b/Sources/Diagnose/Toolchain+SwiftFrontend.swift @@ -20,6 +20,6 @@ extension Toolchain { /// /// - Note: Not discovered as part of the toolchain because `swift-frontend` is only needed in the diagnose commands. package var swiftFrontend: URL? { - return swift?.deletingLastPathComponent().appendingPathComponent("swift-frontend") + return swift?.deletingLastPathComponent().appending(component: "swift-frontend") } } diff --git a/Sources/SKLogging/SetGlobalLogFileHandler.swift b/Sources/SKLogging/SetGlobalLogFileHandler.swift index dbb92d162..2b2ea8a87 100644 --- a/Sources/SKLogging/SetGlobalLogFileHandler.swift +++ b/Sources/SKLogging/SetGlobalLogFileHandler.swift @@ -44,8 +44,9 @@ func getOrCreateLogFileHandle(logDirectory: URL, logRotateCount: Int) -> FileHan } // Name must match the regex in `cleanOldLogFiles` and the prefix in `DiagnoseCommand.addNonDarwinLogs`. - let logFileUrl = logDirectory.appendingPathComponent( - "sourcekit-lsp-\(ProcessInfo.processInfo.processIdentifier).\(logRotateIndex % logRotateCount).log" + let logFileUrl = logDirectory.appending( + component: + "sourcekit-lsp-\(ProcessInfo.processInfo.processIdentifier).\(logRotateIndex % logRotateCount).log" ) do { diff --git a/Sources/SKOptions/SourceKitLSPOptions.swift b/Sources/SKOptions/SourceKitLSPOptions.swift index ae4d60857..4a7897118 100644 --- a/Sources/SKOptions/SourceKitLSPOptions.swift +++ b/Sources/SKOptions/SourceKitLSPOptions.swift @@ -564,8 +564,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable { base: base, override: SourceKitLSPOptions( path: workspaceFolder.fileURL? - .appendingPathComponent(".sourcekit-lsp") - .appendingPathComponent("config.json") + .appending(components: ".sourcekit-lsp", "config.json") ) ) } @@ -575,7 +574,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable { return URL(fileURLWithPath: generatedFilesPath) } - return URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("sourcekit-lsp") + return URL(fileURLWithPath: NSTemporaryDirectory()).appending(component: "sourcekit-lsp") } public func hasExperimentalFeature(_ feature: ExperimentalFeature) -> Bool { diff --git a/Sources/SKTestSupport/CustomBuildServerTestProject.swift b/Sources/SKTestSupport/CustomBuildServerTestProject.swift index 2a5bcc22e..0ecddcd04 100644 --- a/Sources/SKTestSupport/CustomBuildServerTestProject.swift +++ b/Sources/SKTestSupport/CustomBuildServerTestProject.swift @@ -179,8 +179,8 @@ package extension CustomBuildServer { ) throws -> InitializeBuildResponse { return initializationResponse( initializeData: SourceKitInitializeBuildResponseData( - indexDatabasePath: try projectRoot.appendingPathComponent("index-db").filePath, - indexStorePath: try projectRoot.appendingPathComponent("index-store").filePath, + indexDatabasePath: try projectRoot.appending(component: "index-db").filePath, + indexStorePath: try projectRoot.appending(component: "index-store").filePath, outputPathsProvider: outputPathsProvider, prepareProvider: true, sourceKitOptionsProvider: true diff --git a/Sources/SKTestSupport/ExternalBuildServerTestProject.swift b/Sources/SKTestSupport/ExternalBuildServerTestProject.swift index ae0dd35fb..0fa35c02e 100644 --- a/Sources/SKTestSupport/ExternalBuildServerTestProject.swift +++ b/Sources/SKTestSupport/ExternalBuildServerTestProject.swift @@ -29,9 +29,7 @@ private let skTestSupportInputsDirectory: URL = { #if os(macOS) var resources = productsDirectory - .appendingPathComponent("SourceKitLSP_SKTestSupport.bundle") - .appendingPathComponent("Contents") - .appendingPathComponent("Resources") + .appending(components: "SourceKitLSP_SKTestSupport.bundle", "Contents", "Resources") if !FileManager.default.fileExists(at: resources) { // Xcode and command-line swiftpm differ about the path. resources.deleteLastPathComponent() @@ -40,12 +38,12 @@ private let skTestSupportInputsDirectory: URL = { #else let resources = productsDirectory - .appendingPathComponent("SourceKitLSP_SKTestSupport.resources") + .appending(component: "SourceKitLSP_SKTestSupport.resources") #endif guard FileManager.default.fileExists(at: resources) else { fatalError("missing resources \(resources)") } - return resources.appendingPathComponent("INPUTS", isDirectory: true).standardizedFileURL + return resources.appending(component: "INPUTS", directoryHint: .isDirectory).standardizedFileURL }() /// Creates a project that uses a BSP server to provide build settings. diff --git a/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift b/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift index 9a0ca382d..df3286c98 100644 --- a/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift +++ b/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift @@ -84,8 +84,8 @@ package struct IndexedSingleSwiftFileTestProject { ) async throws { let testWorkspaceDirectory = try workspaceDirectory ?? testScratchDir(testName: testName) - let testFileURL = testWorkspaceDirectory.appendingPathComponent("test.swift") - let indexURL = testWorkspaceDirectory.appendingPathComponent("index") + let testFileURL = testWorkspaceDirectory.appending(component: "test.swift") + let indexURL = testWorkspaceDirectory.appending(component: "index") guard let swiftc = await ToolchainRegistry.forTesting.default?.swiftc else { throw Error.swiftcNotFound } @@ -115,30 +115,30 @@ package struct IndexedSingleSwiftFileTestProject { let sdkUrl = URL(fileURLWithPath: sdk) #if os(Windows) let platform = sdkUrl.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent() - let info = try WindowsPlatformInfo(reading: platform.appendingPathComponent("Info.plist")) + let info = try WindowsPlatformInfo(reading: platform.appending(component: "Info.plist")) let xctestModuleDir = platform - .appendingPathComponent("Developer") - .appendingPathComponent("Library") - .appendingPathComponent("XCTest-\(info.defaults.xctestVersion)") - .appendingPathComponent("usr") - .appendingPathComponent("lib") - .appendingPathComponent("swift") - .appendingPathComponent("windows") + .appending( + components: "Developer", + "Library", + "XCTest-\(info.defaults.xctestVersion)", + "usr", + "lib", + "swift", + "windows" + ) compilerArguments += ["-I", try xctestModuleDir.filePath] #else let usrLibDir = sdkUrl .deletingLastPathComponent() .deletingLastPathComponent() - .appendingPathComponent("usr") - .appendingPathComponent("lib") + .appending(components: "usr", "lib") let frameworksDir = sdkUrl .deletingLastPathComponent() .deletingLastPathComponent() - .appendingPathComponent("Library") - .appendingPathComponent("Frameworks") + .appending(components: "Library", "Frameworks") compilerArguments += [ "-I", try usrLibDir.filePath, "-F", try frameworksDir.filePath, @@ -158,7 +158,7 @@ package struct IndexedSingleSwiftFileTestProject { let encoder = JSONEncoder() encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes] try encoder.encode(compilationDatabase).write( - to: testWorkspaceDirectory.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + to: testWorkspaceDirectory.appending(component: JSONCompilationDatabaseBuildServer.dbName) ) // Run swiftc to build the index store diff --git a/Sources/SKTestSupport/MultiFileTestProject.swift b/Sources/SKTestSupport/MultiFileTestProject.swift index 9e9e61641..0b863a8f5 100644 --- a/Sources/SKTestSupport/MultiFileTestProject.swift +++ b/Sources/SKTestSupport/MultiFileTestProject.swift @@ -39,9 +39,9 @@ package struct RelativeFileLocation: Hashable, ExpressibleByStringLiteral { package func url(relativeTo: URL) -> URL { var url = relativeTo for directory in directories { - url = url.appendingPathComponent(directory) + url = url.appending(component: directory) } - url = url.appendingPathComponent(fileName) + url = url.appending(component: fileName) return url } } diff --git a/Sources/SKTestSupport/PluginPaths.swift b/Sources/SKTestSupport/PluginPaths.swift index 7f6d2c695..e7cd8bcca 100644 --- a/Sources/SKTestSupport/PluginPaths.swift +++ b/Sources/SKTestSupport/PluginPaths.swift @@ -58,17 +58,13 @@ private func fileExists(at url: URL) -> Bool { private func pluginPaths(relativeTo base: URL) -> PluginPaths? { // When building in Xcode if let buildConfiguration = inferredXcodeBuildConfiguration { - let frameworksDir = base.appendingPathComponent("Products") - .appendingPathComponent(buildConfiguration) - .appendingPathComponent("PackageFrameworks") + let frameworksDir = base.appending(components: "Products", buildConfiguration, "PackageFrameworks") let clientPlugin = frameworksDir - .appendingPathComponent("SwiftSourceKitClientPlugin.framework") - .appendingPathComponent("SwiftSourceKitClientPlugin") + .appending(components: "SwiftSourceKitClientPlugin.framework", "SwiftSourceKitClientPlugin") let servicePlugin = frameworksDir - .appendingPathComponent("SwiftSourceKitPlugin.framework") - .appendingPathComponent("SwiftSourceKitPlugin") + .appending(components: "SwiftSourceKitPlugin.framework", "SwiftSourceKitPlugin") if fileExists(at: clientPlugin) && fileExists(at: servicePlugin) { return PluginPaths(clientPlugin: clientPlugin, servicePlugin: servicePlugin) } @@ -76,15 +72,13 @@ private func pluginPaths(relativeTo base: URL) -> PluginPaths? { // When creating an `xctestproducts` bundle do { - let frameworksDir = base.appendingPathComponent("PackageFrameworks") + let frameworksDir = base.appending(component: "PackageFrameworks") let clientPlugin = frameworksDir - .appendingPathComponent("SwiftSourceKitClientPlugin.framework") - .appendingPathComponent("SwiftSourceKitClientPlugin") + .appending(components: "SwiftSourceKitClientPlugin.framework", "SwiftSourceKitClientPlugin") let servicePlugin = frameworksDir - .appendingPathComponent("SwiftSourceKitPlugin.framework") - .appendingPathComponent("SwiftSourceKitPlugin") + .appending(components: "SwiftSourceKitPlugin.framework", "SwiftSourceKitPlugin") if fileExists(at: clientPlugin) && fileExists(at: servicePlugin) { return PluginPaths(clientPlugin: clientPlugin, servicePlugin: servicePlugin) } @@ -109,8 +103,8 @@ private func pluginPaths(relativeTo base: URL) -> PluginPaths? { clientPluginName = "libSwiftSourceKitClientPlugin.so" servicePluginName = "libSwiftSourceKitPlugin.so" } - let clientPlugin = base.appendingPathComponent(clientPluginName) - let servicePlugin = base.appendingPathComponent(servicePluginName) + let clientPlugin = base.appending(component: clientPluginName) + let servicePlugin = base.appending(component: servicePluginName) if fileExists(at: clientPlugin) && fileExists(at: servicePlugin) { return PluginPaths(clientPlugin: clientPlugin, servicePlugin: servicePlugin) } diff --git a/Sources/SKTestSupport/SkipUnless.swift b/Sources/SKTestSupport/SkipUnless.swift index 9d8ffdc38..b47dce1c7 100644 --- a/Sources/SKTestSupport/SkipUnless.swift +++ b/Sources/SKTestSupport/SkipUnless.swift @@ -217,9 +217,9 @@ package actor SkipUnless { ) async throws { return try await shared.skipUnlessSupported(allowSkippingInCI: true, file: file, line: line) { let swiftFrontend = try await unwrap(ToolchainRegistry.forTesting.default?.swift).deletingLastPathComponent() - .appendingPathComponent("swift-frontend") + .appending(component: "swift-frontend") return try await withTestScratchDir { scratchDirectory in - let input = scratchDirectory.appendingPathComponent("Input.swift") + let input = scratchDirectory.appending(component: "Input.swift") try FileManager.default.createFile(at: input, contents: nil) // If we can't compile for wasm, this fails complaining that it can't find the stdlib for wasm. let result = try await withTimeout(defaultTimeoutDuration) { diff --git a/Sources/SKTestSupport/SwiftPMDependencyProject.swift b/Sources/SKTestSupport/SwiftPMDependencyProject.swift index 79addaee9..cc5d0061b 100644 --- a/Sources/SKTestSupport/SwiftPMDependencyProject.swift +++ b/Sources/SKTestSupport/SwiftPMDependencyProject.swift @@ -29,7 +29,7 @@ package class SwiftPMDependencyProject { /// The directory in which the repository lives. package var packageDirectory: URL { - return scratchDirectory.appendingPathComponent("MyDependency") + return scratchDirectory.appending(component: "MyDependency") } private func runGitCommand(_ arguments: [String], workingDirectory: URL) async throws { diff --git a/Sources/SKTestSupport/SwiftPMTestProject.swift b/Sources/SKTestSupport/SwiftPMTestProject.swift index 23d7843ae..54e975ad5 100644 --- a/Sources/SKTestSupport/SwiftPMTestProject.swift +++ b/Sources/SKTestSupport/SwiftPMTestProject.swift @@ -53,7 +53,7 @@ package class SwiftPMTestProject: MultiFileTestProject { productsDirectory .deletingLastPathComponent() // arm64-apple-macosx .deletingLastPathComponent() // debug - .appendingPathComponent("checkouts"), + .appending(component: "checkouts"), URL(fileURLWithPath: #filePath) .deletingLastPathComponent() // SwiftPMTestProject.swift .deletingLastPathComponent() // SKTestSupport @@ -64,11 +64,7 @@ package class SwiftPMTestProject: MultiFileTestProject { let swiftSyntaxCShimsModulemap = swiftSyntaxSearchPaths.map { swiftSyntaxSearchPath in swiftSyntaxSearchPath - .appendingPathComponent("swift-syntax") - .appendingPathComponent("Sources") - .appendingPathComponent("_SwiftSyntaxCShims") - .appendingPathComponent("include") - .appendingPathComponent("module.modulemap") + .appending(components: "swift-syntax", "Sources", "_SwiftSyntaxCShims", "include", "module.modulemap") } .first { FileManager.default.fileExists(at: $0) } @@ -82,8 +78,7 @@ package class SwiftPMTestProject: MultiFileTestProject { // build folder wasn't cleaned and thus we would link against the stale `.o` file. let linkFileListURL = productsDirectory - .appendingPathComponent("SourceKitLSPPackageTests.product") - .appendingPathComponent("Objects.LinkFileList") + .appending(components: "SourceKitLSPPackageTests.product", "Objects.LinkFileList") let linkFileListContents = try? String(contentsOf: linkFileListURL, encoding: .utf8) guard let linkFileListContents else { struct LinkFileListNotFoundError: Swift.Error { @@ -122,7 +117,7 @@ package class SwiftPMTestProject: MultiFileTestProject { var objectFiles: [String] = [] for moduleName in swiftSyntaxModulesToLink { - let dir = productsDirectory.appendingPathComponent("\(moduleName).build") + let dir = productsDirectory.appending(component: "\(moduleName).build") let enumerator = FileManager.default.enumerator(at: dir, includingPropertiesForKeys: nil) while let file = enumerator?.nextObject() as? URL { if linkFileList.contains(try file.filePath) { diff --git a/Sources/SKTestSupport/Utils.swift b/Sources/SKTestSupport/Utils.swift index c0c34d507..fa6b7c538 100644 --- a/Sources/SKTestSupport/Utils.swift +++ b/Sources/SKTestSupport/Utils.swift @@ -84,8 +84,8 @@ package func testScratchDir(testName: String = #function) throws -> URL { #endif let url = try FileManager.default.temporaryDirectory.realpath - .appendingPathComponent(testScratchDirsName) - .appendingPathComponent(testScratchName(testName: testName), isDirectory: true) + .appending(component: testScratchDirsName) + .appending(component: testScratchName(testName: testName), directoryHint: .isDirectory) try? FileManager.default.removeItem(at: url) try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true) @@ -120,7 +120,6 @@ var globalModuleCache: URL? { return URL(fileURLWithPath: customModuleCache) } return try FileManager.default.temporaryDirectory.realpath - .appendingPathComponent("sourcekit-lsp-test-scratch") - .appendingPathComponent("shared-module-cache") + .appending(components: "sourcekit-lsp-test-scratch", "shared-module-cache") } } diff --git a/Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift b/Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift index 9ccd2422f..0d6b91e00 100644 --- a/Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift +++ b/Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift @@ -756,8 +756,8 @@ fileprivate extension Process { } logger.debug("Argument list is too long. Using response file.") - let responseFile = FileManager.default.temporaryDirectory.appendingPathComponent( - "index-response-file-\(UUID()).txt" + let responseFile = FileManager.default.temporaryDirectory.appending( + component: "index-response-file-\(UUID()).txt" ) defer { orLog("Failed to remove temporary response file") { diff --git a/Sources/SourceKitLSP/SourceKitLSPServer.swift b/Sources/SourceKitLSP/SourceKitLSPServer.swift index 4bec22b20..dd3c7b830 100644 --- a/Sources/SourceKitLSP/SourceKitLSPServer.swift +++ b/Sources/SourceKitLSP/SourceKitLSPServer.swift @@ -916,8 +916,7 @@ extension SourceKitLSPServer { base: self.options, override: SourceKitLSPOptions( path: workspaceFolder.fileURL? - .appendingPathComponent(".sourcekit-lsp") - .appendingPathComponent("config.json") + .appending(components: ".sourcekit-lsp", "config.json") ) ) logger.log("Creating workspace at \(workspaceFolder.forLogging)") diff --git a/Sources/SwiftLanguageService/MacroExpansion.swift b/Sources/SwiftLanguageService/MacroExpansion.swift index 64d05436b..38494d379 100644 --- a/Sources/SwiftLanguageService/MacroExpansion.swift +++ b/Sources/SwiftLanguageService/MacroExpansion.swift @@ -231,12 +231,11 @@ extension SwiftLanguageService { } var completeExpansionFilePath = - self.generatedMacroExpansionsPath.appendingPathComponent( - Insecure.MD5.hash( - data: Data(completeExpansionDirectoryName.utf8) - ) - .map { String(format: "%02hhx", $0) } // maps each byte of the hash to its hex equivalent `String` - .joined() + self.generatedMacroExpansionsPath.appending( + component: + Insecure.MD5.hash(data: Data(completeExpansionDirectoryName.utf8)) + .map { String(format: "%02hhx", $0) } // maps each byte of the hash to its hex equivalent `String` + .joined() ) do { @@ -251,7 +250,7 @@ extension SwiftLanguageService { } completeExpansionFilePath = - completeExpansionFilePath.appendingPathComponent(parentFileDisplayName) + completeExpansionFilePath.appending(component: parentFileDisplayName) do { try completeExpansionFileContent.write(to: completeExpansionFilePath, atomically: true, encoding: .utf8) } catch { diff --git a/Sources/SwiftLanguageService/OpenInterface.swift b/Sources/SwiftLanguageService/OpenInterface.swift index bfa6b1555..d6f9d402a 100644 --- a/Sources/SwiftLanguageService/OpenInterface.swift +++ b/Sources/SwiftLanguageService/OpenInterface.swift @@ -46,8 +46,7 @@ extension SwiftLanguageService { return GeneratedInterfaceDetails(uri: try urlData.uri, position: position) } let interfaceFilePath = self.generatedInterfacesPath - .appendingPathComponent(buildSettingsFileHash) - .appendingPathComponent(urlData.displayName) + .appending(components: buildSettingsFileHash, urlData.displayName) try FileManager.default.createDirectory( at: interfaceFilePath.deletingLastPathComponent(), withIntermediateDirectories: true diff --git a/Sources/SwiftLanguageService/SwiftLanguageService.swift b/Sources/SwiftLanguageService/SwiftLanguageService.swift index 87c84b8d8..728f6cbe6 100644 --- a/Sources/SwiftLanguageService/SwiftLanguageService.swift +++ b/Sources/SwiftLanguageService/SwiftLanguageService.swift @@ -119,12 +119,12 @@ package actor SwiftLanguageService: LanguageService, Sendable { /// Directory where generated Swift interfaces will be stored. var generatedInterfacesPath: URL { - options.generatedFilesAbsolutePath.appendingPathComponent("GeneratedInterfaces") + options.generatedFilesAbsolutePath.appending(component: "GeneratedInterfaces") } /// Directory where generated Macro expansions will be stored. var generatedMacroExpansionsPath: URL { - options.generatedFilesAbsolutePath.appendingPathComponent("GeneratedMacroExpansions") + options.generatedFilesAbsolutePath.appending(component: "GeneratedMacroExpansions") } /// For each edited document, the last task that was triggered to send a `PublishDiagnosticsNotification`. diff --git a/Sources/SwiftSourceKitPlugin/Plugin.swift b/Sources/SwiftSourceKitPlugin/Plugin.swift index 10a873d38..29b2fcd19 100644 --- a/Sources/SwiftSourceKitPlugin/Plugin.swift +++ b/Sources/SwiftSourceKitPlugin/Plugin.swift @@ -191,16 +191,14 @@ private extension SourceKitD { let inProcUrl = frameworkUrl - .appendingPathComponent("sourcekitdInProc.framework") - .appendingPathComponent("sourcekitdInProc") + .appending(components: "sourcekitdInProc.framework", "sourcekitdInProc") if FileManager.default.fileExists(at: inProcUrl) { return try SourceKitD(dylib: inProcUrl, pluginPaths: nil, initialize: false) } let sourcekitdUrl = frameworkUrl - .appendingPathComponent("sourcekitd.framework") - .appendingPathComponent("sourcekitd") + .appending(components: "sourcekitd.framework", "sourcekitd") return try SourceKitD(dylib: sourcekitdUrl, pluginPaths: nil, initialize: false) } } diff --git a/Sources/ToolchainRegistry/Toolchain.swift b/Sources/ToolchainRegistry/Toolchain.swift index 61fabd1bc..fec13ca8e 100644 --- a/Sources/ToolchainRegistry/Toolchain.swift +++ b/Sources/ToolchainRegistry/Toolchain.swift @@ -297,10 +297,10 @@ public final class Toolchain: Sendable { var foundAny = false let searchPaths = [ - path, path.appendingPathComponent("bin"), path.appendingPathComponent("usr").appendingPathComponent("bin"), + path, path.appending(component: "bin"), path.appending(components: "usr", "bin"), ] for binPath in searchPaths { - let libPath = binPath.deletingLastPathComponent().appendingPathComponent("lib") + let libPath = binPath.deletingLastPathComponent().appending(component: "lib") guard FileManager.default.isDirectory(at: binPath) || FileManager.default.isDirectory(at: libPath) else { continue @@ -308,30 +308,30 @@ public final class Toolchain: Sendable { let execExt = Platform.current?.executableExtension ?? "" - let clangPath = binPath.appendingPathComponent("clang\(execExt)") + let clangPath = binPath.appending(component: "clang\(execExt)") if FileManager.default.isExecutableFile(atPath: clangPath.path) { clang = clangPath foundAny = true } - let clangdPath = binPath.appendingPathComponent("clangd\(execExt)") + let clangdPath = binPath.appending(component: "clangd\(execExt)") if FileManager.default.isExecutableFile(atPath: clangdPath.path) { clangd = clangdPath foundAny = true } - let swiftPath = binPath.appendingPathComponent("swift\(execExt)") + let swiftPath = binPath.appending(component: "swift\(execExt)") if FileManager.default.isExecutableFile(atPath: swiftPath.path) { swift = swiftPath foundAny = true } - let swiftcPath = binPath.appendingPathComponent("swiftc\(execExt)") + let swiftcPath = binPath.appending(component: "swiftc\(execExt)") if FileManager.default.isExecutableFile(atPath: swiftcPath.path) { swiftc = swiftcPath foundAny = true } - let swiftFormatPath = binPath.appendingPathComponent("swift-format\(execExt)") + let swiftFormatPath = binPath.appending(component: "swift-format\(execExt)") if FileManager.default.isExecutableFile(atPath: swiftFormatPath.path) { swiftFormat = swiftFormatPath foundAny = true @@ -347,16 +347,16 @@ public final class Toolchain: Sendable { } func findDylib(named name: String, searchFramework: Bool = false) -> URL? { - let frameworkPath = libPath.appendingPathComponent("\(name).framework").appendingPathComponent(name) + let frameworkPath = libPath.appending(components: "\(name).framework", name) if FileManager.default.isFile(at: frameworkPath) { return frameworkPath } - let libSearchPath = libPath.appendingPathComponent("lib\(name)\(dylibExtension)") + let libSearchPath = libPath.appending(component: "lib\(name)\(dylibExtension)") if FileManager.default.isFile(at: libSearchPath) { return libSearchPath } #if os(Windows) - let binSearchPath = binPath.appendingPathComponent("\(name)\(dylibExtension)") + let binSearchPath = binPath.appending(component: "\(name)\(dylibExtension)") if FileManager.default.isFile(at: binSearchPath) { return binSearchPath } @@ -382,9 +382,9 @@ public final class Toolchain: Sendable { } #if os(Windows) - let libIndexStorePath = binPath.appendingPathComponent("libIndexStore\(dylibExtension)") + let libIndexStorePath = binPath.appending(component: "libIndexStore\(dylibExtension)") #else - let libIndexStorePath = libPath.appendingPathComponent("libIndexStore\(dylibExtension)") + let libIndexStorePath = libPath.appending(component: "libIndexStore\(dylibExtension)") #endif if FileManager.default.isFile(at: libIndexStorePath) { libIndexStore = libIndexStorePath diff --git a/Sources/ToolchainRegistry/ToolchainRegistry.swift b/Sources/ToolchainRegistry/ToolchainRegistry.swift index f4d1665f8..cfa09b155 100644 --- a/Sources/ToolchainRegistry/ToolchainRegistry.swift +++ b/Sources/ToolchainRegistry/ToolchainRegistry.swift @@ -191,15 +191,13 @@ package final actor ToolchainRegistry { var toolchainSearchPaths = xcodes.map { if $0.pathExtension == "app" { - return $0.appendingPathComponent("Contents").appendingPathComponent("Developer").appendingPathComponent( - "Toolchains" - ) + return $0.appending(components: "Contents", "Developer", "Toolchains") } else { - return $0.appendingPathComponent("Toolchains") + return $0.appending(component: "Toolchains") } } toolchainSearchPaths += libraryDirectories.compactMap { - $0.appendingPathComponent("Developer").appendingPathComponent("Toolchains") + $0.appending(components: "Developer", "Toolchains") } for xctoolchainSearchPath in toolchainSearchPaths { diff --git a/Sources/sourcekit-lsp/SourceKitLSP.swift b/Sources/sourcekit-lsp/SourceKitLSP.swift index a7869865c..ca8aa9648 100644 --- a/Sources/sourcekit-lsp/SourceKitLSP.swift +++ b/Sources/sourcekit-lsp/SourceKitLSP.swift @@ -180,8 +180,7 @@ struct SourceKitLSP: AsyncParsableCommand { base: commandLineOptions(), override: SourceKitLSPOptions( path: FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent(".sourcekit-lsp") - .appendingPathComponent("config.json") + .appending(components: ".sourcekit-lsp", "config.json") ) ) if Platform.current == .darwin { @@ -191,8 +190,7 @@ struct SourceKitLSP: AsyncParsableCommand { override: SourceKitLSPOptions( path: applicationSupportDir - .appendingPathComponent("org.swift.sourcekit-lsp") - .appendingPathComponent("config.json") + .appending(components: "org.swift.sourcekit-lsp", "config.json") ) ) } @@ -203,8 +201,7 @@ struct SourceKitLSP: AsyncParsableCommand { override: SourceKitLSPOptions( path: URL(fileURLWithPath: xdgConfigHome) - .appendingPathComponent("sourcekit-lsp") - .appendingPathComponent("config.json") + .appending(components: "sourcekit-lsp", "config.json") ) ) } @@ -218,7 +215,7 @@ struct SourceKitLSP: AsyncParsableCommand { dateFormatter.timeZone = NSTimeZone.local let date = dateFormatter.string(from: Date()).replacingOccurrences(of: ":", with: "-") - let inputMirrorURL = directory.appendingPathComponent("\(date).log") + let inputMirrorURL = directory.appending(component: "\(date).log") logger.log("Mirroring input to \(inputMirrorURL)") try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) @@ -256,8 +253,7 @@ struct SourceKitLSP: AsyncParsableCommand { // Directory should match the directory we are searching for logs in `DiagnoseCommand.addNonDarwinLogs`. let logFileDirectoryURL = FileManager.default.homeDirectoryForCurrentUser - .appendingPathComponent(".sourcekit-lsp") - .appendingPathComponent("logs") + .appending(components: ".sourcekit-lsp", "logs") await setUpGlobalLogFileHandler( logFileDirectory: logFileDirectoryURL, logFileMaxBytes: 5_000_000, diff --git a/Tests/BuildServerIntegrationTests/CompilationDatabaseTests.swift b/Tests/BuildServerIntegrationTests/CompilationDatabaseTests.swift index 4b915c551..4aa86a77b 100644 --- a/Tests/BuildServerIntegrationTests/CompilationDatabaseTests.swift +++ b/Tests/BuildServerIntegrationTests/CompilationDatabaseTests.swift @@ -186,7 +186,7 @@ final class CompilationDatabaseTests: XCTestCase { func testJSONCompilationDatabaseFromDirectory() async throws { try await withTestScratchDir { tempDir in - let dbFile = tempDir.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + let dbFile = tempDir.appending(component: JSONCompilationDatabaseBuildServer.dbName) XCTAssertThrowsError(try JSONCompilationDatabase(file: dbFile)) @@ -206,7 +206,7 @@ final class CompilationDatabaseTests: XCTestCase { func testFixedCompilationDatabase() async throws { try await withTestScratchDir { tempDir in - let dbFile = tempDir.appendingPathComponent(FixedCompilationDatabaseBuildServer.dbName) + let dbFile = tempDir.appending(component: FixedCompilationDatabaseBuildServer.dbName) XCTAssertThrowsError( try FixedCompilationDatabaseBuildServer( @@ -228,7 +228,7 @@ final class CompilationDatabaseTests: XCTestCase { ) ) - let dummyFile = tempDir.appendingPathComponent("a.c") + let dummyFile = tempDir.appending(component: "a.c") let buildSettings = try await buildServer.sourceKitOptions( request: TextDocumentSourceKitOptionsRequest( textDocument: TextDocumentIdentifier(URI(dummyFile)), @@ -248,7 +248,7 @@ final class CompilationDatabaseTests: XCTestCase { func testInvalidCompilationDatabase() async throws { try await withTestScratchDir { tempDir in - let dbFile = tempDir.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + let dbFile = tempDir.appending(component: JSONCompilationDatabaseBuildServer.dbName) try "".write(to: dbFile, atomically: true, encoding: .utf8) XCTAssertThrowsError(try JSONCompilationDatabase(file: dbFile)) @@ -436,7 +436,7 @@ private func checkCompilationDatabaseBuildServer( block: @Sendable (JSONCompilationDatabaseBuildServer) async throws -> Void ) async throws { try await withTestScratchDir { tempDir in - let configPath = tempDir.appendingPathComponent(JSONCompilationDatabaseBuildServer.dbName) + let configPath = tempDir.appending(component: JSONCompilationDatabaseBuildServer.dbName) try compdb.write(to: configPath, atomically: true, encoding: .utf8) let buildServer = try JSONCompilationDatabaseBuildServer( configPath: configPath, diff --git a/Tests/BuildServerIntegrationTests/ExternalBuildServerTests.swift b/Tests/BuildServerIntegrationTests/ExternalBuildServerTests.swift index f7db89d4e..dc1de6bf3 100644 --- a/Tests/BuildServerIntegrationTests/ExternalBuildServerTests.swift +++ b/Tests/BuildServerIntegrationTests/ExternalBuildServerTests.swift @@ -311,7 +311,7 @@ final class ExternalBuildServerTests: XCTestCase { DocumentDiagnosticsRequest(textDocument: TextDocumentIdentifier(uri)) ) XCTAssertEqual(diagnosticsBeforeCrash.fullReport?.items, []) - try FileManager.default.removeItem(at: project.scratchDirectory.appendingPathComponent("should_crash")) + try FileManager.default.removeItem(at: project.scratchDirectory.appending(component: "should_crash")) try await repeatUntilExpectedResult(timeout: .seconds(20)) { let diagnostics = try await project.testClient.send( @@ -611,7 +611,7 @@ final class ExternalBuildServerTests: XCTestCase { } func buildTargetSourcesRequest(_ request: BuildTargetSourcesRequest) -> BuildTargetSourcesResponse { - return dummyTargetSourcesResponse(files: [DocumentURI(projectRoot.appendingPathComponent("Test.swift"))]) + return dummyTargetSourcesResponse(files: [DocumentURI(projectRoot.appending(component: "Test.swift"))]) } func textDocumentSourceKitOptionsRequest( @@ -720,7 +720,7 @@ final class ExternalBuildServerTests: XCTestCase { didReceiveTargetSourcesRequest = true await unlockBuildServerResponses.waitOrXCTFail() - return dummyTargetSourcesResponse(files: [DocumentURI(projectRoot.appendingPathComponent("Test.swift"))]) + return dummyTargetSourcesResponse(files: [DocumentURI(projectRoot.appending(component: "Test.swift"))]) } func textDocumentSourceKitOptionsRequest( diff --git a/Tests/BuildServerIntegrationTests/SwiftPMBuildServerTests.swift b/Tests/BuildServerIntegrationTests/SwiftPMBuildServerTests.swift index 3d52ea35f..20e2e50b5 100644 --- a/Tests/BuildServerIntegrationTests/SwiftPMBuildServerTests.swift +++ b/Tests/BuildServerIntegrationTests/SwiftPMBuildServerTests.swift @@ -56,7 +56,7 @@ struct SwiftPMBuildServerTests { "pkg/Sources/lib/a.swift": "" ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let buildServerSpec = SwiftPMBuildServer.searchForConfig(in: packageRoot, options: try await .testDefault()) #expect(buildServerSpec == nil) } @@ -79,7 +79,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") await expectThrowsError( try await SwiftPMBuildServer( projectRoot: packageRoot, @@ -125,7 +125,7 @@ struct SwiftPMBuildServerTests { ) let dataPath = await swiftpmBuildServer.destinationBuildParameters.dataPath - let expectedScratchPath = packageRoot.appendingPathComponent(try #require(options.swiftPMOrDefault.scratchPath)) + let expectedScratchPath = packageRoot.appending(component: try #require(options.swiftPMOrDefault.scratchPath)) #expect(dataPath.asURL.isDescendant(of: expectedScratchPath)) } } @@ -147,7 +147,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -159,9 +159,7 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let build = try await buildPath(root: packageRoot, platform: hostTriple.platformBuildPathComponent) _ = try #require(await buildServerManager.initializationData?.indexDatabasePath) @@ -191,7 +189,7 @@ struct SwiftPMBuildServerTests { expectArgumentsContain("-target", try await hostTriple.tripleString, arguments: arguments) #endif - expectArgumentsContain("-I", try build.appendingPathComponent("Modules").filePath, arguments: arguments) + expectArgumentsContain("-I", try build.appending(component: "Modules").filePath, arguments: arguments) expectArgumentsContain(try aswift.filePath, arguments: arguments) } @@ -215,7 +213,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -227,9 +225,7 @@ struct SwiftPMBuildServerTests { let aPlusSomething = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a+something.swift") + .appending(components: "Sources", "lib", "a+something.swift") _ = try #require(await buildServerManager.initializationData?.indexStorePath) let pathWithPlusEscaped = "\(try aPlusSomething.filePath.replacing("+", with: "%2B"))" @@ -255,7 +251,7 @@ struct SwiftPMBuildServerTests { ) #expect( try arguments.contains( - packageRoot.appendingPathComponent("Sources").appendingPathComponent("lib").appendingPathComponent("a.swift") + packageRoot.appending(components: "Sources", "lib", "a.swift") .filePath ), "Compiler arguments do not contain a.swift: \(arguments)" @@ -280,11 +276,11 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let options = SourceKitLSPOptions.SwiftPMOptions( configuration: .release, - scratchPath: try packageRoot.appendingPathComponent("non_default_build_path").filePath, + scratchPath: try packageRoot.appending(component: "non_default_build_path").filePath, cCompilerFlags: ["-m32"], swiftCompilerFlags: ["-typecheck"] ) @@ -300,9 +296,7 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let arguments = try #require( await buildServerManager.buildSettingsInferredFromMainFile( @@ -335,7 +329,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -345,7 +339,7 @@ struct SwiftPMBuildServerTests { ) await buildServerManager.waitForUpToDateBuildGraph() - let source = try packageRoot.appendingPathComponent("Package.swift").realpath + let source = try packageRoot.appending(component: "Package.swift").realpath let arguments = try #require( await buildServerManager.buildSettingsInferredFromMainFile( for: DocumentURI(source), @@ -376,7 +370,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -388,14 +382,10 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let bswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("b.swift") + .appending(components: "Sources", "lib", "b.swift") let argumentsA = try #require( await buildServerManager.buildSettingsInferredFromMainFile( @@ -442,7 +432,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -454,14 +444,10 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libA") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "libA", "a.swift") let bswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libB") - .appendingPathComponent("b.swift") + .appending(components: "Sources", "libB", "b.swift") let arguments = try #require( await buildServerManager.buildSettingsInferredFromMainFile( for: DocumentURI(aswift), @@ -476,9 +462,7 @@ struct SwiftPMBuildServerTests { "-I", "-Xcc", try packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libC") - .appendingPathComponent("include") + .appending(components: "Sources", "libC", "include") .filePath, arguments: arguments ) @@ -495,9 +479,7 @@ struct SwiftPMBuildServerTests { expectArgumentsDoNotContain( "-I", try packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libC") - .appendingPathComponent("include") + .appending(components: "Sources", "libC", "include") .filePath, arguments: argumentsB ) @@ -522,7 +504,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -534,14 +516,10 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libA") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "libA", "a.swift") let bswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("libB") - .appendingPathComponent("b.swift") + .appending(components: "Sources", "libB", "b.swift") _ = try #require( await buildServerManager.buildSettingsInferredFromMainFile( for: DocumentURI(aswift), @@ -586,7 +564,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -598,20 +576,13 @@ struct SwiftPMBuildServerTests { let acxx = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.cpp") + .appending(components: "Sources", "lib", "a.cpp") let bcxx = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("b.cpp") + .appending(components: "Sources", "lib", "b.cpp") let header = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("include") - .appendingPathComponent("a.h") + .appending(components: "Sources", "lib", "include", "a.h") let build = buildPath(root: packageRoot, platform: try await hostTriple.platformBuildPathComponent) _ = try #require(await buildServerManager.initializationData?.indexStorePath) @@ -645,16 +616,14 @@ struct SwiftPMBuildServerTests { expectArgumentsContain( "-I", try packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("include") + .appending(components: "Sources", "lib", "include") .filePath, arguments: args ) expectArgumentsDoNotContain("-I", try build.filePath, arguments: args) expectArgumentsDoNotContain(try bcxx.filePath, arguments: args) - URL(fileURLWithPath: try build.appendingPathComponent("lib.build").appendingPathComponent("a.cpp.o").filePath) + URL(fileURLWithPath: try build.appending(components: "lib.build", "a.cpp.o").filePath) .withUnsafeFileSystemRepresentation { expectArgumentsContain("-o", String(cString: $0!), arguments: args) } @@ -679,7 +648,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -691,9 +660,7 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let arguments = try #require( await buildServerManager.buildSettingsInferredFromMainFile( for: DocumentURI(aswift), @@ -732,11 +699,11 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") try FileManager.default.createSymbolicLink( at: URL(fileURLWithPath: packageRoot.filePath), - withDestinationURL: URL(fileURLWithPath: tempDir.appendingPathComponent("pkg_real").filePath) + withDestinationURL: URL(fileURLWithPath: tempDir.appending(component: "pkg_real").filePath) ) let buildServerSpec = try #require( @@ -753,11 +720,9 @@ struct SwiftPMBuildServerTests { let aswiftSymlink = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let aswiftReal = try aswiftSymlink.realpath - let manifest = packageRoot.appendingPathComponent("Package.swift") + let manifest = packageRoot.appending(component: "Package.swift") let argumentsFromSymlink = try #require( await buildServerManager.buildSettingsInferredFromMainFile( @@ -818,12 +783,12 @@ struct SwiftPMBuildServerTests { let acpp = ["Sources", "lib", "a.cpp"] let ah = ["Sources", "lib", "include", "a.h"] - let realRoot = tempDir.appendingPathComponent("pkg_real") - let symlinkRoot = tempDir.appendingPathComponent("pkg") + let realRoot = tempDir.appending(component: "pkg_real") + let symlinkRoot = tempDir.appending(component: "pkg") try FileManager.default.createSymbolicLink( at: URL(fileURLWithPath: symlinkRoot.filePath), - withDestinationURL: URL(fileURLWithPath: tempDir.appendingPathComponent("pkg_real").filePath) + withDestinationURL: URL(fileURLWithPath: tempDir.appending(component: "pkg_real").filePath) ) let buildServerSpec = try #require( @@ -871,7 +836,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath + let packageRoot = try tempDir.appending(component: "pkg").realpath let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -883,9 +848,7 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Sources") - .appendingPathComponent("lib") - .appendingPathComponent("a.swift") + .appending(components: "Sources", "lib", "a.swift") let arguments = try #require( await buildServerManager.buildSettingsInferredFromMainFile( for: DocumentURI(aswift), @@ -923,9 +886,7 @@ struct SwiftPMBuildServerTests { ) let workspaceRoot = tempDir - .appendingPathComponent("pkg") - .appendingPathComponent("Sources") - .appendingPathComponent("lib") + .appending(components: "pkg", "Sources", "lib") let buildServerSpec = SwiftPMBuildServer.searchForConfig(in: workspaceRoot, options: try await .testDefault()) #expect(buildServerSpec == nil) @@ -953,7 +914,7 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = tempDir.appendingPathComponent("pkg") + let packageRoot = tempDir.appending(component: "pkg") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -965,9 +926,7 @@ struct SwiftPMBuildServerTests { let aswift = packageRoot - .appendingPathComponent("Plugins") - .appendingPathComponent("MyPlugin") - .appendingPathComponent("a.swift") + .appending(components: "Plugins", "MyPlugin", "a.swift") _ = try #require(await buildServerManager.initializationData?.indexStorePath) let arguments = try #require( @@ -1081,8 +1040,8 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath - let versionSpecificManifestURL = packageRoot.appendingPathComponent("Package@swift-5.8.swift") + let packageRoot = try tempDir.appending(component: "pkg").realpath + let versionSpecificManifestURL = packageRoot.appending(component: "Package@swift-5.8.swift") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -1115,8 +1074,8 @@ struct SwiftPMBuildServerTests { """, ] ) - let packageRoot = try tempDir.appendingPathComponent("pkg").realpath - let manifestURL = packageRoot.appendingPathComponent("Package.swift") + let packageRoot = try tempDir.appending(component: "pkg").realpath + let manifestURL = packageRoot.appending(component: "Package.swift") let buildServerManager = await BuildServerManager( buildServerSpec: .swiftpmSpec(for: packageRoot), toolchainRegistry: .forTesting, @@ -1179,9 +1138,9 @@ private func buildPath( if let scratchPath = options.scratchPath { URL(fileURLWithPath: scratchPath) } else { - root.appendingPathComponent(".build").appendingPathComponent("index-build") + root.appending(components: ".build", "index-build") } - return buildPath.appendingPathComponent(platform).appendingPathComponent("\(options.configuration ?? .debug)") + return buildPath.appending(components: platform, "\(options.configuration ?? .debug)") } fileprivate extension URL { @@ -1199,7 +1158,7 @@ fileprivate extension BuildServerSpec { return BuildServerSpec( kind: .swiftPM, projectRoot: packageRoot, - configPath: packageRoot.appendingPathComponent("Package.swift") + configPath: packageRoot.appending(component: "Package.swift") ) } } diff --git a/Tests/DiagnoseTests/DiagnoseTests.swift b/Tests/DiagnoseTests/DiagnoseTests.swift index 2650faa17..6fc1aa7df 100644 --- a/Tests/DiagnoseTests/DiagnoseTests.swift +++ b/Tests/DiagnoseTests/DiagnoseTests.swift @@ -161,8 +161,8 @@ final class DiagnoseTests: XCTestCase { func unrelatedB() {} """ - let fileAPath = try scratchDir.appendingPathComponent("a.swift").filePath - let fileBPath = try scratchDir.appendingPathComponent("b.swift").filePath + let fileAPath = try scratchDir.appending(component: "a.swift").filePath + let fileBPath = try scratchDir.appending(component: "b.swift").filePath try fileAContents.write(toFile: fileAPath, atomically: true, encoding: .utf8) try fileBContents.write(toFile: fileBPath, atomically: true, encoding: .utf8) @@ -250,7 +250,7 @@ private func assertReduceSourceKitD( reproducerPredicate(requestResponse as! String) }) ) - let testFilePath = try scratchDir.appendingPathComponent("test.swift").filePath + let testFilePath = try scratchDir.appending(component: "test.swift").filePath try fileContents.write(toFile: testFilePath, atomically: false, encoding: .utf8) let request = @@ -295,8 +295,8 @@ private class InProcessSourceKitRequestExecutor: SourceKitRequestExecutor { self.sourcekitd = try XCTUnwrap(toolchain.sourcekitd) self.swiftFrontend = try XCTUnwrap(toolchain.swiftFrontend) self.reproducerPredicate = reproducerPredicate - temporaryRequestFile = FileManager.default.temporaryDirectory.appendingPathComponent("request-\(UUID()).yml") - temporarySourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduce-\(UUID()).swift") + temporaryRequestFile = FileManager.default.temporaryDirectory.appending(component: "request-\(UUID()).yml") + temporarySourceFile = FileManager.default.temporaryDirectory.appending(component: "reduce-\(UUID()).swift") } deinit { diff --git a/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift b/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift index 7360ae9c6..465f66dac 100644 --- a/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift +++ b/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift @@ -248,8 +248,7 @@ final class BackgroundIndexingTests: XCTestCase { let dependencyUrl = try XCTUnwrap( FileManager.default.findFiles( named: "MyDependency.swift", - in: project.scratchDirectory.appendingPathComponent(".build").appendingPathComponent("index-build") - .appendingPathComponent("checkouts") + in: project.scratchDirectory.appending(components: ".build", "index-build", "checkouts") ).only ) let dependencyUri = DocumentURI(dependencyUrl) @@ -894,8 +893,7 @@ final class BackgroundIndexingTests: XCTestCase { let nestedIndexBuildURL = try XCTUnwrap( project.uri(for: "OtherLib.swift").fileURL? .deletingLastPathComponent() - .appendingPathComponent(".build") - .appendingPathComponent("index-build") + .appending(components: ".build", "index-build") ) XCTAssertFalse( FileManager.default.fileExists(at: nestedIndexBuildURL), @@ -1263,9 +1261,7 @@ final class BackgroundIndexingTests: XCTestCase { """ ]) let dependencySwiftURL = dependencyProject.packageDirectory - .appendingPathComponent("Sources") - .appendingPathComponent("MyDependency") - .appendingPathComponent("Dependency.swift") + .appending(components: "Sources", "MyDependency", "Dependency.swift") defer { dependencyProject.keepAlive() } let project = try await SwiftPMTestProject( @@ -1292,7 +1288,7 @@ final class BackgroundIndexingTests: XCTestCase { """, enableBackgroundIndexing: true ) - let packageResolvedURL = project.scratchDirectory.appendingPathComponent("Package.resolved") + let packageResolvedURL = project.scratchDirectory.appending(component: "Package.resolved") let originalPackageResolvedContents = try String(contentsOf: packageResolvedURL, encoding: .utf8) @@ -1325,7 +1321,7 @@ final class BackgroundIndexingTests: XCTestCase { // Updating Package.swift causes a package reload but should not cause dependencies to be updated. project.testClient.send( DidChangeWatchedFilesNotification(changes: [ - FileEvent(uri: DocumentURI(project.scratchDirectory.appendingPathComponent("Package.swift")), type: .changed) + FileEvent(uri: DocumentURI(project.scratchDirectory.appending(component: "Package.swift")), type: .changed) ]) ) try await project.testClient.send(SynchronizeRequest(index: true)) @@ -1356,7 +1352,7 @@ final class BackgroundIndexingTests: XCTestCase { XCTAssertNotEqual(try String(contentsOf: packageResolvedURL, encoding: .utf8), originalPackageResolvedContents) project.testClient.send( DidChangeWatchedFilesNotification(changes: [ - FileEvent(uri: DocumentURI(project.scratchDirectory.appendingPathComponent("Package.resolved")), type: .changed) + FileEvent(uri: DocumentURI(project.scratchDirectory.appending(component: "Package.resolved")), type: .changed) ]) ) try await project.testClient.send(SynchronizeRequest(index: true)) @@ -1364,9 +1360,7 @@ final class BackgroundIndexingTests: XCTestCase { FileManager.default.findFiles( named: "Dependency.swift", in: project.scratchDirectory - .appendingPathComponent(".build") - .appendingPathComponent("index-build") - .appendingPathComponent("checkouts") + .appending(components: ".build", "index-build", "checkouts") ).only ) // Check that modifying Package.resolved actually modified the dependency checkout inside the package @@ -1400,7 +1394,7 @@ final class BackgroundIndexingTests: XCTestCase { packageInitialized.value = true project.testClient.send( DidChangeWatchedFilesNotification(changes: [ - FileEvent(uri: DocumentURI(project.scratchDirectory.appendingPathComponent("random.swift")), type: .created) + FileEvent(uri: DocumentURI(project.scratchDirectory.appending(component: "random.swift")), type: .created) ]) ) _ = try await project.testClient.send(SynchronizeRequest(index: true)) @@ -1570,12 +1564,10 @@ final class BackgroundIndexingTests: XCTestCase { workspaces: { scratchDirectory in let symlink = scratchDirectory - .appendingPathComponent("Sources") - .appendingPathComponent("MyLibrary") - .appendingPathComponent("symlink.swift") + .appending(components: "Sources", "MyLibrary", "symlink.swift") try FileManager.default.createSymbolicLink( at: symlink, - withDestinationURL: scratchDirectory.appendingPathComponent("original.swift") + withDestinationURL: scratchDirectory.appending(component: "original.swift") ) return [WorkspaceFolder(uri: DocumentURI(scratchDirectory))] }, @@ -1593,13 +1585,11 @@ final class BackgroundIndexingTests: XCTestCase { let symlink = project.scratchDirectory - .appendingPathComponent("Sources") - .appendingPathComponent("MyLibrary") - .appendingPathComponent("symlink.swift") + .appending(components: "Sources", "MyLibrary", "symlink.swift") try FileManager.default.removeItem(at: symlink) try FileManager.default.createSymbolicLink( at: symlink, - withDestinationURL: project.scratchDirectory.appendingPathComponent("updated.swift") + withDestinationURL: project.scratchDirectory.appending(component: "updated.swift") ) project.testClient.send( @@ -1747,10 +1737,10 @@ final class BackgroundIndexingTests: XCTestCase { ) """, workspaces: { scratchDirectory in - let sources = scratchDirectory.appendingPathComponent("Sources") + let sources = scratchDirectory.appending(component: "Sources") try FileManager.default.createSymbolicLink( - at: sources.appendingPathComponent("LibASymlink"), - withDestinationURL: sources.appendingPathComponent("LibA") + at: sources.appending(component: "LibASymlink"), + withDestinationURL: sources.appending(component: "LibA") ) return [WorkspaceFolder(uri: DocumentURI(scratchDirectory))] }, @@ -2091,7 +2081,7 @@ final class BackgroundIndexingTests: XCTestCase { final class BuildServer: CustomBuildServer { let inProgressRequestsTracker = CustomBuildServerInProgressRequestTracker() private let projectRoot: URL - private var testFileURL: URL { projectRoot.appendingPathComponent("Test File.swift") } + private var testFileURL: URL { projectRoot.appending(component: "Test File.swift") } init(projectRoot: URL, connectionToSourceKitLSP: any LanguageServerProtocol.Connection) { self.projectRoot = projectRoot @@ -2100,8 +2090,8 @@ final class BackgroundIndexingTests: XCTestCase { func initializeBuildRequest(_ request: InitializeBuildRequest) async throws -> InitializeBuildResponse { return initializationResponse( initializeData: SourceKitInitializeBuildResponseData( - indexDatabasePath: try projectRoot.appendingPathComponent("index-db").filePath, - indexStorePath: try projectRoot.appendingPathComponent("index-store").filePath, + indexDatabasePath: try projectRoot.appending(component: "index-db").filePath, + indexStorePath: try projectRoot.appending(component: "index-store").filePath, prepareProvider: true, sourceKitOptionsProvider: true ) @@ -2215,7 +2205,7 @@ final class BackgroundIndexingTests: XCTestCase { final class BuildServer: CustomBuildServer { let inProgressRequestsTracker = CustomBuildServerInProgressRequestTracker() private let projectRoot: URL - private var testFileURL: URL { projectRoot.appendingPathComponent("test.c").standardized } + private var testFileURL: URL { projectRoot.appending(component: "test.c").standardized } required init(projectRoot: URL, connectionToSourceKitLSP: any LanguageServerProtocol.Connection) { self.projectRoot = projectRoot @@ -2242,8 +2232,7 @@ final class BackgroundIndexingTests: XCTestCase { } let scratchDirectory = URL(fileURLWithPath: "/tmp") - .appendingPathComponent("sourcekitlsp-test") - .appendingPathComponent(testScratchName()) + .appending(components: "sourcekitlsp-test", testScratchName()) let indexedFiles = ThreadSafeBox<[DocumentURI]>(initialValue: []) let project = try await CustomBuildServerTestProject( files: [ @@ -2290,11 +2279,11 @@ final class BackgroundIndexingTests: XCTestCase { target: libATarget, sources: [ sourceItem( - for: projectRoot.appendingPathComponent("Shared.swift"), + for: projectRoot.appending(component: "Shared.swift"), outputPath: fakeOutputPath(for: "Shared.swift", in: "LibA") ), sourceItem( - for: projectRoot.appendingPathComponent("LibA.swift"), + for: projectRoot.appending(component: "LibA.swift"), outputPath: fakeOutputPath(for: "LibA.swift", in: "LibA") ), ] @@ -2303,11 +2292,11 @@ final class BackgroundIndexingTests: XCTestCase { target: libBTarget, sources: [ sourceItem( - for: projectRoot.appendingPathComponent("Shared.swift"), + for: projectRoot.appending(component: "Shared.swift"), outputPath: fakeOutputPath(for: "Shared.swift", in: "LibB") ), sourceItem( - for: projectRoot.appendingPathComponent("LibB.swift"), + for: projectRoot.appending(component: "LibB.swift"), outputPath: fakeOutputPath(for: "LibB.swift", in: "LibB") ), ] @@ -2407,7 +2396,7 @@ final class BackgroundIndexingTests: XCTestCase { target: libATarget, sources: [ sourceItem( - for: projectRoot.appendingPathComponent("LibA.c"), + for: projectRoot.appending(component: "LibA.c"), outputPath: fakeOutputPath(for: "LibA.c", in: "LibA") ) ] @@ -2416,7 +2405,7 @@ final class BackgroundIndexingTests: XCTestCase { target: libBTarget, sources: [ sourceItem( - for: projectRoot.appendingPathComponent("LibB.c"), + for: projectRoot.appending(component: "LibB.c"), outputPath: fakeOutputPath(for: "LibB.c", in: "LibB") ) ] @@ -2557,7 +2546,7 @@ final class BackgroundIndexingTests: XCTestCase { target: .dummy, sources: [ sourceItem( - for: projectRoot.appendingPathComponent("test.swift"), + for: projectRoot.appending(component: "test.swift"), outputPath: fakeOutputPath(for: "test.swift", in: "dummy") ) ] diff --git a/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift b/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift index f4c5dead8..c3c16290c 100644 --- a/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift +++ b/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift @@ -272,8 +272,8 @@ final class CompilationDatabaseTests: XCTestCase { // Create a dummy swiftly executable that picks the default toolchain for all file unless `fakeToolchain` is in // the source file's path. - let dummySwiftlyExecutableUrl = scratchDirectory.appendingPathComponent("swiftly") - let dummySwiftExecutableUrl = scratchDirectory.appendingPathComponent("swift") + let dummySwiftlyExecutableUrl = scratchDirectory.appending(component: "swiftly") + let dummySwiftExecutableUrl = scratchDirectory.appending(component: "swift") try FileManager.default.createSymbolicLink( at: dummySwiftExecutableUrl, withDestinationURL: dummySwiftlyExecutableUrl diff --git a/Tests/SourceKitLSPTests/DefinitionTests.swift b/Tests/SourceKitLSPTests/DefinitionTests.swift index f87213230..fd3ecfefe 100644 --- a/Tests/SourceKitLSPTests/DefinitionTests.swift +++ b/Tests/SourceKitLSPTests/DefinitionTests.swift @@ -486,7 +486,7 @@ class DefinitionTests: XCTestCase { DocumentURI( definitionUri.fileURL! .deletingLastPathComponent() - .appendingPathComponent("movedDefinition.swift") + .appending(component: "movedDefinition.swift") ) try FileManager.default.moveItem(at: XCTUnwrap(definitionUri.fileURL), to: XCTUnwrap(movedDefinitionUri.fileURL)) @@ -616,7 +616,7 @@ class DefinitionTests: XCTestCase { target: .dummy, sources: [ SourceItem( - uri: DocumentURI(projectRoot.appendingPathComponent("Test.c")), + uri: DocumentURI(projectRoot.appending(component: "Test.c")), kind: .file, generated: false, dataKind: .sourceKit, @@ -628,7 +628,7 @@ class DefinitionTests: XCTestCase { ).encodeToLSPAny() ), SourceItem( - uri: DocumentURI(projectRoot.appendingPathComponent("Test.h")), + uri: DocumentURI(projectRoot.appending(component: "Test.h")), kind: .file, generated: false, dataKind: .sourceKit, diff --git a/Tests/SourceKitLSPTests/DependencyTrackingTests.swift b/Tests/SourceKitLSPTests/DependencyTrackingTests.swift index 767560ddb..f448d3c11 100644 --- a/Tests/SourceKitLSPTests/DependencyTrackingTests.swift +++ b/Tests/SourceKitLSPTests/DependencyTrackingTests.swift @@ -94,7 +94,7 @@ final class DependencyTrackingTests: XCTestCase { ) let generatedHeaderURL = try project.uri(for: "main.c").fileURL!.deletingLastPathComponent() - .appendingPathComponent("lib-generated.h", isDirectory: false) + .appending(component: "lib-generated.h") // Write an empty header file first since clangd doesn't handle missing header // files without a recently upstreamed extension. diff --git a/Tests/SourceKitLSPTests/FormattingTests.swift b/Tests/SourceKitLSPTests/FormattingTests.swift index 806153199..4b252bc44 100644 --- a/Tests/SourceKitLSPTests/FormattingTests.swift +++ b/Tests/SourceKitLSPTests/FormattingTests.swift @@ -313,7 +313,7 @@ final class FormattingTests: XCTestCase { try await withTestScratchDir { scratchDir in let toolchain = try await unwrap(ToolchainRegistry.forTesting.default) - let crashingExecutablePath = scratchDir.appendingPathComponent("crashing-executable") + let crashingExecutablePath = scratchDir.appending(component: "crashing-executable") try await createBinary( """ fatalError() diff --git a/Tests/SourceKitLSPTests/IndexTests.swift b/Tests/SourceKitLSPTests/IndexTests.swift index e0cb79477..42d73fa24 100644 --- a/Tests/SourceKitLSPTests/IndexTests.swift +++ b/Tests/SourceKitLSPTests/IndexTests.swift @@ -128,7 +128,7 @@ final class IndexTests: XCTestCase { XCTAssertEqual(jump.first?.uri, project.fileURI) XCTAssertEqual(jump.first?.range.lowerBound, project.positions["1️⃣"]) - let indexDBURL = project.fileURI.fileURL!.deletingLastPathComponent().appendingPathComponent("IndexDatabase") + let indexDBURL = project.fileURI.fileURL!.deletingLastPathComponent().appending(component: "IndexDatabase") let tmpContents = try listdir(indexDBURL) guard let versionedPath = tmpContents.filter({ $0.lastPathComponent.starts(with: "v") }).only else { XCTFail("expected one version path 'v[0-9]*', found \(tmpContents)") diff --git a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift index b24d60b18..ecabac28a 100644 --- a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift +++ b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift @@ -425,7 +425,7 @@ final class PullDiagnosticsTests: XCTestCase { let project = try await SwiftPMTestProject( files: ["FileA.swift": contents], workspaces: { scratchDirectory in - let symlinkUrl = scratchDirectory.appendingPathComponent("symlink") + let symlinkUrl = scratchDirectory.appending(component: "symlink") try FileManager.default.createSymbolicLink( at: symlinkUrl, withDestinationURL: scratchDirectory @@ -436,10 +436,7 @@ final class PullDiagnosticsTests: XCTestCase { let uri = DocumentURI( project.scratchDirectory - .appendingPathComponent("symlink") - .appendingPathComponent("Sources") - .appendingPathComponent("MyLibrary") - .appendingPathComponent("FileA.swift") + .appending(components: "symlink", "Sources", "MyLibrary", "FileA.swift") ) project.testClient.send( DidOpenTextDocumentNotification( diff --git a/Tests/SourceKitLSPTests/RenameTests.swift b/Tests/SourceKitLSPTests/RenameTests.swift index 82e0bde8d..9935389ac 100644 --- a/Tests/SourceKitLSPTests/RenameTests.swift +++ b/Tests/SourceKitLSPTests/RenameTests.swift @@ -1129,7 +1129,7 @@ final class RenameTests: XCTestCase { DocumentURI( definitionUri.fileURL! .deletingLastPathComponent() - .appendingPathComponent("movedDefinition.swift") + .appending(component: "movedDefinition.swift") ) try FileManager.default.moveItem(at: XCTUnwrap(definitionUri.fileURL), to: XCTUnwrap(movedDefinitionUri.fileURL)) diff --git a/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift b/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift index 2404829ef..e17a5adc3 100644 --- a/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift +++ b/Tests/SourceKitLSPTests/SwiftPMIntegrationTests.swift @@ -112,9 +112,7 @@ final class SwiftPMIntegrationTests: XCTestCase { ) let newFileUrl = project.scratchDirectory - .appendingPathComponent("Sources") - .appendingPathComponent("MyLibrary") - .appendingPathComponent("Other.swift") + .appending(components: "Sources", "MyLibrary", "Other.swift") let newFileUri = DocumentURI(newFileUrl) let newFileContents = """ diff --git a/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift b/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift index 6b9fd2c61..2b1929cdc 100644 --- a/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift +++ b/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift @@ -59,7 +59,7 @@ class WorkspaceSymbolsTests: XCTestCase { """, ], workspaces: { - return [WorkspaceFolder(uri: DocumentURI($0.appendingPathComponent("packageB")))] + return [WorkspaceFolder(uri: DocumentURI($0.appending(component: "packageB")))] }, enableBackgroundIndexing: true ) diff --git a/Tests/SourceKitLSPTests/WorkspaceTests.swift b/Tests/SourceKitLSPTests/WorkspaceTests.swift index f054a48ad..1a813a5d5 100644 --- a/Tests/SourceKitLSPTests/WorkspaceTests.swift +++ b/Tests/SourceKitLSPTests/WorkspaceTests.swift @@ -77,8 +77,8 @@ final class WorkspaceTests: XCTestCase { ], workspaces: { scratchDir in return [ - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageA"))), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageB"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageA"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageB"))), ] }, enableBackgroundIndexing: true @@ -174,14 +174,14 @@ final class WorkspaceTests: XCTestCase { workspaces: { scratchDir in return [ WorkspaceFolder(uri: DocumentURI(scratchDir)), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageA"))), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageB"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageA"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageB"))), ] } ) let bPackageManifestUri = DocumentURI( - project.scratchDirectory.appendingPathComponent("PackageB").appendingPathComponent("Package.swift") + project.scratchDirectory.appending(components: "PackageB", "Package.swift") ) project.testClient.openDocument(SwiftPMTestProject.defaultPackageManifest, uri: bPackageManifestUri) @@ -207,32 +207,30 @@ final class WorkspaceTests: XCTestCase { workspaces: { scratchDir in return [ WorkspaceFolder(uri: DocumentURI(scratchDir)), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageA"))), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageB"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageA"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageB"))), ] } ) let pkgA = DocumentURI( project.scratchDirectory - .appendingPathComponent("PackageA") - .appendingPathComponent("Package.swift") + .appending(components: "PackageA", "Package.swift") ) let pkgB = DocumentURI( project.scratchDirectory - .appendingPathComponent("PackageB") - .appendingPathComponent("Package.swift") + .appending(components: "PackageB", "Package.swift") ) assertEqual( await project.testClient.server.workspaceForDocument(uri: pkgA)?.rootUri, - DocumentURI(project.scratchDirectory.appendingPathComponent("PackageA")) + DocumentURI(project.scratchDirectory.appending(component: "PackageA")) ) assertEqual( await project.testClient.server.workspaceForDocument(uri: pkgB)?.rootUri, - DocumentURI(project.scratchDirectory.appendingPathComponent("PackageB")) + DocumentURI(project.scratchDirectory.appending(component: "PackageB")) ) } @@ -467,8 +465,8 @@ final class WorkspaceTests: XCTestCase { ], workspaces: { scratchDir in return [ - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("WorkspaceA"))), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("WorkspaceB"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "WorkspaceA"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "WorkspaceB"))), ] }, usePullDiagnostics: false @@ -516,8 +514,8 @@ final class WorkspaceTests: XCTestCase { ], workspaces: { scratchDir in return [ - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageA"))), - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("PackageB"))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageA", directoryHint: .isDirectory))), + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "PackageB", directoryHint: .isDirectory))), ] } ) @@ -528,7 +526,7 @@ final class WorkspaceTests: XCTestCase { // yet) will belong to PackageA by default (because it provides fallback build settings for it). assertEqual( await project.testClient.server.workspaceForDocument(uri: mainUri)?.rootUri, - DocumentURI(project.scratchDirectory.appendingPathComponent("PackageA")) + DocumentURI(project.scratchDirectory.appending(component: "PackageA", directoryHint: .isDirectory)) ) // Add the MyExec target to PackageB/Package.swift @@ -547,8 +545,7 @@ final class WorkspaceTests: XCTestCase { """ let packageBManifestPath = project.scratchDirectory - .appendingPathComponent("PackageB") - .appendingPathComponent("Package.swift") + .appending(components: "PackageB", "Package.swift") try await newPackageManifest.writeWithRetry(to: packageBManifestPath) project.testClient.send( @@ -563,7 +560,9 @@ final class WorkspaceTests: XCTestCase { // thus workspace membership should switch to PackageB. // Updating the build settings takes a few seconds. Send code completion requests every second until we receive correct results. - let packageBRootUri = DocumentURI(project.scratchDirectory.appendingPathComponent("PackageB")) + let packageBRootUri = DocumentURI( + project.scratchDirectory.appending(component: "PackageB", directoryHint: .isDirectory) + ) try await repeatUntilExpectedResult { await project.testClient.server.workspaceForDocument(uri: mainUri)?.rootUri == packageBRootUri } @@ -668,7 +667,7 @@ final class WorkspaceTests: XCTestCase { ], workspaces: { scratchDir in return [ - WorkspaceFolder(uri: DocumentURI(scratchDir.appendingPathComponent("fake"))) + WorkspaceFolder(uri: DocumentURI(scratchDir.appending(component: "fake"))) ] } ) @@ -1304,7 +1303,7 @@ final class WorkspaceTests: XCTestCase { // Explicitly create a directory at /tmp (which is a standardized path but whose realpath is /private/tmp) let scratchDirectory = URL(fileURLWithPath: "/tmp") - .appendingPathComponent(testScratchName()) + .appending(component: testScratchName()) try FileManager.default.createDirectory(at: scratchDirectory, withIntermediateDirectories: true) defer { @@ -1343,8 +1342,8 @@ final class WorkspaceTests: XCTestCase { let clangOutput = try await withTimeout(defaultTimeoutDuration) { try await Process.checkNonZeroExit( arguments: [ - clang.filePath, "-index-store-path", scratchDirectory.appendingPathComponent("index").filePath, - scratchDirectory.appendingPathComponent("test.c").filePath, + clang.filePath, "-index-store-path", scratchDirectory.appending(component: "index").filePath, + scratchDirectory.appending(component: "test.c").filePath, "-fsyntax-only", ] ) @@ -1361,7 +1360,7 @@ final class WorkspaceTests: XCTestCase { // path as `/private/tmp` while the build server only knows about it as `/tmp`. let options = try await testClient.send( SourceKitOptionsRequest( - textDocument: TextDocumentIdentifier(scratchDirectory.appendingPathComponent("test.h")), + textDocument: TextDocumentIdentifier(scratchDirectory.appending(component: "test.h")), prepareTarget: false, allowFallbackSettings: false ) diff --git a/Tests/SwiftSourceKitPluginTests/PluginSwiftPMTestProject.swift b/Tests/SwiftSourceKitPluginTests/PluginSwiftPMTestProject.swift index 2315fce0b..00a2d1712 100644 --- a/Tests/SwiftSourceKitPluginTests/PluginSwiftPMTestProject.swift +++ b/Tests/SwiftSourceKitPluginTests/PluginSwiftPMTestProject.swift @@ -36,7 +36,7 @@ final class PluginSwiftPMTestProject { buildServerSpec: BuildServerSpec( kind: .swiftPM, projectRoot: scratchDirectory, - configPath: scratchDirectory.appendingPathComponent("Package.swift") + configPath: scratchDirectory.appending(component: "Package.swift") ), toolchainRegistry: .forTesting, options: try .testDefault(backgroundIndexing: false), diff --git a/Tests/TSCExtensionsTests/ProcessRunTests.swift b/Tests/TSCExtensionsTests/ProcessRunTests.swift index 92bc4b004..48ffe622a 100644 --- a/Tests/TSCExtensionsTests/ProcessRunTests.swift +++ b/Tests/TSCExtensionsTests/ProcessRunTests.swift @@ -21,7 +21,7 @@ import class TSCBasic.Process final class ProcessRunTests: XCTestCase { func testWorkingDirectory() async throws { try await withTestScratchDir { tempDir in - let workingDir = tempDir.appendingPathComponent("working-dir") + let workingDir = tempDir.appending(component: "working-dir") try FileManager.default.createDirectory(at: workingDir, withIntermediateDirectories: true) #if os(Windows) @@ -32,7 +32,7 @@ final class ProcessRunTests: XCTestCase { #endif let python = try await unwrap(findTool(name: pythonName)) - let pythonFile = tempDir.appendingPathComponent("show-cwd.py") + let pythonFile = tempDir.appending(component: "show-cwd.py") try """ import os print(os.getcwd(), end='') diff --git a/Tests/ToolchainRegistryTests/ToolchainRegistryTests.swift b/Tests/ToolchainRegistryTests/ToolchainRegistryTests.swift index 60c4bf10c..32d9b452a 100644 --- a/Tests/ToolchainRegistryTests/ToolchainRegistryTests.swift +++ b/Tests/ToolchainRegistryTests/ToolchainRegistryTests.swift @@ -46,13 +46,12 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + .appending(components: "Xcode.app", "Developer") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") try makeXCToolchain( identifier: ToolchainRegistry.darwinDefaultToolchainIdentifier, opensource: false, - path: toolchains.appendingPathComponent("XcodeDefault.xctoolchain"), + path: toolchains.appending(component: "XcodeDefault.xctoolchain"), sourcekitd: true ) @@ -69,7 +68,7 @@ final class ToolchainRegistryTests: XCTestCase { assertEqual(await tr.default?.identifier, ToolchainRegistry.darwinDefaultToolchainIdentifier) assertEqual( await tr.default?.path, - toolchains.appendingPathComponent("XcodeDefault.xctoolchain", isDirectory: true) + toolchains.appending(component: "XcodeDefault.xctoolchain", directoryHint: .isDirectory) ) assertNotNil(await tr.default?.sourcekitd) @@ -83,20 +82,19 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + .appending(components: "Xcode.app", "Developer") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") try makeXCToolchain( identifier: "com.apple.fake.A", opensource: false, - path: toolchains.appendingPathComponent("A.xctoolchain"), + path: toolchains.appending(component: "A.xctoolchain"), sourcekitd: true ) try makeXCToolchain( identifier: "com.apple.fake.B", opensource: false, - path: toolchains.appendingPathComponent("B.xctoolchain"), + path: toolchains.appending(component: "B.xctoolchain"), sourcekitd: true ) @@ -119,20 +117,19 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + .appending(components: "Xcode.app", "Developer") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") try makeXCToolchain( identifier: "com.apple.fake.C", opensource: false, - path: toolchains.appendingPathComponent("C.wrong_extension"), + path: toolchains.appending(component: "C.wrong_extension"), sourcekitd: true ) try makeXCToolchain( identifier: "com.apple.fake.D", opensource: false, - path: toolchains.appendingPathComponent("D_no_extension"), + path: toolchains.appending(component: "D_no_extension"), sourcekitd: true ) @@ -155,21 +152,20 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") + .appending(components: "Xcode.app", "Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") try makeXCToolchain( identifier: "com.apple.fake.A", opensource: false, - path: toolchains.appendingPathComponent("A.xctoolchain"), + path: toolchains.appending(component: "A.xctoolchain"), sourcekitd: true ) try makeXCToolchain( identifier: "com.apple.fake.A", opensource: false, - path: toolchains.appendingPathComponent("E.xctoolchain"), + path: toolchains.appending(component: "E.xctoolchain"), sourcekitd: true ) @@ -189,15 +185,13 @@ final class ToolchainRegistryTests: XCTestCase { func testGloballyInstalledToolchains() async throws { try SkipUnless.platformIsDarwin("Finding toolchains in Xcode is only supported on macOS") try await withTestScratchDir { tempDir in - let libraryDir = tempDir.appendingPathComponent("Library") + let libraryDir = tempDir.appending(component: "Library") try makeXCToolchain( identifier: "org.fake.global.A", opensource: true, path: libraryDir - .appendingPathComponent("Developer") - .appendingPathComponent("Toolchains") - .appendingPathComponent("A.xctoolchain"), + .appending(components: "Developer", "Toolchains", "A.xctoolchain"), sourcekitd: true ) @@ -219,12 +213,11 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") + .appending(components: "Xcode.app", "Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") - let path = toolchains.appendingPathComponent("Explicit.xctoolchain", isDirectory: true) + let path = toolchains.appending(component: "Explicit.xctoolchain", directoryHint: .isDirectory) try makeXCToolchain( identifier: "org.fake.explicit", opensource: false, @@ -233,7 +226,7 @@ final class ToolchainRegistryTests: XCTestCase { ) let trInstall = ToolchainRegistry( - installPath: path.appendingPathComponent("usr").appendingPathComponent("bin"), + installPath: path.appending(components: "usr", "bin"), environmentVariables: [], xcodes: [], libraryDirectories: [], @@ -251,21 +244,20 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") + .appending(components: "Xcode.app", "Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") try makeXCToolchain( identifier: ToolchainRegistry.darwinDefaultToolchainIdentifier, opensource: false, - path: toolchains.appendingPathComponent("XcodeDefault.xctoolchain"), + path: toolchains.appending(component: "XcodeDefault.xctoolchain"), sourcekitd: true ) try makeXCToolchain( identifier: "org.fake.global.A", opensource: false, - path: toolchains.appendingPathComponent("A.xctoolchain"), + path: toolchains.appending(component: "A.xctoolchain"), sourcekitd: true ) @@ -299,11 +291,10 @@ final class ToolchainRegistryTests: XCTestCase { try await withTestScratchDir { tempDir in let xcodeDeveloper = tempDir - .appendingPathComponent("Xcode.app") - .appendingPathComponent("Developer") - let toolchains = xcodeDeveloper.appendingPathComponent("Toolchains") + .appending(components: "Xcode.app", "Developer") + let toolchains = xcodeDeveloper.appending(component: "Toolchains") - let path = toolchains.appendingPathComponent("Explicit.xctoolchain", isDirectory: true) + let path = toolchains.appending(component: "Explicit.xctoolchain", directoryHint: .isDirectory) try makeXCToolchain( identifier: "org.fake.explicit", opensource: false, @@ -315,7 +306,7 @@ final class ToolchainRegistryTests: XCTestCase { XCTAssertNotNil(tc) XCTAssertEqual(tc?.identifier, "org.fake.explicit") - let tcBin = Toolchain(path.appendingPathComponent("usr").appendingPathComponent("bin")) + let tcBin = Toolchain(path.appending(components: "usr", "bin")) XCTAssertNotNil(tcBin) XCTAssertEqual(tc?.identifier, tcBin?.identifier) XCTAssertEqual(tc?.path, tcBin?.path) @@ -378,7 +369,7 @@ final class ToolchainRegistryTests: XCTestCase { func testSearchExplicitEnvBuiltin() async throws { try await withTestScratchDir { tempDir in - let binPath = tempDir.appendingPathComponent("bin", isDirectory: true) + let binPath = tempDir.appending(component: "bin", directoryHint: .isDirectory) try makeToolchain(binPath: binPath, sourcekitd: true) try ProcessEnv.setVar("TEST_SOURCEKIT_TOOLCHAIN_PATH_1", value: binPath.deletingLastPathComponent().filePath) @@ -409,7 +400,7 @@ final class ToolchainRegistryTests: XCTestCase { func testSearchExplicitEnv() async throws { try await withTestScratchDir { tempDir in - let binPath = tempDir.appendingPathComponent("bin", isDirectory: true) + let binPath = tempDir.appending(component: "bin", directoryHint: .isDirectory) try makeToolchain(binPath: binPath, sourcekitd: true) try ProcessEnv.setVar("TEST_ENV_SOURCEKIT_TOOLCHAIN_PATH_2", value: binPath.deletingLastPathComponent().filePath) @@ -439,9 +430,9 @@ final class ToolchainRegistryTests: XCTestCase { func testFromDirectory() async throws { try await withTestScratchDir { tempDir in - let path = tempDir.appendingPathComponent("A.xctoolchain").appendingPathComponent("usr") + let path = tempDir.appending(components: "A.xctoolchain", "usr") try makeToolchain( - binPath: path.appendingPathComponent("bin"), + binPath: path.appending(component: "bin"), clang: true, clangd: true, swiftc: true, @@ -449,7 +440,7 @@ final class ToolchainRegistryTests: XCTestCase { sourcekitd: true ) - try Data().write(to: path.appendingPathComponent("bin").appendingPathComponent("other")) + try Data().write(to: path.appending(components: "bin", "other")) let t1 = try XCTUnwrap(Toolchain(path.deletingLastPathComponent())) XCTAssertNotNil(t1.sourcekitd) @@ -470,10 +461,10 @@ final class ToolchainRegistryTests: XCTestCase { XCTAssertEqual(chmod(try path.filePath, S_IRUSR | S_IXUSR), 0) } - try chmodRX(path.appendingPathComponent("bin").appendingPathComponent("clang")) - try chmodRX(path.appendingPathComponent("bin").appendingPathComponent("clangd")) - try chmodRX(path.appendingPathComponent("bin").appendingPathComponent("swiftc")) - try chmodRX(path.appendingPathComponent("bin").appendingPathComponent("other")) + try chmodRX(path.appending(components: "bin", "clang")) + try chmodRX(path.appending(components: "bin", "clangd")) + try chmodRX(path.appending(components: "bin", "swiftc")) + try chmodRX(path.appending(components: "bin", "other")) #endif let t2 = try XCTUnwrap(Toolchain(path.deletingLastPathComponent())) @@ -493,7 +484,7 @@ final class ToolchainRegistryTests: XCTestCase { func testDylibNames() async throws { try await withTestScratchDir { tempDir in - let binPath = tempDir.appendingPathComponent("bin", isDirectory: true) + let binPath = tempDir.appending(component: "bin", directoryHint: .isDirectory) try makeToolchain(binPath: binPath, sourcekitdInProc: true, libIndexStore: true) guard let t = Toolchain(binPath) else { XCTFail("could not find any tools") @@ -506,30 +497,28 @@ final class ToolchainRegistryTests: XCTestCase { func testSubDirs() async throws { try await withTestScratchDir { tempDir in - try makeToolchain(binPath: tempDir.appendingPathComponent("t1").appendingPathComponent("bin"), sourcekitd: true) + try makeToolchain(binPath: tempDir.appending(components: "t1", "bin"), sourcekitd: true) try makeToolchain( - binPath: tempDir.appendingPathComponent("t2").appendingPathComponent("usr").appendingPathComponent("bin"), + binPath: tempDir.appending(components: "t2", "usr", "bin"), sourcekitd: true ) - XCTAssertNotNil(Toolchain(tempDir.appendingPathComponent("t1"))) - XCTAssertNotNil(Toolchain(tempDir.appendingPathComponent("t1").appendingPathComponent("bin"))) - XCTAssertNotNil(Toolchain(tempDir.appendingPathComponent("t2"))) + XCTAssertNotNil(Toolchain(tempDir.appending(component: "t1"))) + XCTAssertNotNil(Toolchain(tempDir.appending(components: "t1", "bin"))) + XCTAssertNotNil(Toolchain(tempDir.appending(component: "t2"))) - XCTAssertNil(Toolchain(tempDir.appendingPathComponent("t3"))) + XCTAssertNil(Toolchain(tempDir.appending(component: "t3"))) try FileManager.default.createDirectory( - at: tempDir.appendingPathComponent("t3").appendingPathComponent("bin"), + at: tempDir.appending(components: "t3", "bin"), withIntermediateDirectories: true ) try FileManager.default.createDirectory( - at: tempDir.appendingPathComponent("t3").appendingPathComponent("lib").appendingPathComponent( - "sourcekitd.framework" - ), + at: tempDir.appending(components: "t3", "lib", "sourcekitd.framework"), withIntermediateDirectories: true ) - XCTAssertNil(Toolchain(tempDir.appendingPathComponent("t3"))) - try makeToolchain(binPath: tempDir.appendingPathComponent("t3").appendingPathComponent("bin"), sourcekitd: true) - XCTAssertNotNil(Toolchain(tempDir.appendingPathComponent("t3"))) + XCTAssertNil(Toolchain(tempDir.appending(component: "t3"))) + try makeToolchain(binPath: tempDir.appending(components: "t3", "bin"), sourcekitd: true) + XCTAssertNotNil(Toolchain(tempDir.appending(component: "t3"))) } } @@ -576,7 +565,7 @@ final class ToolchainRegistryTests: XCTestCase { func testInstallPath() async throws { try await withTestScratchDir { tempDir in - let binPath = tempDir.appendingPathComponent("t1").appendingPathComponent("bin", isDirectory: true) + let binPath = tempDir.appending(components: "t1", "bin", directoryHint: .isDirectory) try makeToolchain(binPath: binPath, sourcekitd: true) let trEmpty = ToolchainRegistry( @@ -601,7 +590,7 @@ final class ToolchainRegistryTests: XCTestCase { await assertNotNil(tr1.default?.sourcekitd) let tr2 = ToolchainRegistry( - installPath: tempDir.appendingPathComponent("t2").appendingPathComponent("bin", isDirectory: true), + installPath: tempDir.appending(components: "t2", "bin", directoryHint: .isDirectory), environmentVariables: [], xcodes: [], libraryDirectories: [], @@ -614,8 +603,8 @@ final class ToolchainRegistryTests: XCTestCase { func testInstallPathVsEnv() async throws { try await withTestScratchDir { tempDir in - let t1Bin = tempDir.appendingPathComponent("t1").appendingPathComponent("bin", isDirectory: true) - let t2Bin = tempDir.appendingPathComponent("t2").appendingPathComponent("bin", isDirectory: true) + let t1Bin = tempDir.appending(components: "t1", "bin", directoryHint: .isDirectory) + let t2Bin = tempDir.appending(components: "t2", "bin", directoryHint: .isDirectory) try makeToolchain(binPath: t1Bin, sourcekitd: true) try makeToolchain(binPath: t2Bin, sourcekitd: true) @@ -638,22 +627,21 @@ final class ToolchainRegistryTests: XCTestCase { func testSupersetToolchains() async throws { try await withTestScratchDir { tempDir in - let usrLocal = tempDir.appendingPathComponent("usr").appendingPathComponent("local") - let usr = tempDir.appendingPathComponent("usr") + let usrLocal = tempDir.appending(components: "usr", "local") + let usr = tempDir.appending(component: "usr") let onlySwiftcToolchain = Toolchain( identifier: "onlySwiftc", displayName: "onlySwiftc", path: usrLocal, - swiftc: usrLocal.appendingPathComponent("bin").appendingPathComponent("swiftc") + swiftc: usrLocal.appending(components: "bin", "swiftc") ) let swiftcAndSourcekitdToolchain = Toolchain( identifier: "swiftcAndSourcekitd", displayName: "swiftcAndSourcekitd", path: usr, - swiftc: usr.appendingPathComponent("bin").appendingPathComponent("swiftc"), - sourcekitd: usrLocal.appendingPathComponent("lib").appendingPathComponent("sourcekitd.framework") - .appendingPathComponent("sourcekitd") + swiftc: usr.appending(components: "bin", "swiftc"), + sourcekitd: usrLocal.appending(components: "lib", "sourcekitd.framework", "sourcekitd") ) let tr = ToolchainRegistry(toolchains: [onlySwiftcToolchain, swiftcAndSourcekitdToolchain]) @@ -675,14 +663,14 @@ private func makeXCToolchain( libIndexStore: Bool = false ) throws { try FileManager.default.createDirectory(at: path, withIntermediateDirectories: true) - let infoPlistPath = path.appendingPathComponent(opensource ? "Info.plist" : "ToolchainInfo.plist") + let infoPlistPath = path.appending(component: opensource ? "Info.plist" : "ToolchainInfo.plist") let infoPlist = try PropertyListEncoder().encode( XCToolchainPlist(identifier: identifier, displayName: "name-\(identifier)") ) try infoPlist.write(to: infoPlistPath) try makeToolchain( - binPath: path.appendingPathComponent("usr").appendingPathComponent("bin"), + binPath: path.appending(components: "usr", "bin"), clang: clang, clangd: clangd, swiftc: swiftc, @@ -716,7 +704,7 @@ private func makeToolchain( 0x02, ] - let libPath = binPath.deletingLastPathComponent().appendingPathComponent("lib") + let libPath = binPath.deletingLastPathComponent().appending(component: "lib") try FileManager.default.createDirectory(at: binPath, withIntermediateDirectories: true) try FileManager.default.createDirectory(at: libPath, withIntermediateDirectories: true) @@ -732,37 +720,37 @@ private func makeToolchain( let execExt = Platform.current?.executableExtension ?? "" if clang { - try makeExec(binPath.appendingPathComponent("clang\(execExt)")) + try makeExec(binPath.appending(component: "clang\(execExt)")) } if clangd { - try makeExec(binPath.appendingPathComponent("clangd\(execExt)")) + try makeExec(binPath.appending(component: "clangd\(execExt)")) } if swiftc { - try makeExec(binPath.appendingPathComponent("swiftc\(execExt)")) + try makeExec(binPath.appending(component: "swiftc\(execExt)")) } let dylibSuffix = Platform.current?.dynamicLibraryExtension ?? ".so" if sourcekitd { try FileManager.default.createDirectory( - at: libPath.appendingPathComponent("sourcekitd.framework"), + at: libPath.appending(component: "sourcekitd.framework"), withIntermediateDirectories: true ) - try Data().write(to: libPath.appendingPathComponent("sourcekitd.framework").appendingPathComponent("sourcekitd")) + try Data().write(to: libPath.appending(components: "sourcekitd.framework", "sourcekitd")) } if sourcekitdInProc { #if os(Windows) - try Data().write(to: binPath.appendingPathComponent("sourcekitdInProc\(dylibSuffix)")) + try Data().write(to: binPath.appending(component: "sourcekitdInProc\(dylibSuffix)")) #else - try Data().write(to: libPath.appendingPathComponent("libsourcekitdInProc\(dylibSuffix)")) + try Data().write(to: libPath.appending(component: "libsourcekitdInProc\(dylibSuffix)")) #endif } if libIndexStore { #if os(Windows) // Windows has a prefix of `lib` on this particular library ... - try Data().write(to: binPath.appendingPathComponent("libIndexStore\(dylibSuffix)")) + try Data().write(to: binPath.appending(component: "libIndexStore\(dylibSuffix)")) #else - try Data().write(to: libPath.appendingPathComponent("libIndexStore\(dylibSuffix)")) + try Data().write(to: libPath.appending(component: "libIndexStore\(dylibSuffix)")) #endif } }