Skip to content

Commit bc876fe

Browse files
Dependencies: make xcconfig fix-its multi-line
1 parent afc6b35 commit bc876fe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/SWBCore/Dependencies.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ public struct ModuleDependenciesContext: Sendable, SerializableCodable {
192192
}
193193

194194
func makeFixIt(newModules: [ModuleDependency]) -> Diagnostic.FixIt {
195-
let stringValue = newModules.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().joined(separator: " ")
195+
let stringValue = newModules.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().map { " \\\n \($0)" }.joined(separator: "")
196196
let newText: String
197197
switch modificationStyle {
198198
case .appendToExistingAssignment:
199-
newText = " \(stringValue)"
199+
newText = stringValue
200200
case .insertNewAssignment(let targetNameCondition):
201201
let targetCondition = targetNameCondition.map { "[target=\($0)]" } ?? ""
202-
newText = "\n\(BuiltinMacros.MODULE_DEPENDENCIES.name)\(targetCondition) = $(inherited) \(stringValue)\n"
202+
newText = "\n\(BuiltinMacros.MODULE_DEPENDENCIES.name)\(targetCondition) = $(inherited)\(stringValue)\n"
203203
}
204204

205205
return Diagnostic.FixIt(sourceRange: sourceRange, newText: newText)

Tests/SWBBuildSystemTests/DependencyValidationTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
421421
fixIts: [
422422
Diagnostic.FixIt(
423423
sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: 1, startColumn: 47, endLine: 1, endColumn: 47),
424-
newText: " Foundation"),
424+
newText: " \\\n Foundation"),
425425
],
426426
childDiagnostics: [
427427
Diagnostic(
@@ -430,7 +430,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
430430
data: DiagnosticData("Missing entry in MODULE_DEPENDENCIES: Foundation"),
431431
fixIts: [Diagnostic.FixIt(
432432
sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: 1, startColumn: 47, endLine: 1, endColumn: 47),
433-
newText: " Foundation")],
433+
newText: " \\\n Foundation")],
434434
),
435435
]),
436436
],
@@ -442,7 +442,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
442442
fixIts: [
443443
Diagnostic.FixIt(
444444
sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: .max, startColumn: .max, endLine: .max, endColumn: .max),
445-
newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) Foundation\n"),
445+
newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\\n Foundation\n"),
446446
],
447447
childDiagnostics: [
448448
Diagnostic(
@@ -451,7 +451,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
451451
data: DiagnosticData("Missing entry in MODULE_DEPENDENCIES: Foundation"),
452452
fixIts: [Diagnostic.FixIt(
453453
sourceRange: Diagnostic.SourceRange(path: projectXCConfigPath, startLine: .max, startColumn: .max, endLine: .max, endColumn: .max),
454-
newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) Foundation\n")],
454+
newText: "\nMODULE_DEPENDENCIES[target=TargetB] = $(inherited) \\\n Foundation\n")],
455455
),
456456
]),
457457
],

0 commit comments

Comments
 (0)