Skip to content

Commit 8dcd599

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 4da8d37 commit 8dcd599

File tree

54 files changed

+461
-118
lines changed

Some content is hidden

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

54 files changed

+461
-118
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: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,13 @@ 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"),
303+
.token(tokenKind: "BinaryOperatorToken"),
304+
.keyword(text: "init"),
305+
.keyword(text: "self"),
306+
.keyword(text: "Self"),
307+
]),
302308
nameForDiagnostics: "base name",
303309
documentation: "The base name of the protocol's requirement."
304310
),
@@ -322,7 +328,8 @@ public let ATTRIBUTE_NODES: [Node] = [
322328
kind: .derivativeRegistrationAttributeArguments,
323329
base: .syntax,
324330
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.",
331+
documentation:
332+
"The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list.",
326333
children: [
327334
Child(
328335
name: "OfLabel",
@@ -461,7 +468,8 @@ public let ATTRIBUTE_NODES: [Node] = [
461468
kind: .differentiableAttributeArguments,
462469
base: .syntax,
463470
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.",
471+
documentation:
472+
"The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause.",
465473
children: [
466474
Child(
467475
name: "DiffKind",
@@ -515,7 +523,14 @@ public let ATTRIBUTE_NODES: [Node] = [
515523
kind: .nodeChoices(choices: [
516524
Child(
517525
name: "Token",
518-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "private"), .keyword(text: "fileprivate"), .keyword(text: "internal"), .keyword(text: "public"), .keyword(text: "open")])
526+
kind: .token(choices: [
527+
.token(tokenKind: "IdentifierToken"),
528+
.keyword(text: "private"),
529+
.keyword(text: "fileprivate"),
530+
.keyword(text: "internal"),
531+
.keyword(text: "public"),
532+
.keyword(text: "open"),
533+
])
519534
), // Keywords can be: public, internal, private, fileprivate, open
520535
Child(
521536
name: "String",
@@ -670,7 +685,8 @@ public let ATTRIBUTE_NODES: [Node] = [
670685
kind: .objCSelectorPiece,
671686
base: .syntax,
672687
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",
688+
documentation:
689+
"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",
674690
children: [
675691
Child(
676692
name: "Name",
@@ -776,7 +792,13 @@ public let ATTRIBUTE_NODES: [Node] = [
776792
),
777793
Child(
778794
name: "Name",
779-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "BinaryOperatorToken")]),
795+
kind: .token(choices: [
796+
.token(tokenKind: "IdentifierToken"),
797+
.keyword(text: "self"),
798+
.keyword(text: "Self"),
799+
.keyword(text: "init"),
800+
.token(tokenKind: "BinaryOperatorToken"),
801+
]),
780802
nameForDiagnostics: "base name",
781803
documentation: "The base name of the referenced function."
782804
),

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

Lines changed: 14 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,13 @@ 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"),
68+
.keyword(text: "renamed"),
69+
.keyword(text: "introduced"),
70+
.keyword(text: "obsoleted"),
71+
.keyword(text: "deprecated"),
72+
]),
6373
nameForDiagnostics: "label",
6474
documentation: "The label of the argument"
6575
),
@@ -106,7 +116,8 @@ public let AVAILABILITY_NODES: [Node] = [
106116
name: "Platform",
107117
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
108118
nameForDiagnostics: "platform",
109-
documentation: "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.",
119+
documentation:
120+
"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.",
110121
classification: "Keyword"
111122
),
112123
Child(

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ 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"),
23+
.token(tokenKind: "BinaryOperatorToken"),
24+
.token(tokenKind: "PrefixOperatorToken"),
25+
.token(tokenKind: "PostfixOperatorToken"),
26+
]),
2227
nameForDiagnostics: "name"
2328
),
2429
Child(
@@ -82,7 +87,20 @@ public let DECL_NODES: [Node] = [
8287
),
8388
Child(
8489
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")])
90+
kind: .token(choices: [
91+
.keyword(text: "get"),
92+
.keyword(text: "set"),
93+
.keyword(text: "didSet"),
94+
.keyword(text: "willSet"),
95+
.keyword(text: "unsafeAddress"),
96+
.keyword(text: "addressWithOwner"),
97+
.keyword(text: "addressWithNativeOwner"),
98+
.keyword(text: "unsafeMutableAddress"),
99+
.keyword(text: "mutableAddressWithOwner"),
100+
.keyword(text: "mutableAddressWithNativeOwner"),
101+
.keyword(text: "_read"),
102+
.keyword(text: "_modify"),
103+
])
86104
),
87105
Child(
88106
name: "Parameter",
@@ -374,7 +392,8 @@ public let DECL_NODES: [Node] = [
374392
Child(
375393
name: "MemberBlock",
376394
kind: .node(kind: .memberDeclBlock),
377-
documentation: "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."
395+
documentation:
396+
"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."
378397
),
379398
]
380399
),
@@ -767,7 +786,8 @@ public let DECL_NODES: [Node] = [
767786
Child(
768787
name: "MemberBlock",
769788
kind: .node(kind: .memberDeclBlock),
770-
documentation: "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."
789+
documentation:
790+
"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."
771791
),
772792
]
773793
),
@@ -855,7 +875,12 @@ public let DECL_NODES: [Node] = [
855875
),
856876
Child(
857877
name: "Identifier",
858-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")])
878+
kind: .token(choices: [
879+
.token(tokenKind: "IdentifierToken"),
880+
.token(tokenKind: "BinaryOperatorToken"),
881+
.token(tokenKind: "PrefixOperatorToken"),
882+
.token(tokenKind: "PostfixOperatorToken"),
883+
])
859884
),
860885
Child(
861886
name: "GenericParameterClause",
@@ -1088,7 +1113,17 @@ public let DECL_NODES: [Node] = [
10881113
),
10891114
Child(
10901115
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")]),
1116+
kind: .token(choices: [
1117+
.keyword(text: "typealias"),
1118+
.keyword(text: "struct"),
1119+
.keyword(text: "class"),
1120+
.keyword(text: "enum"),
1121+
.keyword(text: "protocol"),
1122+
.keyword(text: "var"),
1123+
.keyword(text: "let"),
1124+
.keyword(text: "func"),
1125+
.keyword(text: "inout"),
1126+
]),
10921127
documentation: "The kind of declaration being imported. For example, a struct can be imported from a specific module.",
10931128
isOptional: true
10941129
),
@@ -1184,7 +1219,11 @@ public let DECL_NODES: [Node] = [
11841219
),
11851220
Child(
11861221
name: "OptionalMark",
1187-
kind: .token(choices: [.token(tokenKind: "PostfixQuestionMarkToken"), .token(tokenKind: "InfixQuestionMarkToken"), .token(tokenKind: "ExclamationMarkToken")]),
1222+
kind: .token(choices: [
1223+
.token(tokenKind: "PostfixQuestionMarkToken"),
1224+
.token(tokenKind: "InfixQuestionMarkToken"),
1225+
.token(tokenKind: "ExclamationMarkToken"),
1226+
]),
11881227
documentation: "If the initializer is failable, a question mark to indicate that.",
11891228
isOptional: true
11901229
),
@@ -1653,7 +1692,8 @@ public let DECL_NODES: [Node] = [
16531692
Child(
16541693
name: "Flag",
16551694
kind: .token(choices: [.keyword(text: "true"), .keyword(text: "false")]),
1656-
documentation: "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."
1695+
documentation:
1696+
"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."
16571697
),
16581698
]
16591699
),
@@ -1678,7 +1718,8 @@ public let DECL_NODES: [Node] = [
16781718
Child(
16791719
name: "Value",
16801720
kind: .token(choices: [.keyword(text: "left"), .keyword(text: "right"), .keyword(text: "none")]),
1681-
documentation: "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"
1721+
documentation:
1722+
"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"
16821723
),
16831724
]
16841725
),
@@ -2032,7 +2073,8 @@ public let DECL_NODES: [Node] = [
20322073
Child(
20332074
name: "MemberBlock",
20342075
kind: .node(kind: .memberDeclBlock),
2035-
documentation: "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."
2076+
documentation:
2077+
"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."
20362078
),
20372079
]
20382080
),

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 19 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-
documentation: "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+
documentation:
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,14 @@ 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"),
838+
.keyword(text: "self"),
839+
.keyword(text: "Self"),
840+
.keyword(text: "init"),
841+
.token(tokenKind: "DollarIdentifierToken"),
842+
.token(tokenKind: "BinaryOperatorToken"),
843+
])
836844
),
837845
Child(
838846
name: "DeclNameArguments",
@@ -1068,7 +1076,15 @@ public let EXPR_NODES: [Node] = [
10681076
children: [
10691077
Child(
10701078
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")])
1079+
kind: .token(choices: [
1080+
.token(tokenKind: "IdentifierToken"),
1081+
.keyword(text: "self"),
1082+
.keyword(text: "Self"),
1083+
.keyword(text: "init"),
1084+
.token(tokenKind: "DollarIdentifierToken"),
1085+
.token(tokenKind: "BinaryOperatorToken"),
1086+
.token(tokenKind: "IntegerLiteralToken"),
1087+
])
10721088
),
10731089
Child(
10741090
name: "DeclNameArguments",

CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,15 @@ 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"),
195+
.keyword(text: "_TrivialAtMost"),
196+
.keyword(text: "_UnknownLayout"),
197+
.keyword(text: "_RefCountedObject"),
198+
.keyword(text: "_NativeRefCountedObject"),
199+
.keyword(text: "_Class"),
200+
.keyword(text: "_NativeClass"),
201+
])
194202
),
195203
Child(
196204
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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ 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"),
49+
.keyword(text: "__shared"),
50+
.keyword(text: "__owned"),
51+
.keyword(text: "isolated"),
52+
.keyword(text: "_const"),
53+
.keyword(text: "borrowing"),
54+
.keyword(text: "consuming"),
55+
]),
4856
isOptional: true
4957
),
5058
Child(
@@ -408,7 +416,14 @@ public let TYPE_NODES: [Node] = [
408416
children: [
409417
Child(
410418
name: "Name",
411-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "Any"), .token(tokenKind: "KeywordToken"), .token(tokenKind: "WildcardToken")]),
419+
kind: .token(choices: [
420+
.token(tokenKind: "IdentifierToken"),
421+
.keyword(text: "self"),
422+
.keyword(text: "Self"),
423+
.keyword(text: "Any"),
424+
.token(tokenKind: "KeywordToken"),
425+
.token(tokenKind: "WildcardToken"),
426+
]),
412427
classification: "TypeIdentifier"
413428
),
414429
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))

0 commit comments

Comments
 (0)