Skip to content

Commit 208f111

Browse files
authored
Merge pull request #1784 from ahoppen/ahoppen/missing-traits
Add missing trait conformances
2 parents 338a626 + c46097b commit 208f111

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public let ATTRIBUTE_NODES: [Node] = [
184184
base: .syntax,
185185
nameForDiagnostics: "version",
186186
documentation: "A single platform/version pair in an attribute, e.g. `iOS 10.1`.",
187+
traits: ["WithTrailingComma"],
187188
children: [
188189
Child(
189190
name: "AvailabilityVersionRestriction",

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public let AVAILABILITY_NODES: [Node] = [
2121
base: .syntax,
2222
nameForDiagnostics: "availability argument",
2323
documentation: "A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: \"This has been deprecated\"`.",
24+
traits: ["WithTrailingComma"],
2425
children: [
2526
Child(
2627
name: "Entry",

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,7 @@ public let DECL_NODES: [Node] = [
18711871
kind: .precedenceGroupNameElement,
18721872
base: .syntax,
18731873
nameForDiagnostics: nil,
1874+
traits: ["WithTrailingComma"],
18741875
children: [
18751876
Child(
18761877
name: "Name",
@@ -2268,6 +2269,7 @@ public let DECL_NODES: [Node] = [
22682269
traits: [
22692270
"IdentifiedDecl",
22702271
"WithAttributes",
2272+
"WithModifiers",
22712273
],
22722274
children: [
22732275
Child(

Sources/SwiftSyntax/generated/SyntaxTraits.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ extension AssociatedtypeDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax,
499499

500500
extension AttributedTypeSyntax: WithAttributesSyntax {}
501501

502+
extension AvailabilityArgumentSyntax: WithTrailingCommaSyntax {}
503+
504+
extension AvailabilityVersionRestrictionListEntrySyntax: WithTrailingCommaSyntax {}
505+
502506
extension CaseItemSyntax: WithTrailingCommaSyntax {}
503507

504508
extension CatchClauseSyntax: WithCodeBlockSyntax {}
@@ -603,6 +607,8 @@ extension PoundSourceLocationSyntax: ParenthesizedSyntax {}
603607

604608
extension PrecedenceGroupDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}
605609

610+
extension PrecedenceGroupNameElementSyntax: WithTrailingCommaSyntax {}
611+
606612
extension PrimaryAssociatedTypeSyntax: WithTrailingCommaSyntax {}
607613

608614
extension ProtocolDeclSyntax: DeclGroupSyntax, IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}
@@ -635,7 +641,7 @@ extension TupleTypeSyntax: ParenthesizedSyntax {}
635641

636642
extension TypeEffectSpecifiersSyntax: EffectSpecifiersSyntax {}
637643

638-
extension TypealiasDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax {}
644+
extension TypealiasDeclSyntax: IdentifiedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}
639645

640646
extension VariableDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}
641647

Sources/SwiftSyntaxBuilder/generated/ResultBuilders.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ public struct AvailabilitySpecListBuilder {
339339
/// If declared, this will be called on the partial result from the outermost
340340
/// block statement to produce the final returned result.
341341
public static func buildFinalResult(_ component: Component) -> FinalResult {
342-
return .init(component)
342+
let lastIndex = component.count - 1
343+
return .init(component.enumerated().map { index, source in
344+
return index < lastIndex ? source.ensuringTrailingComma() : source
345+
})
343346
}
344347
}
345348

@@ -419,7 +422,10 @@ public struct AvailabilityVersionRestrictionListBuilder {
419422
/// If declared, this will be called on the partial result from the outermost
420423
/// block statement to produce the final returned result.
421424
public static func buildFinalResult(_ component: Component) -> FinalResult {
422-
return .init(component)
425+
let lastIndex = component.count - 1
426+
return .init(component.enumerated().map { index, source in
427+
return index < lastIndex ? source.ensuringTrailingComma() : source
428+
})
423429
}
424430
}
425431

@@ -3128,7 +3134,10 @@ public struct PrecedenceGroupNameListBuilder {
31283134
/// If declared, this will be called on the partial result from the outermost
31293135
/// block statement to produce the final returned result.
31303136
public static func buildFinalResult(_ component: Component) -> FinalResult {
3131-
return .init(component)
3137+
let lastIndex = component.count - 1
3138+
return .init(component.enumerated().map { index, source in
3139+
return index < lastIndex ? source.ensuringTrailingComma() : source
3140+
})
31323141
}
31333142
}
31343143

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ final class MacroSystemTests: XCTestCase {
11231123
expandedSource: #"""
11241124
struct S {
11251125
@attr static var value1 = 1
1126-
@attr typealias A = B
1126+
@attr static typealias A = B
11271127
}
11281128
"""#,
11291129
macros: ["decls": DeclsFromStringsMacro.self],

0 commit comments

Comments
 (0)