From f8c9c8c300c27f5da00b1a5380829558a2b2a4ca Mon Sep 17 00:00:00 2001 From: Mirza Garibovic Date: Thu, 7 Aug 2025 16:51:25 -0700 Subject: [PATCH] Dependencies: make xcconfig fix-its multi-line --- Sources/SWBCore/Dependencies.swift | 6 +++--- Tests/SWBBuildSystemTests/DependencyValidationTests.swift | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/SWBCore/Dependencies.swift b/Sources/SWBCore/Dependencies.swift index 0675792a..46c5a817 100644 --- a/Sources/SWBCore/Dependencies.swift +++ b/Sources/SWBCore/Dependencies.swift @@ -220,14 +220,14 @@ public struct ModuleDependenciesContext: Sendable, SerializableCodable { } func makeFixIt(newModules: [ModuleDependency]) -> Diagnostic.FixIt { - let stringValue = newModules.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().joined(separator: " ") + let stringValue = newModules.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().map { " \\\n \($0)" }.joined(separator: "") let newText: String switch modificationStyle { case .appendToExistingAssignment: - newText = " \(stringValue)" + newText = stringValue case .insertNewAssignment(let targetNameCondition): let targetCondition = targetNameCondition.map { "[target=\($0)]" } ?? "" - newText = "\n\(BuiltinMacros.MODULE_DEPENDENCIES.name)\(targetCondition) = $(inherited) \(stringValue)\n" + newText = "\n\(BuiltinMacros.MODULE_DEPENDENCIES.name)\(targetCondition) = $(inherited)\(stringValue)\n" } return Diagnostic.FixIt(sourceRange: sourceRange, newText: newText) diff --git a/Tests/SWBBuildSystemTests/DependencyValidationTests.swift b/Tests/SWBBuildSystemTests/DependencyValidationTests.swift index 3fd4b2cd..d3542310 100644 --- a/Tests/SWBBuildSystemTests/DependencyValidationTests.swift +++ b/Tests/SWBBuildSystemTests/DependencyValidationTests.swift @@ -421,7 +421,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests { fixIts: [ Diagnostic.FixIt( sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: 1, startColumn: 47, endLine: 1, endColumn: 47), - newText: " Foundation"), + newText: " \\\n Foundation"), ], childDiagnostics: [ Diagnostic( @@ -430,7 +430,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests { data: DiagnosticData("Missing entry in MODULE_DEPENDENCIES: Foundation"), fixIts: [Diagnostic.FixIt( sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: 1, startColumn: 47, endLine: 1, endColumn: 47), - newText: " Foundation")], + newText: " \\\n Foundation")], ), ]), ], @@ -442,7 +442,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests { fixIts: [ Diagnostic.FixIt( sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: .max, startColumn: .max, endLine: .max, endColumn: .max), - newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) Foundation\n"), + newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\\n Foundation\n"), ], childDiagnostics: [ Diagnostic( @@ -451,7 +451,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests { data: DiagnosticData("Missing entry in MODULE_DEPENDENCIES: Foundation"), fixIts: [Diagnostic.FixIt( sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: .max, startColumn: .max, endLine: .max, endColumn: .max), - newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) Foundation\n")], + newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\\n Foundation\n")], ), ]), ],