Skip to content

Commit 12e0db3

Browse files
committed
Add spacing between first and second parameter name
1 parent ac4f8f3 commit 12e0db3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ public let DECL_NODES: [Node] = [
809809
// name to avoid backtracking.
810810
Child(
811811
name: "SecondName",
812-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")]),
812+
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")], requiresLeadingSpace: true),
813813
nameForDiagnostics: "internal name",
814814
isOptional: true
815815
),

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ open class BasicFormat: SyntaxRewriter {
170170
switch keyPath {
171171
case \AvailabilityArgumentSyntax.entry:
172172
return false
173+
case \FunctionParameterSyntax.secondName:
174+
return true
173175
default:
174176
return nil
175177
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import XCTest
14+
import SwiftSyntax
15+
import SwiftSyntaxBuilder
16+
17+
final class FunctionParameterSyntaxTests: XCTestCase {
18+
func testFunctionParameterSyntaxSpacing() {
19+
let builder = FunctionParameterSyntax(firstName: "on", secondName: "eventLoop", colon: .colonToken(), type: TypeSyntax("EventLoop"))
20+
assertBuildResult(builder,
21+
"""
22+
on eventLoop: EventLoop
23+
""")
24+
}
25+
}

0 commit comments

Comments
 (0)