diff --git a/CodeGeneration/Sources/SyntaxSupport/Classification.swift b/CodeGeneration/Sources/SyntaxSupport/Classification.swift index 0b1f5337734..1e04d5fe6e0 100644 --- a/CodeGeneration/Sources/SyntaxSupport/Classification.swift +++ b/CodeGeneration/Sources/SyntaxSupport/Classification.swift @@ -28,16 +28,15 @@ public class SyntaxClassification { public class ChildClassification { public let parent: Node public let childIndex: Int - public let isToken: Bool - public let classification: SyntaxClassification? - public let force: Bool + public let child: Child + public var isToken: Bool { child.isToken } + public var classification: SyntaxClassification? { child.classification } + public var force: Bool { child.forceClassification } public init(node: Node, childIndex: Int, child: Child) { self.parent = node self.childIndex = childIndex - self.isToken = child.syntaxKind.hasSuffix("Token") - self.classification = child.classification - self.force = child.forceClassification + self.child = child } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift b/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift index fb56944b477..3c32c01409a 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift @@ -22,6 +22,7 @@ private let generatedDirName = "generated" private let swiftBasicFormatGeneratedDir = ["SwiftBasicFormat", generatedDirName] private let ideUtilsGeneratedDir = ["IDEUtils", generatedDirName] private let swiftParserGeneratedDir = ["SwiftParser", generatedDirName] +private let swiftParserDiagnosticsGeneratedDir = ["SwiftParserDiagnostics", generatedDirName] private let swiftSyntaxGeneratedDir = ["SwiftSyntax", generatedDirName] private let swiftSyntaxBuilderGeneratedDir = ["SwiftSyntaxBuilder", generatedDirName] private let BASE_KIND_FILES = [ @@ -86,13 +87,18 @@ struct GenerateSwiftSyntax: ParsableCommand { // SwiftParser GeneratedFileSpec(swiftParserGeneratedDir + ["DeclarationModifier.swift"], declarationModifierFile), + GeneratedFileSpec(swiftParserGeneratedDir + ["IsLexerClassified.swift"], isLexerClassifiedFile), GeneratedFileSpec(swiftParserGeneratedDir + ["Parser+Entry.swift"], parserEntryFile), GeneratedFileSpec(swiftParserGeneratedDir + ["TokenSpecStaticMembers.swift"], tokenSpecStaticMembersFile), GeneratedFileSpec(swiftParserGeneratedDir + ["TypeAttribute.swift"], typeAttributeFile), + // SwiftParserDiagnostics + GeneratedFileSpec(swiftParserDiagnosticsGeneratedDir + ["ChildNameForDiagnostics.swift"], childNameForDiagnosticFile), + GeneratedFileSpec(swiftParserDiagnosticsGeneratedDir + ["SyntaxKindNameForDiagnostics.swift"], syntaxKindNameForDiagnosticFile), + GeneratedFileSpec(swiftParserDiagnosticsGeneratedDir + ["TokenNameForDiagnostics.swift"], tokenNameForDiagnosticFile), + // SwiftSyntax GeneratedFileSpec(swiftSyntaxGeneratedDir + ["Keyword.swift"], keywordFile), - GeneratedFileSpec(swiftSyntaxGeneratedDir + ["Misc.swift"], miscFile), GeneratedFileSpec(swiftSyntaxGeneratedDir + ["raw", "RawSyntaxNodes.swift"], rawSyntaxNodesFile), GeneratedFileSpec(swiftSyntaxGeneratedDir + ["raw", "RawSyntaxValidation.swift"], rawSyntaxValidationFile), GeneratedFileSpec(swiftSyntaxGeneratedDir + ["SyntaxAnyVisitor.swift"], syntaxAnyVisitorFile), diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift index 3d057088086..05eeabd1119 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift @@ -62,11 +62,11 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { DeclSyntax( """ open override func visitPre(_ node: Syntax) { - if let keyPath = getKeyPath(node), shouldIndent(keyPath) { + if let keyPath = node.keyPathInParent, shouldIndent(keyPath) { indentationLevel += 1 } if let parent = node.parent, childrenSeparatedByNewline(parent) { - putNextTokenOnNewLine = true && node.previousToken != nil + putNextTokenOnNewLine = true && node.previousToken(viewMode: .sourceAccurate) != nil } } """ @@ -74,7 +74,7 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { DeclSyntax( """ open override func visitPost(_ node: Syntax) { - if let keyPath = getKeyPath(node), shouldIndent(keyPath) { + if let keyPath = node.keyPathInParent, shouldIndent(keyPath) { indentationLevel -= 1 } } @@ -92,7 +92,7 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { if requiresTrailingSpace(node) && trailingTrivia.isEmpty { trailingTrivia += .space } - if let keyPath = getKeyPath(Syntax(node)), requiresLeadingNewline(keyPath), !(leadingTrivia.first?.isNewline ?? false), !shouldOmitNewline(node) { + if let keyPath = node.keyPathInParent, requiresLeadingNewline(keyPath), !(leadingTrivia.first?.isNewline ?? false), !shouldOmitNewline(node) { leadingTrivia = .newline + leadingTrivia } var isOnNewline: Bool = (lastRewrittenToken?.trailingTrivia.pieces.last?.isNewline == true) @@ -206,7 +206,7 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try FunctionDeclSyntax("open func requiresLeadingSpace(_ token: TokenSyntax) -> Bool") { StmtSyntax( """ - if let keyPath = getKeyPath(token), let requiresLeadingSpace = requiresLeadingSpace(keyPath) { + if let keyPath = token.keyPathInParent, let requiresLeadingSpace = requiresLeadingSpace(keyPath) { return requiresLeadingSpace } """ @@ -268,7 +268,7 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { try FunctionDeclSyntax("open func requiresTrailingSpace(_ token: TokenSyntax) -> Bool") { StmtSyntax( """ - if let keyPath = getKeyPath(token), let requiresTrailingSpace = requiresTrailingSpace(keyPath) { + if let keyPath = token.keyPathInParent, let requiresTrailingSpace = requiresTrailingSpace(keyPath) { return requiresTrailingSpace } """ @@ -311,19 +311,5 @@ let basicFormatFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } } } - - DeclSyntax( - """ - private func getKeyPath(_ node: T) -> AnyKeyPath? { - guard let parent = node.parent else { - return nil - } - guard case .layout(let childrenKeyPaths) = parent.kind.syntaxNodeType.structure else { - return nil - } - return childrenKeyPaths[node.indexInParent] - } - """ - ) } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/ideutils/SyntaxClassificationFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/ideutils/SyntaxClassificationFile.swift index 1db6948b9f9..92d3b5c60fb 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/ideutils/SyntaxClassificationFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/ideutils/SyntaxClassificationFile.swift @@ -53,35 +53,17 @@ let syntaxClassificationFile = SourceFileSyntax(leadingTrivia: copyrightHeader) /// - childKind: The node syntax kind. /// - Returns: A pair of classification and whether it is "forced", or nil if /// no classification is attached. - internal static func classify( - parentKind: SyntaxKind, indexInParent: Int, childKind: SyntaxKind - ) -> (SyntaxClassification, Bool)? + internal static func classify(_ keyPath: AnyKeyPath) -> (SyntaxClassification, Bool)? """ ) { - try IfExprSyntax( - """ - // Separate checks for token nodes (most common checks) versus checks for layout nodes. - if childKind == .token - """ - ) { - try SwitchExprSyntax("switch (parentKind, indexInParent)") { - for childClassification in node_child_classifications where childClassification.isToken { - SwitchCaseSyntax("case (.\(raw: childClassification.parent.swiftSyntaxKind), \(raw: childClassification.childIndex)):") { - StmtSyntax("return (.\(raw: childClassification.classification!.swiftName), \(raw: childClassification.force))") - } + try SwitchExprSyntax("switch keyPath") { + for childClassification in node_child_classifications { + SwitchCaseSyntax("case \\\(raw: childClassification.parent.type.syntaxBaseName).\(raw: childClassification.child.swiftName):") { + StmtSyntax("return (.\(raw: childClassification.classification!.swiftName), \(raw: childClassification.force))") } - - SwitchCaseSyntax("default: return nil") } - } else: { - try SwitchExprSyntax("switch (parentKind, indexInParent)") { - for childClassification in node_child_classifications where !childClassification.isToken { - SwitchCaseSyntax("case (.\(raw: childClassification.parent.swiftSyntaxKind), \(raw: childClassification.childIndex)):") { - StmtSyntax("return (.\(raw: childClassification.classification!.swiftName), \(raw: childClassification.force))") - } - } - - SwitchCaseSyntax("default: return nil") + SwitchCaseSyntax("default:") { + StmtSyntax("return nil") } } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/IsLexerClassifiedFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/IsLexerClassifiedFile.swift new file mode 100644 index 00000000000..af92b5b11ed --- /dev/null +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/IsLexerClassifiedFile.swift @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax +import SwiftSyntaxBuilder +import SyntaxSupport +import Utils + +let isLexerClassifiedFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { + DeclSyntax("import SwiftSyntax") + + try! ExtensionDeclSyntax( + """ + extension Keyword + """ + ) { + try! VariableDeclSyntax( + """ + /// Whether the token kind is switched from being an identifier to being a keyword in the lexer. + /// This is true for keywords that used to be considered non-contextual. + var isLexerClassified: Bool + """ + ) { + try! SwitchExprSyntax("switch self") { + for keyword in KEYWORDS { + if keyword.isLexerClassified { + SwitchCaseSyntax("case .\(raw: keyword.escapedName): return true") + } + } + SwitchCaseSyntax("default: return false") + } + } + } + + try! ExtensionDeclSyntax( + """ + extension TokenKind + """ + ) { + try! VariableDeclSyntax( + """ + /// Returns `true` if the token is a Swift keyword. + /// + /// Keywords are reserved unconditionally for use by Swift and may not + /// appear as identifiers in any position without being escaped. For example, + /// `class`, `func`, or `import`. + public var isLexerClassifiedKeyword: Bool + """ + ) { + try! SwitchExprSyntax("switch self") { + SwitchCaseSyntax("case .eof:") { + StmtSyntax("return false") + } + + for token in SYNTAX_TOKENS where token.isKeyword { + SwitchCaseSyntax("case .\(raw: token.swiftKind):") { + StmtSyntax("return true") + } + } + + SwitchCaseSyntax("case .keyword(let keyword):") { + StmtSyntax("return keyword.isLexerClassified") + } + SwitchCaseSyntax("default: return false") + } + } + } +} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/TokenSpecStaticMembersFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/TokenSpecStaticMembersFile.swift index 6ade244e5ac..971ec7c3f03 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/TokenSpecStaticMembersFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/TokenSpecStaticMembersFile.swift @@ -16,7 +16,7 @@ import SyntaxSupport import Utils let tokenSpecStaticMembersFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - DeclSyntax("import SwiftSyntax") + DeclSyntax("@_spi(RawSyntax) import SwiftSyntax") try! ExtensionDeclSyntax("extension TokenSpec") { DeclSyntax("static var eof: TokenSpec { return TokenSpec(.eof) }") diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift new file mode 100644 index 00000000000..b0de7450f29 --- /dev/null +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/ChildNameForDiagnosticsFile.swift @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax +import SwiftSyntaxBuilder +import SyntaxSupport +import Utils + +let childNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { + DeclSyntax("import SwiftSyntax") + + try! FunctionDeclSyntax( + "private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String?" + ) { + try! SwitchExprSyntax("switch keyPath") { + for node in NON_BASE_SYNTAX_NODES where !node.isSyntaxCollection { + for child in node.children { + if let nameForDiagnostics = child.nameForDiagnostics { + SwitchCaseSyntax("case \\\(raw: node.type.syntaxBaseName).\(raw: child.swiftName):") { + StmtSyntax(#"return "\#(raw: nameForDiagnostics)""#) + } + } + } + } + SwitchCaseSyntax( + """ + default: + return nil + """ + ) + } + } + + DeclSyntax( + """ + extension SyntaxProtocol { + var childNameInParent: String? { + guard let keyPath = self.keyPathInParent else { + return nil + } + return childNameForDiagnostics(keyPath) + } + } + """ + ) + +} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift new file mode 100644 index 00000000000..fefa05cc789 --- /dev/null +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/SyntaxKindNameForDiagnosticsFile.swift @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax +import SwiftSyntaxBuilder +import SyntaxSupport +import Utils + +let syntaxKindNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { + DeclSyntax("import SwiftSyntax") + + try! ExtensionDeclSyntax("extension SyntaxKind") { + try VariableDeclSyntax("var nameForDiagnostics: String?") { + try SwitchExprSyntax("switch self") { + SwitchCaseSyntax("case .token:") { + StmtSyntax(#"return "token""#) + } + + for node in NON_BASE_SYNTAX_NODES { + if let nameForDiagnostics = node.nameForDiagnostics { + SwitchCaseSyntax("case .\(raw: node.swiftSyntaxKind):") { + StmtSyntax("return \"\(raw: nameForDiagnostics)\"") + } + } + } + SwitchCaseSyntax( + """ + default: + return nil + """ + ) + } + } + } +} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/TokenNameForDiagnosticsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/TokenNameForDiagnosticsFile.swift new file mode 100644 index 00000000000..0f09ee1d5ec --- /dev/null +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparserdiagnostics/TokenNameForDiagnosticsFile.swift @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax +import SwiftSyntaxBuilder +import SyntaxSupport +import Utils + +let tokenNameForDiagnosticFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { + DeclSyntax("@_spi(RawSyntax) import SwiftSyntax") + + try! ExtensionDeclSyntax("extension TokenKind") { + try! VariableDeclSyntax("var nameForDiagnostics: String") { + try! SwitchExprSyntax("switch self") { + SwitchCaseSyntax("case .eof:") { + StmtSyntax(#"return "end of file""#) + } + + for token in SYNTAX_TOKENS where token.swiftKind != "keyword" { + SwitchCaseSyntax("case .\(raw: token.swiftKind):") { + StmtSyntax("return #\"\(raw: token.nameForDiagnostics)\"#") + } + } + SwitchCaseSyntax("case .keyword(let keyword):") { + StmtSyntax("return String(syntaxText: keyword.defaultText)") + } + } + } + } +} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift index 2a8b04d14ca..3b94cc4a46e 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift @@ -22,17 +22,6 @@ let lookupTable = ArrayExprSyntax(leftSquare: .leftSquareBracketToken(trailingTr } let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - DeclSyntax( - """ - /// Make `StaticString` equatable so we can use it as the raw value for Keyword. - extension StaticString: Equatable { - public static func == (lhs: StaticString, rhs: StaticString) -> Bool { - return SyntaxText(lhs) == SyntaxText(rhs) - } - } - """ - ) - try! EnumDeclSyntax( """ @frozen // FIXME: Not actually stable, works around a miscompile @@ -61,23 +50,6 @@ let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } } - try! VariableDeclSyntax( - """ - /// Whether the token kind is switched from being an identifier to being a keyword in the lexer. - /// This is true for keywords that used to be considered non-contextual. - public var isLexerClassified: Bool - """ - ) { - try! SwitchExprSyntax("switch self") { - for keyword in KEYWORDS { - if keyword.isLexerClassified { - SwitchCaseSyntax("case .\(raw: keyword.escapedName): return true") - } - } - SwitchCaseSyntax("default: return false") - } - } - DeclSyntax( """ /// This is really unfortunate. Really, we should have a `switch` in diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/MiscFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/MiscFile.swift deleted file mode 100644 index 795eaeddb1f..00000000000 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/MiscFile.swift +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import SwiftSyntax -import SwiftSyntaxBuilder -import SyntaxSupport -import Utils - -let miscFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { - try! ExtensionDeclSyntax("extension Syntax") { - try VariableDeclSyntax("public static var structure: SyntaxNodeStructure") { - let choices = ArrayExprSyntax { - ArrayElementSyntax( - leadingTrivia: .newline, - expression: ExprSyntax(".node(TokenSyntax.self)") - ) - - for node in NON_BASE_SYNTAX_NODES { - ArrayElementSyntax( - leadingTrivia: .newline, - expression: ExprSyntax(".node(\(raw: node.name).self)") - ) - } - } - - StmtSyntax("return .choices(\(choices))") - } - } - - try! ExtensionDeclSyntax("extension SyntaxKind") { - try VariableDeclSyntax("public var syntaxNodeType: SyntaxProtocol.Type") { - try SwitchExprSyntax("switch self") { - SwitchCaseSyntax("case .token:") { - StmtSyntax("return TokenSyntax.self") - } - - for node in NON_BASE_SYNTAX_NODES { - SwitchCaseSyntax("case .\(raw: node.swiftSyntaxKind):") { - StmtSyntax("return \(raw: node.name).self") - } - } - } - } - - try VariableDeclSyntax("public var nameForDiagnostics: String?") { - try SwitchExprSyntax("switch self") { - SwitchCaseSyntax("case .token:") { - StmtSyntax(#"return "token""#) - } - - for node in NON_BASE_SYNTAX_NODES { - SwitchCaseSyntax("case .\(raw: node.swiftSyntaxKind):") { - if let nameForDiagnostics = node.nameForDiagnostics { - StmtSyntax("return \"\(raw: nameForDiagnostics)\"") - } else { - StmtSyntax("return nil") - } - } - } - } - } - } -} diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift index 5639dba947f..f441aa96fdc 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift @@ -232,14 +232,6 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { StmtSyntax("return .choices(\(choices))") } - - DeclSyntax( - """ - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } - """ - ) } DeclSyntax( @@ -254,4 +246,25 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { """ ) } + + try! ExtensionDeclSyntax("extension Syntax") { + try VariableDeclSyntax("public static var structure: SyntaxNodeStructure") { + let choices = ArrayExprSyntax { + ArrayElementSyntax( + leadingTrivia: .newline, + expression: ExprSyntax(".node(TokenSyntax.self)") + ) + + for node in NON_BASE_SYNTAX_NODES { + ArrayElementSyntax( + leadingTrivia: .newline, + expression: ExprSyntax(".node(\(raw: node.name).self)") + ) + } + } + + StmtSyntax("return .choices(\(choices))") + } + } + } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift index c38b9fd7aa5..35308524513 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxCollectionsFile.swift @@ -136,8 +136,7 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { DeclSyntax( """ - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } """ @@ -180,7 +179,7 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { DeclSyntax( """ /// The number of elements, `present` or `missing`, in this collection. - public var count: Int { return raw.layoutView!.children.count } + public var count: Int { return layoutView.children.count } """ ) @@ -314,14 +313,6 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } """ ) - - DeclSyntax( - """ - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } - """ - ) } try! ExtensionDeclSyntax( diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift index 9932d6adbda..ab780c870fd 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxKindFile.swift @@ -55,5 +55,19 @@ let syntaxKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } } } + + try VariableDeclSyntax("public var syntaxNodeType: SyntaxProtocol.Type") { + try SwitchExprSyntax("switch self") { + SwitchCaseSyntax("case .token:") { + StmtSyntax("return TokenSyntax.self") + } + + for node in NON_BASE_SYNTAX_NODES { + SwitchCaseSyntax("case .\(raw: node.swiftSyntaxKind):") { + StmtSyntax("return \(raw: node.name).self") + } + } + } + } } } diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodeFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodeFile.swift index 611db94870d..c0f00930116 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodeFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxNodeFile.swift @@ -258,27 +258,6 @@ func syntaxNode(emitKind: String) -> SourceFileSyntax { StmtSyntax("return .layout(\(layout))") } - - try! FunctionDeclSyntax("public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String?") { - try! SwitchExprSyntax("switch index.data?.indexInParent") { - for (index, child) in node.children.enumerated() { - SwitchCaseSyntax("case \(raw: index):") { - if let nameForDiagnostics = child.nameForDiagnostics { - StmtSyntax(#"return "\#(raw: nameForDiagnostics)""#) - } else { - StmtSyntax("return nil") - } - } - } - - SwitchCaseSyntax( - """ - default: - fatalError("Invalid index") - """ - ) - } - } } try! ExtensionDeclSyntax("extension \(raw: node.name): CustomReflectable") { diff --git a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift index f2d3cba606a..3b9fb00cf0c 100644 --- a/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift +++ b/CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/TokenKindFile.swift @@ -96,50 +96,6 @@ let tokenKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { } } - try! VariableDeclSyntax("public var nameForDiagnostics: String") { - try! SwitchExprSyntax("switch self") { - SwitchCaseSyntax("case .eof:") { - StmtSyntax(#"return "end of file""#) - } - - for token in SYNTAX_TOKENS where token.swiftKind != "keyword" { - SwitchCaseSyntax("case .\(raw: token.swiftKind):") { - StmtSyntax("return #\"\(raw: token.nameForDiagnostics)\"#") - } - } - SwitchCaseSyntax("case .keyword(let keyword):") { - StmtSyntax("return String(syntaxText: keyword.defaultText)") - } - } - } - - try VariableDeclSyntax( - """ - /// Returns `true` if the token is a Swift keyword. - /// - /// Keywords are reserved unconditionally for use by Swift and may not - /// appear as identifiers in any position without being escaped. For example, - /// `class`, `func`, or `import`. - public var isLexerClassifiedKeyword: Bool - """ - ) { - try SwitchExprSyntax("switch self") { - SwitchCaseSyntax("case .eof:") { - StmtSyntax("return false") - } - - for token in SYNTAX_TOKENS where token.swiftKind != "keyword" { - SwitchCaseSyntax("case .\(raw: token.swiftKind):") { - StmtSyntax("return \(raw: token.isKeyword)") - } - } - - SwitchCaseSyntax("case .keyword(let keyword):") { - StmtSyntax("return keyword.isLexerClassified") - } - } - } - try VariableDeclSyntax( """ /// Returns `true` if the token is a Swift punctuator. @@ -197,6 +153,7 @@ let tokenKindFile = SourceFileSyntax(leadingTrivia: copyrightHeader) { // `RawTokenBaseKind` for equality. With the raw value, it compiles down to // a primitive integer compare, without, it calls into `__derived_enum_equals`. @frozen // FIXME: Not actually stable, works around a miscompile + @_spi(RawSyntax) public enum RawTokenKind: UInt8, Equatable, Hashable """ ) { diff --git a/Examples/Sources/AddOneToIntegerLiterals/AddOneToIntegerLiterals.swift b/Examples/Sources/AddOneToIntegerLiterals/AddOneToIntegerLiterals.swift index 696b30b07d5..b236587d625 100644 --- a/Examples/Sources/AddOneToIntegerLiterals/AddOneToIntegerLiterals.swift +++ b/Examples/Sources/AddOneToIntegerLiterals/AddOneToIntegerLiterals.swift @@ -31,7 +31,7 @@ private class AddOneToIntegerLiterals: SyntaxRewriter { let int = Int(integerText)! // Create a new integer literal token with `int + 1` as its text. - let newIntegerLiteralToken = token.withKind(.integerLiteral("\(int + 1)")) + let newIntegerLiteralToken = token.with(\.tokenKind, .integerLiteral("\(int + 1)")) // Return the new integer literal. return newIntegerLiteralToken diff --git a/Sources/IDEUtils/SyntaxClassifier.swift b/Sources/IDEUtils/SyntaxClassifier.swift index 797629f87cc..7fba69d10f9 100644 --- a/Sources/IDEUtils/SyntaxClassifier.swift +++ b/Sources/IDEUtils/SyntaxClassifier.swift @@ -17,12 +17,8 @@ fileprivate extension SyntaxProtocol { var contextualClassif: (SyntaxClassification, Bool)? = nil var curData = Syntax(self) repeat { - guard let parent = curData.parent else { break } - contextualClassif = SyntaxClassification.classify( - parentKind: parent.raw.kind, - indexInParent: curData.indexInParent, - childKind: raw.kind - ) + guard let parent = curData.parent, let keyPath = curData.keyPathInParent else { break } + contextualClassif = SyntaxClassification.classify(keyPath) curData = parent } while contextualClassif == nil return contextualClassif @@ -35,7 +31,7 @@ extension TokenSyntax { let contextualClassification = self.contextualClassification let relativeOffset = leadingTriviaLength.utf8Length let absoluteOffset = position.utf8Offset + relativeOffset - return TokenKindAndText(kind: rawTokenKind, text: tokenView.rawText).classify( + return TokenKindAndText(kind: tokenView.rawKind, text: tokenView.rawText).classify( offset: absoluteOffset, contextualClassification: contextualClassification ) @@ -200,16 +196,17 @@ private struct ClassificationVisitor { for case (let index, let child?) in children.enumerated() { - let classficiation = SyntaxClassification.classify( - parentKind: descriptor.node.kind, - indexInParent: index, - childKind: child.kind - ) + let classification: (SyntaxClassification, Bool)? + if case .layout(let layout) = descriptor.node.kind.syntaxNodeType.structure { + classification = SyntaxClassification.classify(layout[index]) + } else { + classification = nil + } let result = visit( .init( node: child, byteOffset: byteOffset, - contextualClassification: classficiation ?? descriptor.contextualClassification + contextualClassification: classification ?? descriptor.contextualClassification ) ) if result == .break { diff --git a/Sources/IDEUtils/generated/SyntaxClassification.swift b/Sources/IDEUtils/generated/SyntaxClassification.swift index b4a9f336ec7..0a5076ebdba 100644 --- a/Sources/IDEUtils/generated/SyntaxClassification.swift +++ b/Sources/IDEUtils/generated/SyntaxClassification.swift @@ -65,52 +65,42 @@ extension SyntaxClassification { /// - childKind: The node syntax kind. /// - Returns: A pair of classification and whether it is "forced", or nil if /// no classification is attached. - internal static func classify( - parentKind: SyntaxKind, indexInParent: Int, childKind: SyntaxKind - ) -> (SyntaxClassification, Bool)? { - // Separate checks for token nodes (most common checks) versus checks for layout nodes. - if childKind == .token { - switch (parentKind, indexInParent) { - case (.availabilityVersionRestriction, 1): - return (.keyword, false) - case (.declModifier, 1): - return (.attribute, false) - case (.expressionSegment, 5): - return (.stringInterpolationAnchor, true) - case (.expressionSegment, 9): - return (.stringInterpolationAnchor, true) - case (.forInStmt, 5): - return (.keyword, false) - case (.ifConfigClause, 1): - return (.buildConfigId, false) - case (.ifConfigDecl, 3): - return (.buildConfigId, false) - case (.memberTypeIdentifier, 5): - return (.typeIdentifier, false) - case (.operatorDecl, 7): - return (.operatorIdentifier, false) - case (.precedenceGroupAssociativity, 1): - return (.keyword, false) - case (.precedenceGroupRelation, 1): - return (.keyword, false) - case (.simpleTypeIdentifier, 1): - return (.typeIdentifier, false) - default: - return nil - } - }else { - switch (parentKind, indexInParent) { - case (.attribute, 3): - return (.attribute, false) - case (.availabilityVersionRestrictionListEntry, 1): - return (.keyword, false) - case (.ifConfigClause, 3): - return (.buildConfigId, false) - case (.operatorDecl, 3): - return (.attribute, false) - default: - return nil - } + internal static func classify(_ keyPath: AnyKeyPath) -> (SyntaxClassification, Bool)? { + switch keyPath { + case \AttributeSyntax.attributeName: + return (.attribute, false) + case \AvailabilityVersionRestrictionListEntrySyntax.availabilityVersionRestriction: + return (.keyword, false) + case \AvailabilityVersionRestrictionSyntax.platform: + return (.keyword, false) + case \DeclModifierSyntax.name: + return (.attribute, false) + case \ExpressionSegmentSyntax.leftParen: + return (.stringInterpolationAnchor, true) + case \ExpressionSegmentSyntax.rightParen: + return (.stringInterpolationAnchor, true) + case \ForInStmtSyntax.awaitKeyword: + return (.keyword, false) + case \IfConfigClauseSyntax.poundKeyword: + return (.buildConfigId, false) + case \IfConfigClauseSyntax.condition: + return (.buildConfigId, false) + case \IfConfigDeclSyntax.poundEndif: + return (.buildConfigId, false) + case \MemberTypeIdentifierSyntax.name: + return (.typeIdentifier, false) + case \OperatorDeclSyntax.modifiers: + return (.attribute, false) + case \OperatorDeclSyntax.identifier: + return (.operatorIdentifier, false) + case \PrecedenceGroupAssociativitySyntax.associativityKeyword: + return (.keyword, false) + case \PrecedenceGroupRelationSyntax.higherThanOrLowerThan: + return (.keyword, false) + case \SimpleTypeIdentifierSyntax.name: + return (.typeIdentifier, false) + default: + return nil } } } diff --git a/Sources/SwiftBasicFormat/generated/BasicFormat.swift b/Sources/SwiftBasicFormat/generated/BasicFormat.swift index b0a446d8bac..548a60da153 100644 --- a/Sources/SwiftBasicFormat/generated/BasicFormat.swift +++ b/Sources/SwiftBasicFormat/generated/BasicFormat.swift @@ -30,16 +30,16 @@ open class BasicFormat: SyntaxRewriter { private var putNextTokenOnNewLine: Bool = false open override func visitPre(_ node: Syntax) { - if let keyPath = getKeyPath(node), shouldIndent(keyPath) { + if let keyPath = node.keyPathInParent, shouldIndent(keyPath) { indentationLevel += 1 } if let parent = node.parent, childrenSeparatedByNewline(parent) { - putNextTokenOnNewLine = true && node.previousToken != nil + putNextTokenOnNewLine = true && node.previousToken(viewMode: .sourceAccurate) != nil } } open override func visitPost(_ node: Syntax) { - if let keyPath = getKeyPath(node), shouldIndent(keyPath) { + if let keyPath = node.keyPathInParent, shouldIndent(keyPath) { indentationLevel -= 1 } } @@ -53,7 +53,7 @@ open class BasicFormat: SyntaxRewriter { if requiresTrailingSpace(node) && trailingTrivia.isEmpty { trailingTrivia += .space } - if let keyPath = getKeyPath(Syntax(node)), requiresLeadingNewline(keyPath), !(leadingTrivia.first?.isNewline ?? false), !shouldOmitNewline(node) { + if let keyPath = node.keyPathInParent, requiresLeadingNewline(keyPath), !(leadingTrivia.first?.isNewline ?? false), !shouldOmitNewline(node) { leadingTrivia = .newline + leadingTrivia } var isOnNewline: Bool = (lastRewrittenToken?.trailingTrivia.pieces.last?.isNewline == true) @@ -176,7 +176,7 @@ open class BasicFormat: SyntaxRewriter { } open func requiresLeadingSpace(_ token: TokenSyntax) -> Bool { - if let keyPath = getKeyPath(token), let requiresLeadingSpace = requiresLeadingSpace(keyPath) { + if let keyPath = token.keyPathInParent, let requiresLeadingSpace = requiresLeadingSpace(keyPath) { return requiresLeadingSpace } switch (token.previousToken(viewMode: .sourceAccurate)?.tokenKind, token.tokenKind) { @@ -231,7 +231,7 @@ open class BasicFormat: SyntaxRewriter { } open func requiresTrailingSpace(_ token: TokenSyntax) -> Bool { - if let keyPath = getKeyPath(token), let requiresTrailingSpace = requiresTrailingSpace(keyPath) { + if let keyPath = token.keyPathInParent, let requiresTrailingSpace = requiresTrailingSpace(keyPath) { return requiresTrailingSpace } switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) { @@ -363,14 +363,4 @@ open class BasicFormat: SyntaxRewriter { return false } } - - private func getKeyPath(_ node: T) -> AnyKeyPath? { - guard let parent = node.parent else { - return nil - } - guard case .layout(let childrenKeyPaths) = parent.kind.syntaxNodeType.structure else { - return nil - } - return childrenKeyPaths[node.indexInParent] - } } diff --git a/Sources/SwiftParser/CMakeLists.txt b/Sources/SwiftParser/CMakeLists.txt index ceb81796173..45b41144fce 100644 --- a/Sources/SwiftParser/CMakeLists.txt +++ b/Sources/SwiftParser/CMakeLists.txt @@ -35,6 +35,7 @@ add_swift_host_library(SwiftParser Types.swift generated/DeclarationModifier.swift + generated/IsLexerClassified.swift generated/Parser+Entry.swift generated/TokenSpecStaticMembers.swift generated/TypeAttribute.swift diff --git a/Sources/SwiftParser/Lookahead.swift b/Sources/SwiftParser/Lookahead.swift index 14ab301871a..94d687afe1f 100644 --- a/Sources/SwiftParser/Lookahead.swift +++ b/Sources/SwiftParser/Lookahead.swift @@ -90,6 +90,7 @@ extension Parser.Lookahead { self.currentToken = self.lexemes.advance() } + @_spi(RawSyntax) public mutating func consumeAnyToken(remapping: RawTokenKind) { self.consumeAnyToken() } diff --git a/Sources/SwiftParser/TokenPrecedence.swift b/Sources/SwiftParser/TokenPrecedence.swift index 93049d329a3..dede4f7a18e 100644 --- a/Sources/SwiftParser/TokenPrecedence.swift +++ b/Sources/SwiftParser/TokenPrecedence.swift @@ -15,7 +15,7 @@ /// Describes how distinctive a token is for parser recovery. When expecting a /// token, tokens with a lower token precedence may be skipped and considered /// unexpected. -public enum TokenPrecedence: Comparable { +enum TokenPrecedence: Comparable { /// An unknown token. This is known garbage and should always be allowed to be skipped. case unknownToken /// Tokens that can be used similar to variable names or literals diff --git a/Sources/SwiftParser/TokenSpec.swift b/Sources/SwiftParser/TokenSpec.swift index 429981aa7d5..642a92daa1d 100644 --- a/Sources/SwiftParser/TokenSpec.swift +++ b/Sources/SwiftParser/TokenSpec.swift @@ -137,7 +137,7 @@ struct TokenSpec { @inline(__always) static func ~= (kind: TokenSpec, token: TokenSyntax) -> Bool { return kind.matches( - rawTokenKind: token.rawTokenKind, + rawTokenKind: token.tokenView.rawKind, keyword: Keyword(token.tokenView.rawText), atStartOfLine: token.leadingTrivia.contains(where: { $0.isNewline }) ) diff --git a/Sources/SwiftParser/generated/IsLexerClassified.swift b/Sources/SwiftParser/generated/IsLexerClassified.swift new file mode 100644 index 00000000000..caf7c25a11c --- /dev/null +++ b/Sources/SwiftParser/generated/IsLexerClassified.swift @@ -0,0 +1,164 @@ +//// Automatically generated by generate-swiftsyntax +//// Do not edit directly! +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax + +extension Keyword { + /// Whether the token kind is switched from being an identifier to being a keyword in the lexer. + /// This is true for keywords that used to be considered non-contextual. + var isLexerClassified: Bool { + switch self { + case .`Any`: + return true + case .`as`: + return true + case .`associatedtype`: + return true + case .`break`: + return true + case .`case`: + return true + case .`catch`: + return true + case .`class`: + return true + case .`continue`: + return true + case .`default`: + return true + case .`defer`: + return true + case .`deinit`: + return true + case .`do`: + return true + case .`else`: + return true + case .`enum`: + return true + case .`extension`: + return true + case .`fallthrough`: + return true + case .`false`: + return true + case .`fileprivate`: + return true + case .`for`: + return true + case .`func`: + return true + case .`guard`: + return true + case .`if`: + return true + case .`import`: + return true + case .`in`: + return true + case .`init`: + return true + case .`inout`: + return true + case .`internal`: + return true + case .`is`: + return true + case .`let`: + return true + case .`nil`: + return true + case .`operator`: + return true + case .`precedencegroup`: + return true + case .`private`: + return true + case .`protocol`: + return true + case .`public`: + return true + case .`repeat`: + return true + case .`rethrows`: + return true + case .`return`: + return true + case .`self`: + return true + case .`Self`: + return true + case .`static`: + return true + case .`struct`: + return true + case .`subscript`: + return true + case .`super`: + return true + case .`switch`: + return true + case .`throw`: + return true + case .`throws`: + return true + case .`true`: + return true + case .`try`: + return true + case .`typealias`: + return true + case .`var`: + return true + case .`where`: + return true + case .`while`: + return true + default: + return false + } + } +} + +extension TokenKind { + /// Returns `true` if the token is a Swift keyword. + /// + /// Keywords are reserved unconditionally for use by Swift and may not + /// appear as identifiers in any position without being escaped. For example, + /// `class`, `func`, or `import`. + public var isLexerClassifiedKeyword: Bool { + switch self { + case .eof: + return false + case .poundAvailableKeyword: + return true + case .poundElseKeyword: + return true + case .poundElseifKeyword: + return true + case .poundEndifKeyword: + return true + case .poundIfKeyword: + return true + case .poundSourceLocationKeyword: + return true + case .poundUnavailableKeyword: + return true + case .keyword(let keyword): + return keyword.isLexerClassified + default: + return false + } + } +} diff --git a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift index dd90a837195..9321eef4b86 100644 --- a/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift +++ b/Sources/SwiftParser/generated/TokenSpecStaticMembers.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -import SwiftSyntax +@_spi(RawSyntax) import SwiftSyntax extension TokenSpec { static var eof: TokenSpec { diff --git a/Sources/SwiftParserDiagnostics/CMakeLists.txt b/Sources/SwiftParserDiagnostics/CMakeLists.txt index de7314a2841..91be323333a 100644 --- a/Sources/SwiftParserDiagnostics/CMakeLists.txt +++ b/Sources/SwiftParserDiagnostics/CMakeLists.txt @@ -16,7 +16,12 @@ add_swift_host_library(SwiftParserDiagnostics ParseDiagnosticsGenerator.swift PresenceUtils.swift SyntaxExtensions.swift - Utils.swift) + Utils.swift + + generated/ChildNameForDiagnostics.swift + generated/SyntaxKindNameForDiagnostics.swift + generated/TokenNameForDiagnostics.swift +) target_link_libraries(SwiftParserDiagnostics PUBLIC SwiftBasicFormat diff --git a/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift b/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift index 82f2ccbb7a5..52958b404d8 100644 --- a/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift +++ b/Sources/SwiftParserDiagnostics/LexerDiagnosticMessages.swift @@ -204,7 +204,7 @@ public extension SwiftSyntax.TokenDiagnostic { .replacingFirstOccurence(of: "“", with: #"""#) .replacingLastOccurence(of: "”", with: #"""#) - let fixedToken = token.withKind(TokenKind.fromRaw(kind: rawKind, text: replacedText)) + let fixedToken = token.with(\.tokenKind, TokenKind.fromRaw(kind: rawKind, text: replacedText)) return [ FixIt(message: .replaceCurlyQuoteByNormalQuote, changes: [.replace(oldNode: Syntax(token), newNode: Syntax(fixedToken))]) ] diff --git a/Sources/SwiftParserDiagnostics/MissingNodesError.swift b/Sources/SwiftParserDiagnostics/MissingNodesError.swift index 9e17832a686..bf562748ac3 100644 --- a/Sources/SwiftParserDiagnostics/MissingNodesError.swift +++ b/Sources/SwiftParserDiagnostics/MissingNodesError.swift @@ -347,7 +347,7 @@ extension ParseDiagnosticsGenerator { missingNodes += [sibling] } else if sibling.isMissingAllTokens && sibling.hasTokens { missingNodes += [sibling] - } else if sibling.isCollection && sibling.children(viewMode: .sourceAccurate).count == 0 { + } else if sibling.kind.isSyntaxCollection && sibling.children(viewMode: .sourceAccurate).count == 0 { // Skip over any syntax collections without any elements while looking ahead for further missing nodes. } else { // Otherwise we have found a present node, so stop looking ahead. diff --git a/Sources/SwiftParserDiagnostics/MissingTokenError.swift b/Sources/SwiftParserDiagnostics/MissingTokenError.swift index 791cfe52855..24b84119710 100644 --- a/Sources/SwiftParserDiagnostics/MissingTokenError.swift +++ b/Sources/SwiftParserDiagnostics/MissingTokenError.swift @@ -27,7 +27,7 @@ extension ParseDiagnosticsGenerator { // this token. let handled: Bool - switch (missingToken.rawTokenKind, invalidToken.rawTokenKind) { + switch (missingToken.tokenView.rawKind, invalidToken.tokenView.rawKind) { case (.identifier, _): handled = handleInvalidIdentifier(invalidToken: invalidToken, missingToken: missingToken, invalidTokenContainer: invalidTokenContainer) case (.multilineStringQuote, .multilineStringQuote): @@ -103,7 +103,7 @@ extension ParseDiagnosticsGenerator { ] if let identifier = missingToken.nextToken(viewMode: .all), - identifier.rawTokenKind == .identifier, + identifier.tokenView.rawKind == .identifier, identifier.presence == .missing { // The extraneous whitespace caused a missing identifier, output a diff --git a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift index 181e546b9c3..e559a211d47 100644 --- a/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift +++ b/Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift @@ -20,9 +20,9 @@ fileprivate extension TokenSyntax { var negatedAvailabilityKeyword: TokenSyntax { switch self.tokenKind { case .poundAvailableKeyword: - return self.withKind(.poundUnavailableKeyword) + return self.with(\.tokenKind, .poundUnavailableKeyword) case .poundUnavailableKeyword: - return self.withKind(.poundAvailableKeyword) + return self.with(\.tokenKind, .poundAvailableKeyword) default: preconditionFailure("The availability token of an AvailabilityConditionSyntax should always be #available or #unavailable") } diff --git a/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift new file mode 100644 index 00000000000..c1fe58ff4f3 --- /dev/null +++ b/Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift @@ -0,0 +1,377 @@ +//// Automatically generated by generate-swiftsyntax +//// Do not edit directly! +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax + +private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String? { + switch keyPath { + case \AccessPathComponentSyntax.name: + return "name" + case \AccessorDeclSyntax.attributes: + return "attributes" + case \AccessorDeclSyntax.modifier: + return "modifiers" + case \AccessorDeclSyntax.parameter: + return "parameter" + case \AccessorParameterSyntax.name: + return "name" + case \ActorDeclSyntax.attributes: + return "attributes" + case \ActorDeclSyntax.modifiers: + return "modifiers" + case \ActorDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \ActorDeclSyntax.inheritanceClause: + return "type inheritance clause" + case \ActorDeclSyntax.genericWhereClause: + return "generic where clause" + case \ArrayElementSyntax.expression: + return "value" + case \AssociatedtypeDeclSyntax.attributes: + return "attributes" + case \AssociatedtypeDeclSyntax.modifiers: + return "modifiers" + case \AssociatedtypeDeclSyntax.inheritanceClause: + return "inheritance clause" + case \AssociatedtypeDeclSyntax.genericWhereClause: + return "generic where clause" + case \AttributeSyntax.attributeName: + return "name" + case \AvailabilityEntrySyntax.label: + return "label" + case \AvailabilityLabeledArgumentSyntax.label: + return "label" + case \AvailabilityLabeledArgumentSyntax.value: + return "value" + case \AvailabilityVersionRestrictionSyntax.platform: + return "platform" + case \AvailabilityVersionRestrictionSyntax.version: + return "version" + case \BreakStmtSyntax.label: + return "label" + case \ClassDeclSyntax.attributes: + return "attributes" + case \ClassDeclSyntax.modifiers: + return "modifiers" + case \ClassDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \ClassDeclSyntax.inheritanceClause: + return "inheritance clause" + case \ClassDeclSyntax.genericWhereClause: + return "generic where clause" + case \ClosureParamSyntax.name: + return "name" + case \ClosureParameterClauseSyntax.parameterList: + return "parameters" + case \ClosureParameterSyntax.attributes: + return "attributes" + case \ClosureParameterSyntax.modifiers: + return "modifiers" + case \ClosureParameterSyntax.type: + return "type" + case \ClosureSignatureSyntax.attributes: + return "attributes" + case \CodeBlockSyntax.statements: + return "statements" + case \ContinueStmtSyntax.label: + return "label" + case \DeclNameSyntax.declBaseName: + return "base name" + case \DeclNameSyntax.declNameArguments: + return "arguments" + case \DeinitializerDeclSyntax.attributes: + return "attributes" + case \DeinitializerDeclSyntax.modifiers: + return "modifiers" + case \DictionaryElementSyntax.keyExpression: + return "key" + case \DictionaryElementSyntax.valueExpression: + return "value" + case \DictionaryTypeSyntax.keyType: + return "key type" + case \DictionaryTypeSyntax.valueType: + return "value type" + case \DifferentiabilityParamsClauseSyntax.parameters: + return "parameters" + case \DoStmtSyntax.body: + return "body" + case \DocumentationAttributeArgumentSyntax.label: + return "label" + case \EnumCaseDeclSyntax.attributes: + return "attributes" + case \EnumCaseDeclSyntax.modifiers: + return "modifiers" + case \EnumCaseDeclSyntax.elements: + return "elements" + case \EnumCaseElementSyntax.associatedValue: + return "associated values" + case \EnumCaseParameterClauseSyntax.parameterList: + return "parameters" + case \EnumCaseParameterSyntax.modifiers: + return "modifiers" + case \EnumCaseParameterSyntax.type: + return "type" + case \EnumCaseParameterSyntax.defaultArgument: + return "default argument" + case \EnumDeclSyntax.attributes: + return "attributes" + case \EnumDeclSyntax.modifiers: + return "modifiers" + case \EnumDeclSyntax.genericParameters: + return "generic parameter clause" + case \EnumDeclSyntax.inheritanceClause: + return "inheritance clause" + case \EnumDeclSyntax.genericWhereClause: + return "generic where clause" + case \ExtensionDeclSyntax.attributes: + return "attributes" + case \ExtensionDeclSyntax.modifiers: + return "modifiers" + case \ExtensionDeclSyntax.inheritanceClause: + return "inheritance clause" + case \ExtensionDeclSyntax.genericWhereClause: + return "generic where clause" + case \ForInStmtSyntax.body: + return "body" + case \FunctionCallExprSyntax.calledExpression: + return "called expression" + case \FunctionCallExprSyntax.argumentList: + return "arguments" + case \FunctionCallExprSyntax.trailingClosure: + return "trailing closure" + case \FunctionCallExprSyntax.additionalTrailingClosures: + return "trailing closures" + case \FunctionDeclSyntax.attributes: + return "attributes" + case \FunctionDeclSyntax.modifiers: + return "modifiers" + case \FunctionDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \FunctionDeclSyntax.signature: + return "function signature" + case \FunctionDeclSyntax.genericWhereClause: + return "generic where clause" + case \FunctionParameterSyntax.attributes: + return "attributes" + case \FunctionParameterSyntax.modifiers: + return "modifiers" + case \FunctionParameterSyntax.secondName: + return "internal name" + case \FunctionParameterSyntax.type: + return "type" + case \FunctionParameterSyntax.defaultArgument: + return "default argument" + case \GenericParameterSyntax.each: + return "parameter pack specifier" + case \GenericParameterSyntax.name: + return "name" + case \GenericParameterSyntax.inheritedType: + return "inherited type" + case \GuardStmtSyntax.conditions: + return "condition" + case \GuardStmtSyntax.body: + return "body" + case \IfConfigClauseSyntax.condition: + return "condition" + case \IfExprSyntax.body: + return "body" + case \IfExprSyntax.elseBody: + return "else body" + case \ImplementsAttributeArgumentsSyntax.type: + return "type" + case \ImplementsAttributeArgumentsSyntax.declBaseName: + return "declaration base name" + case \ImplementsAttributeArgumentsSyntax.declNameArguments: + return "declaration name arguments" + case \ImportDeclSyntax.attributes: + return "attributes" + case \ImportDeclSyntax.modifiers: + return "modifiers" + case \InitializerDeclSyntax.attributes: + return "attributes" + case \InitializerDeclSyntax.modifiers: + return "modifiers" + case \InitializerDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \InitializerDeclSyntax.signature: + return "function signature" + case \InitializerDeclSyntax.genericWhereClause: + return "generic where clause" + case \KeyPathExprSyntax.root: + return "root" + case \KeyPathSubscriptComponentSyntax.argumentList: + return "arguments" + case \LabeledSpecializeEntrySyntax.label: + return "label" + case \LabeledSpecializeEntrySyntax.value: + return "value" + case \LabeledStmtSyntax.labelName: + return "label name" + case \LayoutRequirementSyntax.typeIdentifier: + return "constrained type" + case \LayoutRequirementSyntax.size: + return "size" + case \LayoutRequirementSyntax.alignment: + return "alignment" + case \MacroDeclSyntax.attributes: + return "attributes" + case \MacroDeclSyntax.modifiers: + return "modifiers" + case \MacroDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \MacroDeclSyntax.signature: + return "macro signature" + case \MacroDeclSyntax.definition: + return "macro definition" + case \MacroDeclSyntax.genericWhereClause: + return "generic where clause" + case \MemberAccessExprSyntax.base: + return "base" + case \MemberAccessExprSyntax.name: + return "name" + case \MemberTypeIdentifierSyntax.baseType: + return "base type" + case \MemberTypeIdentifierSyntax.name: + return "name" + case \MetatypeTypeSyntax.baseType: + return "base type" + case \MultipleTrailingClosureElementSyntax.label: + return "label" + case \ObjCSelectorPieceSyntax.name: + return "name" + case \OperatorDeclSyntax.attributes: + return "attributes" + case \OperatorDeclSyntax.modifiers: + return "modifiers" + case \OperatorPrecedenceAndTypesSyntax.precedenceGroup: + return "precedence group" + case \ParameterClauseSyntax.parameterList: + return "parameters" + case \PatternBindingSyntax.typeAnnotation: + return "type annotation" + case \PoundSourceLocationArgsSyntax.fileName: + return "file name" + case \PoundSourceLocationArgsSyntax.lineNumber: + return "line number" + case \PoundSourceLocationSyntax.args: + return "arguments" + case \PrecedenceGroupDeclSyntax.attributes: + return "attributes" + case \PrecedenceGroupDeclSyntax.modifiers: + return "modifiers" + case \PrecedenceGroupNameElementSyntax.name: + return "name" + case \PrimaryAssociatedTypeSyntax.name: + return "name" + case \ProtocolDeclSyntax.attributes: + return "attributes" + case \ProtocolDeclSyntax.modifiers: + return "modifiers" + case \ProtocolDeclSyntax.primaryAssociatedTypeClause: + return "primary associated type clause" + case \ProtocolDeclSyntax.inheritanceClause: + return "inheritance clause" + case \ProtocolDeclSyntax.genericWhereClause: + return "generic where clause" + case \QualifiedDeclNameSyntax.baseType: + return "base type" + case \QualifiedDeclNameSyntax.name: + return "base name" + case \QualifiedDeclNameSyntax.arguments: + return "arguments" + case \RepeatWhileStmtSyntax.body: + return "body" + case \RepeatWhileStmtSyntax.condition: + return "condition" + case \ReturnClauseSyntax.returnType: + return "return type" + case \SameTypeRequirementSyntax.leftTypeIdentifier: + return "left-hand type" + case \SameTypeRequirementSyntax.rightTypeIdentifier: + return "right-hand type" + case \StructDeclSyntax.attributes: + return "attributes" + case \StructDeclSyntax.modifiers: + return "modifiers" + case \StructDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \StructDeclSyntax.inheritanceClause: + return "type inheritance clause" + case \StructDeclSyntax.genericWhereClause: + return "generic where clause" + case \SubscriptDeclSyntax.attributes: + return "attributes" + case \SubscriptDeclSyntax.modifiers: + return "modifiers" + case \SubscriptDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \SubscriptDeclSyntax.genericWhereClause: + return "generic where clause" + case \SubscriptExprSyntax.calledExpression: + return "called expression" + case \SubscriptExprSyntax.argumentList: + return "arguments" + case \SubscriptExprSyntax.trailingClosure: + return "trailing closure" + case \SubscriptExprSyntax.additionalTrailingClosures: + return "trailing closures" + case \SwitchCaseSyntax.label: + return "label" + case \TargetFunctionEntrySyntax.label: + return "label" + case \TargetFunctionEntrySyntax.declname: + return "declaration name" + case \TernaryExprSyntax.conditionExpression: + return "condition" + case \TernaryExprSyntax.firstChoice: + return "first choice" + case \TernaryExprSyntax.secondChoice: + return "second choice" + case \TupleExprElementSyntax.label: + return "label" + case \TupleExprElementSyntax.expression: + return "value" + case \TuplePatternElementSyntax.labelName: + return "label" + case \TupleTypeElementSyntax.name: + return "name" + case \TupleTypeElementSyntax.secondName: + return "internal name" + case \TypeInitializerClauseSyntax.value: + return "type" + case \TypealiasDeclSyntax.attributes: + return "attributes" + case \TypealiasDeclSyntax.modifiers: + return "modifiers" + case \TypealiasDeclSyntax.genericParameterClause: + return "generic parameter clause" + case \TypealiasDeclSyntax.genericWhereClause: + return "generic where clause" + case \VariableDeclSyntax.attributes: + return "attributes" + case \VariableDeclSyntax.modifiers: + return "modifiers" + default: + return nil + } +} + +extension SyntaxProtocol { + var childNameInParent: String? { + guard let keyPath = self.keyPathInParent else { + return nil + } + return childNameForDiagnostics(keyPath) + } +} diff --git a/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift new file mode 100644 index 00000000000..e5d39584be2 --- /dev/null +++ b/Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift @@ -0,0 +1,398 @@ +//// Automatically generated by generate-swiftsyntax +//// Do not edit directly! +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import SwiftSyntax + +extension SyntaxKind { + var nameForDiagnostics: String? { + switch self { + case .token: + return "token" + case .accessorDecl: + return "accessor" + case .actorDecl: + return "actor" + case .arrayElement: + return "array element" + case .arrayExpr: + return "array" + case .arrayType: + return "array type" + case .asExpr: + return "'as'" + case .associatedtypeDecl: + return "associatedtype declaration" + case .attributeList: + return "attributes" + case .attribute: + return "attribute" + case .attributedType: + return "type" + case .availabilityArgument: + return "availability argument" + case .availabilityCondition: + return "availability condition" + case .availabilityEntry: + return "availability entry" + case .availabilityLabeledArgument: + return "availability argument" + case .availabilitySpecList: + return "'@availability' arguments" + case .availabilityVersionRestrictionListEntry: + return "version" + case .availabilityVersionRestrictionList: + return "version list" + case .availabilityVersionRestriction: + return "version restriction" + case .awaitExpr: + return "'await' expression" + case .backDeployedAttributeSpecList: + return "'@backDeployed' arguments" + case .binaryOperatorExpr: + return "operator" + case .booleanLiteralExpr: + return "bool literal" + case .borrowExpr: + return "'_borrow' expression" + case .breakStmt: + return "'break' statement" + case .catchClauseList: + return "'catch' clause" + case .catchClause: + return "'catch' clause" + case .classDecl: + return "class" + case .closureCaptureItemSpecifier: + return "closure capture specifier" + case .closureCaptureItem: + return "closure capture item" + case .closureCaptureSignature: + return "closure capture signature" + case .closureExpr: + return "closure" + case .closureParam: + return "closure parameter" + case .closureParameterClause: + return "parameter clause" + case .closureParameterList: + return "parameter list" + case .closureParameter: + return "parameter" + case .closureSignature: + return "closure signature" + case .codeBlock: + return "code block" + case .compositionType: + return "type composition" + case .conformanceRequirement: + return "conformance requirement" + case .constrainedSugarType: + return "type" + case .continueStmt: + return "'continue' statement" + case .conventionAttributeArguments: + return "@convention(...) arguments" + case .conventionWitnessMethodAttributeArguments: + return "@convention(...) arguments for witness methods" + case .declEffectSpecifiers: + return "effect specifiers" + case .declModifier: + return "modifier" + case .declName: + return "declaration name" + case .deferStmt: + return "'defer' statement" + case .deinitializerDecl: + return "deinitializer" + case .derivativeRegistrationAttributeArguments: + return "attribute arguments" + case .dictionaryElement: + return "dictionary element" + case .dictionaryExpr: + return "dictionary" + case .dictionaryType: + return "dictionary type" + case .differentiabilityParamList: + return "differentiability parameters" + case .differentiabilityParam: + return "differentiability parameter" + case .differentiabilityParamsClause: + return "'@differentiable' argument" + case .differentiabilityParams: + return "differentiability parameters" + case .differentiableAttributeArguments: + return "'@differentiable' arguments" + case .doStmt: + return "'do' statement" + case .documentationAttributeArgument: + return "@_documentation argument" + case .documentationAttributeArguments: + return "@_documentation arguments" + case .dynamicReplacementArguments: + return "@_dynamicReplacement argument" + case .editorPlaceholderDecl: + return "editor placeholder" + case .editorPlaceholderExpr: + return "editor placeholder" + case .effectsArguments: + return "@_effects arguments" + case .enumCaseDecl: + return "enum case" + case .enumCaseParameterClause: + return "parameter clause" + case .enumCaseParameterList: + return "parameter list" + case .enumCaseParameter: + return "parameter" + case .enumDecl: + return "enum" + case .exposeAttributeArguments: + return "@_expose arguments" + case .expressionPattern: + return "pattern" + case .expressionStmt: + return "expression" + case .extensionDecl: + return "extension" + case .fallthroughStmt: + return "'fallthrough' statement" + case .floatLiteralExpr: + return "floating literal" + case .forInStmt: + return "'for' statement" + case .forcedValueExpr: + return "force unwrap" + case .forgetStmt: + return "'forget' statement" + case .functionCallExpr: + return "function call" + case .functionDecl: + return "function" + case .functionParameterList: + return "parameter list" + case .functionParameter: + return "parameter" + case .functionSignature: + return "function signature" + case .functionType: + return "function type" + case .genericArgumentClause: + return "generic argument clause" + case .genericArgument: + return "generic argument" + case .genericParameterClause: + return "generic parameter clause" + case .genericParameter: + return "generic parameter" + case .genericWhereClause: + return "'where' clause" + case .guardStmt: + return "'guard' statement" + case .identifierPattern: + return "pattern" + case .ifConfigClause: + return "conditional compilation clause" + case .ifConfigDecl: + return "conditional compilation block" + case .ifExpr: + return "'if' statement" + case .implementsAttributeArguments: + return "@_implements arguemnts" + case .implicitlyUnwrappedOptionalType: + return "implicitly unwrapped optional type" + case .importDecl: + return "import" + case .inOutExpr: + return "inout expression" + case .inheritedType: + return "inherited type" + case .initializerDecl: + return "initializer" + case .integerLiteralExpr: + return "integer literal" + case .isExpr: + return "'is'" + case .isTypePattern: + return "'is' pattern" + case .keyPathComponent: + return "key path component" + case .keyPathExpr: + return "key path" + case .keyPathOptionalComponent: + return "key path optional component" + case .keyPathPropertyComponent: + return "key path property component" + case .keyPathSubscriptComponent: + return "key path subscript component" + case .labeledSpecializeEntry: + return "attribute argument" + case .labeledStmt: + return "labeled statement" + case .layoutRequirement: + return "layout requirement" + case .macroDecl: + return "macro" + case .macroExpansionDecl: + return "macro expansion" + case .macroExpansionExpr: + return "macro expansion" + case .matchingPatternCondition: + return "pattern matching" + case .memberAccessExpr: + return "member access" + case .memberDeclBlock: + return "member block" + case .memberTypeIdentifier: + return "member type" + case .metatypeType: + return "metatype" + case .missingDecl: + return "declaration" + case .missingExpr: + return "expression" + case .missingPattern: + return "pattern" + case .missingStmt: + return "statement" + case .missingType: + return "type" + case .moveExpr: + return "'_move' expression" + case .multipleTrailingClosureElement: + return "trailing closure" + case .namedOpaqueReturnType: + return "named opaque return type" + case .objCSelectorPiece: + return "Objective-C selector piece" + case .objCSelector: + return "Objective-C selector" + case .opaqueReturnTypeOfAttributeArguments: + return "opaque return type arguments" + case .operatorDecl: + return "operator declaration" + case .optionalBindingCondition: + return "optional binding" + case .optionalChainingExpr: + return "optional chaining" + case .optionalType: + return "optional type" + case .originallyDefinedInArguments: + return "@_originallyDefinedIn arguments" + case .packExpansionType: + return "variadic expansion" + case .packReferenceType: + return "pack reference" + case .parameterClause: + return "parameter clause" + case .postfixUnaryExpr: + return "postfix expression" + case .poundSourceLocationArgs: + return "'#sourceLocation' arguments" + case .poundSourceLocation: + return "'#sourceLocation' directive" + case .precedenceGroupAssignment: + return "'assignment' property of precedencegroup" + case .precedenceGroupAssociativity: + return "'associativity' property of precedencegroup" + case .precedenceGroupDecl: + return "precedencegroup" + case .precedenceGroupRelation: + return "'relation' property of precedencegroup" + case .prefixOperatorExpr: + return "operator" + case .primaryAssociatedTypeClause: + return "primary associated type clause" + case .protocolDecl: + return "protocol" + case .qualifiedDeclName: + return "declaration name" + case .regexLiteralExpr: + return "regex literal" + case .repeatWhileStmt: + return "'repeat' statement" + case .returnStmt: + return "'return' statement" + case .sameTypeRequirement: + return "same type requirement" + case .simpleTypeIdentifier: + return "type" + case .sourceFile: + return "source file" + case .specializeAttributeSpecList: + return "argument to '@_specialize" + case .stringLiteralExpr: + return "string literal" + case .structDecl: + return "struct" + case .subscriptDecl: + return "subscript" + case .subscriptExpr: + return "subscript" + case .switchCase: + return "switch case" + case .switchExpr: + return "'switch' statement" + case .targetFunctionEntry: + return "attribute argument" + case .ternaryExpr: + return "ternay expression" + case .throwStmt: + return "'throw' statement" + case .tryExpr: + return "'try' expression" + case .tupleExpr: + return "tuple" + case .tuplePattern: + return "tuple pattern" + case .tupleType: + return "tuple type" + case .typeAnnotation: + return "type annotation" + case .typeEffectSpecifiers: + return "effect specifiers" + case .typeInheritanceClause: + return "inheritance clause" + case .typealiasDecl: + return "typealias declaration" + case .unavailableFromAsyncArguments: + return "@_unavailableFromAsync argument" + case .underscorePrivateAttributeArguments: + return "@_private argument" + case .unresolvedAsExpr: + return "'as'" + case .unresolvedIsExpr: + return "'is'" + case .unresolvedTernaryExpr: + return "ternary operator" + case .valueBindingPattern: + return "value binding pattern" + case .variableDecl: + return "variable" + case .versionTuple: + return "version tuple" + case .whereClause: + return "'where' clause" + case .whileStmt: + return "'while' statement" + case .wildcardPattern: + return "wildcard pattern" + case .yieldExprList: + return "yield list" + case .yieldStmt: + return "'yield' statement" + default: + return nil + } + } +} diff --git a/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift new file mode 100644 index 00000000000..6dd7537bb85 --- /dev/null +++ b/Sources/SwiftParserDiagnostics/generated/TokenNameForDiagnostics.swift @@ -0,0 +1,120 @@ +//// Automatically generated by generate-swiftsyntax +//// Do not edit directly! +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +@_spi(RawSyntax) import SwiftSyntax + +extension TokenKind { + var nameForDiagnostics: String { + switch self { + case .eof: + return "end of file" + case .arrow: + return #"->"# + case .atSign: + return #"@"# + case .backslash: + return #"\"# + case .backtick: + return #"`"# + case .binaryOperator: + return #"binary operator"# + case .colon: + return #":"# + case .comma: + return #","# + case .dollarIdentifier: + return #"dollar identifier"# + case .ellipsis: + return #"..."# + case .equal: + return #"="# + case .exclamationMark: + return #"!"# + case .extendedRegexDelimiter: + return #"extended delimiter"# + case .floatingLiteral: + return #"floating literal"# + case .identifier: + return #"identifier"# + case .infixQuestionMark: + return #"?"# + case .integerLiteral: + return #"integer literal"# + case .leftAngle: + return #"<"# + case .leftBrace: + return #"{"# + case .leftParen: + return #"("# + case .leftSquareBracket: + return #"["# + case .multilineStringQuote: + return #"""""# + case .period: + return #"."# + case .postfixOperator: + return #"postfix operator"# + case .postfixQuestionMark: + return #"?"# + case .pound: + return #"#"# + case .poundAvailableKeyword: + return #"#available"# + case .poundElseKeyword: + return #"#else"# + case .poundElseifKeyword: + return #"#elseif"# + case .poundEndifKeyword: + return #"#endif"# + case .poundIfKeyword: + return #"#if"# + case .poundSourceLocationKeyword: + return #"#sourceLocation"# + case .poundUnavailableKeyword: + return #"#unavailable"# + case .prefixAmpersand: + return #"&"# + case .prefixOperator: + return #"prefix operator"# + case .rawStringDelimiter: + return #"raw string delimiter"# + case .regexLiteralPattern: + return #"regex pattern"# + case .regexSlash: + return #"/"# + case .rightAngle: + return #">"# + case .rightBrace: + return #"}"# + case .rightParen: + return #")"# + case .rightSquareBracket: + return #"]"# + case .semicolon: + return #";"# + case .singleQuote: + return #"'"# + case .stringQuote: + return #"""# + case .stringSegment: + return #"string segment"# + case .unknown: + return #"token"# + case .wildcard: + return #"wildcard"# + case .keyword(let keyword): + return String(syntaxText: keyword.defaultText) + } + } +} diff --git a/Sources/SwiftRefactor/AddSeparatorsToIntegerLiteral.swift b/Sources/SwiftRefactor/AddSeparatorsToIntegerLiteral.swift index b75cd020a0e..77f38b6865d 100644 --- a/Sources/SwiftRefactor/AddSeparatorsToIntegerLiteral.swift +++ b/Sources/SwiftRefactor/AddSeparatorsToIntegerLiteral.swift @@ -51,7 +51,7 @@ public struct AddSeparatorsToIntegerLiteral: RefactoringProvider { formattedText += value.byAddingGroupSeparators(at: lit.idealGroupSize) return lit - .with(\.digits, lit.digits.withKind(.integerLiteral(formattedText))) + .with(\.digits, lit.digits.with(\.tokenKind, .integerLiteral(formattedText))) } } diff --git a/Sources/SwiftRefactor/FormatRawStringLiteral.swift b/Sources/SwiftRefactor/FormatRawStringLiteral.swift index ada7682a1e2..738adc3d540 100644 --- a/Sources/SwiftRefactor/FormatRawStringLiteral.swift +++ b/Sources/SwiftRefactor/FormatRawStringLiteral.swift @@ -49,15 +49,15 @@ public struct FormatRawStringLiteral: RefactoringProvider { guard maximumHashes > 0 else { return lit - .with(\.openDelimiter, lit.openDelimiter?.withKind(.rawStringDelimiter(""))) - .with(\.closeDelimiter, lit.closeDelimiter?.withKind(.rawStringDelimiter(""))) + .with(\.openDelimiter, lit.openDelimiter?.with(\.tokenKind, .rawStringDelimiter(""))) + .with(\.closeDelimiter, lit.closeDelimiter?.with(\.tokenKind, .rawStringDelimiter(""))) } let delimiters = String(repeating: "#", count: maximumHashes + 1) return lit - .with(\.openDelimiter, lit.openDelimiter?.withKind(.rawStringDelimiter(delimiters))) - .with(\.closeDelimiter, lit.closeDelimiter?.withKind(.rawStringDelimiter(delimiters))) + .with(\.openDelimiter, lit.openDelimiter?.with(\.tokenKind, .rawStringDelimiter(delimiters))) + .with(\.closeDelimiter, lit.closeDelimiter?.with(\.tokenKind, .rawStringDelimiter(delimiters))) } } diff --git a/Sources/SwiftRefactor/RemoveSeparatorsFromIntegerLiteral.swift b/Sources/SwiftRefactor/RemoveSeparatorsFromIntegerLiteral.swift index 880b543fed8..ddd7c2f1318 100644 --- a/Sources/SwiftRefactor/RemoveSeparatorsFromIntegerLiteral.swift +++ b/Sources/SwiftRefactor/RemoveSeparatorsFromIntegerLiteral.swift @@ -32,6 +32,6 @@ public struct RemoveSeparatorsFromIntegerLiteral: RefactoringProvider { return lit } let formattedText = lit.digits.text.filter({ $0 != "_" }) - return lit.with(\.digits, lit.digits.withKind(.integerLiteral(formattedText))) + return lit.with(\.digits, lit.digits.with(\.tokenKind, .integerLiteral(formattedText))) } } diff --git a/Sources/SwiftSyntax/CMakeLists.txt b/Sources/SwiftSyntax/CMakeLists.txt index 3972f10ee73..2560ee6de90 100644 --- a/Sources/SwiftSyntax/CMakeLists.txt +++ b/Sources/SwiftSyntax/CMakeLists.txt @@ -35,7 +35,6 @@ add_swift_host_library(SwiftSyntax generated/raw/RawSyntaxValidation.swift generated/Keyword.swift - generated/Misc.swift generated/SyntaxAnyVisitor.swift generated/SyntaxBaseNodes.swift generated/SyntaxCollections.swift diff --git a/Sources/SwiftSyntax/SourcePresence.swift b/Sources/SwiftSyntax/SourcePresence.swift index f0bc492fbf7..9dbf122e25a 100644 --- a/Sources/SwiftSyntax/SourcePresence.swift +++ b/Sources/SwiftSyntax/SourcePresence.swift @@ -14,10 +14,10 @@ /// /// A `missing` node does not mean, necessarily, that the source item is /// considered "implicit", but rather that it was not found in the source. -public enum SourcePresence: String { +public enum SourcePresence { /// The syntax was authored by a human and found, or was generated. - case present = "Present" + case present /// The syntax was expected or optional, but not found in the source. - case missing = "Missing" + case missing } diff --git a/Sources/SwiftSyntax/Syntax.swift b/Sources/SwiftSyntax/Syntax.swift index 3b90ca08be8..7e4ce1deb06 100644 --- a/Sources/SwiftSyntax/Syntax.swift +++ b/Sources/SwiftSyntax/Syntax.swift @@ -95,10 +95,6 @@ public struct Syntax: SyntaxProtocol, SyntaxHashable { return self.raw.kind.syntaxNodeType.init(self)! } - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return self.raw.kind.syntaxNodeType.init(self)!.childNameForDiagnostics(index) - } - public func hash(into hasher: inout Hasher) { return data.nodeId.hash(into: &hasher) } @@ -174,12 +170,6 @@ public protocol SyntaxProtocol: CustomStringConvertible, /// The statically allowed structure of the syntax node. static var structure: SyntaxNodeStructure { get } - - /// Return a name with which the child at the given `index` can be referred to - /// in diagnostics. - /// Typically, you want to use `childNameInParent` on the child instead of - /// calling this method on the parent. - func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? } // Casting functions to specialized syntax nodes. @@ -216,18 +206,6 @@ public extension SyntaxProtocol { } } -public extension SyntaxProtocol { - /// If the parent has a dedicated "name for diagnostics" for this node, return it. - /// Otherwise, return `nil`. - var childNameInParent: String? { - if let parent = self.parent, let childName = parent.childNameForDiagnostics(self.index) { - return childName - } else { - return nil - } - } -} - extension SyntaxProtocol { var data: SyntaxData { return _syntaxNode.data @@ -265,19 +243,6 @@ public extension SyntaxProtocol { return SyntaxChildrenIndex(self.data.absoluteInfo) } - /// Whether or not this node is a token one. - var isToken: Bool { - return raw.isToken - } - - /// Whether or not this node represents an SyntaxCollection. - var isCollection: Bool { - // We need to provide a custom implementation for is(SyntaxCollection.self) - // since SyntaxCollection has generic or self requirements and can thus - // not be used as a method argument. - return raw.kind.isSyntaxCollection - } - /// Whether the tree contained by this layout has any /// - missing nodes or /// - unexpected nodes or @@ -306,18 +271,22 @@ public extension SyntaxProtocol { return data.parent.map(Syntax.init(_:)) } - /// The index of this node in the parent's children. - var indexInParent: Int { - return data.indexInParent - } - /// Whether or not this node has a parent. var hasParent: Bool { return parent != nil } - /// Recursively walks through the tree to find the token semantically before - /// this node. + var keyPathInParent: AnyKeyPath? { + guard let parent = self.parent else { + return nil + } + guard case .layout(let childrenKeyPaths) = parent.kind.syntaxNodeType.structure else { + return nil + } + return childrenKeyPaths[data.indexInParent] + } + + @available(*, deprecated, message: "Use previousToken(viewMode:) instead") var previousToken: TokenSyntax? { return self.previousToken(viewMode: .sourceAccurate) } @@ -342,8 +311,7 @@ public extension SyntaxProtocol { return parent.previousToken(viewMode: viewMode) } - /// Recursively walks through the tree to find the next token semantically - /// after this node. + @available(*, deprecated, message: "Use nextToken(viewMode:) instead") var nextToken: TokenSyntax? { return self.nextToken(viewMode: .sourceAccurate) } @@ -365,8 +333,7 @@ public extension SyntaxProtocol { return parent.nextToken(viewMode: viewMode) } - /// Returns the first token in this syntax node in the source accurate view of - /// the syntax tree. + @available(*, deprecated, message: "Use firstToken(viewMode: .sourceAccurate) instead") var firstToken: TokenSyntax? { return self.firstToken(viewMode: .sourceAccurate) } @@ -386,7 +353,7 @@ public extension SyntaxProtocol { return nil } - /// Returns the last token node that is part of this syntax node. + @available(*, deprecated, message: "Use lastToken(viewMode: .sourceAccurate) instead") var lastToken: TokenSyntax? { return self.lastToken(viewMode: .sourceAccurate) } @@ -702,12 +669,6 @@ public extension SyntaxProtocol { /// possible types a child node might have. public protocol SyntaxChildChoices: SyntaxProtocol {} -public extension SyntaxChildChoices { - func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } -} - /// Sequence of tokens that are part of the provided Syntax node. public struct TokenSequence: Sequence { public struct Iterator: IteratorProtocol { diff --git a/Sources/SwiftSyntax/SyntaxArena.swift b/Sources/SwiftSyntax/SyntaxArena.swift index 5a4f03eecb4..d4130987c5d 100644 --- a/Sources/SwiftSyntax/SyntaxArena.swift +++ b/Sources/SwiftSyntax/SyntaxArena.swift @@ -135,8 +135,7 @@ public class SyntaxArena { /// /// "managed" means it's empty, a part of "source buffer", or in the memory /// allocated by the underlying arena. - @_spi(RawSyntax) - public func contains(text: SyntaxText) -> Bool { + func contains(text: SyntaxText) -> Bool { return (text.isEmpty || allocator.contains(address: text.baseAddress!)) } } @@ -165,6 +164,7 @@ public class ParsingSyntaxArena: SyntaxArena { /// The interned buffer is guaranteed to be null-terminated. /// `contains(address _:)` is faster if the address is inside the memory /// range this function returned. + @_spi(RawSyntax) public func internSourceBuffer(_ buffer: UnsafeBufferPointer) -> UnsafeBufferPointer { let allocated = allocator.allocate( UInt8.self, diff --git a/Sources/SwiftSyntax/SyntaxChildren.swift b/Sources/SwiftSyntax/SyntaxChildren.swift index 6eb2d788ef0..bc3d086b84f 100644 --- a/Sources/SwiftSyntax/SyntaxChildren.swift +++ b/Sources/SwiftSyntax/SyntaxChildren.swift @@ -14,7 +14,7 @@ /// The data for an index in a syntax children collection that is not the end /// index. See `SyntaxChildrenIndex` for the representation of the end index. -public struct SyntaxChildrenIndexData: Comparable { +struct SyntaxChildrenIndexData: Comparable { /// The UTF-8 offset of the item at this index in the source file /// See `AbsoluteSyntaxPosition.offset` let offset: UInt32 @@ -25,7 +25,7 @@ public struct SyntaxChildrenIndexData: Comparable { /// See `SyntaxIdentifier.indexIntree` let indexInTree: SyntaxIndexInTree - public static func < ( + static func < ( lhs: SyntaxChildrenIndexData, rhs: SyntaxChildrenIndexData ) -> Bool { diff --git a/Sources/SwiftSyntax/TokenSyntax.swift b/Sources/SwiftSyntax/TokenSyntax.swift index 78f83af3426..838daeff2d1 100644 --- a/Sources/SwiftSyntax/TokenSyntax.swift +++ b/Sources/SwiftSyntax/TokenSyntax.swift @@ -68,22 +68,6 @@ public struct TokenSyntax: SyntaxProtocol, SyntaxHashable { return tokenKind.text } - public var rawTokenKind: RawTokenKind { - return tokenView.rawKind - } - - /// Returns a new TokenSyntax with its kind replaced - /// by the provided token kind. - public func withKind(_ tokenKind: TokenKind) -> TokenSyntax { - guard raw.kind == .token else { - fatalError("TokenSyntax must have token as its raw") - } - let arena = SyntaxArena() - let newRaw = tokenView.withKind(tokenKind, arena: arena) - let newData = data.replacingSelf(newRaw, arena: arena) - return TokenSyntax(newData) - } - /// The leading trivia (spaces, newlines, etc.) associated with this token. public var leadingTrivia: Trivia { get { @@ -110,7 +94,13 @@ public struct TokenSyntax: SyntaxProtocol, SyntaxHashable { return tokenView.formKind() } set { - self = withKind(newValue) + guard raw.kind == .token else { + fatalError("TokenSyntax must have token as its raw") + } + let arena = SyntaxArena() + let newRaw = tokenView.withKind(newValue, arena: arena) + let newData = data.replacingSelf(newRaw, arena: arena) + self = TokenSyntax(newData) } } @@ -139,10 +129,6 @@ public struct TokenSyntax: SyntaxProtocol, SyntaxHashable { return .layout([]) } - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } - /// If the token has a lexical error, the type of the error. public var tokenDiagnostic: TokenDiagnostic? { return tokenView.tokenDiagnostic diff --git a/Sources/SwiftSyntax/generated/Keyword.swift b/Sources/SwiftSyntax/generated/Keyword.swift index 789bab162ac..877671648de 100644 --- a/Sources/SwiftSyntax/generated/Keyword.swift +++ b/Sources/SwiftSyntax/generated/Keyword.swift @@ -12,13 +12,6 @@ // //===----------------------------------------------------------------------===// -/// Make `StaticString` equatable so we can use it as the raw value for Keyword. -extension StaticString: Equatable { - public static func == (lhs: StaticString, rhs: StaticString) -> Bool { - return SyntaxText(lhs) == SyntaxText(rhs) - } -} - @frozen // FIXME: Not actually stable, works around a miscompile public enum Keyword: UInt8, Hashable { case __consuming @@ -735,121 +728,6 @@ public enum Keyword: UInt8, Hashable { } } - /// Whether the token kind is switched from being an identifier to being a keyword in the lexer. - /// This is true for keywords that used to be considered non-contextual. - public var isLexerClassified: Bool { - switch self { - case .`Any`: - return true - case .`as`: - return true - case .`associatedtype`: - return true - case .`break`: - return true - case .`case`: - return true - case .`catch`: - return true - case .`class`: - return true - case .`continue`: - return true - case .`default`: - return true - case .`defer`: - return true - case .`deinit`: - return true - case .`do`: - return true - case .`else`: - return true - case .`enum`: - return true - case .`extension`: - return true - case .`fallthrough`: - return true - case .`false`: - return true - case .`fileprivate`: - return true - case .`for`: - return true - case .`func`: - return true - case .`guard`: - return true - case .`if`: - return true - case .`import`: - return true - case .`in`: - return true - case .`init`: - return true - case .`inout`: - return true - case .`internal`: - return true - case .`is`: - return true - case .`let`: - return true - case .`nil`: - return true - case .`operator`: - return true - case .`precedencegroup`: - return true - case .`private`: - return true - case .`protocol`: - return true - case .`public`: - return true - case .`repeat`: - return true - case .`rethrows`: - return true - case .`return`: - return true - case .`self`: - return true - case .`Self`: - return true - case .`static`: - return true - case .`struct`: - return true - case .`subscript`: - return true - case .`super`: - return true - case .`switch`: - return true - case .`throw`: - return true - case .`throws`: - return true - case .`true`: - return true - case .`try`: - return true - case .`typealias`: - return true - case .`var`: - return true - case .`where`: - return true - case .`while`: - return true - default: - return false - } - } - /// This is really unfortunate. Really, we should have a `switch` in /// `Keyword.defaultText` to return the keyword's kind but the constant lookup /// table is significantly faster. Ideally, we could also get the compiler to diff --git a/Sources/SwiftSyntax/generated/Misc.swift b/Sources/SwiftSyntax/generated/Misc.swift deleted file mode 100644 index 8d549a36a3a..00000000000 --- a/Sources/SwiftSyntax/generated/Misc.swift +++ /dev/null @@ -1,1372 +0,0 @@ -//// Automatically generated by generate-swiftsyntax -//// Do not edit directly! -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -extension Syntax { - public static var structure: SyntaxNodeStructure { - return .choices([ - .node(TokenSyntax.self), - .node(AccessPathComponentSyntax.self), - .node(AccessPathSyntax.self), - .node(AccessorBlockSyntax.self), - .node(AccessorDeclSyntax.self), - .node(AccessorListSyntax.self), - .node(AccessorParameterSyntax.self), - .node(ActorDeclSyntax.self), - .node(ArrayElementListSyntax.self), - .node(ArrayElementSyntax.self), - .node(ArrayExprSyntax.self), - .node(ArrayTypeSyntax.self), - .node(ArrowExprSyntax.self), - .node(AsExprSyntax.self), - .node(AssignmentExprSyntax.self), - .node(AssociatedtypeDeclSyntax.self), - .node(AttributeListSyntax.self), - .node(AttributeSyntax.self), - .node(AttributedTypeSyntax.self), - .node(AvailabilityArgumentSyntax.self), - .node(AvailabilityConditionSyntax.self), - .node(AvailabilityEntrySyntax.self), - .node(AvailabilityLabeledArgumentSyntax.self), - .node(AvailabilitySpecListSyntax.self), - .node(AvailabilityVersionRestrictionListEntrySyntax.self), - .node(AvailabilityVersionRestrictionListSyntax.self), - .node(AvailabilityVersionRestrictionSyntax.self), - .node(AwaitExprSyntax.self), - .node(BackDeployedAttributeSpecListSyntax.self), - .node(BinaryOperatorExprSyntax.self), - .node(BooleanLiteralExprSyntax.self), - .node(BorrowExprSyntax.self), - .node(BreakStmtSyntax.self), - .node(CaseItemListSyntax.self), - .node(CaseItemSyntax.self), - .node(CatchClauseListSyntax.self), - .node(CatchClauseSyntax.self), - .node(CatchItemListSyntax.self), - .node(CatchItemSyntax.self), - .node(ClassDeclSyntax.self), - .node(ClassRestrictionTypeSyntax.self), - .node(ClosureCaptureItemListSyntax.self), - .node(ClosureCaptureItemSpecifierSyntax.self), - .node(ClosureCaptureItemSyntax.self), - .node(ClosureCaptureSignatureSyntax.self), - .node(ClosureExprSyntax.self), - .node(ClosureParamListSyntax.self), - .node(ClosureParamSyntax.self), - .node(ClosureParameterClauseSyntax.self), - .node(ClosureParameterListSyntax.self), - .node(ClosureParameterSyntax.self), - .node(ClosureSignatureSyntax.self), - .node(CodeBlockItemListSyntax.self), - .node(CodeBlockItemSyntax.self), - .node(CodeBlockSyntax.self), - .node(CompositionTypeElementListSyntax.self), - .node(CompositionTypeElementSyntax.self), - .node(CompositionTypeSyntax.self), - .node(ConditionElementListSyntax.self), - .node(ConditionElementSyntax.self), - .node(ConformanceRequirementSyntax.self), - .node(ConstrainedSugarTypeSyntax.self), - .node(ContinueStmtSyntax.self), - .node(ConventionAttributeArgumentsSyntax.self), - .node(ConventionWitnessMethodAttributeArgumentsSyntax.self), - .node(DeclEffectSpecifiersSyntax.self), - .node(DeclModifierDetailSyntax.self), - .node(DeclModifierSyntax.self), - .node(DeclNameArgumentListSyntax.self), - .node(DeclNameArgumentSyntax.self), - .node(DeclNameArgumentsSyntax.self), - .node(DeclNameSyntax.self), - .node(DeferStmtSyntax.self), - .node(DeinitializerDeclSyntax.self), - .node(DerivativeRegistrationAttributeArgumentsSyntax.self), - .node(DesignatedTypeElementSyntax.self), - .node(DesignatedTypeListSyntax.self), - .node(DictionaryElementListSyntax.self), - .node(DictionaryElementSyntax.self), - .node(DictionaryExprSyntax.self), - .node(DictionaryTypeSyntax.self), - .node(DifferentiabilityParamListSyntax.self), - .node(DifferentiabilityParamSyntax.self), - .node(DifferentiabilityParamsClauseSyntax.self), - .node(DifferentiabilityParamsSyntax.self), - .node(DifferentiableAttributeArgumentsSyntax.self), - .node(DiscardAssignmentExprSyntax.self), - .node(DoStmtSyntax.self), - .node(DocumentationAttributeArgumentSyntax.self), - .node(DocumentationAttributeArgumentsSyntax.self), - .node(DynamicReplacementArgumentsSyntax.self), - .node(EditorPlaceholderDeclSyntax.self), - .node(EditorPlaceholderExprSyntax.self), - .node(EffectsArgumentsSyntax.self), - .node(EnumCaseDeclSyntax.self), - .node(EnumCaseElementListSyntax.self), - .node(EnumCaseElementSyntax.self), - .node(EnumCaseParameterClauseSyntax.self), - .node(EnumCaseParameterListSyntax.self), - .node(EnumCaseParameterSyntax.self), - .node(EnumDeclSyntax.self), - .node(ExposeAttributeArgumentsSyntax.self), - .node(ExprListSyntax.self), - .node(ExpressionPatternSyntax.self), - .node(ExpressionSegmentSyntax.self), - .node(ExpressionStmtSyntax.self), - .node(ExtensionDeclSyntax.self), - .node(FallthroughStmtSyntax.self), - .node(FloatLiteralExprSyntax.self), - .node(ForInStmtSyntax.self), - .node(ForcedValueExprSyntax.self), - .node(ForgetStmtSyntax.self), - .node(FunctionCallExprSyntax.self), - .node(FunctionDeclSyntax.self), - .node(FunctionParameterListSyntax.self), - .node(FunctionParameterSyntax.self), - .node(FunctionSignatureSyntax.self), - .node(FunctionTypeSyntax.self), - .node(GenericArgumentClauseSyntax.self), - .node(GenericArgumentListSyntax.self), - .node(GenericArgumentSyntax.self), - .node(GenericParameterClauseSyntax.self), - .node(GenericParameterListSyntax.self), - .node(GenericParameterSyntax.self), - .node(GenericRequirementListSyntax.self), - .node(GenericRequirementSyntax.self), - .node(GenericWhereClauseSyntax.self), - .node(GuardStmtSyntax.self), - .node(IdentifierExprSyntax.self), - .node(IdentifierPatternSyntax.self), - .node(IfConfigClauseListSyntax.self), - .node(IfConfigClauseSyntax.self), - .node(IfConfigDeclSyntax.self), - .node(IfExprSyntax.self), - .node(ImplementsAttributeArgumentsSyntax.self), - .node(ImplicitlyUnwrappedOptionalTypeSyntax.self), - .node(ImportDeclSyntax.self), - .node(InOutExprSyntax.self), - .node(InfixOperatorExprSyntax.self), - .node(InheritedTypeListSyntax.self), - .node(InheritedTypeSyntax.self), - .node(InitializerClauseSyntax.self), - .node(InitializerDeclSyntax.self), - .node(IntegerLiteralExprSyntax.self), - .node(IsExprSyntax.self), - .node(IsTypePatternSyntax.self), - .node(KeyPathComponentListSyntax.self), - .node(KeyPathComponentSyntax.self), - .node(KeyPathExprSyntax.self), - .node(KeyPathOptionalComponentSyntax.self), - .node(KeyPathPropertyComponentSyntax.self), - .node(KeyPathSubscriptComponentSyntax.self), - .node(LabeledSpecializeEntrySyntax.self), - .node(LabeledStmtSyntax.self), - .node(LayoutRequirementSyntax.self), - .node(MacroDeclSyntax.self), - .node(MacroExpansionDeclSyntax.self), - .node(MacroExpansionExprSyntax.self), - .node(MatchingPatternConditionSyntax.self), - .node(MemberAccessExprSyntax.self), - .node(MemberDeclBlockSyntax.self), - .node(MemberDeclListItemSyntax.self), - .node(MemberDeclListSyntax.self), - .node(MemberTypeIdentifierSyntax.self), - .node(MetatypeTypeSyntax.self), - .node(MissingDeclSyntax.self), - .node(MissingExprSyntax.self), - .node(MissingPatternSyntax.self), - .node(MissingStmtSyntax.self), - .node(MissingSyntax.self), - .node(MissingTypeSyntax.self), - .node(ModifierListSyntax.self), - .node(MoveExprSyntax.self), - .node(MultipleTrailingClosureElementListSyntax.self), - .node(MultipleTrailingClosureElementSyntax.self), - .node(NamedOpaqueReturnTypeSyntax.self), - .node(NilLiteralExprSyntax.self), - .node(ObjCSelectorPieceSyntax.self), - .node(ObjCSelectorSyntax.self), - .node(OpaqueReturnTypeOfAttributeArgumentsSyntax.self), - .node(OperatorDeclSyntax.self), - .node(OperatorPrecedenceAndTypesSyntax.self), - .node(OptionalBindingConditionSyntax.self), - .node(OptionalChainingExprSyntax.self), - .node(OptionalTypeSyntax.self), - .node(OriginallyDefinedInArgumentsSyntax.self), - .node(PackElementExprSyntax.self), - .node(PackExpansionExprSyntax.self), - .node(PackExpansionTypeSyntax.self), - .node(PackReferenceTypeSyntax.self), - .node(ParameterClauseSyntax.self), - .node(PatternBindingListSyntax.self), - .node(PatternBindingSyntax.self), - .node(PostfixIfConfigExprSyntax.self), - .node(PostfixUnaryExprSyntax.self), - .node(PoundSourceLocationArgsSyntax.self), - .node(PoundSourceLocationSyntax.self), - .node(PrecedenceGroupAssignmentSyntax.self), - .node(PrecedenceGroupAssociativitySyntax.self), - .node(PrecedenceGroupAttributeListSyntax.self), - .node(PrecedenceGroupDeclSyntax.self), - .node(PrecedenceGroupNameElementSyntax.self), - .node(PrecedenceGroupNameListSyntax.self), - .node(PrecedenceGroupRelationSyntax.self), - .node(PrefixOperatorExprSyntax.self), - .node(PrimaryAssociatedTypeClauseSyntax.self), - .node(PrimaryAssociatedTypeListSyntax.self), - .node(PrimaryAssociatedTypeSyntax.self), - .node(ProtocolDeclSyntax.self), - .node(QualifiedDeclNameSyntax.self), - .node(RegexLiteralExprSyntax.self), - .node(RepeatWhileStmtSyntax.self), - .node(ReturnClauseSyntax.self), - .node(ReturnStmtSyntax.self), - .node(SameTypeRequirementSyntax.self), - .node(SequenceExprSyntax.self), - .node(SimpleTypeIdentifierSyntax.self), - .node(SourceFileSyntax.self), - .node(SpecializeAttributeSpecListSyntax.self), - .node(SpecializeExprSyntax.self), - .node(StringLiteralExprSyntax.self), - .node(StringLiteralSegmentsSyntax.self), - .node(StringSegmentSyntax.self), - .node(StructDeclSyntax.self), - .node(SubscriptDeclSyntax.self), - .node(SubscriptExprSyntax.self), - .node(SuperRefExprSyntax.self), - .node(SwitchCaseLabelSyntax.self), - .node(SwitchCaseListSyntax.self), - .node(SwitchCaseSyntax.self), - .node(SwitchDefaultLabelSyntax.self), - .node(SwitchExprSyntax.self), - .node(TargetFunctionEntrySyntax.self), - .node(TernaryExprSyntax.self), - .node(ThrowStmtSyntax.self), - .node(TryExprSyntax.self), - .node(TupleExprElementListSyntax.self), - .node(TupleExprElementSyntax.self), - .node(TupleExprSyntax.self), - .node(TuplePatternElementListSyntax.self), - .node(TuplePatternElementSyntax.self), - .node(TuplePatternSyntax.self), - .node(TupleTypeElementListSyntax.self), - .node(TupleTypeElementSyntax.self), - .node(TupleTypeSyntax.self), - .node(TypeAnnotationSyntax.self), - .node(TypeEffectSpecifiersSyntax.self), - .node(TypeExprSyntax.self), - .node(TypeInheritanceClauseSyntax.self), - .node(TypeInitializerClauseSyntax.self), - .node(TypealiasDeclSyntax.self), - .node(UnavailableFromAsyncArgumentsSyntax.self), - .node(UnderscorePrivateAttributeArgumentsSyntax.self), - .node(UnexpectedNodesSyntax.self), - .node(UnresolvedAsExprSyntax.self), - .node(UnresolvedIsExprSyntax.self), - .node(UnresolvedPatternExprSyntax.self), - .node(UnresolvedTernaryExprSyntax.self), - .node(ValueBindingPatternSyntax.self), - .node(VariableDeclSyntax.self), - .node(VersionTupleSyntax.self), - .node(WhereClauseSyntax.self), - .node(WhileStmtSyntax.self), - .node(WildcardPatternSyntax.self), - .node(YieldExprListElementSyntax.self), - .node(YieldExprListSyntax.self), - .node(YieldListSyntax.self), - .node(YieldStmtSyntax.self) - ]) - } -} - -extension SyntaxKind { - public var syntaxNodeType: SyntaxProtocol.Type { - switch self { - case .token: - return TokenSyntax.self - case .accessPathComponent: - return AccessPathComponentSyntax.self - case .accessPath: - return AccessPathSyntax.self - case .accessorBlock: - return AccessorBlockSyntax.self - case .accessorDecl: - return AccessorDeclSyntax.self - case .accessorList: - return AccessorListSyntax.self - case .accessorParameter: - return AccessorParameterSyntax.self - case .actorDecl: - return ActorDeclSyntax.self - case .arrayElementList: - return ArrayElementListSyntax.self - case .arrayElement: - return ArrayElementSyntax.self - case .arrayExpr: - return ArrayExprSyntax.self - case .arrayType: - return ArrayTypeSyntax.self - case .arrowExpr: - return ArrowExprSyntax.self - case .asExpr: - return AsExprSyntax.self - case .assignmentExpr: - return AssignmentExprSyntax.self - case .associatedtypeDecl: - return AssociatedtypeDeclSyntax.self - case .attributeList: - return AttributeListSyntax.self - case .attribute: - return AttributeSyntax.self - case .attributedType: - return AttributedTypeSyntax.self - case .availabilityArgument: - return AvailabilityArgumentSyntax.self - case .availabilityCondition: - return AvailabilityConditionSyntax.self - case .availabilityEntry: - return AvailabilityEntrySyntax.self - case .availabilityLabeledArgument: - return AvailabilityLabeledArgumentSyntax.self - case .availabilitySpecList: - return AvailabilitySpecListSyntax.self - case .availabilityVersionRestrictionListEntry: - return AvailabilityVersionRestrictionListEntrySyntax.self - case .availabilityVersionRestrictionList: - return AvailabilityVersionRestrictionListSyntax.self - case .availabilityVersionRestriction: - return AvailabilityVersionRestrictionSyntax.self - case .awaitExpr: - return AwaitExprSyntax.self - case .backDeployedAttributeSpecList: - return BackDeployedAttributeSpecListSyntax.self - case .binaryOperatorExpr: - return BinaryOperatorExprSyntax.self - case .booleanLiteralExpr: - return BooleanLiteralExprSyntax.self - case .borrowExpr: - return BorrowExprSyntax.self - case .breakStmt: - return BreakStmtSyntax.self - case .caseItemList: - return CaseItemListSyntax.self - case .caseItem: - return CaseItemSyntax.self - case .catchClauseList: - return CatchClauseListSyntax.self - case .catchClause: - return CatchClauseSyntax.self - case .catchItemList: - return CatchItemListSyntax.self - case .catchItem: - return CatchItemSyntax.self - case .classDecl: - return ClassDeclSyntax.self - case .classRestrictionType: - return ClassRestrictionTypeSyntax.self - case .closureCaptureItemList: - return ClosureCaptureItemListSyntax.self - case .closureCaptureItemSpecifier: - return ClosureCaptureItemSpecifierSyntax.self - case .closureCaptureItem: - return ClosureCaptureItemSyntax.self - case .closureCaptureSignature: - return ClosureCaptureSignatureSyntax.self - case .closureExpr: - return ClosureExprSyntax.self - case .closureParamList: - return ClosureParamListSyntax.self - case .closureParam: - return ClosureParamSyntax.self - case .closureParameterClause: - return ClosureParameterClauseSyntax.self - case .closureParameterList: - return ClosureParameterListSyntax.self - case .closureParameter: - return ClosureParameterSyntax.self - case .closureSignature: - return ClosureSignatureSyntax.self - case .codeBlockItemList: - return CodeBlockItemListSyntax.self - case .codeBlockItem: - return CodeBlockItemSyntax.self - case .codeBlock: - return CodeBlockSyntax.self - case .compositionTypeElementList: - return CompositionTypeElementListSyntax.self - case .compositionTypeElement: - return CompositionTypeElementSyntax.self - case .compositionType: - return CompositionTypeSyntax.self - case .conditionElementList: - return ConditionElementListSyntax.self - case .conditionElement: - return ConditionElementSyntax.self - case .conformanceRequirement: - return ConformanceRequirementSyntax.self - case .constrainedSugarType: - return ConstrainedSugarTypeSyntax.self - case .continueStmt: - return ContinueStmtSyntax.self - case .conventionAttributeArguments: - return ConventionAttributeArgumentsSyntax.self - case .conventionWitnessMethodAttributeArguments: - return ConventionWitnessMethodAttributeArgumentsSyntax.self - case .declEffectSpecifiers: - return DeclEffectSpecifiersSyntax.self - case .declModifierDetail: - return DeclModifierDetailSyntax.self - case .declModifier: - return DeclModifierSyntax.self - case .declNameArgumentList: - return DeclNameArgumentListSyntax.self - case .declNameArgument: - return DeclNameArgumentSyntax.self - case .declNameArguments: - return DeclNameArgumentsSyntax.self - case .declName: - return DeclNameSyntax.self - case .deferStmt: - return DeferStmtSyntax.self - case .deinitializerDecl: - return DeinitializerDeclSyntax.self - case .derivativeRegistrationAttributeArguments: - return DerivativeRegistrationAttributeArgumentsSyntax.self - case .designatedTypeElement: - return DesignatedTypeElementSyntax.self - case .designatedTypeList: - return DesignatedTypeListSyntax.self - case .dictionaryElementList: - return DictionaryElementListSyntax.self - case .dictionaryElement: - return DictionaryElementSyntax.self - case .dictionaryExpr: - return DictionaryExprSyntax.self - case .dictionaryType: - return DictionaryTypeSyntax.self - case .differentiabilityParamList: - return DifferentiabilityParamListSyntax.self - case .differentiabilityParam: - return DifferentiabilityParamSyntax.self - case .differentiabilityParamsClause: - return DifferentiabilityParamsClauseSyntax.self - case .differentiabilityParams: - return DifferentiabilityParamsSyntax.self - case .differentiableAttributeArguments: - return DifferentiableAttributeArgumentsSyntax.self - case .discardAssignmentExpr: - return DiscardAssignmentExprSyntax.self - case .doStmt: - return DoStmtSyntax.self - case .documentationAttributeArgument: - return DocumentationAttributeArgumentSyntax.self - case .documentationAttributeArguments: - return DocumentationAttributeArgumentsSyntax.self - case .dynamicReplacementArguments: - return DynamicReplacementArgumentsSyntax.self - case .editorPlaceholderDecl: - return EditorPlaceholderDeclSyntax.self - case .editorPlaceholderExpr: - return EditorPlaceholderExprSyntax.self - case .effectsArguments: - return EffectsArgumentsSyntax.self - case .enumCaseDecl: - return EnumCaseDeclSyntax.self - case .enumCaseElementList: - return EnumCaseElementListSyntax.self - case .enumCaseElement: - return EnumCaseElementSyntax.self - case .enumCaseParameterClause: - return EnumCaseParameterClauseSyntax.self - case .enumCaseParameterList: - return EnumCaseParameterListSyntax.self - case .enumCaseParameter: - return EnumCaseParameterSyntax.self - case .enumDecl: - return EnumDeclSyntax.self - case .exposeAttributeArguments: - return ExposeAttributeArgumentsSyntax.self - case .exprList: - return ExprListSyntax.self - case .expressionPattern: - return ExpressionPatternSyntax.self - case .expressionSegment: - return ExpressionSegmentSyntax.self - case .expressionStmt: - return ExpressionStmtSyntax.self - case .extensionDecl: - return ExtensionDeclSyntax.self - case .fallthroughStmt: - return FallthroughStmtSyntax.self - case .floatLiteralExpr: - return FloatLiteralExprSyntax.self - case .forInStmt: - return ForInStmtSyntax.self - case .forcedValueExpr: - return ForcedValueExprSyntax.self - case .forgetStmt: - return ForgetStmtSyntax.self - case .functionCallExpr: - return FunctionCallExprSyntax.self - case .functionDecl: - return FunctionDeclSyntax.self - case .functionParameterList: - return FunctionParameterListSyntax.self - case .functionParameter: - return FunctionParameterSyntax.self - case .functionSignature: - return FunctionSignatureSyntax.self - case .functionType: - return FunctionTypeSyntax.self - case .genericArgumentClause: - return GenericArgumentClauseSyntax.self - case .genericArgumentList: - return GenericArgumentListSyntax.self - case .genericArgument: - return GenericArgumentSyntax.self - case .genericParameterClause: - return GenericParameterClauseSyntax.self - case .genericParameterList: - return GenericParameterListSyntax.self - case .genericParameter: - return GenericParameterSyntax.self - case .genericRequirementList: - return GenericRequirementListSyntax.self - case .genericRequirement: - return GenericRequirementSyntax.self - case .genericWhereClause: - return GenericWhereClauseSyntax.self - case .guardStmt: - return GuardStmtSyntax.self - case .identifierExpr: - return IdentifierExprSyntax.self - case .identifierPattern: - return IdentifierPatternSyntax.self - case .ifConfigClauseList: - return IfConfigClauseListSyntax.self - case .ifConfigClause: - return IfConfigClauseSyntax.self - case .ifConfigDecl: - return IfConfigDeclSyntax.self - case .ifExpr: - return IfExprSyntax.self - case .implementsAttributeArguments: - return ImplementsAttributeArgumentsSyntax.self - case .implicitlyUnwrappedOptionalType: - return ImplicitlyUnwrappedOptionalTypeSyntax.self - case .importDecl: - return ImportDeclSyntax.self - case .inOutExpr: - return InOutExprSyntax.self - case .infixOperatorExpr: - return InfixOperatorExprSyntax.self - case .inheritedTypeList: - return InheritedTypeListSyntax.self - case .inheritedType: - return InheritedTypeSyntax.self - case .initializerClause: - return InitializerClauseSyntax.self - case .initializerDecl: - return InitializerDeclSyntax.self - case .integerLiteralExpr: - return IntegerLiteralExprSyntax.self - case .isExpr: - return IsExprSyntax.self - case .isTypePattern: - return IsTypePatternSyntax.self - case .keyPathComponentList: - return KeyPathComponentListSyntax.self - case .keyPathComponent: - return KeyPathComponentSyntax.self - case .keyPathExpr: - return KeyPathExprSyntax.self - case .keyPathOptionalComponent: - return KeyPathOptionalComponentSyntax.self - case .keyPathPropertyComponent: - return KeyPathPropertyComponentSyntax.self - case .keyPathSubscriptComponent: - return KeyPathSubscriptComponentSyntax.self - case .labeledSpecializeEntry: - return LabeledSpecializeEntrySyntax.self - case .labeledStmt: - return LabeledStmtSyntax.self - case .layoutRequirement: - return LayoutRequirementSyntax.self - case .macroDecl: - return MacroDeclSyntax.self - case .macroExpansionDecl: - return MacroExpansionDeclSyntax.self - case .macroExpansionExpr: - return MacroExpansionExprSyntax.self - case .matchingPatternCondition: - return MatchingPatternConditionSyntax.self - case .memberAccessExpr: - return MemberAccessExprSyntax.self - case .memberDeclBlock: - return MemberDeclBlockSyntax.self - case .memberDeclListItem: - return MemberDeclListItemSyntax.self - case .memberDeclList: - return MemberDeclListSyntax.self - case .memberTypeIdentifier: - return MemberTypeIdentifierSyntax.self - case .metatypeType: - return MetatypeTypeSyntax.self - case .missingDecl: - return MissingDeclSyntax.self - case .missingExpr: - return MissingExprSyntax.self - case .missingPattern: - return MissingPatternSyntax.self - case .missingStmt: - return MissingStmtSyntax.self - case .missing: - return MissingSyntax.self - case .missingType: - return MissingTypeSyntax.self - case .modifierList: - return ModifierListSyntax.self - case .moveExpr: - return MoveExprSyntax.self - case .multipleTrailingClosureElementList: - return MultipleTrailingClosureElementListSyntax.self - case .multipleTrailingClosureElement: - return MultipleTrailingClosureElementSyntax.self - case .namedOpaqueReturnType: - return NamedOpaqueReturnTypeSyntax.self - case .nilLiteralExpr: - return NilLiteralExprSyntax.self - case .objCSelectorPiece: - return ObjCSelectorPieceSyntax.self - case .objCSelector: - return ObjCSelectorSyntax.self - case .opaqueReturnTypeOfAttributeArguments: - return OpaqueReturnTypeOfAttributeArgumentsSyntax.self - case .operatorDecl: - return OperatorDeclSyntax.self - case .operatorPrecedenceAndTypes: - return OperatorPrecedenceAndTypesSyntax.self - case .optionalBindingCondition: - return OptionalBindingConditionSyntax.self - case .optionalChainingExpr: - return OptionalChainingExprSyntax.self - case .optionalType: - return OptionalTypeSyntax.self - case .originallyDefinedInArguments: - return OriginallyDefinedInArgumentsSyntax.self - case .packElementExpr: - return PackElementExprSyntax.self - case .packExpansionExpr: - return PackExpansionExprSyntax.self - case .packExpansionType: - return PackExpansionTypeSyntax.self - case .packReferenceType: - return PackReferenceTypeSyntax.self - case .parameterClause: - return ParameterClauseSyntax.self - case .patternBindingList: - return PatternBindingListSyntax.self - case .patternBinding: - return PatternBindingSyntax.self - case .postfixIfConfigExpr: - return PostfixIfConfigExprSyntax.self - case .postfixUnaryExpr: - return PostfixUnaryExprSyntax.self - case .poundSourceLocationArgs: - return PoundSourceLocationArgsSyntax.self - case .poundSourceLocation: - return PoundSourceLocationSyntax.self - case .precedenceGroupAssignment: - return PrecedenceGroupAssignmentSyntax.self - case .precedenceGroupAssociativity: - return PrecedenceGroupAssociativitySyntax.self - case .precedenceGroupAttributeList: - return PrecedenceGroupAttributeListSyntax.self - case .precedenceGroupDecl: - return PrecedenceGroupDeclSyntax.self - case .precedenceGroupNameElement: - return PrecedenceGroupNameElementSyntax.self - case .precedenceGroupNameList: - return PrecedenceGroupNameListSyntax.self - case .precedenceGroupRelation: - return PrecedenceGroupRelationSyntax.self - case .prefixOperatorExpr: - return PrefixOperatorExprSyntax.self - case .primaryAssociatedTypeClause: - return PrimaryAssociatedTypeClauseSyntax.self - case .primaryAssociatedTypeList: - return PrimaryAssociatedTypeListSyntax.self - case .primaryAssociatedType: - return PrimaryAssociatedTypeSyntax.self - case .protocolDecl: - return ProtocolDeclSyntax.self - case .qualifiedDeclName: - return QualifiedDeclNameSyntax.self - case .regexLiteralExpr: - return RegexLiteralExprSyntax.self - case .repeatWhileStmt: - return RepeatWhileStmtSyntax.self - case .returnClause: - return ReturnClauseSyntax.self - case .returnStmt: - return ReturnStmtSyntax.self - case .sameTypeRequirement: - return SameTypeRequirementSyntax.self - case .sequenceExpr: - return SequenceExprSyntax.self - case .simpleTypeIdentifier: - return SimpleTypeIdentifierSyntax.self - case .sourceFile: - return SourceFileSyntax.self - case .specializeAttributeSpecList: - return SpecializeAttributeSpecListSyntax.self - case .specializeExpr: - return SpecializeExprSyntax.self - case .stringLiteralExpr: - return StringLiteralExprSyntax.self - case .stringLiteralSegments: - return StringLiteralSegmentsSyntax.self - case .stringSegment: - return StringSegmentSyntax.self - case .structDecl: - return StructDeclSyntax.self - case .subscriptDecl: - return SubscriptDeclSyntax.self - case .subscriptExpr: - return SubscriptExprSyntax.self - case .superRefExpr: - return SuperRefExprSyntax.self - case .switchCaseLabel: - return SwitchCaseLabelSyntax.self - case .switchCaseList: - return SwitchCaseListSyntax.self - case .switchCase: - return SwitchCaseSyntax.self - case .switchDefaultLabel: - return SwitchDefaultLabelSyntax.self - case .switchExpr: - return SwitchExprSyntax.self - case .targetFunctionEntry: - return TargetFunctionEntrySyntax.self - case .ternaryExpr: - return TernaryExprSyntax.self - case .throwStmt: - return ThrowStmtSyntax.self - case .tryExpr: - return TryExprSyntax.self - case .tupleExprElementList: - return TupleExprElementListSyntax.self - case .tupleExprElement: - return TupleExprElementSyntax.self - case .tupleExpr: - return TupleExprSyntax.self - case .tuplePatternElementList: - return TuplePatternElementListSyntax.self - case .tuplePatternElement: - return TuplePatternElementSyntax.self - case .tuplePattern: - return TuplePatternSyntax.self - case .tupleTypeElementList: - return TupleTypeElementListSyntax.self - case .tupleTypeElement: - return TupleTypeElementSyntax.self - case .tupleType: - return TupleTypeSyntax.self - case .typeAnnotation: - return TypeAnnotationSyntax.self - case .typeEffectSpecifiers: - return TypeEffectSpecifiersSyntax.self - case .typeExpr: - return TypeExprSyntax.self - case .typeInheritanceClause: - return TypeInheritanceClauseSyntax.self - case .typeInitializerClause: - return TypeInitializerClauseSyntax.self - case .typealiasDecl: - return TypealiasDeclSyntax.self - case .unavailableFromAsyncArguments: - return UnavailableFromAsyncArgumentsSyntax.self - case .underscorePrivateAttributeArguments: - return UnderscorePrivateAttributeArgumentsSyntax.self - case .unexpectedNodes: - return UnexpectedNodesSyntax.self - case .unresolvedAsExpr: - return UnresolvedAsExprSyntax.self - case .unresolvedIsExpr: - return UnresolvedIsExprSyntax.self - case .unresolvedPatternExpr: - return UnresolvedPatternExprSyntax.self - case .unresolvedTernaryExpr: - return UnresolvedTernaryExprSyntax.self - case .valueBindingPattern: - return ValueBindingPatternSyntax.self - case .variableDecl: - return VariableDeclSyntax.self - case .versionTuple: - return VersionTupleSyntax.self - case .whereClause: - return WhereClauseSyntax.self - case .whileStmt: - return WhileStmtSyntax.self - case .wildcardPattern: - return WildcardPatternSyntax.self - case .yieldExprListElement: - return YieldExprListElementSyntax.self - case .yieldExprList: - return YieldExprListSyntax.self - case .yieldList: - return YieldListSyntax.self - case .yieldStmt: - return YieldStmtSyntax.self - } - } - - public var nameForDiagnostics: String? { - switch self { - case .token: - return "token" - case .accessPathComponent: - return nil - case .accessPath: - return nil - case .accessorBlock: - return nil - case .accessorDecl: - return "accessor" - case .accessorList: - return nil - case .accessorParameter: - return nil - case .actorDecl: - return "actor" - case .arrayElementList: - return nil - case .arrayElement: - return "array element" - case .arrayExpr: - return "array" - case .arrayType: - return "array type" - case .arrowExpr: - return nil - case .asExpr: - return "'as'" - case .assignmentExpr: - return nil - case .associatedtypeDecl: - return "associatedtype declaration" - case .attributeList: - return "attributes" - case .attribute: - return "attribute" - case .attributedType: - return "type" - case .availabilityArgument: - return "availability argument" - case .availabilityCondition: - return "availability condition" - case .availabilityEntry: - return "availability entry" - case .availabilityLabeledArgument: - return "availability argument" - case .availabilitySpecList: - return "'@availability' arguments" - case .availabilityVersionRestrictionListEntry: - return "version" - case .availabilityVersionRestrictionList: - return "version list" - case .availabilityVersionRestriction: - return "version restriction" - case .awaitExpr: - return "'await' expression" - case .backDeployedAttributeSpecList: - return "'@backDeployed' arguments" - case .binaryOperatorExpr: - return "operator" - case .booleanLiteralExpr: - return "bool literal" - case .borrowExpr: - return "'_borrow' expression" - case .breakStmt: - return "'break' statement" - case .caseItemList: - return nil - case .caseItem: - return nil - case .catchClauseList: - return "'catch' clause" - case .catchClause: - return "'catch' clause" - case .catchItemList: - return nil - case .catchItem: - return nil - case .classDecl: - return "class" - case .classRestrictionType: - return nil - case .closureCaptureItemList: - return nil - case .closureCaptureItemSpecifier: - return "closure capture specifier" - case .closureCaptureItem: - return "closure capture item" - case .closureCaptureSignature: - return "closure capture signature" - case .closureExpr: - return "closure" - case .closureParamList: - return nil - case .closureParam: - return "closure parameter" - case .closureParameterClause: - return "parameter clause" - case .closureParameterList: - return "parameter list" - case .closureParameter: - return "parameter" - case .closureSignature: - return "closure signature" - case .codeBlockItemList: - return nil - case .codeBlockItem: - return nil - case .codeBlock: - return "code block" - case .compositionTypeElementList: - return nil - case .compositionTypeElement: - return nil - case .compositionType: - return "type composition" - case .conditionElementList: - return nil - case .conditionElement: - return nil - case .conformanceRequirement: - return "conformance requirement" - case .constrainedSugarType: - return "type" - case .continueStmt: - return "'continue' statement" - case .conventionAttributeArguments: - return "@convention(...) arguments" - case .conventionWitnessMethodAttributeArguments: - return "@convention(...) arguments for witness methods" - case .declEffectSpecifiers: - return "effect specifiers" - case .declModifierDetail: - return nil - case .declModifier: - return "modifier" - case .declNameArgumentList: - return nil - case .declNameArgument: - return nil - case .declNameArguments: - return nil - case .declName: - return "declaration name" - case .deferStmt: - return "'defer' statement" - case .deinitializerDecl: - return "deinitializer" - case .derivativeRegistrationAttributeArguments: - return "attribute arguments" - case .designatedTypeElement: - return nil - case .designatedTypeList: - return nil - case .dictionaryElementList: - return nil - case .dictionaryElement: - return "dictionary element" - case .dictionaryExpr: - return "dictionary" - case .dictionaryType: - return "dictionary type" - case .differentiabilityParamList: - return "differentiability parameters" - case .differentiabilityParam: - return "differentiability parameter" - case .differentiabilityParamsClause: - return "'@differentiable' argument" - case .differentiabilityParams: - return "differentiability parameters" - case .differentiableAttributeArguments: - return "'@differentiable' arguments" - case .discardAssignmentExpr: - return nil - case .doStmt: - return "'do' statement" - case .documentationAttributeArgument: - return "@_documentation argument" - case .documentationAttributeArguments: - return "@_documentation arguments" - case .dynamicReplacementArguments: - return "@_dynamicReplacement argument" - case .editorPlaceholderDecl: - return "editor placeholder" - case .editorPlaceholderExpr: - return "editor placeholder" - case .effectsArguments: - return "@_effects arguments" - case .enumCaseDecl: - return "enum case" - case .enumCaseElementList: - return nil - case .enumCaseElement: - return nil - case .enumCaseParameterClause: - return "parameter clause" - case .enumCaseParameterList: - return "parameter list" - case .enumCaseParameter: - return "parameter" - case .enumDecl: - return "enum" - case .exposeAttributeArguments: - return "@_expose arguments" - case .exprList: - return nil - case .expressionPattern: - return "pattern" - case .expressionSegment: - return nil - case .expressionStmt: - return "expression" - case .extensionDecl: - return "extension" - case .fallthroughStmt: - return "'fallthrough' statement" - case .floatLiteralExpr: - return "floating literal" - case .forInStmt: - return "'for' statement" - case .forcedValueExpr: - return "force unwrap" - case .forgetStmt: - return "'forget' statement" - case .functionCallExpr: - return "function call" - case .functionDecl: - return "function" - case .functionParameterList: - return "parameter list" - case .functionParameter: - return "parameter" - case .functionSignature: - return "function signature" - case .functionType: - return "function type" - case .genericArgumentClause: - return "generic argument clause" - case .genericArgumentList: - return nil - case .genericArgument: - return "generic argument" - case .genericParameterClause: - return "generic parameter clause" - case .genericParameterList: - return nil - case .genericParameter: - return "generic parameter" - case .genericRequirementList: - return nil - case .genericRequirement: - return nil - case .genericWhereClause: - return "'where' clause" - case .guardStmt: - return "'guard' statement" - case .identifierExpr: - return nil - case .identifierPattern: - return "pattern" - case .ifConfigClauseList: - return nil - case .ifConfigClause: - return "conditional compilation clause" - case .ifConfigDecl: - return "conditional compilation block" - case .ifExpr: - return "'if' statement" - case .implementsAttributeArguments: - return "@_implements arguemnts" - case .implicitlyUnwrappedOptionalType: - return "implicitly unwrapped optional type" - case .importDecl: - return "import" - case .inOutExpr: - return "inout expression" - case .infixOperatorExpr: - return nil - case .inheritedTypeList: - return nil - case .inheritedType: - return "inherited type" - case .initializerClause: - return nil - case .initializerDecl: - return "initializer" - case .integerLiteralExpr: - return "integer literal" - case .isExpr: - return "'is'" - case .isTypePattern: - return "'is' pattern" - case .keyPathComponentList: - return nil - case .keyPathComponent: - return "key path component" - case .keyPathExpr: - return "key path" - case .keyPathOptionalComponent: - return "key path optional component" - case .keyPathPropertyComponent: - return "key path property component" - case .keyPathSubscriptComponent: - return "key path subscript component" - case .labeledSpecializeEntry: - return "attribute argument" - case .labeledStmt: - return "labeled statement" - case .layoutRequirement: - return "layout requirement" - case .macroDecl: - return "macro" - case .macroExpansionDecl: - return "macro expansion" - case .macroExpansionExpr: - return "macro expansion" - case .matchingPatternCondition: - return "pattern matching" - case .memberAccessExpr: - return "member access" - case .memberDeclBlock: - return "member block" - case .memberDeclListItem: - return nil - case .memberDeclList: - return nil - case .memberTypeIdentifier: - return "member type" - case .metatypeType: - return "metatype" - case .missingDecl: - return "declaration" - case .missingExpr: - return "expression" - case .missingPattern: - return "pattern" - case .missingStmt: - return "statement" - case .missing: - return nil - case .missingType: - return "type" - case .modifierList: - return nil - case .moveExpr: - return "'_move' expression" - case .multipleTrailingClosureElementList: - return nil - case .multipleTrailingClosureElement: - return "trailing closure" - case .namedOpaqueReturnType: - return "named opaque return type" - case .nilLiteralExpr: - return nil - case .objCSelectorPiece: - return "Objective-C selector piece" - case .objCSelector: - return "Objective-C selector" - case .opaqueReturnTypeOfAttributeArguments: - return "opaque return type arguments" - case .operatorDecl: - return "operator declaration" - case .operatorPrecedenceAndTypes: - return nil - case .optionalBindingCondition: - return "optional binding" - case .optionalChainingExpr: - return "optional chaining" - case .optionalType: - return "optional type" - case .originallyDefinedInArguments: - return "@_originallyDefinedIn arguments" - case .packElementExpr: - return nil - case .packExpansionExpr: - return nil - case .packExpansionType: - return "variadic expansion" - case .packReferenceType: - return "pack reference" - case .parameterClause: - return "parameter clause" - case .patternBindingList: - return nil - case .patternBinding: - return nil - case .postfixIfConfigExpr: - return nil - case .postfixUnaryExpr: - return "postfix expression" - case .poundSourceLocationArgs: - return "'#sourceLocation' arguments" - case .poundSourceLocation: - return "'#sourceLocation' directive" - case .precedenceGroupAssignment: - return "'assignment' property of precedencegroup" - case .precedenceGroupAssociativity: - return "'associativity' property of precedencegroup" - case .precedenceGroupAttributeList: - return nil - case .precedenceGroupDecl: - return "precedencegroup" - case .precedenceGroupNameElement: - return nil - case .precedenceGroupNameList: - return nil - case .precedenceGroupRelation: - return "'relation' property of precedencegroup" - case .prefixOperatorExpr: - return "operator" - case .primaryAssociatedTypeClause: - return "primary associated type clause" - case .primaryAssociatedTypeList: - return nil - case .primaryAssociatedType: - return nil - case .protocolDecl: - return "protocol" - case .qualifiedDeclName: - return "declaration name" - case .regexLiteralExpr: - return "regex literal" - case .repeatWhileStmt: - return "'repeat' statement" - case .returnClause: - return nil - case .returnStmt: - return "'return' statement" - case .sameTypeRequirement: - return "same type requirement" - case .sequenceExpr: - return nil - case .simpleTypeIdentifier: - return "type" - case .sourceFile: - return "source file" - case .specializeAttributeSpecList: - return "argument to '@_specialize" - case .specializeExpr: - return nil - case .stringLiteralExpr: - return "string literal" - case .stringLiteralSegments: - return nil - case .stringSegment: - return nil - case .structDecl: - return "struct" - case .subscriptDecl: - return "subscript" - case .subscriptExpr: - return "subscript" - case .superRefExpr: - return nil - case .switchCaseLabel: - return nil - case .switchCaseList: - return nil - case .switchCase: - return "switch case" - case .switchDefaultLabel: - return nil - case .switchExpr: - return "'switch' statement" - case .targetFunctionEntry: - return "attribute argument" - case .ternaryExpr: - return "ternay expression" - case .throwStmt: - return "'throw' statement" - case .tryExpr: - return "'try' expression" - case .tupleExprElementList: - return nil - case .tupleExprElement: - return nil - case .tupleExpr: - return "tuple" - case .tuplePatternElementList: - return nil - case .tuplePatternElement: - return nil - case .tuplePattern: - return "tuple pattern" - case .tupleTypeElementList: - return nil - case .tupleTypeElement: - return nil - case .tupleType: - return "tuple type" - case .typeAnnotation: - return "type annotation" - case .typeEffectSpecifiers: - return "effect specifiers" - case .typeExpr: - return nil - case .typeInheritanceClause: - return "inheritance clause" - case .typeInitializerClause: - return nil - case .typealiasDecl: - return "typealias declaration" - case .unavailableFromAsyncArguments: - return "@_unavailableFromAsync argument" - case .underscorePrivateAttributeArguments: - return "@_private argument" - case .unexpectedNodes: - return nil - case .unresolvedAsExpr: - return "'as'" - case .unresolvedIsExpr: - return "'is'" - case .unresolvedPatternExpr: - return nil - case .unresolvedTernaryExpr: - return "ternary operator" - case .valueBindingPattern: - return "value binding pattern" - case .variableDecl: - return "variable" - case .versionTuple: - return "version tuple" - case .whereClause: - return "'where' clause" - case .whileStmt: - return "'while' statement" - case .wildcardPattern: - return "wildcard pattern" - case .yieldExprListElement: - return nil - case .yieldExprList: - return "yield list" - case .yieldList: - return nil - case .yieldStmt: - return "'yield' statement" - } - } -} diff --git a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift index 304d5334ce8..a4b9fad17eb 100644 --- a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift +++ b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift @@ -147,10 +147,6 @@ public struct DeclSyntax: DeclSyntaxProtocol, SyntaxHashable { .node(VariableDeclSyntax.self) ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } } extension DeclSyntax: CustomReflectable { @@ -320,10 +316,6 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable { .node(UnresolvedTernaryExprSyntax.self) ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } } extension ExprSyntax: CustomReflectable { @@ -452,10 +444,6 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable { .node(WildcardPatternSyntax.self) ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } } extension PatternSyntax: CustomReflectable { @@ -593,10 +581,6 @@ public struct StmtSyntax: StmtSyntaxProtocol, SyntaxHashable { .node(YieldStmtSyntax.self) ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } } extension StmtSyntax: CustomReflectable { @@ -735,10 +719,6 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable { .node(TupleTypeSyntax.self) ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return Syntax(self).childNameForDiagnostics(index) - } } extension TypeSyntax: CustomReflectable { @@ -748,3 +728,278 @@ extension TypeSyntax: CustomReflectable { return Mirror(reflecting: Syntax(self).asProtocol(SyntaxProtocol.self)) } } + +extension Syntax { + public static var structure: SyntaxNodeStructure { + return .choices([ + .node(TokenSyntax.self), + .node(AccessPathComponentSyntax.self), + .node(AccessPathSyntax.self), + .node(AccessorBlockSyntax.self), + .node(AccessorDeclSyntax.self), + .node(AccessorListSyntax.self), + .node(AccessorParameterSyntax.self), + .node(ActorDeclSyntax.self), + .node(ArrayElementListSyntax.self), + .node(ArrayElementSyntax.self), + .node(ArrayExprSyntax.self), + .node(ArrayTypeSyntax.self), + .node(ArrowExprSyntax.self), + .node(AsExprSyntax.self), + .node(AssignmentExprSyntax.self), + .node(AssociatedtypeDeclSyntax.self), + .node(AttributeListSyntax.self), + .node(AttributeSyntax.self), + .node(AttributedTypeSyntax.self), + .node(AvailabilityArgumentSyntax.self), + .node(AvailabilityConditionSyntax.self), + .node(AvailabilityEntrySyntax.self), + .node(AvailabilityLabeledArgumentSyntax.self), + .node(AvailabilitySpecListSyntax.self), + .node(AvailabilityVersionRestrictionListEntrySyntax.self), + .node(AvailabilityVersionRestrictionListSyntax.self), + .node(AvailabilityVersionRestrictionSyntax.self), + .node(AwaitExprSyntax.self), + .node(BackDeployedAttributeSpecListSyntax.self), + .node(BinaryOperatorExprSyntax.self), + .node(BooleanLiteralExprSyntax.self), + .node(BorrowExprSyntax.self), + .node(BreakStmtSyntax.self), + .node(CaseItemListSyntax.self), + .node(CaseItemSyntax.self), + .node(CatchClauseListSyntax.self), + .node(CatchClauseSyntax.self), + .node(CatchItemListSyntax.self), + .node(CatchItemSyntax.self), + .node(ClassDeclSyntax.self), + .node(ClassRestrictionTypeSyntax.self), + .node(ClosureCaptureItemListSyntax.self), + .node(ClosureCaptureItemSpecifierSyntax.self), + .node(ClosureCaptureItemSyntax.self), + .node(ClosureCaptureSignatureSyntax.self), + .node(ClosureExprSyntax.self), + .node(ClosureParamListSyntax.self), + .node(ClosureParamSyntax.self), + .node(ClosureParameterClauseSyntax.self), + .node(ClosureParameterListSyntax.self), + .node(ClosureParameterSyntax.self), + .node(ClosureSignatureSyntax.self), + .node(CodeBlockItemListSyntax.self), + .node(CodeBlockItemSyntax.self), + .node(CodeBlockSyntax.self), + .node(CompositionTypeElementListSyntax.self), + .node(CompositionTypeElementSyntax.self), + .node(CompositionTypeSyntax.self), + .node(ConditionElementListSyntax.self), + .node(ConditionElementSyntax.self), + .node(ConformanceRequirementSyntax.self), + .node(ConstrainedSugarTypeSyntax.self), + .node(ContinueStmtSyntax.self), + .node(ConventionAttributeArgumentsSyntax.self), + .node(ConventionWitnessMethodAttributeArgumentsSyntax.self), + .node(DeclEffectSpecifiersSyntax.self), + .node(DeclModifierDetailSyntax.self), + .node(DeclModifierSyntax.self), + .node(DeclNameArgumentListSyntax.self), + .node(DeclNameArgumentSyntax.self), + .node(DeclNameArgumentsSyntax.self), + .node(DeclNameSyntax.self), + .node(DeferStmtSyntax.self), + .node(DeinitializerDeclSyntax.self), + .node(DerivativeRegistrationAttributeArgumentsSyntax.self), + .node(DesignatedTypeElementSyntax.self), + .node(DesignatedTypeListSyntax.self), + .node(DictionaryElementListSyntax.self), + .node(DictionaryElementSyntax.self), + .node(DictionaryExprSyntax.self), + .node(DictionaryTypeSyntax.self), + .node(DifferentiabilityParamListSyntax.self), + .node(DifferentiabilityParamSyntax.self), + .node(DifferentiabilityParamsClauseSyntax.self), + .node(DifferentiabilityParamsSyntax.self), + .node(DifferentiableAttributeArgumentsSyntax.self), + .node(DiscardAssignmentExprSyntax.self), + .node(DoStmtSyntax.self), + .node(DocumentationAttributeArgumentSyntax.self), + .node(DocumentationAttributeArgumentsSyntax.self), + .node(DynamicReplacementArgumentsSyntax.self), + .node(EditorPlaceholderDeclSyntax.self), + .node(EditorPlaceholderExprSyntax.self), + .node(EffectsArgumentsSyntax.self), + .node(EnumCaseDeclSyntax.self), + .node(EnumCaseElementListSyntax.self), + .node(EnumCaseElementSyntax.self), + .node(EnumCaseParameterClauseSyntax.self), + .node(EnumCaseParameterListSyntax.self), + .node(EnumCaseParameterSyntax.self), + .node(EnumDeclSyntax.self), + .node(ExposeAttributeArgumentsSyntax.self), + .node(ExprListSyntax.self), + .node(ExpressionPatternSyntax.self), + .node(ExpressionSegmentSyntax.self), + .node(ExpressionStmtSyntax.self), + .node(ExtensionDeclSyntax.self), + .node(FallthroughStmtSyntax.self), + .node(FloatLiteralExprSyntax.self), + .node(ForInStmtSyntax.self), + .node(ForcedValueExprSyntax.self), + .node(ForgetStmtSyntax.self), + .node(FunctionCallExprSyntax.self), + .node(FunctionDeclSyntax.self), + .node(FunctionParameterListSyntax.self), + .node(FunctionParameterSyntax.self), + .node(FunctionSignatureSyntax.self), + .node(FunctionTypeSyntax.self), + .node(GenericArgumentClauseSyntax.self), + .node(GenericArgumentListSyntax.self), + .node(GenericArgumentSyntax.self), + .node(GenericParameterClauseSyntax.self), + .node(GenericParameterListSyntax.self), + .node(GenericParameterSyntax.self), + .node(GenericRequirementListSyntax.self), + .node(GenericRequirementSyntax.self), + .node(GenericWhereClauseSyntax.self), + .node(GuardStmtSyntax.self), + .node(IdentifierExprSyntax.self), + .node(IdentifierPatternSyntax.self), + .node(IfConfigClauseListSyntax.self), + .node(IfConfigClauseSyntax.self), + .node(IfConfigDeclSyntax.self), + .node(IfExprSyntax.self), + .node(ImplementsAttributeArgumentsSyntax.self), + .node(ImplicitlyUnwrappedOptionalTypeSyntax.self), + .node(ImportDeclSyntax.self), + .node(InOutExprSyntax.self), + .node(InfixOperatorExprSyntax.self), + .node(InheritedTypeListSyntax.self), + .node(InheritedTypeSyntax.self), + .node(InitializerClauseSyntax.self), + .node(InitializerDeclSyntax.self), + .node(IntegerLiteralExprSyntax.self), + .node(IsExprSyntax.self), + .node(IsTypePatternSyntax.self), + .node(KeyPathComponentListSyntax.self), + .node(KeyPathComponentSyntax.self), + .node(KeyPathExprSyntax.self), + .node(KeyPathOptionalComponentSyntax.self), + .node(KeyPathPropertyComponentSyntax.self), + .node(KeyPathSubscriptComponentSyntax.self), + .node(LabeledSpecializeEntrySyntax.self), + .node(LabeledStmtSyntax.self), + .node(LayoutRequirementSyntax.self), + .node(MacroDeclSyntax.self), + .node(MacroExpansionDeclSyntax.self), + .node(MacroExpansionExprSyntax.self), + .node(MatchingPatternConditionSyntax.self), + .node(MemberAccessExprSyntax.self), + .node(MemberDeclBlockSyntax.self), + .node(MemberDeclListItemSyntax.self), + .node(MemberDeclListSyntax.self), + .node(MemberTypeIdentifierSyntax.self), + .node(MetatypeTypeSyntax.self), + .node(MissingDeclSyntax.self), + .node(MissingExprSyntax.self), + .node(MissingPatternSyntax.self), + .node(MissingStmtSyntax.self), + .node(MissingSyntax.self), + .node(MissingTypeSyntax.self), + .node(ModifierListSyntax.self), + .node(MoveExprSyntax.self), + .node(MultipleTrailingClosureElementListSyntax.self), + .node(MultipleTrailingClosureElementSyntax.self), + .node(NamedOpaqueReturnTypeSyntax.self), + .node(NilLiteralExprSyntax.self), + .node(ObjCSelectorPieceSyntax.self), + .node(ObjCSelectorSyntax.self), + .node(OpaqueReturnTypeOfAttributeArgumentsSyntax.self), + .node(OperatorDeclSyntax.self), + .node(OperatorPrecedenceAndTypesSyntax.self), + .node(OptionalBindingConditionSyntax.self), + .node(OptionalChainingExprSyntax.self), + .node(OptionalTypeSyntax.self), + .node(OriginallyDefinedInArgumentsSyntax.self), + .node(PackElementExprSyntax.self), + .node(PackExpansionExprSyntax.self), + .node(PackExpansionTypeSyntax.self), + .node(PackReferenceTypeSyntax.self), + .node(ParameterClauseSyntax.self), + .node(PatternBindingListSyntax.self), + .node(PatternBindingSyntax.self), + .node(PostfixIfConfigExprSyntax.self), + .node(PostfixUnaryExprSyntax.self), + .node(PoundSourceLocationArgsSyntax.self), + .node(PoundSourceLocationSyntax.self), + .node(PrecedenceGroupAssignmentSyntax.self), + .node(PrecedenceGroupAssociativitySyntax.self), + .node(PrecedenceGroupAttributeListSyntax.self), + .node(PrecedenceGroupDeclSyntax.self), + .node(PrecedenceGroupNameElementSyntax.self), + .node(PrecedenceGroupNameListSyntax.self), + .node(PrecedenceGroupRelationSyntax.self), + .node(PrefixOperatorExprSyntax.self), + .node(PrimaryAssociatedTypeClauseSyntax.self), + .node(PrimaryAssociatedTypeListSyntax.self), + .node(PrimaryAssociatedTypeSyntax.self), + .node(ProtocolDeclSyntax.self), + .node(QualifiedDeclNameSyntax.self), + .node(RegexLiteralExprSyntax.self), + .node(RepeatWhileStmtSyntax.self), + .node(ReturnClauseSyntax.self), + .node(ReturnStmtSyntax.self), + .node(SameTypeRequirementSyntax.self), + .node(SequenceExprSyntax.self), + .node(SimpleTypeIdentifierSyntax.self), + .node(SourceFileSyntax.self), + .node(SpecializeAttributeSpecListSyntax.self), + .node(SpecializeExprSyntax.self), + .node(StringLiteralExprSyntax.self), + .node(StringLiteralSegmentsSyntax.self), + .node(StringSegmentSyntax.self), + .node(StructDeclSyntax.self), + .node(SubscriptDeclSyntax.self), + .node(SubscriptExprSyntax.self), + .node(SuperRefExprSyntax.self), + .node(SwitchCaseLabelSyntax.self), + .node(SwitchCaseListSyntax.self), + .node(SwitchCaseSyntax.self), + .node(SwitchDefaultLabelSyntax.self), + .node(SwitchExprSyntax.self), + .node(TargetFunctionEntrySyntax.self), + .node(TernaryExprSyntax.self), + .node(ThrowStmtSyntax.self), + .node(TryExprSyntax.self), + .node(TupleExprElementListSyntax.self), + .node(TupleExprElementSyntax.self), + .node(TupleExprSyntax.self), + .node(TuplePatternElementListSyntax.self), + .node(TuplePatternElementSyntax.self), + .node(TuplePatternSyntax.self), + .node(TupleTypeElementListSyntax.self), + .node(TupleTypeElementSyntax.self), + .node(TupleTypeSyntax.self), + .node(TypeAnnotationSyntax.self), + .node(TypeEffectSpecifiersSyntax.self), + .node(TypeExprSyntax.self), + .node(TypeInheritanceClauseSyntax.self), + .node(TypeInitializerClauseSyntax.self), + .node(TypealiasDeclSyntax.self), + .node(UnavailableFromAsyncArgumentsSyntax.self), + .node(UnderscorePrivateAttributeArgumentsSyntax.self), + .node(UnexpectedNodesSyntax.self), + .node(UnresolvedAsExprSyntax.self), + .node(UnresolvedIsExprSyntax.self), + .node(UnresolvedPatternExprSyntax.self), + .node(UnresolvedTernaryExprSyntax.self), + .node(ValueBindingPatternSyntax.self), + .node(VariableDeclSyntax.self), + .node(VersionTupleSyntax.self), + .node(WhereClauseSyntax.self), + .node(WhileStmtSyntax.self), + .node(WildcardPatternSyntax.self), + .node(YieldExprListElementSyntax.self), + .node(YieldExprListSyntax.self), + .node(YieldListSyntax.self), + .node(YieldStmtSyntax.self) + ]) + } +} diff --git a/Sources/SwiftSyntax/generated/SyntaxCollections.swift b/Sources/SwiftSyntax/generated/SyntaxCollections.swift index cb42686c965..1eef68f6e13 100644 --- a/Sources/SwiftSyntax/generated/SyntaxCollections.swift +++ b/Sources/SwiftSyntax/generated/SyntaxCollections.swift @@ -34,8 +34,7 @@ public struct AccessPathSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -67,7 +66,7 @@ public struct AccessPathSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `AccessPathSyntax` by replacing the underlying layout with @@ -168,10 +167,6 @@ public struct AccessPathSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `AccessPathSyntax` to the `BidirectionalCollection` protocol. @@ -249,8 +244,7 @@ public struct AccessorListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -282,7 +276,7 @@ public struct AccessorListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `AccessorListSyntax` by replacing the underlying layout with @@ -383,10 +377,6 @@ public struct AccessorListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `AccessorListSyntax` to the `BidirectionalCollection` protocol. @@ -464,8 +454,7 @@ public struct ArrayElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -497,7 +486,7 @@ public struct ArrayElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ArrayElementListSyntax` by replacing the underlying layout with @@ -598,10 +587,6 @@ public struct ArrayElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ArrayElementListSyntax` to the `BidirectionalCollection` protocol. @@ -722,8 +707,7 @@ public struct AttributeListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -755,7 +739,7 @@ public struct AttributeListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `AttributeListSyntax` by replacing the underlying layout with @@ -856,10 +840,6 @@ public struct AttributeListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `AttributeListSyntax` to the `BidirectionalCollection` protocol. @@ -937,8 +917,7 @@ public struct AvailabilitySpecListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -970,7 +949,7 @@ public struct AvailabilitySpecListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `AvailabilitySpecListSyntax` by replacing the underlying layout with @@ -1071,10 +1050,6 @@ public struct AvailabilitySpecListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `AvailabilitySpecListSyntax` to the `BidirectionalCollection` protocol. @@ -1152,8 +1127,7 @@ public struct AvailabilityVersionRestrictionListSyntax: SyntaxCollection, Syntax public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -1185,7 +1159,7 @@ public struct AvailabilityVersionRestrictionListSyntax: SyntaxCollection, Syntax /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `AvailabilityVersionRestrictionListSyntax` by replacing the underlying layout with @@ -1286,10 +1260,6 @@ public struct AvailabilityVersionRestrictionListSyntax: SyntaxCollection, Syntax newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `AvailabilityVersionRestrictionListSyntax` to the `BidirectionalCollection` protocol. @@ -1367,8 +1337,7 @@ public struct CaseItemListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -1400,7 +1369,7 @@ public struct CaseItemListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `CaseItemListSyntax` by replacing the underlying layout with @@ -1501,10 +1470,6 @@ public struct CaseItemListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `CaseItemListSyntax` to the `BidirectionalCollection` protocol. @@ -1582,8 +1547,7 @@ public struct CatchClauseListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -1615,7 +1579,7 @@ public struct CatchClauseListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `CatchClauseListSyntax` by replacing the underlying layout with @@ -1716,10 +1680,6 @@ public struct CatchClauseListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `CatchClauseListSyntax` to the `BidirectionalCollection` protocol. @@ -1797,8 +1757,7 @@ public struct CatchItemListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -1830,7 +1789,7 @@ public struct CatchItemListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `CatchItemListSyntax` by replacing the underlying layout with @@ -1931,10 +1890,6 @@ public struct CatchItemListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `CatchItemListSyntax` to the `BidirectionalCollection` protocol. @@ -2012,8 +1967,7 @@ public struct ClosureCaptureItemListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -2045,7 +1999,7 @@ public struct ClosureCaptureItemListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ClosureCaptureItemListSyntax` by replacing the underlying layout with @@ -2146,10 +2100,6 @@ public struct ClosureCaptureItemListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ClosureCaptureItemListSyntax` to the `BidirectionalCollection` protocol. @@ -2227,8 +2177,7 @@ public struct ClosureParamListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -2260,7 +2209,7 @@ public struct ClosureParamListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ClosureParamListSyntax` by replacing the underlying layout with @@ -2361,10 +2310,6 @@ public struct ClosureParamListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ClosureParamListSyntax` to the `BidirectionalCollection` protocol. @@ -2576,10 +2521,6 @@ public struct ClosureParameterListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ClosureParameterListSyntax` to the `BidirectionalCollection` protocol. @@ -2657,8 +2598,7 @@ public struct CodeBlockItemListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -2690,7 +2630,7 @@ public struct CodeBlockItemListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `CodeBlockItemListSyntax` by replacing the underlying layout with @@ -2791,10 +2731,6 @@ public struct CodeBlockItemListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `CodeBlockItemListSyntax` to the `BidirectionalCollection` protocol. @@ -2872,8 +2808,7 @@ public struct CompositionTypeElementListSyntax: SyntaxCollection, SyntaxHashable public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -2905,7 +2840,7 @@ public struct CompositionTypeElementListSyntax: SyntaxCollection, SyntaxHashable /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `CompositionTypeElementListSyntax` by replacing the underlying layout with @@ -3006,10 +2941,6 @@ public struct CompositionTypeElementListSyntax: SyntaxCollection, SyntaxHashable newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `CompositionTypeElementListSyntax` to the `BidirectionalCollection` protocol. @@ -3087,8 +3018,7 @@ public struct ConditionElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -3120,7 +3050,7 @@ public struct ConditionElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ConditionElementListSyntax` by replacing the underlying layout with @@ -3221,10 +3151,6 @@ public struct ConditionElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ConditionElementListSyntax` to the `BidirectionalCollection` protocol. @@ -3302,8 +3228,7 @@ public struct DeclNameArgumentListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -3335,7 +3260,7 @@ public struct DeclNameArgumentListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `DeclNameArgumentListSyntax` by replacing the underlying layout with @@ -3436,10 +3361,6 @@ public struct DeclNameArgumentListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `DeclNameArgumentListSyntax` to the `BidirectionalCollection` protocol. @@ -3517,8 +3438,7 @@ public struct DesignatedTypeListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -3550,7 +3470,7 @@ public struct DesignatedTypeListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `DesignatedTypeListSyntax` by replacing the underlying layout with @@ -3651,10 +3571,6 @@ public struct DesignatedTypeListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `DesignatedTypeListSyntax` to the `BidirectionalCollection` protocol. @@ -3732,8 +3648,7 @@ public struct DictionaryElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -3765,7 +3680,7 @@ public struct DictionaryElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `DictionaryElementListSyntax` by replacing the underlying layout with @@ -3866,10 +3781,6 @@ public struct DictionaryElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `DictionaryElementListSyntax` to the `BidirectionalCollection` protocol. @@ -3947,8 +3858,7 @@ public struct DifferentiabilityParamListSyntax: SyntaxCollection, SyntaxHashable public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -3980,7 +3890,7 @@ public struct DifferentiabilityParamListSyntax: SyntaxCollection, SyntaxHashable /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `DifferentiabilityParamListSyntax` by replacing the underlying layout with @@ -4081,10 +3991,6 @@ public struct DifferentiabilityParamListSyntax: SyntaxCollection, SyntaxHashable newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `DifferentiabilityParamListSyntax` to the `BidirectionalCollection` protocol. @@ -4159,8 +4065,7 @@ public struct DocumentationAttributeArgumentsSyntax: SyntaxCollection, SyntaxHas public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -4192,7 +4097,7 @@ public struct DocumentationAttributeArgumentsSyntax: SyntaxCollection, SyntaxHas /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `DocumentationAttributeArgumentsSyntax` by replacing the underlying layout with @@ -4293,10 +4198,6 @@ public struct DocumentationAttributeArgumentsSyntax: SyntaxCollection, SyntaxHas newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `DocumentationAttributeArgumentsSyntax` to the `BidirectionalCollection` protocol. @@ -4371,8 +4272,7 @@ public struct EffectsArgumentsSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -4404,7 +4304,7 @@ public struct EffectsArgumentsSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `EffectsArgumentsSyntax` by replacing the underlying layout with @@ -4505,10 +4405,6 @@ public struct EffectsArgumentsSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `EffectsArgumentsSyntax` to the `BidirectionalCollection` protocol. @@ -4583,8 +4479,7 @@ public struct EnumCaseElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -4616,7 +4511,7 @@ public struct EnumCaseElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `EnumCaseElementListSyntax` by replacing the underlying layout with @@ -4717,10 +4612,6 @@ public struct EnumCaseElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `EnumCaseElementListSyntax` to the `BidirectionalCollection` protocol. @@ -4932,10 +4823,6 @@ public struct EnumCaseParameterListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `EnumCaseParameterListSyntax` to the `BidirectionalCollection` protocol. @@ -5010,8 +4897,7 @@ public struct ExprListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -5043,7 +4929,7 @@ public struct ExprListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ExprListSyntax` by replacing the underlying layout with @@ -5144,10 +5030,6 @@ public struct ExprListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ExprListSyntax` to the `BidirectionalCollection` protocol. @@ -5225,8 +5107,7 @@ public struct FunctionParameterListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -5258,7 +5139,7 @@ public struct FunctionParameterListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `FunctionParameterListSyntax` by replacing the underlying layout with @@ -5359,10 +5240,6 @@ public struct FunctionParameterListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `FunctionParameterListSyntax` to the `BidirectionalCollection` protocol. @@ -5440,8 +5317,7 @@ public struct GenericArgumentListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -5473,7 +5349,7 @@ public struct GenericArgumentListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `GenericArgumentListSyntax` by replacing the underlying layout with @@ -5574,10 +5450,6 @@ public struct GenericArgumentListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `GenericArgumentListSyntax` to the `BidirectionalCollection` protocol. @@ -5655,8 +5527,7 @@ public struct GenericParameterListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -5688,7 +5559,7 @@ public struct GenericParameterListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `GenericParameterListSyntax` by replacing the underlying layout with @@ -5789,10 +5660,6 @@ public struct GenericParameterListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `GenericParameterListSyntax` to the `BidirectionalCollection` protocol. @@ -5870,8 +5737,7 @@ public struct GenericRequirementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -5903,7 +5769,7 @@ public struct GenericRequirementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `GenericRequirementListSyntax` by replacing the underlying layout with @@ -6004,10 +5870,6 @@ public struct GenericRequirementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `GenericRequirementListSyntax` to the `BidirectionalCollection` protocol. @@ -6085,8 +5947,7 @@ public struct IfConfigClauseListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -6118,7 +5979,7 @@ public struct IfConfigClauseListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `IfConfigClauseListSyntax` by replacing the underlying layout with @@ -6219,10 +6080,6 @@ public struct IfConfigClauseListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `IfConfigClauseListSyntax` to the `BidirectionalCollection` protocol. @@ -6300,8 +6157,7 @@ public struct InheritedTypeListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -6333,7 +6189,7 @@ public struct InheritedTypeListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `InheritedTypeListSyntax` by replacing the underlying layout with @@ -6434,10 +6290,6 @@ public struct InheritedTypeListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `InheritedTypeListSyntax` to the `BidirectionalCollection` protocol. @@ -6515,8 +6367,7 @@ public struct KeyPathComponentListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -6548,7 +6399,7 @@ public struct KeyPathComponentListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `KeyPathComponentListSyntax` by replacing the underlying layout with @@ -6649,10 +6500,6 @@ public struct KeyPathComponentListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `KeyPathComponentListSyntax` to the `BidirectionalCollection` protocol. @@ -6730,8 +6577,7 @@ public struct MemberDeclListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -6763,7 +6609,7 @@ public struct MemberDeclListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `MemberDeclListSyntax` by replacing the underlying layout with @@ -6864,10 +6710,6 @@ public struct MemberDeclListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `MemberDeclListSyntax` to the `BidirectionalCollection` protocol. @@ -6945,8 +6787,7 @@ public struct ModifierListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -6978,7 +6819,7 @@ public struct ModifierListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ModifierListSyntax` by replacing the underlying layout with @@ -7079,10 +6920,6 @@ public struct ModifierListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ModifierListSyntax` to the `BidirectionalCollection` protocol. @@ -7160,8 +6997,7 @@ public struct MultipleTrailingClosureElementListSyntax: SyntaxCollection, Syntax public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -7193,7 +7029,7 @@ public struct MultipleTrailingClosureElementListSyntax: SyntaxCollection, Syntax /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `MultipleTrailingClosureElementListSyntax` by replacing the underlying layout with @@ -7294,10 +7130,6 @@ public struct MultipleTrailingClosureElementListSyntax: SyntaxCollection, Syntax newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `MultipleTrailingClosureElementListSyntax` to the `BidirectionalCollection` protocol. @@ -7375,8 +7207,7 @@ public struct ObjCSelectorSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -7408,7 +7239,7 @@ public struct ObjCSelectorSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `ObjCSelectorSyntax` by replacing the underlying layout with @@ -7509,10 +7340,6 @@ public struct ObjCSelectorSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `ObjCSelectorSyntax` to the `BidirectionalCollection` protocol. @@ -7590,8 +7417,7 @@ public struct PatternBindingListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -7623,7 +7449,7 @@ public struct PatternBindingListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `PatternBindingListSyntax` by replacing the underlying layout with @@ -7724,10 +7550,6 @@ public struct PatternBindingListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `PatternBindingListSyntax` to the `BidirectionalCollection` protocol. @@ -7860,8 +7682,7 @@ public struct PrecedenceGroupAttributeListSyntax: SyntaxCollection, SyntaxHashab public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -7893,7 +7714,7 @@ public struct PrecedenceGroupAttributeListSyntax: SyntaxCollection, SyntaxHashab /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `PrecedenceGroupAttributeListSyntax` by replacing the underlying layout with @@ -7994,10 +7815,6 @@ public struct PrecedenceGroupAttributeListSyntax: SyntaxCollection, SyntaxHashab newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `PrecedenceGroupAttributeListSyntax` to the `BidirectionalCollection` protocol. @@ -8075,8 +7892,7 @@ public struct PrecedenceGroupNameListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -8108,7 +7924,7 @@ public struct PrecedenceGroupNameListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `PrecedenceGroupNameListSyntax` by replacing the underlying layout with @@ -8209,10 +8025,6 @@ public struct PrecedenceGroupNameListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `PrecedenceGroupNameListSyntax` to the `BidirectionalCollection` protocol. @@ -8290,8 +8102,7 @@ public struct PrimaryAssociatedTypeListSyntax: SyntaxCollection, SyntaxHashable public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -8323,7 +8134,7 @@ public struct PrimaryAssociatedTypeListSyntax: SyntaxCollection, SyntaxHashable /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `PrimaryAssociatedTypeListSyntax` by replacing the underlying layout with @@ -8424,10 +8235,6 @@ public struct PrimaryAssociatedTypeListSyntax: SyntaxCollection, SyntaxHashable newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `PrimaryAssociatedTypeListSyntax` to the `BidirectionalCollection` protocol. @@ -8570,8 +8377,7 @@ public struct SpecializeAttributeSpecListSyntax: SyntaxCollection, SyntaxHashabl public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -8603,7 +8409,7 @@ public struct SpecializeAttributeSpecListSyntax: SyntaxCollection, SyntaxHashabl /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `SpecializeAttributeSpecListSyntax` by replacing the underlying layout with @@ -8704,10 +8510,6 @@ public struct SpecializeAttributeSpecListSyntax: SyntaxCollection, SyntaxHashabl newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `SpecializeAttributeSpecListSyntax` to the `BidirectionalCollection` protocol. @@ -8828,8 +8630,7 @@ public struct StringLiteralSegmentsSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -8861,7 +8662,7 @@ public struct StringLiteralSegmentsSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `StringLiteralSegmentsSyntax` by replacing the underlying layout with @@ -8962,10 +8763,6 @@ public struct StringLiteralSegmentsSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `StringLiteralSegmentsSyntax` to the `BidirectionalCollection` protocol. @@ -9086,8 +8883,7 @@ public struct SwitchCaseListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -9119,7 +8915,7 @@ public struct SwitchCaseListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `SwitchCaseListSyntax` by replacing the underlying layout with @@ -9220,10 +9016,6 @@ public struct SwitchCaseListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `SwitchCaseListSyntax` to the `BidirectionalCollection` protocol. @@ -9301,8 +9093,7 @@ public struct TupleExprElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -9334,7 +9125,7 @@ public struct TupleExprElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `TupleExprElementListSyntax` by replacing the underlying layout with @@ -9435,10 +9226,6 @@ public struct TupleExprElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `TupleExprElementListSyntax` to the `BidirectionalCollection` protocol. @@ -9516,8 +9303,7 @@ public struct TuplePatternElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -9549,7 +9335,7 @@ public struct TuplePatternElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `TuplePatternElementListSyntax` by replacing the underlying layout with @@ -9650,10 +9436,6 @@ public struct TuplePatternElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `TuplePatternElementListSyntax` to the `BidirectionalCollection` protocol. @@ -9731,8 +9513,7 @@ public struct TupleTypeElementListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -9764,7 +9545,7 @@ public struct TupleTypeElementListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `TupleTypeElementListSyntax` by replacing the underlying layout with @@ -9865,10 +9646,6 @@ public struct TupleTypeElementListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `TupleTypeElementListSyntax` to the `BidirectionalCollection` protocol. @@ -9943,8 +9720,7 @@ public struct UnexpectedNodesSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -9976,7 +9752,7 @@ public struct UnexpectedNodesSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `UnexpectedNodesSyntax` by replacing the underlying layout with @@ -10077,10 +9853,6 @@ public struct UnexpectedNodesSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `UnexpectedNodesSyntax` to the `BidirectionalCollection` protocol. @@ -10158,8 +9930,7 @@ public struct YieldExprListSyntax: SyntaxCollection, SyntaxHashable { public let _syntaxNode: Syntax - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { + private var layoutView: RawSyntaxLayoutView { data.raw.layoutView! } @@ -10191,7 +9962,7 @@ public struct YieldExprListSyntax: SyntaxCollection, SyntaxHashable { /// The number of elements, `present` or `missing`, in this collection. public var count: Int { - return raw.layoutView!.children.count + return layoutView.children.count } /// Creates a new `YieldExprListSyntax` by replacing the underlying layout with @@ -10292,10 +10063,6 @@ public struct YieldExprListSyntax: SyntaxCollection, SyntaxHashable { newLayout.removeLast() return replacingLayout(newLayout) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - return nil - } } /// Conformance for `YieldExprListSyntax` to the `BidirectionalCollection` protocol. diff --git a/Sources/SwiftSyntax/generated/SyntaxKind.swift b/Sources/SwiftSyntax/generated/SyntaxKind.swift index 983c8b5b057..e551b4c9b4c 100644 --- a/Sources/SwiftSyntax/generated/SyntaxKind.swift +++ b/Sources/SwiftSyntax/generated/SyntaxKind.swift @@ -401,4 +401,545 @@ public enum SyntaxKind { return false } } + + public var syntaxNodeType: SyntaxProtocol.Type { + switch self { + case .token: + return TokenSyntax.self + case .accessPathComponent: + return AccessPathComponentSyntax.self + case .accessPath: + return AccessPathSyntax.self + case .accessorBlock: + return AccessorBlockSyntax.self + case .accessorDecl: + return AccessorDeclSyntax.self + case .accessorList: + return AccessorListSyntax.self + case .accessorParameter: + return AccessorParameterSyntax.self + case .actorDecl: + return ActorDeclSyntax.self + case .arrayElementList: + return ArrayElementListSyntax.self + case .arrayElement: + return ArrayElementSyntax.self + case .arrayExpr: + return ArrayExprSyntax.self + case .arrayType: + return ArrayTypeSyntax.self + case .arrowExpr: + return ArrowExprSyntax.self + case .asExpr: + return AsExprSyntax.self + case .assignmentExpr: + return AssignmentExprSyntax.self + case .associatedtypeDecl: + return AssociatedtypeDeclSyntax.self + case .attributeList: + return AttributeListSyntax.self + case .attribute: + return AttributeSyntax.self + case .attributedType: + return AttributedTypeSyntax.self + case .availabilityArgument: + return AvailabilityArgumentSyntax.self + case .availabilityCondition: + return AvailabilityConditionSyntax.self + case .availabilityEntry: + return AvailabilityEntrySyntax.self + case .availabilityLabeledArgument: + return AvailabilityLabeledArgumentSyntax.self + case .availabilitySpecList: + return AvailabilitySpecListSyntax.self + case .availabilityVersionRestrictionListEntry: + return AvailabilityVersionRestrictionListEntrySyntax.self + case .availabilityVersionRestrictionList: + return AvailabilityVersionRestrictionListSyntax.self + case .availabilityVersionRestriction: + return AvailabilityVersionRestrictionSyntax.self + case .awaitExpr: + return AwaitExprSyntax.self + case .backDeployedAttributeSpecList: + return BackDeployedAttributeSpecListSyntax.self + case .binaryOperatorExpr: + return BinaryOperatorExprSyntax.self + case .booleanLiteralExpr: + return BooleanLiteralExprSyntax.self + case .borrowExpr: + return BorrowExprSyntax.self + case .breakStmt: + return BreakStmtSyntax.self + case .caseItemList: + return CaseItemListSyntax.self + case .caseItem: + return CaseItemSyntax.self + case .catchClauseList: + return CatchClauseListSyntax.self + case .catchClause: + return CatchClauseSyntax.self + case .catchItemList: + return CatchItemListSyntax.self + case .catchItem: + return CatchItemSyntax.self + case .classDecl: + return ClassDeclSyntax.self + case .classRestrictionType: + return ClassRestrictionTypeSyntax.self + case .closureCaptureItemList: + return ClosureCaptureItemListSyntax.self + case .closureCaptureItemSpecifier: + return ClosureCaptureItemSpecifierSyntax.self + case .closureCaptureItem: + return ClosureCaptureItemSyntax.self + case .closureCaptureSignature: + return ClosureCaptureSignatureSyntax.self + case .closureExpr: + return ClosureExprSyntax.self + case .closureParamList: + return ClosureParamListSyntax.self + case .closureParam: + return ClosureParamSyntax.self + case .closureParameterClause: + return ClosureParameterClauseSyntax.self + case .closureParameterList: + return ClosureParameterListSyntax.self + case .closureParameter: + return ClosureParameterSyntax.self + case .closureSignature: + return ClosureSignatureSyntax.self + case .codeBlockItemList: + return CodeBlockItemListSyntax.self + case .codeBlockItem: + return CodeBlockItemSyntax.self + case .codeBlock: + return CodeBlockSyntax.self + case .compositionTypeElementList: + return CompositionTypeElementListSyntax.self + case .compositionTypeElement: + return CompositionTypeElementSyntax.self + case .compositionType: + return CompositionTypeSyntax.self + case .conditionElementList: + return ConditionElementListSyntax.self + case .conditionElement: + return ConditionElementSyntax.self + case .conformanceRequirement: + return ConformanceRequirementSyntax.self + case .constrainedSugarType: + return ConstrainedSugarTypeSyntax.self + case .continueStmt: + return ContinueStmtSyntax.self + case .conventionAttributeArguments: + return ConventionAttributeArgumentsSyntax.self + case .conventionWitnessMethodAttributeArguments: + return ConventionWitnessMethodAttributeArgumentsSyntax.self + case .declEffectSpecifiers: + return DeclEffectSpecifiersSyntax.self + case .declModifierDetail: + return DeclModifierDetailSyntax.self + case .declModifier: + return DeclModifierSyntax.self + case .declNameArgumentList: + return DeclNameArgumentListSyntax.self + case .declNameArgument: + return DeclNameArgumentSyntax.self + case .declNameArguments: + return DeclNameArgumentsSyntax.self + case .declName: + return DeclNameSyntax.self + case .deferStmt: + return DeferStmtSyntax.self + case .deinitializerDecl: + return DeinitializerDeclSyntax.self + case .derivativeRegistrationAttributeArguments: + return DerivativeRegistrationAttributeArgumentsSyntax.self + case .designatedTypeElement: + return DesignatedTypeElementSyntax.self + case .designatedTypeList: + return DesignatedTypeListSyntax.self + case .dictionaryElementList: + return DictionaryElementListSyntax.self + case .dictionaryElement: + return DictionaryElementSyntax.self + case .dictionaryExpr: + return DictionaryExprSyntax.self + case .dictionaryType: + return DictionaryTypeSyntax.self + case .differentiabilityParamList: + return DifferentiabilityParamListSyntax.self + case .differentiabilityParam: + return DifferentiabilityParamSyntax.self + case .differentiabilityParamsClause: + return DifferentiabilityParamsClauseSyntax.self + case .differentiabilityParams: + return DifferentiabilityParamsSyntax.self + case .differentiableAttributeArguments: + return DifferentiableAttributeArgumentsSyntax.self + case .discardAssignmentExpr: + return DiscardAssignmentExprSyntax.self + case .doStmt: + return DoStmtSyntax.self + case .documentationAttributeArgument: + return DocumentationAttributeArgumentSyntax.self + case .documentationAttributeArguments: + return DocumentationAttributeArgumentsSyntax.self + case .dynamicReplacementArguments: + return DynamicReplacementArgumentsSyntax.self + case .editorPlaceholderDecl: + return EditorPlaceholderDeclSyntax.self + case .editorPlaceholderExpr: + return EditorPlaceholderExprSyntax.self + case .effectsArguments: + return EffectsArgumentsSyntax.self + case .enumCaseDecl: + return EnumCaseDeclSyntax.self + case .enumCaseElementList: + return EnumCaseElementListSyntax.self + case .enumCaseElement: + return EnumCaseElementSyntax.self + case .enumCaseParameterClause: + return EnumCaseParameterClauseSyntax.self + case .enumCaseParameterList: + return EnumCaseParameterListSyntax.self + case .enumCaseParameter: + return EnumCaseParameterSyntax.self + case .enumDecl: + return EnumDeclSyntax.self + case .exposeAttributeArguments: + return ExposeAttributeArgumentsSyntax.self + case .exprList: + return ExprListSyntax.self + case .expressionPattern: + return ExpressionPatternSyntax.self + case .expressionSegment: + return ExpressionSegmentSyntax.self + case .expressionStmt: + return ExpressionStmtSyntax.self + case .extensionDecl: + return ExtensionDeclSyntax.self + case .fallthroughStmt: + return FallthroughStmtSyntax.self + case .floatLiteralExpr: + return FloatLiteralExprSyntax.self + case .forInStmt: + return ForInStmtSyntax.self + case .forcedValueExpr: + return ForcedValueExprSyntax.self + case .forgetStmt: + return ForgetStmtSyntax.self + case .functionCallExpr: + return FunctionCallExprSyntax.self + case .functionDecl: + return FunctionDeclSyntax.self + case .functionParameterList: + return FunctionParameterListSyntax.self + case .functionParameter: + return FunctionParameterSyntax.self + case .functionSignature: + return FunctionSignatureSyntax.self + case .functionType: + return FunctionTypeSyntax.self + case .genericArgumentClause: + return GenericArgumentClauseSyntax.self + case .genericArgumentList: + return GenericArgumentListSyntax.self + case .genericArgument: + return GenericArgumentSyntax.self + case .genericParameterClause: + return GenericParameterClauseSyntax.self + case .genericParameterList: + return GenericParameterListSyntax.self + case .genericParameter: + return GenericParameterSyntax.self + case .genericRequirementList: + return GenericRequirementListSyntax.self + case .genericRequirement: + return GenericRequirementSyntax.self + case .genericWhereClause: + return GenericWhereClauseSyntax.self + case .guardStmt: + return GuardStmtSyntax.self + case .identifierExpr: + return IdentifierExprSyntax.self + case .identifierPattern: + return IdentifierPatternSyntax.self + case .ifConfigClauseList: + return IfConfigClauseListSyntax.self + case .ifConfigClause: + return IfConfigClauseSyntax.self + case .ifConfigDecl: + return IfConfigDeclSyntax.self + case .ifExpr: + return IfExprSyntax.self + case .implementsAttributeArguments: + return ImplementsAttributeArgumentsSyntax.self + case .implicitlyUnwrappedOptionalType: + return ImplicitlyUnwrappedOptionalTypeSyntax.self + case .importDecl: + return ImportDeclSyntax.self + case .inOutExpr: + return InOutExprSyntax.self + case .infixOperatorExpr: + return InfixOperatorExprSyntax.self + case .inheritedTypeList: + return InheritedTypeListSyntax.self + case .inheritedType: + return InheritedTypeSyntax.self + case .initializerClause: + return InitializerClauseSyntax.self + case .initializerDecl: + return InitializerDeclSyntax.self + case .integerLiteralExpr: + return IntegerLiteralExprSyntax.self + case .isExpr: + return IsExprSyntax.self + case .isTypePattern: + return IsTypePatternSyntax.self + case .keyPathComponentList: + return KeyPathComponentListSyntax.self + case .keyPathComponent: + return KeyPathComponentSyntax.self + case .keyPathExpr: + return KeyPathExprSyntax.self + case .keyPathOptionalComponent: + return KeyPathOptionalComponentSyntax.self + case .keyPathPropertyComponent: + return KeyPathPropertyComponentSyntax.self + case .keyPathSubscriptComponent: + return KeyPathSubscriptComponentSyntax.self + case .labeledSpecializeEntry: + return LabeledSpecializeEntrySyntax.self + case .labeledStmt: + return LabeledStmtSyntax.self + case .layoutRequirement: + return LayoutRequirementSyntax.self + case .macroDecl: + return MacroDeclSyntax.self + case .macroExpansionDecl: + return MacroExpansionDeclSyntax.self + case .macroExpansionExpr: + return MacroExpansionExprSyntax.self + case .matchingPatternCondition: + return MatchingPatternConditionSyntax.self + case .memberAccessExpr: + return MemberAccessExprSyntax.self + case .memberDeclBlock: + return MemberDeclBlockSyntax.self + case .memberDeclListItem: + return MemberDeclListItemSyntax.self + case .memberDeclList: + return MemberDeclListSyntax.self + case .memberTypeIdentifier: + return MemberTypeIdentifierSyntax.self + case .metatypeType: + return MetatypeTypeSyntax.self + case .missingDecl: + return MissingDeclSyntax.self + case .missingExpr: + return MissingExprSyntax.self + case .missingPattern: + return MissingPatternSyntax.self + case .missingStmt: + return MissingStmtSyntax.self + case .missing: + return MissingSyntax.self + case .missingType: + return MissingTypeSyntax.self + case .modifierList: + return ModifierListSyntax.self + case .moveExpr: + return MoveExprSyntax.self + case .multipleTrailingClosureElementList: + return MultipleTrailingClosureElementListSyntax.self + case .multipleTrailingClosureElement: + return MultipleTrailingClosureElementSyntax.self + case .namedOpaqueReturnType: + return NamedOpaqueReturnTypeSyntax.self + case .nilLiteralExpr: + return NilLiteralExprSyntax.self + case .objCSelectorPiece: + return ObjCSelectorPieceSyntax.self + case .objCSelector: + return ObjCSelectorSyntax.self + case .opaqueReturnTypeOfAttributeArguments: + return OpaqueReturnTypeOfAttributeArgumentsSyntax.self + case .operatorDecl: + return OperatorDeclSyntax.self + case .operatorPrecedenceAndTypes: + return OperatorPrecedenceAndTypesSyntax.self + case .optionalBindingCondition: + return OptionalBindingConditionSyntax.self + case .optionalChainingExpr: + return OptionalChainingExprSyntax.self + case .optionalType: + return OptionalTypeSyntax.self + case .originallyDefinedInArguments: + return OriginallyDefinedInArgumentsSyntax.self + case .packElementExpr: + return PackElementExprSyntax.self + case .packExpansionExpr: + return PackExpansionExprSyntax.self + case .packExpansionType: + return PackExpansionTypeSyntax.self + case .packReferenceType: + return PackReferenceTypeSyntax.self + case .parameterClause: + return ParameterClauseSyntax.self + case .patternBindingList: + return PatternBindingListSyntax.self + case .patternBinding: + return PatternBindingSyntax.self + case .postfixIfConfigExpr: + return PostfixIfConfigExprSyntax.self + case .postfixUnaryExpr: + return PostfixUnaryExprSyntax.self + case .poundSourceLocationArgs: + return PoundSourceLocationArgsSyntax.self + case .poundSourceLocation: + return PoundSourceLocationSyntax.self + case .precedenceGroupAssignment: + return PrecedenceGroupAssignmentSyntax.self + case .precedenceGroupAssociativity: + return PrecedenceGroupAssociativitySyntax.self + case .precedenceGroupAttributeList: + return PrecedenceGroupAttributeListSyntax.self + case .precedenceGroupDecl: + return PrecedenceGroupDeclSyntax.self + case .precedenceGroupNameElement: + return PrecedenceGroupNameElementSyntax.self + case .precedenceGroupNameList: + return PrecedenceGroupNameListSyntax.self + case .precedenceGroupRelation: + return PrecedenceGroupRelationSyntax.self + case .prefixOperatorExpr: + return PrefixOperatorExprSyntax.self + case .primaryAssociatedTypeClause: + return PrimaryAssociatedTypeClauseSyntax.self + case .primaryAssociatedTypeList: + return PrimaryAssociatedTypeListSyntax.self + case .primaryAssociatedType: + return PrimaryAssociatedTypeSyntax.self + case .protocolDecl: + return ProtocolDeclSyntax.self + case .qualifiedDeclName: + return QualifiedDeclNameSyntax.self + case .regexLiteralExpr: + return RegexLiteralExprSyntax.self + case .repeatWhileStmt: + return RepeatWhileStmtSyntax.self + case .returnClause: + return ReturnClauseSyntax.self + case .returnStmt: + return ReturnStmtSyntax.self + case .sameTypeRequirement: + return SameTypeRequirementSyntax.self + case .sequenceExpr: + return SequenceExprSyntax.self + case .simpleTypeIdentifier: + return SimpleTypeIdentifierSyntax.self + case .sourceFile: + return SourceFileSyntax.self + case .specializeAttributeSpecList: + return SpecializeAttributeSpecListSyntax.self + case .specializeExpr: + return SpecializeExprSyntax.self + case .stringLiteralExpr: + return StringLiteralExprSyntax.self + case .stringLiteralSegments: + return StringLiteralSegmentsSyntax.self + case .stringSegment: + return StringSegmentSyntax.self + case .structDecl: + return StructDeclSyntax.self + case .subscriptDecl: + return SubscriptDeclSyntax.self + case .subscriptExpr: + return SubscriptExprSyntax.self + case .superRefExpr: + return SuperRefExprSyntax.self + case .switchCaseLabel: + return SwitchCaseLabelSyntax.self + case .switchCaseList: + return SwitchCaseListSyntax.self + case .switchCase: + return SwitchCaseSyntax.self + case .switchDefaultLabel: + return SwitchDefaultLabelSyntax.self + case .switchExpr: + return SwitchExprSyntax.self + case .targetFunctionEntry: + return TargetFunctionEntrySyntax.self + case .ternaryExpr: + return TernaryExprSyntax.self + case .throwStmt: + return ThrowStmtSyntax.self + case .tryExpr: + return TryExprSyntax.self + case .tupleExprElementList: + return TupleExprElementListSyntax.self + case .tupleExprElement: + return TupleExprElementSyntax.self + case .tupleExpr: + return TupleExprSyntax.self + case .tuplePatternElementList: + return TuplePatternElementListSyntax.self + case .tuplePatternElement: + return TuplePatternElementSyntax.self + case .tuplePattern: + return TuplePatternSyntax.self + case .tupleTypeElementList: + return TupleTypeElementListSyntax.self + case .tupleTypeElement: + return TupleTypeElementSyntax.self + case .tupleType: + return TupleTypeSyntax.self + case .typeAnnotation: + return TypeAnnotationSyntax.self + case .typeEffectSpecifiers: + return TypeEffectSpecifiersSyntax.self + case .typeExpr: + return TypeExprSyntax.self + case .typeInheritanceClause: + return TypeInheritanceClauseSyntax.self + case .typeInitializerClause: + return TypeInitializerClauseSyntax.self + case .typealiasDecl: + return TypealiasDeclSyntax.self + case .unavailableFromAsyncArguments: + return UnavailableFromAsyncArgumentsSyntax.self + case .underscorePrivateAttributeArguments: + return UnderscorePrivateAttributeArgumentsSyntax.self + case .unexpectedNodes: + return UnexpectedNodesSyntax.self + case .unresolvedAsExpr: + return UnresolvedAsExprSyntax.self + case .unresolvedIsExpr: + return UnresolvedIsExprSyntax.self + case .unresolvedPatternExpr: + return UnresolvedPatternExprSyntax.self + case .unresolvedTernaryExpr: + return UnresolvedTernaryExprSyntax.self + case .valueBindingPattern: + return ValueBindingPatternSyntax.self + case .variableDecl: + return VariableDeclSyntax.self + case .versionTuple: + return VersionTupleSyntax.self + case .whereClause: + return WhereClauseSyntax.self + case .whileStmt: + return WhileStmtSyntax.self + case .wildcardPattern: + return WildcardPatternSyntax.self + case .yieldExprListElement: + return YieldExprListElementSyntax.self + case .yieldExprList: + return YieldExprListSyntax.self + case .yieldList: + return YieldListSyntax.self + case .yieldStmt: + return YieldStmtSyntax.self + } + } } diff --git a/Sources/SwiftSyntax/generated/TokenKind.swift b/Sources/SwiftSyntax/generated/TokenKind.swift index 227f514f270..e3958611ec2 100644 --- a/Sources/SwiftSyntax/generated/TokenKind.swift +++ b/Sources/SwiftSyntax/generated/TokenKind.swift @@ -253,217 +253,6 @@ public enum TokenKind: Hashable { } } - public var nameForDiagnostics: String { - switch self { - case .eof: - return "end of file" - case .arrow: - return #"->"# - case .atSign: - return #"@"# - case .backslash: - return #"\"# - case .backtick: - return #"`"# - case .binaryOperator: - return #"binary operator"# - case .colon: - return #":"# - case .comma: - return #","# - case .dollarIdentifier: - return #"dollar identifier"# - case .ellipsis: - return #"..."# - case .equal: - return #"="# - case .exclamationMark: - return #"!"# - case .extendedRegexDelimiter: - return #"extended delimiter"# - case .floatingLiteral: - return #"floating literal"# - case .identifier: - return #"identifier"# - case .infixQuestionMark: - return #"?"# - case .integerLiteral: - return #"integer literal"# - case .leftAngle: - return #"<"# - case .leftBrace: - return #"{"# - case .leftParen: - return #"("# - case .leftSquareBracket: - return #"["# - case .multilineStringQuote: - return #"""""# - case .period: - return #"."# - case .postfixOperator: - return #"postfix operator"# - case .postfixQuestionMark: - return #"?"# - case .pound: - return #"#"# - case .poundAvailableKeyword: - return #"#available"# - case .poundElseKeyword: - return #"#else"# - case .poundElseifKeyword: - return #"#elseif"# - case .poundEndifKeyword: - return #"#endif"# - case .poundIfKeyword: - return #"#if"# - case .poundSourceLocationKeyword: - return #"#sourceLocation"# - case .poundUnavailableKeyword: - return #"#unavailable"# - case .prefixAmpersand: - return #"&"# - case .prefixOperator: - return #"prefix operator"# - case .rawStringDelimiter: - return #"raw string delimiter"# - case .regexLiteralPattern: - return #"regex pattern"# - case .regexSlash: - return #"/"# - case .rightAngle: - return #">"# - case .rightBrace: - return #"}"# - case .rightParen: - return #")"# - case .rightSquareBracket: - return #"]"# - case .semicolon: - return #";"# - case .singleQuote: - return #"'"# - case .stringQuote: - return #"""# - case .stringSegment: - return #"string segment"# - case .unknown: - return #"token"# - case .wildcard: - return #"wildcard"# - case .keyword(let keyword): - return String(syntaxText: keyword.defaultText) - } - } - - /// Returns `true` if the token is a Swift keyword. - /// - /// Keywords are reserved unconditionally for use by Swift and may not - /// appear as identifiers in any position without being escaped. For example, - /// `class`, `func`, or `import`. - public var isLexerClassifiedKeyword: Bool { - switch self { - case .eof: - return false - case .arrow: - return false - case .atSign: - return false - case .backslash: - return false - case .backtick: - return false - case .binaryOperator: - return false - case .colon: - return false - case .comma: - return false - case .dollarIdentifier: - return false - case .ellipsis: - return false - case .equal: - return false - case .exclamationMark: - return false - case .extendedRegexDelimiter: - return false - case .floatingLiteral: - return false - case .identifier: - return false - case .infixQuestionMark: - return false - case .integerLiteral: - return false - case .leftAngle: - return false - case .leftBrace: - return false - case .leftParen: - return false - case .leftSquareBracket: - return false - case .multilineStringQuote: - return false - case .period: - return false - case .postfixOperator: - return false - case .postfixQuestionMark: - return false - case .pound: - return false - case .poundAvailableKeyword: - return true - case .poundElseKeyword: - return true - case .poundElseifKeyword: - return true - case .poundEndifKeyword: - return true - case .poundIfKeyword: - return true - case .poundSourceLocationKeyword: - return true - case .poundUnavailableKeyword: - return true - case .prefixAmpersand: - return false - case .prefixOperator: - return false - case .rawStringDelimiter: - return false - case .regexLiteralPattern: - return false - case .regexSlash: - return false - case .rightAngle: - return false - case .rightBrace: - return false - case .rightParen: - return false - case .rightSquareBracket: - return false - case .semicolon: - return false - case .singleQuote: - return false - case .stringQuote: - return false - case .stringSegment: - return false - case .unknown: - return false - case .wildcard: - return false - case .keyword(let keyword): - return keyword.isLexerClassified - } - } - /// Returns `true` if the token is a Swift punctuator. /// /// Punctuation tokens generally separate identifiers from each other. For @@ -685,6 +474,7 @@ extension TokenKind: Equatable { // `RawTokenBaseKind` for equality. With the raw value, it compiles down to // a primitive integer compare, without, it calls into `__derived_enum_equals`. @frozen // FIXME: Not actually stable, works around a miscompile +@_spi(RawSyntax) public enum RawTokenKind: UInt8, Equatable, Hashable { case eof case arrow diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift index e746180f2c0..365262da656 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift @@ -248,39 +248,6 @@ public struct AccessorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "parameter" - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - default: - fatalError("Invalid index") - } - } } extension AccessorDeclSyntax: CustomReflectable { @@ -610,47 +577,6 @@ public struct ActorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "type inheritance clause" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension ActorDeclSyntax: CustomReflectable { @@ -958,43 +884,6 @@ public struct AssociatedtypeDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericWhereClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "inheritance clause" - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension AssociatedtypeDeclSyntax: CustomReflectable { @@ -1326,47 +1215,6 @@ public struct ClassDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "inheritance clause" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension ClassDeclSyntax: CustomReflectable { @@ -1596,31 +1444,6 @@ public struct DeinitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension DeinitializerDeclSyntax: CustomReflectable { @@ -1714,19 +1537,6 @@ public struct EditorPlaceholderDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeIdentifier, \Self.identifier, \Self.unexpectedAfterIdentifier]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension EditorPlaceholderDeclSyntax: CustomReflectable { @@ -1964,31 +1774,6 @@ public struct EnumCaseDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterElements ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "elements" - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension EnumCaseDeclSyntax: CustomReflectable { @@ -2322,47 +2107,6 @@ public struct EnumDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "inheritance clause" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension EnumDeclSyntax: CustomReflectable { @@ -2670,43 +2414,6 @@ public struct ExtensionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "inheritance clause" - case 10: - return nil - case 11: - return "generic where clause" - case 12: - return nil - case 13: - return nil - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension ExtensionDeclSyntax: CustomReflectable { @@ -3038,47 +2745,6 @@ public struct FunctionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "function signature" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension FunctionDeclSyntax: CustomReflectable { @@ -3237,23 +2903,6 @@ public struct IfConfigDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPoundEndif ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension IfConfigDeclSyntax: CustomReflectable { @@ -3516,35 +3165,6 @@ public struct ImportDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPath ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension ImportDeclSyntax: CustomReflectable { @@ -3872,47 +3492,6 @@ public struct InitializerDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "function signature" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension InitializerDeclSyntax: CustomReflectable { @@ -4246,47 +3825,6 @@ public struct MacroDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericWhereClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "macro signature" - case 12: - return nil - case 13: - return "macro definition" - case 14: - return nil - case 15: - return "generic where clause" - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension MacroDeclSyntax: CustomReflectable { @@ -4621,47 +4159,6 @@ public struct MacroExpansionDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAdditionalTrailingClosures ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension MacroExpansionDeclSyntax: CustomReflectable { @@ -4839,23 +4336,6 @@ public struct MissingDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterModifiers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingDeclSyntax: CustomReflectable { @@ -5102,35 +4582,6 @@ public struct OperatorDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterOperatorPrecedenceAndTypes ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension OperatorDeclSyntax: CustomReflectable { @@ -5316,31 +4767,6 @@ public struct PoundSourceLocationSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "arguments" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension PoundSourceLocationSyntax: CustomReflectable { @@ -5663,43 +5089,6 @@ public struct PrecedenceGroupDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension PrecedenceGroupDeclSyntax: CustomReflectable { @@ -6031,47 +5420,6 @@ public struct ProtocolDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "primary associated type clause" - case 10: - return nil - case 11: - return "inheritance clause" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension ProtocolDeclSyntax: CustomReflectable { @@ -6405,47 +5753,6 @@ public struct StructDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterMembers ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return "type inheritance clause" - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension StructDeclSyntax: CustomReflectable { @@ -6821,47 +6128,6 @@ public struct SubscriptDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAccessor ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "generic parameter clause" - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension SubscriptDeclSyntax: CustomReflectable { @@ -7169,43 +6435,6 @@ public struct TypealiasDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericWhereClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "generic parameter clause" - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return "generic where clause" - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension TypealiasDeclSyntax: CustomReflectable { @@ -7452,31 +6681,6 @@ public struct VariableDeclSyntax: DeclSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBindings ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension VariableDeclSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift index ba423b3bf91..6a062c3adf3 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift @@ -170,27 +170,6 @@ public struct ArrayExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightSquare ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ArrayExprSyntax: CustomReflectable { @@ -320,23 +299,6 @@ public struct ArrowExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterArrowToken ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ArrowExprSyntax: CustomReflectable { @@ -516,31 +478,6 @@ public struct AsExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTypeName ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension AsExprSyntax: CustomReflectable { @@ -634,19 +571,6 @@ public struct AssignmentExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeAssignToken, \Self.assignToken, \Self.unexpectedAfterAssignToken]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension AssignmentExprSyntax: CustomReflectable { @@ -771,23 +695,6 @@ public struct AwaitExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension AwaitExprSyntax: CustomReflectable { @@ -877,19 +784,6 @@ public struct BinaryOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeOperatorToken, \Self.operatorToken, \Self.unexpectedAfterOperatorToken]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension BinaryOperatorExprSyntax: CustomReflectable { @@ -976,19 +870,6 @@ public struct BooleanLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeBooleanLiteral, \Self.booleanLiteral, \Self.unexpectedAfterBooleanLiteral]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension BooleanLiteralExprSyntax: CustomReflectable { @@ -1113,23 +994,6 @@ public struct BorrowExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension BorrowExprSyntax: CustomReflectable { @@ -1328,31 +1192,6 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureExprSyntax: CustomReflectable { @@ -1552,27 +1391,6 @@ public struct DictionaryExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightSquare ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DictionaryExprSyntax: CustomReflectable { @@ -1664,19 +1482,6 @@ public struct DiscardAssignmentExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeWildcard, \Self.wildcard, \Self.unexpectedAfterWildcard]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension DiscardAssignmentExprSyntax: CustomReflectable { @@ -1763,19 +1568,6 @@ public struct EditorPlaceholderExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeIdentifier, \Self.identifier, \Self.unexpectedAfterIdentifier]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension EditorPlaceholderExprSyntax: CustomReflectable { @@ -1862,19 +1654,6 @@ public struct FloatLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeFloatingDigits, \Self.floatingDigits, \Self.unexpectedAfterFloatingDigits]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension FloatLiteralExprSyntax: CustomReflectable { @@ -1999,23 +1778,6 @@ public struct ForcedValueExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExclamationMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ForcedValueExprSyntax: CustomReflectable { @@ -2285,39 +2047,6 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAdditionalTrailingClosures ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "called expression" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "arguments" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "trailing closure" - case 10: - return nil - case 11: - return "trailing closures" - case 12: - return nil - default: - fatalError("Invalid index") - } - } } extension FunctionCallExprSyntax: CustomReflectable { @@ -2453,23 +2182,6 @@ public struct IdentifierExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterDeclNameArguments ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension IdentifierExprSyntax: CustomReflectable { @@ -2736,35 +2448,6 @@ public struct IfExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterElseBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "body" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "else body" - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension IfExprSyntax: CustomReflectable { @@ -2898,23 +2581,6 @@ public struct InOutExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension InOutExprSyntax: CustomReflectable { @@ -3068,27 +2734,6 @@ public struct InfixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightOperand ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension InfixOperatorExprSyntax: CustomReflectable { @@ -3180,19 +2825,6 @@ public struct IntegerLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeDigits, \Self.digits, \Self.unexpectedAfterDigits]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension IntegerLiteralExprSyntax: CustomReflectable { @@ -3343,27 +2975,6 @@ public struct IsExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTypeName ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension IsExprSyntax: CustomReflectable { @@ -3573,27 +3184,6 @@ public struct KeyPathExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterComponents ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "root" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension KeyPathExprSyntax: CustomReflectable { @@ -3918,47 +3508,6 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAdditionalTrailingClosures ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension MacroExpansionExprSyntax: CustomReflectable { @@ -4189,31 +3738,6 @@ public struct MemberAccessExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterDeclNameArguments ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "base" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension MemberAccessExprSyntax: CustomReflectable { @@ -4286,15 +3810,6 @@ public struct MissingExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpected]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingExprSyntax: CustomReflectable { @@ -4417,23 +3932,6 @@ public struct MoveExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension MoveExprSyntax: CustomReflectable { @@ -4523,19 +4021,6 @@ public struct NilLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeNilKeyword, \Self.nilKeyword, \Self.unexpectedAfterNilKeyword]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension NilLiteralExprSyntax: CustomReflectable { @@ -4660,23 +4145,6 @@ public struct OptionalChainingExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterQuestionMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension OptionalChainingExprSyntax: CustomReflectable { @@ -4804,23 +4272,6 @@ public struct PackElementExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPackRefExpr ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PackElementExprSyntax: CustomReflectable { @@ -4948,23 +4399,6 @@ public struct PackExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPatternExpr ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PackExpansionExprSyntax: CustomReflectable { @@ -5123,23 +4557,6 @@ public struct PostfixIfConfigExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterConfig ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PostfixIfConfigExprSyntax: CustomReflectable { @@ -5267,23 +4684,6 @@ public struct PostfixUnaryExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterOperatorToken ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PostfixUnaryExprSyntax: CustomReflectable { @@ -5411,23 +4811,6 @@ public struct PrefixOperatorExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPostfixExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PrefixOperatorExprSyntax: CustomReflectable { @@ -5633,35 +5016,6 @@ public struct RegexLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterClosingPounds ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension RegexLiteralExprSyntax: CustomReflectable { @@ -5776,19 +5130,6 @@ public struct SequenceExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeElements, \Self.elements, \Self.unexpectedAfterElements]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension SequenceExprSyntax: CustomReflectable { @@ -5913,23 +5254,6 @@ public struct SpecializeExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericArgumentClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension SpecializeExprSyntax: CustomReflectable { @@ -6154,35 +5478,6 @@ public struct StringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterCloseDelimiter ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension StringLiteralExprSyntax: CustomReflectable { @@ -6458,39 +5753,6 @@ public struct SubscriptExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAdditionalTrailingClosures ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "called expression" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "arguments" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "trailing closure" - case 10: - return nil - case 11: - return "trailing closures" - case 12: - return nil - default: - fatalError("Invalid index") - } - } } extension SubscriptExprSyntax: CustomReflectable { @@ -6588,19 +5850,6 @@ public struct SuperRefExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeSuperKeyword, \Self.superKeyword, \Self.unexpectedAfterSuperKeyword]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension SuperRefExprSyntax: CustomReflectable { @@ -6822,35 +6071,6 @@ public struct SwitchExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension SwitchExprSyntax: CustomReflectable { @@ -7062,35 +6282,6 @@ public struct TernaryExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterSecondChoice ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "condition" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "first choice" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "second choice" - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension TernaryExprSyntax: CustomReflectable { @@ -7250,27 +6441,6 @@ public struct TryExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension TryExprSyntax: CustomReflectable { @@ -7445,27 +6615,6 @@ public struct TupleExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension TupleExprSyntax: CustomReflectable { @@ -7557,19 +6706,6 @@ public struct TypeExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeType, \Self.type, \Self.unexpectedAfterType]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension TypeExprSyntax: CustomReflectable { @@ -7694,23 +6830,6 @@ public struct UnresolvedAsExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterQuestionOrExclamationMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension UnresolvedAsExprSyntax: CustomReflectable { @@ -7800,19 +6919,6 @@ public struct UnresolvedIsExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeIsTok, \Self.isTok, \Self.unexpectedAfterIsTok]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension UnresolvedIsExprSyntax: CustomReflectable { @@ -7899,19 +7005,6 @@ public struct UnresolvedPatternExprSyntax: ExprSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforePattern, \Self.pattern, \Self.unexpectedAfterPattern]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension UnresolvedPatternExprSyntax: CustomReflectable { @@ -8062,27 +7155,6 @@ public struct UnresolvedTernaryExprSyntax: ExprSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterColonMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension UnresolvedTernaryExprSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift index 47cd997fa13..5a31a4404ad 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodes.swift @@ -125,23 +125,6 @@ public struct AccessPathComponentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingDot ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension AccessPathComponentSyntax: CustomReflectable { @@ -314,27 +297,6 @@ public struct AccessorBlockSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension AccessorBlockSyntax: CustomReflectable { @@ -490,27 +452,6 @@ public struct AccessorParameterSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "name" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension AccessorParameterSyntax: CustomReflectable { @@ -640,23 +581,6 @@ public struct ArrayElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "value" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ArrayElementSyntax: CustomReflectable { @@ -1128,35 +1052,6 @@ public struct AttributeSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "name" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension AttributeSyntax: CustomReflectable { @@ -1345,23 +1240,6 @@ public struct AvailabilityArgumentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityArgumentSyntax: CustomReflectable { @@ -1560,31 +1438,6 @@ public struct AvailabilityConditionSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityConditionSyntax: CustomReflectable { @@ -1789,31 +1642,6 @@ public struct AvailabilityEntrySyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterSemicolon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityEntrySyntax: CustomReflectable { @@ -2016,27 +1844,6 @@ public struct AvailabilityLabeledArgumentSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterValue ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "value" - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityLabeledArgumentSyntax: CustomReflectable { @@ -2167,23 +1974,6 @@ public struct AvailabilityVersionRestrictionListEntrySyntax: SyntaxProtocol, Syn \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityVersionRestrictionListEntrySyntax: CustomReflectable { @@ -2312,23 +2102,6 @@ public struct AvailabilityVersionRestrictionSyntax: SyntaxProtocol, SyntaxHashab \Self.unexpectedAfterVersion ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "platform" - case 2: - return nil - case 3: - return "version" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension AvailabilityVersionRestrictionSyntax: CustomReflectable { @@ -2504,27 +2277,6 @@ public struct BackDeployedAttributeSpecListSyntax: SyntaxProtocol, SyntaxHashabl \Self.unexpectedAfterVersionList ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension BackDeployedAttributeSpecListSyntax: CustomReflectable { @@ -2680,27 +2432,6 @@ public struct CaseItemSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension CaseItemSyntax: CustomReflectable { @@ -2875,27 +2606,6 @@ public struct CatchClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension CatchClauseSyntax: CustomReflectable { @@ -3086,27 +2796,6 @@ public struct CatchItemSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension CatchItemSyntax: CustomReflectable { @@ -3288,31 +2977,6 @@ public struct ClosureCaptureItemSpecifierSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureCaptureItemSpecifierSyntax: CustomReflectable { @@ -3522,35 +3186,6 @@ public struct ClosureCaptureItemSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureCaptureItemSyntax: CustomReflectable { @@ -3729,27 +3364,6 @@ public struct ClosureCaptureSignatureSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightSquare ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureCaptureSignatureSyntax: CustomReflectable { @@ -3879,23 +3493,6 @@ public struct ClosureParamSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureParamSyntax: CustomReflectable { @@ -4071,27 +3668,6 @@ public struct ClosureParameterClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "parameters" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureParameterClauseSyntax: CustomReflectable { @@ -4476,47 +4052,6 @@ public struct ClosureParameterSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return "type" - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureParameterSyntax: CustomReflectable { @@ -4821,39 +4356,6 @@ public struct ClosureSignatureSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterInTok ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - default: - fatalError("Invalid index") - } - } } extension ClosureSignatureSyntax: CustomReflectable { @@ -5044,23 +4546,6 @@ public struct CodeBlockItemSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterSemicolon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension CodeBlockItemSyntax: CustomReflectable { @@ -5233,27 +4718,6 @@ public struct CodeBlockSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "statements" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension CodeBlockSyntax: CustomReflectable { @@ -5383,23 +4847,6 @@ public struct CompositionTypeElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterAmpersand ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension CompositionTypeElementSyntax: CustomReflectable { @@ -5596,23 +5043,6 @@ public struct ConditionElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ConditionElementSyntax: CustomReflectable { @@ -5766,27 +5196,6 @@ public struct ConformanceRequirementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightTypeIdentifier ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ConformanceRequirementSyntax: CustomReflectable { @@ -5995,35 +5404,6 @@ public struct ConventionAttributeArgumentsSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterCTypeString ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension ConventionAttributeArgumentsSyntax: CustomReflectable { @@ -6183,27 +5563,6 @@ public struct ConventionWitnessMethodAttributeArgumentsSyntax: SyntaxProtocol, S \Self.unexpectedAfterProtocolName ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ConventionWitnessMethodAttributeArgumentsSyntax: CustomReflectable { @@ -6333,23 +5692,6 @@ public struct DeclEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterThrowsSpecifier ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclEffectSpecifiersSyntax: CustomReflectable { @@ -6503,27 +5845,6 @@ public struct DeclModifierDetailSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclModifierDetailSyntax: CustomReflectable { @@ -6653,23 +5974,6 @@ public struct DeclModifierSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterDetail ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclModifierSyntax: CustomReflectable { @@ -6797,23 +6101,6 @@ public struct DeclNameArgumentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterColon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclNameArgumentSyntax: CustomReflectable { @@ -6986,27 +6273,6 @@ public struct DeclNameArgumentsSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclNameArgumentsSyntax: CustomReflectable { @@ -7138,23 +6404,6 @@ public struct DeclNameSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterDeclNameArguments ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "base name" - case 2: - return nil - case 3: - return "arguments" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DeclNameSyntax: CustomReflectable { @@ -7417,43 +6666,6 @@ public struct DerivativeRegistrationAttributeArgumentsSyntax: SyntaxProtocol, Sy \Self.unexpectedAfterDiffParams ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension DerivativeRegistrationAttributeArgumentsSyntax: CustomReflectable { @@ -7591,23 +6803,6 @@ public struct DesignatedTypeElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterName ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DesignatedTypeElementSyntax: CustomReflectable { @@ -7787,31 +6982,6 @@ public struct DictionaryElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "key" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "value" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension DictionaryElementSyntax: CustomReflectable { @@ -7943,23 +7113,6 @@ public struct DifferentiabilityParamSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DifferentiabilityParamSyntax: CustomReflectable { @@ -8157,27 +7310,6 @@ public struct DifferentiabilityParamsClauseSyntax: SyntaxProtocol, SyntaxHashabl \Self.unexpectedAfterParameters ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "parameters" - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DifferentiabilityParamsClauseSyntax: CustomReflectable { @@ -8353,27 +7485,6 @@ public struct DifferentiabilityParamsSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DifferentiabilityParamsSyntax: CustomReflectable { @@ -8583,35 +7694,6 @@ public struct DifferentiableAttributeArgumentsSyntax: SyntaxProtocol, SyntaxHash \Self.unexpectedAfterWhereClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension DifferentiableAttributeArgumentsSyntax: CustomReflectable { @@ -8840,31 +7922,6 @@ public struct DocumentationAttributeArgumentSyntax: SyntaxProtocol, SyntaxHashab \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension DocumentationAttributeArgumentSyntax: CustomReflectable { @@ -9022,27 +8079,6 @@ public struct DynamicReplacementArgumentsSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterDeclname ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DynamicReplacementArgumentsSyntax: CustomReflectable { @@ -9228,31 +8264,6 @@ public struct EnumCaseElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "associated values" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension EnumCaseElementSyntax: CustomReflectable { @@ -9432,27 +8443,6 @@ public struct EnumCaseParameterClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "parameters" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension EnumCaseParameterClauseSyntax: CustomReflectable { @@ -9735,43 +8725,6 @@ public struct EnumCaseParameterSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "modifiers" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "type" - case 10: - return nil - case 11: - return "default argument" - case 12: - return nil - case 13: - return nil - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension EnumCaseParameterSyntax: CustomReflectable { @@ -9935,27 +8888,6 @@ public struct ExposeAttributeArgumentsSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterCxxName ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ExposeAttributeArgumentsSyntax: CustomReflectable { @@ -10182,35 +9114,6 @@ public struct ExpressionSegmentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension ExpressionSegmentSyntax: CustomReflectable { @@ -10564,51 +9467,6 @@ public struct FunctionParameterSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "attributes" - case 2: - return nil - case 3: - return "modifiers" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "internal name" - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return "type" - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return "default argument" - case 16: - return nil - case 17: - return nil - case 18: - return nil - default: - fatalError("Invalid index") - } - } } extension FunctionParameterSyntax: CustomReflectable { @@ -10776,27 +9634,6 @@ public struct FunctionSignatureSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterOutput ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension FunctionSignatureSyntax: CustomReflectable { @@ -10971,27 +9808,6 @@ public struct GenericArgumentClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightAngleBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension GenericArgumentClauseSyntax: CustomReflectable { @@ -11121,23 +9937,6 @@ public struct GenericArgumentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension GenericArgumentSyntax: CustomReflectable { @@ -11336,31 +10135,6 @@ public struct GenericParameterClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightAngleBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension GenericParameterClauseSyntax: CustomReflectable { @@ -11662,39 +10436,6 @@ public struct GenericParameterSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "parameter pack specifier" - case 4: - return nil - case 5: - return "name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "inherited type" - case 10: - return nil - case 11: - return nil - case 12: - return nil - default: - fatalError("Invalid index") - } - } } extension GenericParameterSyntax: CustomReflectable { @@ -11880,25 +10621,8 @@ public struct GenericRequirementSyntax: SyntaxProtocol, SyntaxHashable { \Self.body, \Self.unexpectedBetweenBodyAndTrailingComma, \Self.trailingComma, - \Self.unexpectedAfterTrailingComma - ]) - } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } + \Self.unexpectedAfterTrailingComma + ]) } } @@ -12046,23 +10770,6 @@ public struct GenericWhereClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRequirementList ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension GenericWhereClauseSyntax: CustomReflectable { @@ -12332,27 +11039,6 @@ public struct IfConfigClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterElements ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "condition" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension IfConfigClauseSyntax: CustomReflectable { @@ -12538,31 +11224,6 @@ public struct ImplementsAttributeArgumentsSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterDeclNameArguments ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "declaration base name" - case 6: - return nil - case 7: - return "declaration name arguments" - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension ImplementsAttributeArgumentsSyntax: CustomReflectable { @@ -12720,27 +11381,6 @@ public struct InheritedTypeSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension InheritedTypeSyntax: CustomReflectable { @@ -12870,23 +11510,6 @@ public struct InitializerClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterValue ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension InitializerClauseSyntax: CustomReflectable { @@ -13067,23 +11690,6 @@ public struct KeyPathComponentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterComponent ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension KeyPathComponentSyntax: CustomReflectable { @@ -13173,19 +11779,6 @@ public struct KeyPathOptionalComponentSyntax: SyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeQuestionOrExclamationMark, \Self.questionOrExclamationMark, \Self.unexpectedAfterQuestionOrExclamationMark]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension KeyPathOptionalComponentSyntax: CustomReflectable { @@ -13336,27 +11929,6 @@ public struct KeyPathPropertyComponentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericArgumentClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension KeyPathPropertyComponentSyntax: CustomReflectable { @@ -13531,27 +12103,6 @@ public struct KeyPathSubscriptComponentSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "arguments" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension KeyPathSubscriptComponentSyntax: CustomReflectable { @@ -13737,31 +12288,6 @@ public struct LabeledSpecializeEntrySyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "value" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension LabeledSpecializeEntrySyntax: CustomReflectable { @@ -14049,47 +12575,6 @@ public struct LayoutRequirementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "constrained type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return "size" - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return "alignment" - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension LayoutRequirementSyntax: CustomReflectable { @@ -14281,31 +12766,6 @@ public struct MatchingPatternConditionSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterInitializer ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension MatchingPatternConditionSyntax: CustomReflectable { @@ -14482,27 +12942,6 @@ public struct MemberDeclBlockSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightBrace ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension MemberDeclBlockSyntax: CustomReflectable { @@ -14634,23 +13073,6 @@ public struct MemberDeclListItemSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterSemicolon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension MemberDeclListItemSyntax: CustomReflectable { @@ -14719,15 +13141,6 @@ public struct MissingSyntax: SyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpected]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingSyntax: CustomReflectable { @@ -14876,27 +13289,6 @@ public struct MultipleTrailingClosureElementSyntax: SyntaxProtocol, SyntaxHashab \Self.unexpectedAfterClosure ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension MultipleTrailingClosureElementSyntax: CustomReflectable { @@ -15026,23 +13418,6 @@ public struct ObjCSelectorPieceSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterColon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ObjCSelectorPieceSyntax: CustomReflectable { @@ -15198,27 +13573,6 @@ public struct OpaqueReturnTypeOfAttributeArgumentsSyntax: SyntaxProtocol, Syntax \Self.unexpectedAfterOrdinal ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension OpaqueReturnTypeOfAttributeArgumentsSyntax: CustomReflectable { @@ -15395,27 +13749,6 @@ public struct OperatorPrecedenceAndTypesSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterDesignatedTypes ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "precedence group" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension OperatorPrecedenceAndTypesSyntax: CustomReflectable { @@ -15597,31 +13930,6 @@ public struct OptionalBindingConditionSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterInitializer ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension OptionalBindingConditionSyntax: CustomReflectable { @@ -15850,35 +14158,6 @@ public struct OriginallyDefinedInArgumentsSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterPlatforms ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension OriginallyDefinedInArgumentsSyntax: CustomReflectable { @@ -16057,27 +14336,6 @@ public struct ParameterClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "parameters" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ParameterClauseSyntax: CustomReflectable { @@ -16327,35 +14585,6 @@ public struct PatternBindingSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "type annotation" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension PatternBindingSyntax: CustomReflectable { @@ -16619,43 +14848,6 @@ public struct PoundSourceLocationArgsSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterLineNumber ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "file name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return "line number" - case 14: - return nil - default: - fatalError("Invalid index") - } - } } extension PoundSourceLocationArgsSyntax: CustomReflectable { @@ -16812,34 +15004,13 @@ public struct PrecedenceGroupAssignmentSyntax: SyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([ \Self.unexpectedBeforeAssignmentKeyword, - \Self.assignmentKeyword, - \Self.unexpectedBetweenAssignmentKeywordAndColon, - \Self.colon, - \Self.unexpectedBetweenColonAndFlag, - \Self.flag, - \Self.unexpectedAfterFlag - ]) - } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } + \Self.assignmentKeyword, + \Self.unexpectedBetweenAssignmentKeywordAndColon, + \Self.colon, + \Self.unexpectedBetweenColonAndFlag, + \Self.flag, + \Self.unexpectedAfterFlag + ]) } } @@ -16997,27 +15168,6 @@ public struct PrecedenceGroupAssociativitySyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterValue ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension PrecedenceGroupAssociativitySyntax: CustomReflectable { @@ -17147,23 +15297,6 @@ public struct PrecedenceGroupNameElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PrecedenceGroupNameElementSyntax: CustomReflectable { @@ -17338,27 +15471,6 @@ public struct PrecedenceGroupRelationSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterOtherNames ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension PrecedenceGroupRelationSyntax: CustomReflectable { @@ -17533,27 +15645,6 @@ public struct PrimaryAssociatedTypeClauseSyntax: SyntaxProtocol, SyntaxHashable \Self.unexpectedAfterRightAngleBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension PrimaryAssociatedTypeClauseSyntax: CustomReflectable { @@ -17683,23 +15774,6 @@ public struct PrimaryAssociatedTypeSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PrimaryAssociatedTypeSyntax: CustomReflectable { @@ -17921,31 +15995,6 @@ public struct QualifiedDeclNameSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterArguments ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "base type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "base name" - case 6: - return nil - case 7: - return "arguments" - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension QualifiedDeclNameSyntax: CustomReflectable { @@ -18077,23 +16126,6 @@ public struct ReturnClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterReturnType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "return type" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ReturnClauseSyntax: CustomReflectable { @@ -18247,27 +16279,6 @@ public struct SameTypeRequirementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightTypeIdentifier ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "left-hand type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "right-hand type" - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension SameTypeRequirementSyntax: CustomReflectable { @@ -18416,23 +16427,6 @@ public struct SourceFileSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterEOFToken ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension SourceFileSyntax: CustomReflectable { @@ -18522,19 +16516,6 @@ public struct StringSegmentSyntax: SyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeContent, \Self.content, \Self.unexpectedAfterContent]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension StringSegmentSyntax: CustomReflectable { @@ -18704,27 +16685,6 @@ public struct SwitchCaseLabelSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterColon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension SwitchCaseLabelSyntax: CustomReflectable { @@ -18941,27 +16901,6 @@ public struct SwitchCaseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterStatements ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "label" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension SwitchCaseSyntax: CustomReflectable { @@ -19091,23 +17030,6 @@ public struct SwitchDefaultLabelSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterColon ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension SwitchDefaultLabelSyntax: CustomReflectable { @@ -19291,31 +17213,6 @@ public struct TargetFunctionEntrySyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "declaration name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension TargetFunctionEntrySyntax: CustomReflectable { @@ -19499,31 +17396,6 @@ public struct TupleExprElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "value" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension TupleExprElementSyntax: CustomReflectable { @@ -19707,31 +17579,6 @@ public struct TuplePatternElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension TuplePatternElementSyntax: CustomReflectable { @@ -20019,47 +17866,6 @@ public struct TupleTypeElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTrailingComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "name" - case 4: - return nil - case 5: - return "internal name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return nil - case 16: - return nil - default: - fatalError("Invalid index") - } - } } extension TupleTypeElementSyntax: CustomReflectable { @@ -20199,23 +18005,6 @@ public struct TypeAnnotationSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension TypeAnnotationSyntax: CustomReflectable { @@ -20343,23 +18132,6 @@ public struct TypeEffectSpecifiersSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterThrowsSpecifier ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension TypeEffectSpecifiersSyntax: CustomReflectable { @@ -20506,23 +18278,6 @@ public struct TypeInheritanceClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterInheritedTypeCollection ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension TypeInheritanceClauseSyntax: CustomReflectable { @@ -20650,23 +18405,6 @@ public struct TypeInitializerClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterValue ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "type" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension TypeInitializerClauseSyntax: CustomReflectable { @@ -20820,27 +18558,6 @@ public struct UnavailableFromAsyncArgumentsSyntax: SyntaxProtocol, SyntaxHashabl \Self.unexpectedAfterMessage ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension UnavailableFromAsyncArgumentsSyntax: CustomReflectable { @@ -20996,27 +18713,6 @@ public struct UnderscorePrivateAttributeArgumentsSyntax: SyntaxProtocol, SyntaxH \Self.unexpectedAfterFilename ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension UnderscorePrivateAttributeArgumentsSyntax: CustomReflectable { @@ -21229,35 +18925,6 @@ public struct VersionTupleSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPatch ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension VersionTupleSyntax: CustomReflectable { @@ -21391,23 +19058,6 @@ public struct WhereClauseSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGuardResult ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension WhereClauseSyntax: CustomReflectable { @@ -21535,23 +19185,6 @@ public struct YieldExprListElementSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterComma ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension YieldExprListElementSyntax: CustomReflectable { @@ -21724,27 +19357,6 @@ public struct YieldListSyntax: SyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension YieldListSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift index b8d981a60d4..78bdcd1475c 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxPatternNodes.swift @@ -87,19 +87,6 @@ public struct ExpressionPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeExpression, \Self.expression, \Self.unexpectedAfterExpression]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension ExpressionPatternSyntax: CustomReflectable { @@ -186,19 +173,6 @@ public struct IdentifierPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeIdentifier, \Self.identifier, \Self.unexpectedAfterIdentifier]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension IdentifierPatternSyntax: CustomReflectable { @@ -323,23 +297,6 @@ public struct IsTypePatternSyntax: PatternSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension IsTypePatternSyntax: CustomReflectable { @@ -408,15 +365,6 @@ public struct MissingPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpected]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingPatternSyntax: CustomReflectable { @@ -584,27 +532,6 @@ public struct TuplePatternSyntax: PatternSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension TuplePatternSyntax: CustomReflectable { @@ -734,23 +661,6 @@ public struct ValueBindingPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterValuePattern ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ValueBindingPatternSyntax: CustomReflectable { @@ -878,23 +788,6 @@ public struct WildcardPatternSyntax: PatternSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTypeAnnotation ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension WildcardPatternSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift index be6a678e6bd..ab7ca1abcaf 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxStmtNodes.swift @@ -125,23 +125,6 @@ public struct BreakStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterLabel ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "label" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension BreakStmtSyntax: CustomReflectable { @@ -269,23 +252,6 @@ public struct ContinueStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterLabel ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "label" - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ContinueStmtSyntax: CustomReflectable { @@ -413,23 +379,6 @@ public struct DeferStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension DeferStmtSyntax: CustomReflectable { @@ -602,27 +551,6 @@ public struct DoStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterCatchClauses ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "body" - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension DoStmtSyntax: CustomReflectable { @@ -714,19 +642,6 @@ public struct ExpressionStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeExpression, \Self.expression, \Self.unexpectedAfterExpression]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension ExpressionStmtSyntax: CustomReflectable { @@ -813,19 +728,6 @@ public struct FallthroughStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeFallthroughKeyword, \Self.fallthroughKeyword, \Self.unexpectedAfterFallthroughKeyword]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension FallthroughStmtSyntax: CustomReflectable { @@ -1158,55 +1060,6 @@ public struct ForInStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - case 11: - return nil - case 12: - return nil - case 13: - return nil - case 14: - return nil - case 15: - return nil - case 16: - return nil - case 17: - return nil - case 18: - return nil - case 19: - return "body" - case 20: - return nil - default: - fatalError("Invalid index") - } - } } extension ForInStmtSyntax: CustomReflectable { @@ -1350,23 +1203,6 @@ public struct ForgetStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ForgetStmtSyntax: CustomReflectable { @@ -1565,31 +1401,6 @@ public struct GuardStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "condition" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "body" - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension GuardStmtSyntax: CustomReflectable { @@ -1747,27 +1558,6 @@ public struct LabeledStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterStatement ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "label name" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension LabeledStmtSyntax: CustomReflectable { @@ -1838,15 +1628,6 @@ public struct MissingStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpected]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingStmtSyntax: CustomReflectable { @@ -2021,31 +1802,6 @@ public struct RepeatWhileStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterCondition ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "body" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "condition" - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension RepeatWhileStmtSyntax: CustomReflectable { @@ -2208,23 +1964,6 @@ public struct ReturnStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ReturnStmtSyntax: CustomReflectable { @@ -2352,23 +2091,6 @@ public struct ThrowStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterExpression ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ThrowStmtSyntax: CustomReflectable { @@ -2541,27 +2263,6 @@ public struct WhileStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBody ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension WhileStmtSyntax: CustomReflectable { @@ -2733,23 +2434,6 @@ public struct YieldStmtSyntax: StmtSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterYields ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension YieldStmtSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift index 9d7bdc5b953..49860809262 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxTypeNodes.swift @@ -151,27 +151,6 @@ public struct ArrayTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightSquareBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension ArrayTypeSyntax: CustomReflectable { @@ -346,27 +325,6 @@ public struct AttributedTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBaseType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension AttributedTypeSyntax: CustomReflectable { @@ -458,19 +416,6 @@ public struct ClassRestrictionTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeClassKeyword, \Self.classKeyword, \Self.unexpectedAfterClassKeyword]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension ClassRestrictionTypeSyntax: CustomReflectable { @@ -576,19 +521,6 @@ public struct CompositionTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpectedBeforeElements, \Self.elements, \Self.unexpectedAfterElements]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - default: - fatalError("Invalid index") - } - } } extension CompositionTypeSyntax: CustomReflectable { @@ -713,23 +645,6 @@ public struct ConstrainedSugarTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBaseType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ConstrainedSugarTypeSyntax: CustomReflectable { @@ -935,35 +850,6 @@ public struct DictionaryTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightSquareBracket ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return "key type" - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return "value type" - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension DictionaryTypeSyntax: CustomReflectable { @@ -1194,35 +1080,6 @@ public struct FunctionTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterOutput ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - case 7: - return nil - case 8: - return nil - case 9: - return nil - case 10: - return nil - default: - fatalError("Invalid index") - } - } } extension FunctionTypeSyntax: CustomReflectable { @@ -1356,23 +1213,6 @@ public struct ImplicitlyUnwrappedOptionalTypeSyntax: TypeSyntaxProtocol, SyntaxH \Self.unexpectedAfterExclamationMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension ImplicitlyUnwrappedOptionalTypeSyntax: CustomReflectable { @@ -1552,31 +1392,6 @@ public struct MemberTypeIdentifierSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericArgumentClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "base type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return "name" - case 6: - return nil - case 7: - return nil - case 8: - return nil - default: - fatalError("Invalid index") - } - } } extension MemberTypeIdentifierSyntax: CustomReflectable { @@ -1734,27 +1549,6 @@ public struct MetatypeTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterTypeOrProtocol ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return "base type" - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension MetatypeTypeSyntax: CustomReflectable { @@ -1825,15 +1619,6 @@ public struct MissingTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { public static var structure: SyntaxNodeStructure { return .layout([\Self.unexpected]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - default: - fatalError("Invalid index") - } - } } extension MissingTypeSyntax: CustomReflectable { @@ -1956,23 +1741,6 @@ public struct NamedOpaqueReturnTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterBaseType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension NamedOpaqueReturnTypeSyntax: CustomReflectable { @@ -2100,23 +1868,6 @@ public struct OptionalTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterQuestionMark ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension OptionalTypeSyntax: CustomReflectable { @@ -2244,23 +1995,6 @@ public struct PackExpansionTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPatternType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PackExpansionTypeSyntax: CustomReflectable { @@ -2388,23 +2122,6 @@ public struct PackReferenceTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterPackType ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension PackReferenceTypeSyntax: CustomReflectable { @@ -2532,23 +2249,6 @@ public struct SimpleTypeIdentifierSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterGenericArgumentClause ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - default: - fatalError("Invalid index") - } - } } extension SimpleTypeIdentifierSyntax: CustomReflectable { @@ -2721,27 +2421,6 @@ public struct TupleTypeSyntax: TypeSyntaxProtocol, SyntaxHashable { \Self.unexpectedAfterRightParen ]) } - - public func childNameForDiagnostics(_ index: SyntaxChildrenIndex) -> String? { - switch index.data?.indexInParent { - case 0: - return nil - case 1: - return nil - case 2: - return nil - case 3: - return nil - case 4: - return nil - case 5: - return nil - case 6: - return nil - default: - fatalError("Invalid index") - } - } } extension TupleTypeSyntax: CustomReflectable { diff --git a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift index 68c69ddd816..745f9e8a545 100644 --- a/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift +++ b/Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift @@ -283,7 +283,7 @@ extension StringLiteralExprSyntax { } } - let escapedContent = content.escapingForStringLiteral(usingDelimiter: closeDelimiter?.text ?? "", isMultiline: openQuote.rawTokenKind == .multilineStringQuote) + let escapedContent = content.escapingForStringLiteral(usingDelimiter: closeDelimiter?.text ?? "", isMultiline: openQuote.tokenView.rawKind == .multilineStringQuote) let contentToken = TokenSyntax.stringSegment(escapedContent) let segment = StringSegmentSyntax(content: contentToken) let segments = StringLiteralSegmentsSyntax([.stringSegment(segment)]) diff --git a/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift b/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift index fa92f2bc1c3..33b21f06860 100644 --- a/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift +++ b/Sources/_SwiftSyntaxTestSupport/SyntaxComparison.swift @@ -118,7 +118,7 @@ public extension SyntaxProtocol { return .nodeType } - if isToken { + if self.is(TokenSyntax.self) { if let token = Syntax(self).as(TokenSyntax.self), let baselineToken = Syntax(baseline).as(TokenSyntax.self) { if token.presence != baselineToken.presence { return .presence diff --git a/Sources/_SwiftSyntaxTestSupport/SyntaxProtocol+Initializer.swift b/Sources/_SwiftSyntaxTestSupport/SyntaxProtocol+Initializer.swift index a0b88d8d0ae..21ac942154f 100644 --- a/Sources/_SwiftSyntaxTestSupport/SyntaxProtocol+Initializer.swift +++ b/Sources/_SwiftSyntaxTestSupport/SyntaxProtocol+Initializer.swift @@ -114,7 +114,7 @@ extension SyntaxProtocol { private func debugInitCallExpr(includeTrivia: Bool) -> ExprSyntax { let mirror = Mirror(reflecting: self) - if self.isCollection { + if self.kind.isSyntaxCollection { let typeName = String(describing: type(of: self)) return ExprSyntax( FunctionCallExprSyntax(callee: IdentifierExprSyntax(identifier: .identifier(typeName))) { diff --git a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift index c6f1cf49b4b..cc50c50019f 100644 --- a/Tests/SwiftSyntaxTest/RawSyntaxTests.swift +++ b/Tests/SwiftSyntaxTest/RawSyntaxTests.swift @@ -142,7 +142,7 @@ final class RawSyntaxTests: XCTestCase { XCTAssertEqual(ident.description, "\nfoo ") let identSyntax = Syntax(raw: ident.raw).as(TokenSyntax.self)! - let barIdentSyntax = identSyntax.withKind(.keyword(.open)) + let barIdentSyntax = identSyntax.with(\.tokenKind, .keyword(.open)) let barIdent = barIdentSyntax.raw.as(RawTokenSyntax.self)! XCTAssertEqual(barIdent.tokenKind, .keyword) diff --git a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift index 7646f9bcd19..a9dd335a03e 100644 --- a/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift +++ b/Tests/SwiftSyntaxTest/SyntaxCollectionsTests.swift @@ -29,10 +29,10 @@ public class SyntaxCollectionsTests: XCTestCase { ]) let newArrayElementList = arrayElementList.appending(integerLiteralElement(1)) - XCTAssert(newArrayElementList.isCollection) + XCTAssert(newArrayElementList.kind.isSyntaxCollection) XCTAssertEqual(newArrayElementList.count, 2) XCTAssertNotNil(newArrayElementList.child(at: 1)) - XCTAssert(!newArrayElementList.child(at: 1)!.isCollection) + XCTAssert(!newArrayElementList.child(at: 1)!.kind.isSyntaxCollection) XCTAssertEqual("\(newArrayElementList.child(at: 1)!)", "1") } diff --git a/utils/group.json b/utils/group.json index 79ea737900a..7a989792a9b 100644 --- a/utils/group.json +++ b/utils/group.json @@ -43,7 +43,6 @@ "SyntaxTransform.swift", "SyntaxText.swift", "SyntaxVisitor.swift", - "Misc.swift", ], "Position": [ "AbsolutePosition.swift",