Skip to content

Reduce line-length to 160 characters #1714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"lineLength": 1000,
"lineLength": 160,
"indentation": {
"spaces": 2
},
Expand Down
34 changes: 28 additions & 6 deletions CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,13 @@ public let ATTRIBUTE_NODES: [Node] = [
children: [
Child(
name: "DeclBaseName",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .keyword(text: "init"), .keyword(text: "self"), .keyword(text: "Self")]),
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
.keyword(text: "init"),
.keyword(text: "self"),
.keyword(text: "Self"),
]),
nameForDiagnostics: "base name",
documentation: "The base name of the protocol's requirement."
),
Expand All @@ -322,7 +328,8 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .derivativeRegistrationAttributeArguments,
base: .syntax,
nameForDiagnostics: "attribute arguments",
documentation: "The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list.",
documentation:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a swift-format option for making the string multiline?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there isn’t. Really these doc comments should just be multi-line strings so that the generated documentation also has newlines to improve readability. But if we want to change that, I’d like to do it in a follow-up PR.

"The arguments for the '@derivative(of:)' and '@transpose(of:)' attributes: the 'of:' label, the original declaration name, and an optional differentiability parameter list.",
children: [
Child(
name: "OfLabel",
Expand Down Expand Up @@ -461,7 +468,8 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .differentiableAttributeArguments,
base: .syntax,
nameForDiagnostics: "'@differentiable' arguments",
documentation: "The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause.",
documentation:
"The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional 'where' clause.",
children: [
Child(
name: "DiffKind",
Expand Down Expand Up @@ -515,7 +523,14 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .nodeChoices(choices: [
Child(
name: "Token",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "private"), .keyword(text: "fileprivate"), .keyword(text: "internal"), .keyword(text: "public"), .keyword(text: "open")])
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.keyword(text: "private"),
.keyword(text: "fileprivate"),
.keyword(text: "internal"),
.keyword(text: "public"),
.keyword(text: "open"),
])
), // Keywords can be: public, internal, private, fileprivate, open
Child(
name: "String",
Expand Down Expand Up @@ -670,7 +685,8 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .objCSelectorPiece,
base: .syntax,
nameForDiagnostics: "Objective-C selector piece",
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",
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",
children: [
Child(
name: "Name",
Expand Down Expand Up @@ -776,7 +792,13 @@ public let ATTRIBUTE_NODES: [Node] = [
),
Child(
name: "Name",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "BinaryOperatorToken")]),
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.keyword(text: "self"),
.keyword(text: "Self"),
.keyword(text: "init"),
.token(tokenKind: "BinaryOperatorToken"),
]),
nameForDiagnostics: "base name",
documentation: "The base name of the referenced function."
),
Expand Down
17 changes: 14 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public let AVAILABILITY_NODES: [Node] = [
kind: .nodeChoices(choices: [
Child(
name: "Token",
kind: .token(choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false)
kind: .token(
choices: [.token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IdentifierToken")],
requiresLeadingSpace: false,
requiresTrailingSpace: false
)
),
Child(
name: "AvailabilityVersionRestriction",
Expand Down Expand Up @@ -59,7 +63,13 @@ public let AVAILABILITY_NODES: [Node] = [
children: [
Child(
name: "Label",
kind: .token(choices: [.keyword(text: "message"), .keyword(text: "renamed"), .keyword(text: "introduced"), .keyword(text: "obsoleted"), .keyword(text: "deprecated")]),
kind: .token(choices: [
.keyword(text: "message"),
.keyword(text: "renamed"),
.keyword(text: "introduced"),
.keyword(text: "obsoleted"),
.keyword(text: "deprecated"),
]),
nameForDiagnostics: "label",
documentation: "The label of the argument"
),
Expand Down Expand Up @@ -106,7 +116,8 @@ public let AVAILABILITY_NODES: [Node] = [
name: "Platform",
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
nameForDiagnostics: "platform",
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.",
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.",
classification: "Keyword"
),
Child(
Expand Down
62 changes: 52 additions & 10 deletions CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public let DECL_NODES: [Node] = [
children: [
Child(
name: "Name",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")]),
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
.token(tokenKind: "PrefixOperatorToken"),
.token(tokenKind: "PostfixOperatorToken"),
]),
nameForDiagnostics: "name"
),
Child(
Expand Down Expand Up @@ -81,7 +86,20 @@ public let DECL_NODES: [Node] = [
),
Child(
name: "AccessorKind",
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")])
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"),
])
),
Child(
name: "Parameter",
Expand Down Expand Up @@ -373,7 +391,8 @@ public let DECL_NODES: [Node] = [
Child(
name: "MemberBlock",
kind: .node(kind: .memberDeclBlock),
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."
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."
),
]
),
Expand Down Expand Up @@ -766,7 +785,8 @@ public let DECL_NODES: [Node] = [
Child(
name: "MemberBlock",
kind: .node(kind: .memberDeclBlock),
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."
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."
),
]
),
Expand Down Expand Up @@ -854,7 +874,12 @@ public let DECL_NODES: [Node] = [
),
Child(
name: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "PrefixOperatorToken"), .token(tokenKind: "PostfixOperatorToken")])
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
.token(tokenKind: "PrefixOperatorToken"),
.token(tokenKind: "PostfixOperatorToken"),
])
),
Child(
name: "GenericParameterClause",
Expand Down Expand Up @@ -1085,7 +1110,17 @@ public let DECL_NODES: [Node] = [
),
Child(
name: "ImportKind",
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")]),
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"),
]),
documentation: "The kind of declaration being imported. For example, a struct can be imported from a specific module.",
isOptional: true
),
Expand Down Expand Up @@ -1181,7 +1216,11 @@ public let DECL_NODES: [Node] = [
),
Child(
name: "OptionalMark",
kind: .token(choices: [.token(tokenKind: "PostfixQuestionMarkToken"), .token(tokenKind: "InfixQuestionMarkToken"), .token(tokenKind: "ExclamationMarkToken")]),
kind: .token(choices: [
.token(tokenKind: "PostfixQuestionMarkToken"),
.token(tokenKind: "InfixQuestionMarkToken"),
.token(tokenKind: "ExclamationMarkToken"),
]),
documentation: "If the initializer is failable, a question mark to indicate that.",
isOptional: true
),
Expand Down Expand Up @@ -1638,7 +1677,8 @@ public let DECL_NODES: [Node] = [
Child(
name: "Flag",
kind: .token(choices: [.keyword(text: "true"), .keyword(text: "false")]),
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."
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."
),
]
),
Expand All @@ -1663,7 +1703,8 @@ public let DECL_NODES: [Node] = [
Child(
name: "Value",
kind: .token(choices: [.keyword(text: "left"), .keyword(text: "right"), .keyword(text: "none")]),
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"
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"
),
]
),
Expand Down Expand Up @@ -2017,7 +2058,8 @@ public let DECL_NODES: [Node] = [
Child(
name: "MemberBlock",
kind: .node(kind: .memberDeclBlock),
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."
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."
),
]
),
Expand Down
22 changes: 19 additions & 3 deletions CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ public let EXPR_NODES: [Node] = [
Child(
name: "SecondName",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "WildcardToken")]),
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.",
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.",
isOptional: true
),
Child(
Expand Down Expand Up @@ -831,7 +832,14 @@ public let EXPR_NODES: [Node] = [
children: [
Child(
name: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken")])
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.keyword(text: "self"),
.keyword(text: "Self"),
.keyword(text: "init"),
.token(tokenKind: "DollarIdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
])
),
Child(
name: "DeclNameArguments",
Expand Down Expand Up @@ -1067,7 +1075,15 @@ public let EXPR_NODES: [Node] = [
children: [
Child(
name: "Identifier",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init"), .token(tokenKind: "DollarIdentifierToken"), .token(tokenKind: "BinaryOperatorToken"), .token(tokenKind: "IntegerLiteralToken")])
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.keyword(text: "self"),
.keyword(text: "Self"),
.keyword(text: "init"),
.token(tokenKind: "DollarIdentifierToken"),
.token(tokenKind: "BinaryOperatorToken"),
.token(tokenKind: "IntegerLiteralToken"),
])
),
Child(
name: "DeclNameArguments",
Expand Down
10 changes: 9 additions & 1 deletion CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,15 @@ public let GENERIC_NODES: [Node] = [
),
Child(
name: "LayoutConstraint",
kind: .token(choices: [.keyword(text: "_Trivial"), .keyword(text: "_TrivialAtMost"), .keyword(text: "_UnknownLayout"), .keyword(text: "_RefCountedObject"), .keyword(text: "_NativeRefCountedObject"), .keyword(text: "_Class"), .keyword(text: "_NativeClass")])
kind: .token(choices: [
.keyword(text: "_Trivial"),
.keyword(text: "_TrivialAtMost"),
.keyword(text: "_UnknownLayout"),
.keyword(text: "_RefCountedObject"),
.keyword(text: "_NativeRefCountedObject"),
.keyword(text: "_Class"),
.keyword(text: "_NativeClass"),
])
),
Child(
name: "LeftParen",
Expand Down
9 changes: 8 additions & 1 deletion CodeGeneration/Sources/SyntaxSupport/TokenSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ public let SYNTAX_TOKENS: [TokenSpec] = [
PunctuatorSpec(name: "AtSign", kind: "at_sign", text: "@", classification: "Attribute"),
PunctuatorSpec(name: "Backslash", kind: "backslash", text: "\\"),
PunctuatorSpec(name: "Backtick", kind: "backtick", text: "`"),
MiscSpec(name: "BinaryOperator", kind: "oper_binary", nameForDiagnostics: "binary operator", classification: "OperatorIdentifier", requiresLeadingSpace: true, requiresTrailingSpace: true),
MiscSpec(
name: "BinaryOperator",
kind: "oper_binary",
nameForDiagnostics: "binary operator",
classification: "OperatorIdentifier",
requiresLeadingSpace: true,
requiresTrailingSpace: true
),
PunctuatorSpec(name: "Colon", kind: "colon", text: ":", requiresTrailingSpace: true),
PunctuatorSpec(name: "Comma", kind: "comma", text: ",", requiresTrailingSpace: true),
MiscSpec(name: "DollarIdentifier", kind: "dollarident", nameForDiagnostics: "dollar identifier", classification: "DollarIdentifier"),
Expand Down
19 changes: 17 additions & 2 deletions CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ public let TYPE_NODES: [Node] = [
children: [
Child(
name: "Specifier",
kind: .token(choices: [.keyword(text: "inout"), .keyword(text: "__shared"), .keyword(text: "__owned"), .keyword(text: "isolated"), .keyword(text: "_const"), .keyword(text: "borrowing"), .keyword(text: "consuming")]),
kind: .token(choices: [
.keyword(text: "inout"),
.keyword(text: "__shared"),
.keyword(text: "__owned"),
.keyword(text: "isolated"),
.keyword(text: "_const"),
.keyword(text: "borrowing"),
.keyword(text: "consuming"),
]),
isOptional: true
),
Child(
Expand Down Expand Up @@ -408,7 +416,14 @@ public let TYPE_NODES: [Node] = [
children: [
Child(
name: "Name",
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "Any"), .token(tokenKind: "KeywordToken"), .token(tokenKind: "WildcardToken")]),
kind: .token(choices: [
.token(tokenKind: "IdentifierToken"),
.keyword(text: "self"),
.keyword(text: "Self"),
.keyword(text: "Any"),
.token(tokenKind: "KeywordToken"),
.token(tokenKind: "WildcardToken"),
]),
classification: "TypeIdentifier"
),
Child(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ struct GenerateSwiftSyntax: ParsableCommand {
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableCollectionNodes.swift"], buildableCollectionNodesFile),
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["BuildableNodes.swift"], buildableNodesFile),
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["ResultBuilders.swift"], resultBuildersFile),
GeneratedFileSpec(swiftSyntaxBuilderGeneratedDir + ["SyntaxExpressibleByStringInterpolationConformances.swift"], syntaxExpressibleByStringInterpolationConformancesFile),
GeneratedFileSpec(
swiftSyntaxBuilderGeneratedDir + ["SyntaxExpressibleByStringInterpolationConformances.swift"],
syntaxExpressibleByStringInterpolationConformancesFile
),
]
+ BASE_KIND_FILES.map { baseKind in
GeneratedFileSpec(swiftSyntaxGeneratedDir + ["syntaxNodes", baseKind.value], syntaxNode(emitKind: baseKind.key))
Expand Down
Loading