Skip to content

Commit b5a4d60

Browse files
committed
Mark TupleTypeElementLists as indented
1 parent 3c8827d commit b5a4d60

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

CodeGeneration/Sources/SyntaxSupport/gyb_generated/TypeNodes.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ public let TYPE_NODES: [Node] = [
300300
]),
301301
Child(name: "Elements",
302302
kind: "TupleTypeElementList",
303-
collectionElementName: "Element"),
303+
collectionElementName: "Element",
304+
isIndented: true),
304305
Child(name: "RightParen",
305306
kind: "RightParenToken",
306307
tokenChoices: [
@@ -322,7 +323,8 @@ public let TYPE_NODES: [Node] = [
322323
]),
323324
Child(name: "Arguments",
324325
kind: "TupleTypeElementList",
325-
collectionElementName: "Argument"),
326+
collectionElementName: "Argument",
327+
isIndented: true),
326328
Child(name: "RightParen",
327329
kind: "RightParenToken",
328330
tokenChoices: [

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ open class BasicFormat: SyntaxRewriter {
7878
return true
7979
case \FunctionCallExprSyntax.argumentList:
8080
return true
81+
case \FunctionTypeSyntax.arguments:
82+
return true
8183
case \MemberDeclBlockSyntax.members:
8284
return true
8385
case \ParameterClauseSyntax.parameterList:
@@ -86,6 +88,8 @@ open class BasicFormat: SyntaxRewriter {
8688
return true
8789
case \TupleExprSyntax.elementList:
8890
return true
91+
case \TupleTypeSyntax.elements:
92+
return true
8993
default:
9094
return false
9195
}

Tests/SwiftSyntaxBuilderTest/TupleTests.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class TupleTests: XCTestCase {
2323
AssertBuildResult(builder, "(p1: value1, p2: value2, p3: value3)")
2424
}
2525

26-
func testMultilineElementList() {
26+
func testMultilineTupleExpr() {
2727
let builder = TupleExprSyntax("""
2828
(
2929
p1: value1,
@@ -46,4 +46,28 @@ final class TupleTests: XCTestCase {
4646
)
4747
""")
4848
}
49+
50+
func testMultilineTupleType() {
51+
let builder = TupleTypeSyntax("""
52+
(
53+
Int,
54+
p2: Int,
55+
Int,
56+
p4: Int,
57+
Int
58+
)
59+
""")
60+
61+
print(builder.formatted().description)
62+
63+
AssertBuildResult(builder, """
64+
(
65+
Int,
66+
p2: Int,
67+
Int,
68+
p4: Int,
69+
Int
70+
)
71+
""")
72+
}
4973
}

gyb_syntax_support/TypeNodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
children=[
171171
Child('LeftParen', kind='LeftParenToken'),
172172
Child('Elements', kind='TupleTypeElementList',
173-
collection_element_name='Element'),
173+
collection_element_name='Element', is_indented=True),
174174
Child('RightParen', kind='RightParenToken'),
175175
]),
176176

@@ -182,7 +182,7 @@
182182
children=[
183183
Child('LeftParen', kind='LeftParenToken'),
184184
Child('Arguments', kind='TupleTypeElementList',
185-
collection_element_name='Argument'),
185+
collection_element_name='Argument', is_indented=True),
186186
Child('RightParen', kind='RightParenToken'),
187187
Child('AsyncKeyword', kind='ContextualKeyworkToken',
188188
text_choices=['async'], is_optional=True),

0 commit comments

Comments
 (0)