diff --git a/Sources/SafeDICore/Models/Initializer.swift b/Sources/SafeDICore/Models/Initializer.swift index 9606265b..4c4272f6 100644 --- a/Sources/SafeDICore/Models/Initializer.swift +++ b/Sources/SafeDICore/Models/Initializer.swift @@ -143,7 +143,16 @@ public struct Initializer: Codable, Hashable, Sendable { signature: FunctionSignatureSyntax( parameterClause: FunctionParameterClauseSyntax( parameters: FunctionParameterListSyntax(itemsBuilder: { - for functionParameter in dependencies.initializerFunctionParameters { + for functionParameter in dependencies.initializerFunctionParameters.enumerated().map({ index, parameter in + var parameter = parameter + if dependencies.initializerFunctionParameters.endIndex > 1 { + if index == 0 { + parameter.leadingTrivia = .newline + } + parameter.trailingTrivia = .newline + } + return parameter + }) { functionParameter } }) diff --git a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift index 97c83065..fa7d9de9 100644 --- a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift +++ b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift @@ -1218,7 +1218,11 @@ import SafeDICore """ @Instantiable public struct ExampleService: Instantiable { - public init(forwardedA: ForwardedA, receivedA: ReceivedA, receivedB: ReceivedB) { + public init( + forwardedA: ForwardedA, + receivedA: ReceivedA, + receivedB: ReceivedB + ) { self.forwardedA = forwardedA self.receivedA = receivedA self.receivedB = receivedB @@ -1241,7 +1245,11 @@ import SafeDICore } expansion: { """ public struct ExampleService: Instantiable { - public init(forwardedA: ForwardedA, receivedA: ReceivedA, receivedB: ReceivedB) { + public init( + forwardedA: ForwardedA, + receivedA: ReceivedA, + receivedB: ReceivedB + ) { self.forwardedA = forwardedA self.receivedA = receivedA self.receivedB = receivedB @@ -1291,7 +1299,10 @@ import SafeDICore """ @Instantiable public final class UserService: Instantiable { - public init(userID: String, userName: String) { + public init( + userID: String, + userName: String + ) { self.userID = userID self.userName = userName } @@ -1306,7 +1317,10 @@ import SafeDICore } expansion: { """ public final class UserService: Instantiable { - public init(userID: String, userName: String) { + public init( + userID: String, + userName: String + ) { self.userID = userID self.userName = userName }