From 4438e8816a71125bbfb60832d8056003270d8f7f Mon Sep 17 00:00:00 2001 From: Kim de Vos Date: Sun, 9 Apr 2023 19:56:12 +0200 Subject: [PATCH] Add spacing between first and second parameter name --- .../Sources/SyntaxSupport/DeclNodes.swift | 2 +- .../generated/BasicFormat.swift | 2 ++ .../FunctionParameterSyntaxTests.swift | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Tests/SwiftSyntaxBuilderTest/FunctionParameterSyntaxTests.swift diff --git a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift index 6aef6e887b5..96911aab784 100644 --- a/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift @@ -809,7 +809,7 @@ public let DECL_NODES: [Node] = [ // name to avoid backtracking. Child( name: "SecondName", - kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")]), + kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")], requiresLeadingSpace: true), nameForDiagnostics: "internal name", isOptional: true ), diff --git a/Sources/SwiftBasicFormat/generated/BasicFormat.swift b/Sources/SwiftBasicFormat/generated/BasicFormat.swift index b0a446d8bac..8eef6f259d6 100644 --- a/Sources/SwiftBasicFormat/generated/BasicFormat.swift +++ b/Sources/SwiftBasicFormat/generated/BasicFormat.swift @@ -170,6 +170,8 @@ open class BasicFormat: SyntaxRewriter { switch keyPath { case \AvailabilityArgumentSyntax.entry: return false + case \FunctionParameterSyntax.secondName: + return true default: return nil } diff --git a/Tests/SwiftSyntaxBuilderTest/FunctionParameterSyntaxTests.swift b/Tests/SwiftSyntaxBuilderTest/FunctionParameterSyntaxTests.swift new file mode 100644 index 00000000000..1cd98a3149b --- /dev/null +++ b/Tests/SwiftSyntaxBuilderTest/FunctionParameterSyntaxTests.swift @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import XCTest +import SwiftSyntax +import SwiftSyntaxBuilder + +final class FunctionParameterSyntaxTests: XCTestCase { + func testFunctionParameterSyntaxSpacing() { + let builder = FunctionParameterSyntax(firstName: "on", secondName: "eventLoop", type: TypeSyntax("EventLoop")) + assertBuildResult( + builder, + """ + on eventLoop: EventLoop + """ + ) + } +}