Skip to content

Commit 332eb9a

Browse files
committed
Reduce line-length to 160 characters
I played around withs some maximum line lengths and 160 seems to strike a good balance of prohibiting excessivly long lines while not forcing line wraps on lines that are more clearly represented on a single line.
1 parent 547ab8c commit 332eb9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+395
-98
lines changed

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"lineLength": 1000,
3+
"lineLength": 160,
44
"indentation": {
55
"spaces": 2
66
},

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ public let ATTRIBUTE_NODES: [Node] = [
298298
children: [
299299
Child(
300300
name: "DeclBaseName",
301-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .keyword(text: "init"), .keyword(text: "self"), .keyword(text: "Self")]),
301+
kind: .token(choices: [
302+
.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .keyword(text: "init"), .keyword(text: "self"),
303+
.keyword(text: "Self"),
304+
]),
302305
nameForDiagnostics: "base name",
303306
description: "The base name of the protocol's requirement."
304307
),
@@ -322,7 +325,8 @@ public let ATTRIBUTE_NODES: [Node] = [
322325
kind: .derivativeRegistrationAttributeArguments,
323326
base: .syntax,
324327
nameForDiagnostics: "attribute arguments",
325-
documentation: "The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list.",
328+
documentation:
329+
"The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list.",
326330
children: [
327331
Child(
328332
name: "OfLabel",
@@ -461,7 +465,8 @@ public let ATTRIBUTE_NODES: [Node] = [
461465
kind: .differentiableAttributeArguments,
462466
base: .syntax,
463467
nameForDiagnostics: "'@differentiable' arguments",
464-
documentation: "The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause.",
468+
documentation:
469+
"The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause.",
465470
children: [
466471
Child(
467472
name: "DiffKind",
@@ -515,7 +520,11 @@ public let ATTRIBUTE_NODES: [Node] = [
515520
kind: .nodeChoices(choices: [
516521
Child(
517522
name: "Token",
518-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "private"), .keyword(text: "fileprivate"), .keyword(text: "internal"), .keyword(text: "public"), .keyword(text: "open")])
523+
kind: .token(choices: [
524+
.token(tokenKind: "IdentifierToken"), .keyword(text: "private"), .keyword(text: "fileprivate"), .keyword(text: "internal"),
525+
.keyword(text: "public"),
526+
.keyword(text: "open"),
527+
])
519528
), // Keywords can be: public, internal, private, fileprivate, open
520529
Child(
521530
name: "String",
@@ -670,7 +679,8 @@ public let ATTRIBUTE_NODES: [Node] = [
670679
kind: .objCSelectorPiece,
671680
base: .syntax,
672681
nameForDiagnostics: "Objective-C selector piece",
673-
documentation: "A piece of an Objective-C selector. Either consisting of just an identifier for a nullary selector, an identifier and a colon for a labeled argument or just a colon for an unlabeled argument",
682+
documentation:
683+
"A piece of an Objective-C selector. Either consisting of just an identifier for a nullary selector, an identifier and a colon for a labeled argument or just a colon for an unlabeled argument",
674684
children: [
675685
Child(
676686
name: "Name",
@@ -776,7 +786,10 @@ public let ATTRIBUTE_NODES: [Node] = [
776786
),
777787
Child(
778788
name: "Name",
779-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "BinaryOperatorToken")]),
789+
kind: .token(choices: [
790+
.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"),
791+
.token(tokenKind: "BinaryOperatorToken"),
792+
]),
780793
nameForDiagnostics: "base name",
781794
description: "The base name of the referenced function."
782795
),

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public let AVAILABILITY_NODES: [Node] = [
2727
kind: .nodeChoices(choices: [
2828
Child(
2929
name: "Token",
30-
kind: .token(choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false)
30+
kind: .token(
31+
choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IdentifierToken")],
32+
requiresLeadingSpace: false,
33+
requiresTrailingSpace: false
34+
)
3135
),
3236
Child(
3337
name: "AvailabilityVersionRestriction",
@@ -59,7 +63,9 @@ public let AVAILABILITY_NODES: [Node] = [
5963
children: [
6064
Child(
6165
name: "Label",
62-
kind: .token(choices: [.keyword(text: "message"), .keyword(text: "renamed"), .keyword(text: "introduced"), .keyword(text: "obsoleted"), .keyword(text: "deprecated")]),
66+
kind: .token(choices: [
67+
.keyword(text: "message"), .keyword(text: "renamed"), .keyword(text: "introduced"), .keyword(text: "obsoleted"), .keyword(text: "deprecated"),
68+
]),
6369
nameForDiagnostics: "label",
6470
description: "The label of the argument"
6571
),
@@ -106,7 +112,8 @@ public let AVAILABILITY_NODES: [Node] = [
106112
name: "Platform",
107113
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
108114
nameForDiagnostics: "platform",
109-
description: "The name of the OS on which the availability should be restricted or 'swift' if the availability should be restricted based on a Swift version.",
115+
description:
116+
"The name of the OS on which the availability should be restricted or 'swift' if the availability should be restricted based on a Swift version.",
110117
classification: "Keyword"
111118
),
112119
Child(

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public let DECL_NODES: [Node] = [
1818
children: [
1919
Child(
2020
name: "Name",
21-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")]),
21+
kind: .token(choices: [
22+
.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"),
23+
.token(tokenKind: "PostfixOperatorToken"),
24+
]),
2225
nameForDiagnostics: "name"
2326
),
2427
Child(
@@ -82,7 +85,13 @@ public let DECL_NODES: [Node] = [
8285
),
8386
Child(
8487
name: "AccessorKind",
85-
kind: .token(choices: [.keyword(text: "get"), .keyword(text: "set"), .keyword(text: "didSet"), .keyword(text: "willSet"), .keyword(text: "unsafeAddress"), .keyword(text: "addressWithOwner"), .keyword(text: "addressWithNativeOwner"), .keyword(text: "unsafeMutableAddress"), .keyword(text: "mutableAddressWithOwner"), .keyword(text: "mutableAddressWithNativeOwner"), .keyword(text: "_read"), .keyword(text: "_modify")])
88+
kind: .token(choices: [
89+
.keyword(text: "get"), .keyword(text: "set"), .keyword(text: "didSet"), .keyword(text: "willSet"), .keyword(text: "unsafeAddress"),
90+
.keyword(text: "addressWithOwner"),
91+
.keyword(text: "addressWithNativeOwner"), .keyword(text: "unsafeMutableAddress"), .keyword(text: "mutableAddressWithOwner"),
92+
.keyword(text: "mutableAddressWithNativeOwner"),
93+
.keyword(text: "_read"), .keyword(text: "_modify"),
94+
])
8695
),
8796
Child(
8897
name: "Parameter",
@@ -374,7 +383,8 @@ public let DECL_NODES: [Node] = [
374383
Child(
375384
name: "MemberBlock",
376385
kind: .node(kind: .memberDeclBlock),
377-
description: "The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn't guaranteed to be a complete list of members for this type."
386+
description:
387+
"The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn't guaranteed to be a complete list of members for this type."
378388
),
379389
]
380390
),
@@ -767,7 +777,8 @@ public let DECL_NODES: [Node] = [
767777
Child(
768778
name: "MemberBlock",
769779
kind: .node(kind: .memberDeclBlock),
770-
description: "The cases and other members associated with this enum declaration. Because enum extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
780+
description:
781+
"The cases and other members associated with this enum declaration. Because enum extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
771782
),
772783
]
773784
),
@@ -855,7 +866,10 @@ public let DECL_NODES: [Node] = [
855866
),
856867
Child(
857868
name: "Identifier",
858-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")])
869+
kind: .token(choices: [
870+
.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"),
871+
.token(tokenKind: "PostfixOperatorToken"),
872+
])
859873
),
860874
Child(
861875
name: "GenericParameterClause",
@@ -1088,7 +1102,12 @@ public let DECL_NODES: [Node] = [
10881102
),
10891103
Child(
10901104
name: "ImportKind",
1091-
kind: .token(choices: [.keyword(text: "typealias"), .keyword(text: "struct"), .keyword(text: "class"), .keyword(text: "enum"), .keyword(text: "protocol"), .keyword(text: "var"), .keyword(text: "let"), .keyword(text: "func"), .keyword(text: "inout")]),
1105+
kind: .token(choices: [
1106+
.keyword(text: "typealias"), .keyword(text: "struct"), .keyword(text: "class"), .keyword(text: "enum"), .keyword(text: "protocol"),
1107+
.keyword(text: "var"),
1108+
.keyword(text: "let"),
1109+
.keyword(text: "func"), .keyword(text: "inout"),
1110+
]),
10921111
description: "The kind of declaration being imported. For example, a struct can be imported from a specific module.",
10931112
isOptional: true
10941113
),
@@ -1184,7 +1203,9 @@ public let DECL_NODES: [Node] = [
11841203
),
11851204
Child(
11861205
name: "OptionalMark",
1187-
kind: .token(choices: [.token(tokenKind: "PostfixQuestionMarkToken"), .token(tokenKind: "InfixQuestionMarkToken"), .token(tokenKind: "ExclamationMarkToken")]),
1206+
kind: .token(choices: [
1207+
.token(tokenKind: "PostfixQuestionMarkToken"), .token(tokenKind: "InfixQuestionMarkToken"), .token(tokenKind: "ExclamationMarkToken"),
1208+
]),
11881209
description: "If the initializer is failable, a question mark to indicate that.",
11891210
isOptional: true
11901211
),
@@ -1653,7 +1674,8 @@ public let DECL_NODES: [Node] = [
16531674
Child(
16541675
name: "Flag",
16551676
kind: .token(choices: [.keyword(text: "true"), .keyword(text: "false")]),
1656-
description: "When true, an operator in the corresponding precedence group uses the same grouping rules during optional chaining as the assignment operators from the standard library. Otherwise, operators in the precedence group follows the same optional chaining rules as operators that don't perform assignment."
1677+
description:
1678+
"When true, an operator in the corresponding precedence group uses the same grouping rules during optional chaining as the assignment operators from the standard library. Otherwise, operators in the precedence group follows the same optional chaining rules as operators that don't perform assignment."
16571679
),
16581680
]
16591681
),
@@ -1678,7 +1700,8 @@ public let DECL_NODES: [Node] = [
16781700
Child(
16791701
name: "Value",
16801702
kind: .token(choices: [.keyword(text: "left"), .keyword(text: "right"), .keyword(text: "none")]),
1681-
description: "Operators that are `left`-associative group left-to-right. Operators that are `right`-associative group right-to-left. Operators that are specified with an associativity of `none` don't associate at all"
1703+
description:
1704+
"Operators that are `left`-associative group left-to-right. Operators that are `right`-associative group right-to-left. Operators that are specified with an associativity of `none` don't associate at all"
16821705
),
16831706
]
16841707
),
@@ -2032,7 +2055,8 @@ public let DECL_NODES: [Node] = [
20322055
Child(
20332056
name: "MemberBlock",
20342057
kind: .node(kind: .memberDeclBlock),
2035-
description: "The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
2058+
description:
2059+
"The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
20362060
),
20372061
]
20382062
),

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ public let EXPR_NODES: [Node] = [
382382
Child(
383383
name: "SecondName",
384384
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")]),
385-
description: "If this is specified, it is the name by which the parameter can be referenced inside the closure body. If it is `nil`, the closure parameter is referenced by the first name.",
385+
description:
386+
"If this is specified, it is the name by which the parameter can be referenced inside the closure body. If it is `nil`, the closure parameter is referenced by the first name.",
386387
isOptional: true
387388
),
388389
Child(
@@ -832,7 +833,11 @@ public let EXPR_NODES: [Node] = [
832833
children: [
833834
Child(
834835
name: "Identifier",
835-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken")])
836+
kind: .token(choices: [
837+
.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"),
838+
.token(tokenKind: "DollarIdentifierToken"),
839+
.token(tokenKind: "BinaryOperatorToken"),
840+
])
836841
),
837842
Child(
838843
name: "DeclNameArguments",
@@ -1068,7 +1073,11 @@ public let EXPR_NODES: [Node] = [
10681073
children: [
10691074
Child(
10701075
name: "Identifier",
1071-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IntegerLiteralToken")])
1076+
kind: .token(choices: [
1077+
.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"),
1078+
.token(tokenKind: "DollarIdentifierToken"),
1079+
.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IntegerLiteralToken"),
1080+
])
10721081
),
10731082
Child(
10741083
name: "DeclNameArguments",

CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ public let GENERIC_NODES: [Node] = [
190190
),
191191
Child(
192192
name: "LayoutConstraint",
193-
kind: .token(choices: [.keyword(text: "_Trivial"), .keyword(text: "_TrivialAtMost"), .keyword(text: "_UnknownLayout"), .keyword(text: "_RefCountedObject"), .keyword(text: "_NativeRefCountedObject"), .keyword(text: "_Class"), .keyword(text: "_NativeClass")])
193+
kind: .token(choices: [
194+
.keyword(text: "_Trivial"), .keyword(text: "_TrivialAtMost"), .keyword(text: "_UnknownLayout"), .keyword(text: "_RefCountedObject"),
195+
.keyword(text: "_NativeRefCountedObject"),
196+
.keyword(text: "_Class"), .keyword(text: "_NativeClass"),
197+
])
194198
),
195199
Child(
196200
name: "LeftParen",

CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
171171
PunctuatorSpec(name: "AtSign", kind: "at_sign", text: "@", classification: "Attribute"),
172172
PunctuatorSpec(name: "Backslash", kind: "backslash", text: "\\"),
173173
PunctuatorSpec(name: "Backtick", kind: "backtick", text: "`"),
174-
MiscSpec(name: "BinaryOperator", kind: "oper_binary", nameForDiagnostics: "binary operator", classification: "OperatorIdentifier", requiresLeadingSpace: true, requiresTrailingSpace: true),
174+
MiscSpec(
175+
name: "BinaryOperator",
176+
kind: "oper_binary",
177+
nameForDiagnostics: "binary operator",
178+
classification: "OperatorIdentifier",
179+
requiresLeadingSpace: true,
180+
requiresTrailingSpace: true
181+
),
175182
PunctuatorSpec(name: "Colon", kind: "colon", text: ":", requiresTrailingSpace: true),
176183
PunctuatorSpec(name: "Comma", kind: "comma", text: ",", requiresTrailingSpace: true),
177184
MiscSpec(name: "DollarIdentifier", kind: "dollarident", nameForDiagnostics: "dollar identifier", classification: "DollarIdentifier"),

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public let TYPE_NODES: [Node] = [
4444
children: [
4545
Child(
4646
name: "Specifier",
47-
kind: .token(choices: [.keyword(text: "inout"), .keyword(text: "__shared"), .keyword(text: "__owned"), .keyword(text: "isolated"), .keyword(text: "_const"), .keyword(text: "borrowing"), .keyword(text: "consuming")]),
47+
kind: .token(choices: [
48+
.keyword(text: "inout"), .keyword(text: "__shared"), .keyword(text: "__owned"), .keyword(text: "isolated"), .keyword(text: "_const"),
49+
.keyword(text: "borrowing"),
50+
.keyword(text: "consuming"),
51+
]),
4852
isOptional: true
4953
),
5054
Child(
@@ -408,7 +412,10 @@ public let TYPE_NODES: [Node] = [
408412
children: [
409413
Child(
410414
name: "Name",
411-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "Any"), .token(tokenKind: "KeywordToken"), .token(tokenKind: "WildcardToken")]),
415+
kind: .token(choices: [
416+
.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "Any"), .token(tokenKind: "KeywordToken"),
417+
.token(tokenKind: "WildcardToken"),
418+
]),
412419
classification: "TypeIdentifier"
413420
),
414421
Child(

CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ struct GenerateSwiftSyntax: ParsableCommand {
120120
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableCollectionNodes.swift"], buildableCollectionNodesFile),
121121
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableNodes.swift"], buildableNodesFile),
122122
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["ResultBuilders.swift"], resultBuildersFile),
123-
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["SyntaxExpressibleByStringInterpolationConformances.swift"], syntaxExpressibleByStringInterpolationConformancesFile),
123+
GeneratedFileSpec(
124+
swiftSyntaxBuilderGeneratedDir + ["SyntaxExpressibleByStringInterpolationConformances.swift"],
125+
syntaxExpressibleByStringInterpolationConformancesFile
126+
),
124127
]
125128
+ BASE_KIND_FILES.map { baseKind in
126129
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["syntaxNodes", baseKind.value], syntaxNode(emitKind: baseKind.key))

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/BuildableCollectionNodesFile.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ let buildableCollectionNodesFile = SourceFileSyntax(leadingTrivia: copyrightHead
2222
for node in SYNTAX_NODES.compactMap(\.collectionNode) {
2323
let elementType = node.collectionElementType
2424

25-
let docComment = node.documentation.isEmpty ? [.docLineComment("/// `\(node.kind.syntaxType)` represents a collection of `\(elementType.syntaxBaseName)`")] : node.documentation
25+
let docComment =
26+
node.documentation.isEmpty
27+
? [.docLineComment("/// `\(node.kind.syntaxType)` represents a collection of `\(elementType.syntaxBaseName)`")]
28+
: node.documentation
2629
// Generate collection node struct
2730
try! ExtensionDeclSyntax(
2831
"""

0 commit comments

Comments
 (0)