diff --git a/CodeGeneration/Sources/SyntaxSupport/Child.swift b/CodeGeneration/Sources/SyntaxSupport/Child.swift index cdee62b383b..7d1d2760745 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Child.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Child.swift @@ -10,6 +10,8 @@ // //===----------------------------------------------------------------------===// +import SwiftSyntax + /// The kind of token a node can contain. Either a token of a specific kind or a /// keyword with the given text. public enum TokenChoice: Equatable { @@ -56,13 +58,33 @@ public enum ChildKind { /// A child of a node, that may be declared optional or a token with a /// restricted subset of acceptable kinds or texts. public class Child { + /// The name of the child. + /// + /// The first character of the name is always uppercase. public let name: String + + /// If the child has been renamed, its old, now deprecated, name. + /// + /// This is used to generate deprecated compatibility layers. public let deprecatedName: String? + + /// The kind of the child (node, token, collection, ...) public let kind: ChildKind - public let nameForDiagnostics: String? - public let documentation: String? + + /// Whether this child is optional and can be `nil`. public let isOptional: Bool + /// A name of this child that can be shown in diagnostics. + /// + /// This is used to e.g. describe the child if all of its tokens are missing in the source file. + public let nameForDiagnostics: String? + + /// A doc comment describing the child. + public let documentation: SwiftSyntax.Trivia + + /// The first line of the child's documentation + public let documentationAbstract: String + public var syntaxNodeKind: SyntaxNodeKind { switch kind { case .node(kind: let kind): @@ -77,16 +99,16 @@ public class Child { } /// A name of this child that's suitable to be used for variable or enum case names. - public var varName: String { - return lowercaseFirstWord(name: name) + public var varOrCaseName: TokenSyntax { + return .identifier(lowercaseFirstWord(name: name)) } /// The deprecated name of this child that's suitable to be used for variable or enum case names. - public var deprecatedVarName: String? { + public var deprecatedVarName: TokenSyntax? { guard let deprecatedName = deprecatedName else { return nil } - return lowercaseFirstWord(name: deprecatedName) + return .identifier(lowercaseFirstWord(name: deprecatedName)) } /// If the child ends with "token" in the kind, it's considered a token node. @@ -146,12 +168,6 @@ public class Child { } } - /// Returns `true` if this child's type is one of the base syntax kinds and - /// it's optional. - public var hasOptionalBaseType: Bool { - return hasBaseType && isOptional - } - /// If a classification is passed, it specifies the color identifiers in /// that subtree should inherit for syntax coloring. Must be a member of /// ``SyntaxClassification``. @@ -172,7 +188,8 @@ public class Child { self.deprecatedName = deprecatedName self.kind = kind self.nameForDiagnostics = nameForDiagnostics - self.documentation = documentation + self.documentation = docCommentTrivia(from: documentation) + self.documentationAbstract = String(documentation?.split(whereSeparator: \.isNewline).first ?? "") self.isOptional = isOptional } } diff --git a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift index 88bd93029d6..8d77feaec42 100644 --- a/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift @@ -181,6 +181,7 @@ public let COMMON_NODES: [Node] = [ kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ A placeholder, i.e. `<#decl#>`, that can be inserted into the source code to represent the missing declaration. + This token should always have `presence = .missing`. """ ), @@ -201,6 +202,7 @@ public let COMMON_NODES: [Node] = [ kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ A placeholder, i.e. `<#expression#>`, that can be inserted into the source code to represent the missing expression. + This token should always have `presence = .missing`. """ ) @@ -221,6 +223,7 @@ public let COMMON_NODES: [Node] = [ kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ A placeholder, i.e. `<#pattern#>`, that can be inserted into the source code to represent the missing pattern. + This token should always have `presence = .missing`. """ ) @@ -241,6 +244,7 @@ public let COMMON_NODES: [Node] = [ kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ A placeholder, i.e. `<#statement#>`, that can be inserted into the source code to represent the missing pattern. + This token should always have `presence = .missing`. """ ) @@ -261,6 +265,7 @@ public let COMMON_NODES: [Node] = [ kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ A placeholder, i.e. `<#syntax#>`, that can be inserted into the source code to represent the missing pattern. + This token should always have `presence = .missing` """ ) @@ -280,7 +285,9 @@ public let COMMON_NODES: [Node] = [ name: "Placeholder", kind: .token(choices: [.token(tokenKind: "IdentifierToken")], requiresLeadingSpace: false, requiresTrailingSpace: false), documentation: """ - A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. This token should always have `presence = .missing`. + A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. + + This token should always have `presence = .missing`. """ ) ] diff --git a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift index 542cdfcb111..8cb759d873c 100644 --- a/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift +++ b/CodeGeneration/Sources/SyntaxSupport/GrammarGenerator.swift @@ -57,7 +57,7 @@ struct GrammarGenerator { return children .filter { !$0.isUnexpectedNodes } - .map { " - `\($0.varName)`: \(generator.grammar(for: $0))" } + .map { " - `\($0.varOrCaseName)`: \(generator.grammar(for: $0))" } .joined(separator: "\n") } } diff --git a/CodeGeneration/Sources/SyntaxSupport/Utils.swift b/CodeGeneration/Sources/SyntaxSupport/Utils.swift index 29405fe19be..b555aa58c5a 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Utils.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Utils.swift @@ -65,3 +65,15 @@ public extension Collection { } } } + +public extension TokenSyntax { + var backtickedIfNeeded: TokenSyntax { + if KEYWORDS.contains(where: { + $0.name == self.description && $0.isLexerClassified + }) { + return "`\(self)`" + } else { + return self + } + } +} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/LayoutNode+Extensions.swift b/CodeGeneration/Sources/generate-swiftsyntax/LayoutNode+Extensions.swift index f3bb390fd70..66a0dcbbbfc 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/LayoutNode+Extensions.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/LayoutNode+Extensions.swift @@ -39,18 +39,18 @@ extension LayoutNode { } } - let parameterName: String + let parameterName: TokenSyntax if useDeprecatedChildName, let deprecatedVarName = child.deprecatedVarName { parameterName = deprecatedVarName } else { - parameterName = child.varName + parameterName = child.varOrCaseName } return FunctionParameterSyntax( leadingTrivia: .newline, - firstName: child.isUnexpectedNodes ? .wildcardToken(trailingTrivia: .space) : .identifier(parameterName), - secondName: child.isUnexpectedNodes ? .identifier(parameterName) : nil, + firstName: child.isUnexpectedNodes ? .wildcardToken(trailingTrivia: .space) : parameterName, + secondName: child.isUnexpectedNodes ? parameterName : nil, colon: .colonToken(), type: paramType, defaultArgument: child.defaultInitialization @@ -77,13 +77,10 @@ extension LayoutNode { func generateInitializerDocComment() -> SwiftSyntax.Trivia { func generateParamDocComment(for child: Child) -> String? { - guard let documentation = child.documentation, - let firstLine = documentation.split(whereSeparator: \.isNewline).first - else { + if child.documentationAbstract.isEmpty { return nil } - - return " - \(child.varName): \(firstLine)" + return " - \(child.varOrCaseName): \(child.documentationAbstract)" } let formattedParams = """ @@ -114,12 +111,12 @@ extension LayoutNode { for child in children { /// The expression that is used to call the default initializer defined above. let produceExpr: ExprSyntax - let childName: String + let childName: TokenSyntax if useDeprecatedChildName, let deprecatedVarName = child.deprecatedVarName { childName = deprecatedVarName } else { - childName = child.varName + childName = child.varOrCaseName } if child.type.isBuilderInitializable { @@ -129,12 +126,12 @@ extension LayoutNode { if child.type.builderInitializableType != child.type { let param = Node.from(type: child.type).layoutNode!.singleNonDefaultedChild if child.isOptional { - produceExpr = ExprSyntax("\(raw: childName)Builder().map { \(raw: child.type.syntaxBaseName)(\(raw: param.varName): $0) }") + produceExpr = ExprSyntax("\(childName)Builder().map { \(raw: child.type.syntaxBaseName)(\(param.varOrCaseName): $0) }") } else { - produceExpr = ExprSyntax("\(raw: child.type.syntaxBaseName)(\(raw: param.varName): \(raw: childName)Builder())") + produceExpr = ExprSyntax("\(raw: child.type.syntaxBaseName)(\(param.varOrCaseName): \(childName)Builder())") } } else { - produceExpr = ExprSyntax("\(raw: childName)Builder()") + produceExpr = ExprSyntax("\(childName)Builder()") } builderParameters.append( FunctionParameterSyntax( @@ -145,14 +142,20 @@ extension LayoutNode { produceExpr = convertFromSyntaxProtocolToSyntaxType(child: child, useDeprecatedChildName: useDeprecatedChildName) normalParameters.append( FunctionParameterSyntax( - firstName: .identifier(childName), + firstName: childName, colon: .colonToken(), type: child.parameterType, defaultArgument: child.defaultInitialization ) ) } - delegatedInitArgs.append(TupleExprElementSyntax(label: child.isUnexpectedNodes ? nil : child.varName, expression: produceExpr)) + delegatedInitArgs.append( + TupleExprElementSyntax( + label: child.isUnexpectedNodes ? nil : child.varOrCaseName, + colon: child.isUnexpectedNodes ? nil : .colonToken(), + expression: produceExpr + ) + ) } guard shouldCreateInitializer else { @@ -185,11 +188,11 @@ extension LayoutNode { } fileprivate func convertFromSyntaxProtocolToSyntaxType(child: Child, useDeprecatedChildName: Bool = false) -> ExprSyntax { - let childName: String + let childName: TokenSyntax if useDeprecatedChildName, let deprecatedVarName = child.deprecatedVarName { childName = deprecatedVarName } else { - childName = child.varName + childName = child.varOrCaseName } if child.type.isBaseType && !child.kind.isNodeChoices { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift index 6fa493e5561..702c0245f0d 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift @@ -25,7 +25,7 @@ let childNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader for node in NON_BASE_SYNTAX_NODES.compactMap(\.layoutNode) { for child in node.children { if let nameForDiagnostics = child.nameForDiagnostics { - SwitchCaseSyntax("case \\\(raw: node.type.syntaxBaseName).\(raw: child.varName):") { + SwitchCaseSyntax("case \\\(raw: node.type.syntaxBaseName).\(child.varOrCaseName):") { StmtSyntax(#"return "\#(raw: nameForDiagnostics)""#) } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/ChildNameForKeyPathFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/ChildNameForKeyPathFile.swift index 933b4a4a137..e8ba810b865 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/ChildNameForKeyPathFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/ChildNameForKeyPathFile.swift @@ -29,8 +29,8 @@ let childNameForKeyPathFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { for child in node.children { SwitchCaseSyntax( """ - case \\\(raw: node.type.syntaxBaseName).\(raw: child.varName): - return \(literal: child.varName) + case \\\(raw: node.type.syntaxBaseName).\(child.varOrCaseName): + return \(literal: child.varOrCaseName.description) """ ) } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift index 319bed3c599..1276247f8cb 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift @@ -22,7 +22,7 @@ fileprivate extension Node { return node.children.compactMap { child -> (name: TokenSyntax, choices: [(caseName: TokenSyntax, kind: SyntaxNodeKind)])? in switch child.kind { case .nodeChoices(let choices): - return (.identifier(child.name), choices.map { (.identifier($0.varName), $0.syntaxNodeKind) }) + return (.identifier(child.name), choices.map { ($0.varOrCaseName, $0.syntaxNodeKind) }) default: return nil } @@ -202,8 +202,8 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { let params = FunctionParameterListSyntax { for child in node.children { FunctionParameterSyntax( - firstName: child.isUnexpectedNodes ? .wildcardToken(trailingTrivia: .space) : .identifier(child.varName), - secondName: child.isUnexpectedNodes ? .identifier(child.varName) : nil, + firstName: child.isUnexpectedNodes ? .wildcardToken(trailingTrivia: .space) : child.varOrCaseName, + secondName: child.isUnexpectedNodes ? child.varOrCaseName : nil, colon: .colonToken(), type: child.rawParameterType, defaultArgument: child.isUnexpectedNodes ? child.defaultInitialization : nil @@ -218,7 +218,7 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { ExprSyntax("layout.initialize(repeating: nil)") for (index, child) in node.children.enumerated() { let optionalMark = child.isOptional ? "?" : "" - ExprSyntax("layout[\(raw: index)] = \(raw: child.varName.backtickedIfNeeded)\(raw: optionalMark).raw") + ExprSyntax("layout[\(raw: index)] = \(child.varOrCaseName.backtickedIfNeeded)\(raw: optionalMark).raw") .with(\.leadingTrivia, .newline) } } @@ -238,7 +238,7 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } for (index, child) in node.children.enumerated() { - try VariableDeclSyntax("public var \(raw: child.varName.backtickedIfNeeded): Raw\(raw: child.type.buildable)") { + try VariableDeclSyntax("public var \(child.varOrCaseName.backtickedIfNeeded): Raw\(raw: child.type.buildable)") { let iuoMark = child.isOptional ? "" : "!" if child.syntaxNodeKind == .syntax { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift index d0d130b5d6a..6dd85158f13 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift @@ -25,13 +25,13 @@ let renamedChildrenCompatibilityFile = try! SourceFileSyntax(leadingTrivia: copy DeclSyntax( """ - @available(*, deprecated, renamed: "\(raw: child.varName)") + @available(*, deprecated, renamed: "\(child.varOrCaseName)") public var \(raw: deprecatedVarName): \(raw: type) { get { - return \(raw: child.varName.backtickedIfNeeded) + return \(child.varOrCaseName.backtickedIfNeeded) } set { - \(raw: child.varName.backtickedIfNeeded) = newValue + \(child.varOrCaseName.backtickedIfNeeded) = newValue } } """ @@ -57,7 +57,7 @@ let renamedChildrenCompatibilityFile = try! SourceFileSyntax(leadingTrivia: copy let deprecatedNames = layoutNode.children .filter { !$0.isUnexpectedNodes && $0.deprecatedName != nil } - .map { $0.varName } + .map { $0.varOrCaseName.description } .joined(separator: ", ") try! InitializerDeclSyntax( @@ -71,9 +71,13 @@ let renamedChildrenCompatibilityFile = try! SourceFileSyntax(leadingTrivia: copy TupleExprElementSyntax(label: "leadingTrivia", expression: ExprSyntax("leadingTrivia")) for child in layoutNode.children { if child.isUnexpectedNodes { - TupleExprElementSyntax(expression: ExprSyntax("\(raw: child.deprecatedVarName ?? child.varName)")) + TupleExprElementSyntax(expression: ExprSyntax("\(raw: child.deprecatedVarName ?? child.varOrCaseName)")) } else { - TupleExprElementSyntax(label: "\(child.varName)", expression: ExprSyntax("\(raw: child.deprecatedVarName ?? child.varName)")) + TupleExprElementSyntax( + label: child.varOrCaseName, + colon: .colonToken(), + expression: IdentifierExprSyntax(identifier: child.deprecatedVarName ?? child.varOrCaseName) + ) } } TupleExprElementSyntax(label: "trailingTrivia", expression: ExprSyntax("trailingTrivia")) diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift index 8408d609ad3..9cc31607337 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodesFile.swift @@ -15,17 +15,6 @@ import SwiftSyntaxBuilder import SyntaxSupport import Utils -extension Child { - public var docComment: SwiftSyntax.Trivia { - guard let description = documentation else { - return [] - } - let lines = description.split(separator: "\n", omittingEmptySubsequences: false) - let pieces = lines.map { SwiftSyntax.TriviaPiece.docLineComment("/// \($0)") } - return Trivia(pieces: pieces) - } -} - /// This file generates the syntax nodes for SwiftSyntax. To keep the generated /// files at a manageable file size, it is to be invoked multiple times with the /// variable `emitKind` set to a base kind listed in @@ -89,7 +78,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { ) { let parameters = ClosureParameterListSyntax { for child in node.children { - ClosureParameterSyntax(firstName: .identifier(child.varName.backtickedIfNeeded)) + ClosureParameterSyntax(firstName: child.varOrCaseName.backtickedIfNeeded) } } @@ -107,7 +96,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { for child in node.children { ArrayElementSyntax( expression: MemberAccessExprSyntax( - base: child.type.optionalChained(expr: ExprSyntax("\(raw: child.varName.backtickedIfNeeded)")), + base: child.type.optionalChained(expr: ExprSyntax("\(child.varOrCaseName.backtickedIfNeeded)")), period: .periodToken(), name: "raw" ) @@ -168,8 +157,8 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { try! VariableDeclSyntax( """ - \(raw: child.docComment) - public var \(raw: child.varName.backtickedIfNeeded): \(type) + \(raw: child.documentation) + public var \(child.varOrCaseName.backtickedIfNeeded): \(type) """ ) { AccessorDeclSyntax(accessorSpecifier: .keyword(.get)) { @@ -202,12 +191,12 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { DeclSyntax( """ - /// Adds the provided `element` to the node's `\(raw: child.varName)` + /// Adds the provided `element` to the node's `\(child.varOrCaseName)` /// collection. /// - param element: The new `\(raw: childElt)` to add to the node's - /// `\(raw: child.varName)` collection. + /// `\(child.varOrCaseName)` collection. /// - returns: A copy of the receiver with the provided `\(raw: childElt)` - /// appended to its `\(raw: child.varName)` collection. + /// appended to its `\(child.varOrCaseName)` collection. public func add\(raw: childElt)(_ element: \(raw: childEltType)) -> \(node.kind.syntaxType) { var collection: RawSyntax let arena = SyntaxArena() @@ -229,7 +218,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax { let layout = ArrayExprSyntax { for child in node.children { ArrayElementSyntax( - expression: ExprSyntax(#"\Self.\#(raw: child.varName)"#) + expression: ExprSyntax(#"\Self.\#(child.varOrCaseName)"#) ) } } @@ -248,13 +237,13 @@ private func generateSyntaxChildChoices(for child: Child) throws -> EnumDeclSynt return try! EnumDeclSyntax("public enum \(raw: child.name): SyntaxChildChoices") { for choice in choices { - DeclSyntax("case `\(raw: choice.varName)`(\(raw: choice.syntaxNodeKind.syntaxType))") + DeclSyntax("case `\(choice.varOrCaseName)`(\(raw: choice.syntaxNodeKind.syntaxType))") } try! VariableDeclSyntax("public var _syntaxNode: Syntax") { try! SwitchExprSyntax("switch self") { for choice in choices { - SwitchCaseSyntax("case .\(raw: choice.varName)(let node):") { + SwitchCaseSyntax("case .\(choice.varOrCaseName)(let node):") { StmtSyntax("return node._syntaxNode") } } @@ -268,7 +257,7 @@ private func generateSyntaxChildChoices(for child: Child) throws -> EnumDeclSynt DeclSyntax( """ public init(_ node: some \(choiceNode.kind.protocolType)) { - self = .\(raw: choice.varName)(\(choiceNode.kind.syntaxType)(node)) + self = .\(choice.varOrCaseName)(\(choiceNode.kind.syntaxType)(node)) } """ ) @@ -277,7 +266,7 @@ private func generateSyntaxChildChoices(for child: Child) throws -> EnumDeclSynt DeclSyntax( """ public init(_ node: \(choice.syntaxNodeKind.syntaxType)) { - self = .\(raw: choice.varName)(node) + self = .\(choice.varOrCaseName)(node) } """ ) @@ -289,7 +278,7 @@ private func generateSyntaxChildChoices(for child: Child) throws -> EnumDeclSynt StmtSyntax( """ if let node = node.as(\(choice.syntaxNodeKind.syntaxType).self) { - self = .\(raw: choice.varName)(node) + self = .\(choice.varOrCaseName)(node) return } """ diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTraitsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTraitsFile.swift index 8dec61eff10..fc4cd4cbe0d 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTraitsFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTraitsFile.swift @@ -28,8 +28,8 @@ let syntaxTraitsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { for child in trait.children { DeclSyntax( """ - \(raw: child.docComment) - var \(raw: child.varName): \(child.syntaxNodeKind.syntaxType)\(raw: child.isOptional ? "?" : "") { get set } + \(raw: child.documentation) + var \(child.varOrCaseName): \(child.syntaxNodeKind.syntaxType)\(raw: child.isOptional ? "?" : "") { get set } """ ) } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/RenamedChildrenBuilderCompatibilityFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/RenamedChildrenBuilderCompatibilityFile.swift index ea114bd94e1..aa082a58ef4 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/RenamedChildrenBuilderCompatibilityFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntaxbuilder/RenamedChildrenBuilderCompatibilityFile.swift @@ -22,7 +22,7 @@ let renamedChildrenBuilderCompatibilityFile = try! SourceFileSyntax(leadingTrivi if let convenienceInit = try layoutNode.createConvenienceBuilderInitializer(useDeprecatedChildName: true) { let deprecatedNames = layoutNode.children .filter { !$0.isUnexpectedNodes && $0.deprecatedName != nil } - .compactMap { $0.varName } + .compactMap { $0.varOrCaseName.description } .joined(separator: ", ") DeclSyntax( diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift index 26d7383d8ba..36e58a1bfba 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift @@ -4803,7 +4803,9 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#decl#>`, that can be inserted into the source code to represent the missing declaration./// This token should always have `presence = .missing`. + /// A placeholder, i.e. `<#decl#>`, that can be inserted into the source code to represent the missing declaration. + /// + /// This token should always have `presence = .missing`. public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 5, parent: Syntax(self))!) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index 678ba544fec..7022596bfbd 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -4171,7 +4171,9 @@ public struct MissingExprSyntax: ExprSyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#expression#>`, that can be inserted into the source code to represent the missing expression./// This token should always have `presence = .missing`. + /// A placeholder, i.e. `<#expression#>`, that can be inserted into the source code to represent the missing expression. + /// + /// This token should always have `presence = .missing`. public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 1, parent: Syntax(self))!) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index 39555a96445..d392b02754b 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -13475,7 +13475,9 @@ public struct MissingSyntax: SyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#syntax#>`, that can be inserted into the source code to represent the missing pattern./// This token should always have `presence = .missing` + /// A placeholder, i.e. `<#syntax#>`, that can be inserted into the source code to represent the missing pattern. + /// + /// This token should always have `presence = .missing` public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 1, parent: Syntax(self))!) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift index 97180ce2a9d..90760fd732c 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift @@ -363,7 +363,9 @@ public struct MissingPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#pattern#>`, that can be inserted into the source code to represent the missing pattern./// This token should always have `presence = .missing`. + /// A placeholder, i.e. `<#pattern#>`, that can be inserted into the source code to represent the missing pattern. + /// + /// This token should always have `presence = .missing`. public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 1, parent: Syntax(self))!) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift index c04d524150e..6acb3b69a7c 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift @@ -1589,7 +1589,9 @@ public struct MissingStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#statement#>`, that can be inserted into the source code to represent the missing pattern./// This token should always have `presence = .missing`. + /// A placeholder, i.e. `<#statement#>`, that can be inserted into the source code to represent the missing pattern. + /// + /// This token should always have `presence = .missing`. public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 1, parent: Syntax(self))!) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift index a133c6af7a3..4832a1b0712 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift @@ -1550,7 +1550,7 @@ public struct MissingTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. - /// - placeholder: A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. This token should always have `presence = .missing`. + /// - placeholder: A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1586,7 +1586,9 @@ public struct MissingTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { } } - /// A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. This token should always have `presence = .missing`. + /// A placeholder, i.e. `<#type#>`, that can be inserted into the source code to represent the missing type. + /// + /// This token should always have `presence = .missing`. public var placeholder: TokenSyntax { get { return TokenSyntax(data.child(at: 1, parent: Syntax(self))!)