From 72e524c5aa36c91c9cfb59b1d773143620ebd179 Mon Sep 17 00:00:00 2001 From: leogdion Date: Tue, 16 Sep 2025 12:46:47 -0400 Subject: [PATCH 01/10] Cleaning up Parser Code (#103) --- .periphery.yml | 1 + Package.swift | 51 ++-- Sources/SyntaxKit/Parser/String.swift | 70 ------ .../SyntaxKit/Parser/StructureProperty.swift | 54 ----- Sources/SyntaxKit/Parser/Token.swift | 54 ----- .../Parser/TokenVisitor+Helpers.swift | 84 ------- Sources/SyntaxKit/Parser/TokenVisitor.swift | 223 ------------------ Sources/SyntaxKit/Parser/TreeNode.swift | 76 ------ Sources/SyntaxParser/README.md | 86 +++++++ Sources/SyntaxParser/SourceRange.swift | 68 ++++++ Sources/SyntaxParser/SyntaxParser.swift | 116 +++++++++ Sources/SyntaxParser/SyntaxResponse.swift | 63 +++++ Sources/SyntaxParser/TreeNode.swift | 146 ++++++++++++ .../String.swift} | 8 +- Sources/TokenVisitor/StructureProperty.swift | 137 +++++++++++ Sources/TokenVisitor/StructureValue.swift | 71 ++++++ .../Syntax.swift} | 50 ++-- Sources/TokenVisitor/SyntaxClassifiable.swift | 40 ++++ .../AttributeListSyntax.swift} | 25 +- .../CatchClauseListSyntax.swift | 39 +++ .../CodeBlockItemListSyntax.swift | 39 +++ .../ConditionElementListSyntax.swift | 39 +++ .../DeclModifierListSyntax.swift | 39 +++ .../SyntaxClassifiable/DeclSyntax.swift} | 12 +- .../SyntaxClassifiable/ExprSyntax.swift | 38 +++ .../FunctionParameterListSyntax.swift | 39 +++ .../IdentifierPatternSyntax.swift} | 15 +- .../IdentifierTypeSyntax.swift | 36 +++ .../LabeledExprListSyntax.swift | 39 +++ .../PatternBindingListSyntax.swift | 39 +++ .../SyntaxClassifiable/PatternSyntax.swift | 38 +++ .../SwitchCaseItemListSyntax.swift | 39 +++ .../SwitchCaseListSyntax.swift | 39 +++ .../SyntaxClassifiable/TypeSyntax.swift | 38 +++ .../VariableDeclSyntax.swift | 36 +++ Sources/TokenVisitor/SyntaxType.swift | 69 ++++++ Sources/TokenVisitor/Token.swift | 67 ++++++ Sources/TokenVisitor/TokenVisitor.swift | 178 ++++++++++++++ .../TreeNodeProtocol+Extensions.swift | 199 ++++++++++++++++ Sources/TokenVisitor/TreeNodeProtocol.swift | 48 ++++ Sources/TokenVisitor/TriviaPiece.swift | 92 ++++++++ .../StructureValue.swift => skit/Skit.swift} | 33 ++- Sources/skit/main.swift | 52 ---- TreeNodeProtocol+Extensions.swift | 219 +++++++++++++++++ 44 files changed, 2236 insertions(+), 708 deletions(-) delete mode 100644 Sources/SyntaxKit/Parser/String.swift delete mode 100644 Sources/SyntaxKit/Parser/StructureProperty.swift delete mode 100644 Sources/SyntaxKit/Parser/Token.swift delete mode 100644 Sources/SyntaxKit/Parser/TokenVisitor+Helpers.swift delete mode 100644 Sources/SyntaxKit/Parser/TokenVisitor.swift delete mode 100644 Sources/SyntaxKit/Parser/TreeNode.swift create mode 100644 Sources/SyntaxParser/README.md create mode 100644 Sources/SyntaxParser/SourceRange.swift create mode 100644 Sources/SyntaxParser/SyntaxParser.swift create mode 100644 Sources/SyntaxParser/SyntaxResponse.swift create mode 100644 Sources/SyntaxParser/TreeNode.swift rename Sources/{SyntaxKit/Parser/SyntaxResponse.swift => TokenVisitor/String.swift} (91%) create mode 100644 Sources/TokenVisitor/StructureProperty.swift create mode 100644 Sources/TokenVisitor/StructureValue.swift rename Sources/{SyntaxKit/Parser/SyntaxParser.swift => TokenVisitor/Syntax.swift} (52%) create mode 100644 Sources/TokenVisitor/SyntaxClassifiable.swift rename Sources/{SyntaxKit/Parser/SourceRange.swift => TokenVisitor/SyntaxClassifiable/AttributeListSyntax.swift} (74%) create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/CatchClauseListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/CodeBlockItemListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/ConditionElementListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/DeclModifierListSyntax.swift rename Sources/{SyntaxKit/Parser/String+Extensions.swift => TokenVisitor/SyntaxClassifiable/DeclSyntax.swift} (80%) create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/ExprSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/FunctionParameterListSyntax.swift rename Sources/{SyntaxKit/Parser/SyntaxType.swift => TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift} (87%) create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/LabeledExprListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/PatternBindingListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/PatternSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseItemListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseListSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/TypeSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift create mode 100644 Sources/TokenVisitor/SyntaxType.swift create mode 100644 Sources/TokenVisitor/Token.swift create mode 100644 Sources/TokenVisitor/TokenVisitor.swift create mode 100644 Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift create mode 100644 Sources/TokenVisitor/TreeNodeProtocol.swift create mode 100644 Sources/TokenVisitor/TriviaPiece.swift rename Sources/{SyntaxKit/Parser/StructureValue.swift => skit/Skit.swift} (69%) delete mode 100644 Sources/skit/main.swift create mode 100644 TreeNodeProtocol+Extensions.swift diff --git a/.periphery.yml b/.periphery.yml index 85b884a..18092e6 100644 --- a/.periphery.yml +++ b/.periphery.yml @@ -1 +1,2 @@ retain_public: true +retain_codable_properties: true \ No newline at end of file diff --git a/Package.swift b/Package.swift index d480205..f8f6c12 100644 --- a/Package.swift +++ b/Package.swift @@ -59,21 +59,21 @@ let swiftSettings: [SwiftSetting] = [ // Warn unsafe reflection .enableExperimentalFeature("WarnUnsafeReflection"), - // // Enhanced compiler checking - // .unsafeFlags([ - // // Enable concurrency warnings - // "-warn-concurrency", - // // Enable actor data race checks - // "-enable-actor-data-race-checks", - // // Complete strict concurrency checking - // "-strict-concurrency=complete", - // // Enable testing support - // "-enable-testing", - // // Warn about functions with >100 lines - // "-Xfrontend", "-warn-long-function-bodies=100", - // // Warn about slow type checking expressions - // "-Xfrontend", "-warn-long-expression-type-checking=100" - // ]) + // Enhanced compiler checking + .unsafeFlags([ + // Enable concurrency warnings + "-warn-concurrency", + // Enable actor data race checks + "-enable-actor-data-race-checks", + // Complete strict concurrency checking + "-strict-concurrency=complete", + // Enable testing support + "-enable-testing", + // Warn about functions with >100 lines + "-Xfrontend", "-warn-long-function-bodies=100", + // Warn about slow type checking expressions + "-Xfrontend", "-warn-long-expression-type-checking=100" + ]) ] // swiftlint:disable:next explicit_top_level_acl explicit_acl @@ -110,6 +110,25 @@ let package = Package( ], swiftSettings: swiftSettings ), + .target( + name: "TokenVisitor", + dependencies: [ + .product(name: "SwiftSyntax", package: "swift-syntax"), + .product(name: "SwiftOperators", package: "swift-syntax"), + .product(name: "SwiftParser", package: "swift-syntax") + ], + swiftSettings: swiftSettings + ), + .target( + name: "SyntaxParser", + dependencies: [ + "TokenVisitor", + .product(name: "SwiftSyntax", package: "swift-syntax"), + .product(name: "SwiftOperators", package: "swift-syntax"), + .product(name: "SwiftParser", package: "swift-syntax") + ], + swiftSettings: swiftSettings + ), .target( name: "DocumentationHarness", dependencies: [ @@ -121,7 +140,7 @@ let package = Package( ), .executableTarget( name: "skit", - dependencies: ["SyntaxKit"], + dependencies: ["SyntaxParser"], swiftSettings: swiftSettings ), .testTarget( diff --git a/Sources/SyntaxKit/Parser/String.swift b/Sources/SyntaxKit/Parser/String.swift deleted file mode 100644 index fe6214b..0000000 --- a/Sources/SyntaxKit/Parser/String.swift +++ /dev/null @@ -1,70 +0,0 @@ -// -// String.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation - -extension String { - internal func escapeHTML() -> String { - var string = self - let specialCharacters = [ - ("&", "&"), - ("<", "<"), - (">", ">"), - ("\"", """), - ("'", "'"), - ] - for (unescaped, escaped) in specialCharacters { - string = string.replacingOccurrences( - of: unescaped, - with: escaped, - options: .literal, - range: nil - ) - } - return string - } - - internal func replaceInvisiblesWithHTML() -> String { - self - .replacingOccurrences(of: " ", with: " ") - .replacingOccurrences(of: "\n", with: "
") - } - - internal func replaceInvisiblesWithSymbols() -> String { - self - .replacingOccurrences(of: " ", with: "␣") - .replacingOccurrences(of: "\n", with: "↲") - } - - internal func replaceHTMLWhitespacesWithSymbols() -> String { - self - .replacingOccurrences(of: " ", with: "") - .replacingOccurrences(of: "
", with: "
") - } -} diff --git a/Sources/SyntaxKit/Parser/StructureProperty.swift b/Sources/SyntaxKit/Parser/StructureProperty.swift deleted file mode 100644 index 59dfb23..0000000 --- a/Sources/SyntaxKit/Parser/StructureProperty.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// StructureProperty.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation - -internal struct StructureProperty: Codable, Equatable { - internal let name: String - internal let value: StructureValue? - internal let ref: String? - - internal init(name: String, value: StructureValue? = nil, ref: String? = nil) { - self.name = name.escapeHTML() - self.value = value - self.ref = ref?.escapeHTML() - } -} - -extension StructureProperty: CustomStringConvertible { - internal var description: String { - """ - { - name: \(name) - value: \(String(describing: value)) - ref: \(String(describing: ref)) - } - """ - } -} diff --git a/Sources/SyntaxKit/Parser/Token.swift b/Sources/SyntaxKit/Parser/Token.swift deleted file mode 100644 index d52a04c..0000000 --- a/Sources/SyntaxKit/Parser/Token.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// Token.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation - -internal struct Token: Codable, Equatable { - internal let kind: String - internal var leadingTrivia: String - internal var trailingTrivia: String - - internal init(kind: String, leadingTrivia: String, trailingTrivia: String) { - self.kind = kind.escapeHTML() - self.leadingTrivia = leadingTrivia - self.trailingTrivia = trailingTrivia - } -} - -extension Token: CustomStringConvertible { - internal var description: String { - """ - { - kind: \(kind) - leadingTrivia: \(leadingTrivia) - trailingTrivia: \(trailingTrivia) - } - """ - } -} diff --git a/Sources/SyntaxKit/Parser/TokenVisitor+Helpers.swift b/Sources/SyntaxKit/Parser/TokenVisitor+Helpers.swift deleted file mode 100644 index b95abb3..0000000 --- a/Sources/SyntaxKit/Parser/TokenVisitor+Helpers.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// TokenVisitor+Helpers.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation -import SwiftSyntax - -extension TokenVisitor { - internal func processToken(_ token: TokenSyntax) { - var kind = "\(token.tokenKind)" - if let index = kind.firstIndex(of: "(") { - kind = String(kind.prefix(upTo: index)) - } - if kind.hasSuffix("Keyword") { - kind = "keyword" - } - - let sourceRange = token.sourceRange(converter: locationConverter) - let start = sourceRange.start - let end = sourceRange.end - let text = token.presence == .present || showMissingTokens ? token.text : "" - } - - internal func processTriviaPiece(_ piece: TriviaPiece) -> String { - func wrapWithSpanTag(class className: String, text: String) -> String { - "\(text.escapeHTML().replaceInvisiblesWithHTML())" - } - - var trivia = "" - switch piece { - case .spaces(let count): - trivia += String(repeating: " ", count: count) - case .tabs(let count): - trivia += String(repeating: " ", count: count * 2) - case .verticalTabs, .formfeeds: - break - case .newlines(let count), .carriageReturns(let count), .carriageReturnLineFeeds(let count): - trivia += String(repeating: "
", count: count) - case .lineComment(let text): - trivia += wrapWithSpanTag(class: "lineComment", text: text) - case .blockComment(let text): - trivia += wrapWithSpanTag(class: "blockComment", text: text) - case .docLineComment(let text): - trivia += wrapWithSpanTag(class: "docLineComment", text: text) - case .docBlockComment(let text): - trivia += wrapWithSpanTag(class: "docBlockComment", text: text) - case .unexpectedText(let text): - trivia += wrapWithSpanTag(class: "unexpectedText", text: text) - case .backslashes(let count): - trivia += String(repeating: #"\"#, count: count) - case .pounds(let count): - trivia += String(repeating: "#", count: count) - } - return trivia - } -} diff --git a/Sources/SyntaxKit/Parser/TokenVisitor.swift b/Sources/SyntaxKit/Parser/TokenVisitor.swift deleted file mode 100644 index c031143..0000000 --- a/Sources/SyntaxKit/Parser/TokenVisitor.swift +++ /dev/null @@ -1,223 +0,0 @@ -// -// TokenVisitor.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation -@_spi(RawSyntax) import SwiftSyntax - -internal final class TokenVisitor: SyntaxRewriter { - // var list = [String]() - internal var tree = [TreeNode]() - - private var current: TreeNode! - private var index = 0 - - internal let locationConverter: SourceLocationConverter - internal let showMissingTokens: Bool - - internal init(locationConverter: SourceLocationConverter, showMissingTokens: Bool) { - self.locationConverter = locationConverter - self.showMissingTokens = showMissingTokens - super.init(viewMode: showMissingTokens ? .all : .sourceAccurate) - } - - // swiftlint:disable:next cyclomatic_complexity function_body_length - override internal func visitPre(_ node: Syntax) { - let syntaxNodeType = node.syntaxNodeType - - let className: String - if "\(syntaxNodeType)".hasSuffix("Syntax") { - className = String("\(syntaxNodeType)".dropLast(6)) - } else { - className = "\(syntaxNodeType)" - } - - let sourceRange = node.sourceRange(converter: locationConverter) - let start = sourceRange.start - let end = sourceRange.end - - let graphemeStartColumn: Int - if let prefix = String( - locationConverter.sourceLines[start.line - 1].utf8.prefix(start.column - 1) - ) { - graphemeStartColumn = prefix.utf16.count + 1 - } else { - graphemeStartColumn = start.column - } - let graphemeEndColumn: Int - if let prefix = String( - locationConverter.sourceLines[end.line - 1].utf8.prefix(end.column - 1) - ) { - graphemeEndColumn = prefix.utf16.count + 1 - } else { - graphemeEndColumn = end.column - } - - let syntaxType: SyntaxType - switch node { - case _ where node.is(DeclSyntax.self): - syntaxType = .decl - case _ where node.is(ExprSyntax.self): - syntaxType = .expr - case _ where node.is(PatternSyntax.self): - syntaxType = .pattern - case _ where node.is(TypeSyntax.self): - syntaxType = .type - default: - syntaxType = .other - } - - let treeNode = TreeNode( - id: index, - text: className, - range: SourceRange( - startRow: start.line, - startColumn: start.column, - endRow: end.line, - endColumn: end.column - ), - type: syntaxType - ) - - tree.append(treeNode) - index += 1 - - let allChildren = node.children(viewMode: .all) - - switch node.syntaxNodeType.structure { - case .layout(let keyPaths): - if let syntaxNode = node.as(node.syntaxNodeType) { - for keyPath in keyPaths { - guard let name = childName(keyPath) else { - continue - } - guard allChildren.contains(where: { child in child.keyPathInParent == keyPath }) else { - treeNode.structure.append( - StructureProperty(name: name, value: StructureValue(text: "nil")) - ) - continue - } - - let keyPath = keyPath as AnyKeyPath - switch syntaxNode[keyPath: keyPath] { - case let value as TokenSyntax: - if value.presence == .missing { - treeNode.structure.append( - StructureProperty( - name: name, - value: StructureValue( - text: value.text, - kind: "\(value.tokenKind)" - ) - ) - ) - } else { - treeNode.structure.append( - StructureProperty( - name: name, - value: StructureValue( - text: value.text, - kind: "\(value.tokenKind)" - ) - ) - ) - } - case let value?: - if let value = value as? any SyntaxProtocol { - let type = "\(value.syntaxNodeType)" - treeNode.structure.append( - StructureProperty( - name: name, - value: StructureValue(text: "\(type)"), - ref: "\(type)" - ) - ) - } else { - treeNode.structure.append( - StructureProperty(name: name, value: StructureValue(text: "\(value)")) - ) - } - case .none: - treeNode.structure.append(StructureProperty(name: name)) - } - } - } - case .collection(let syntax): - treeNode.type = .collection - treeNode.structure.append( - StructureProperty( - name: "Element", - value: StructureValue(text: "\(syntax)") - ) - ) - treeNode.structure.append( - StructureProperty( - name: "Count", - value: StructureValue(text: "\(node.children(viewMode: .all).count)") - ) - ) - case .choices: - break - } - - if let current { - treeNode.parent = current.id - } - current = treeNode - } - - override internal func visit(_ token: TokenSyntax) -> TokenSyntax { - current.text = token - .text - .escapeHTML() - .replaceInvisiblesWithHTML() - .replaceHTMLWhitespacesWithSymbols() - - current.token = Token(kind: "\(token.tokenKind)", leadingTrivia: "", trailingTrivia: "") - - for piece in token.leadingTrivia { - let trivia = processTriviaPiece(piece) - current.token?.leadingTrivia += trivia.replaceHTMLWhitespacesWithSymbols() - } - processToken(token) - for piece in token.trailingTrivia { - let trivia = processTriviaPiece(piece) - current.token?.trailingTrivia += trivia.replaceHTMLWhitespacesWithSymbols() - } - - return token - } - - override internal func visitPost(_ node: Syntax) { - if let parent = current.parent { - current = tree[parent] - } else { - current = nil - } - } -} diff --git a/Sources/SyntaxKit/Parser/TreeNode.swift b/Sources/SyntaxKit/Parser/TreeNode.swift deleted file mode 100644 index 661ed6b..0000000 --- a/Sources/SyntaxKit/Parser/TreeNode.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// TreeNode.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation - -internal final class TreeNode: Codable { - internal let id: Int - internal var parent: Int? - - internal var text: String - internal var range = SourceRange( - startRow: 0, - startColumn: 0, - endRow: 0, - endColumn: 0 - ) - internal var structure = [StructureProperty]() - internal var type: SyntaxType - internal var token: Token? - - internal init(id: Int, text: String, range: SourceRange, type: SyntaxType) { - self.id = id - self.text = text.escapeHTML() - self.range = range - self.type = type - } -} - -extension TreeNode: Equatable { - internal static func == (lhs: TreeNode, rhs: TreeNode) -> Bool { - lhs.id == rhs.id && lhs.parent == rhs.parent && lhs.text == rhs.text && lhs.range == rhs.range - && lhs.structure == rhs.structure && lhs.type == rhs.type && lhs.token == rhs.token - } -} - -extension TreeNode: CustomStringConvertible { - internal var description: String { - """ - { - id: \(id) - parent: \(String(describing: parent)) - text: \(text) - range: \(range) - structure: \(structure) - type: \(type) - token: \(String(describing: token)) - } - """ - } -} diff --git a/Sources/SyntaxParser/README.md b/Sources/SyntaxParser/README.md new file mode 100644 index 0000000..8385f14 --- /dev/null +++ b/Sources/SyntaxParser/README.md @@ -0,0 +1,86 @@ +# SyntaxParser Module Architecture + +The SyntaxParser module provides a bridge between Apple's SwiftSyntax framework and +JSON-based tools that need to analyze Swift source code. It transforms the complex +SwiftSyntax AST into a simplified, flat structure suitable for serialization and +external consumption. + +## Key Components + +### Core Parser (`SyntaxParser`) +- Main entry point for parsing Swift code +- Handles operator precedence folding options +- Orchestrates the parsing pipeline +- Returns JSON-serialized results + +### AST Visitor (`TokenVisitor`) +- Implements SwiftSyntax's SyntaxRewriter protocol +- Performs depth-first traversal of the syntax tree +- Extracts essential information from each node +- Builds flattened tree structure with ID-based relationships +- Processes tokens and trivia (whitespace, comments) + +### Data Structures +- `TreeNode`: Core representation of syntax elements with metadata +- `StructureProperty`: Named properties within syntax nodes +- `StructureValue`: Terminal values and type references +- `Token`: Token-specific metadata (kind, trivia) +- `SourceRange`: Line/column location coordinates +- `SyntaxType`: Semantic classification of syntax elements +- `SyntaxResponse`: Container for final JSON output (deprecated) + +## Processing Pipeline + +1. **Parse**: SwiftSyntax parses Swift source code into AST +2. **Transform**: Optional operator precedence folding +3. **Visit**: TokenVisitor traverses AST and extracts data +4. **Classify**: Nodes are semantically classified (decl/expr/pattern/type/other) +5. **Flatten**: Tree structure is flattened using ID references +6. **Serialize**: Result is encoded to JSON format + +## Output Format + +The JSON output contains a flat array of TreeNode objects, each with: +- Unique ID and parent reference (creates tree structure) +- Semantic type classification for easy filtering +- Source location for mapping back to original code +- Structural properties describing internal organization +- Token metadata for leaf nodes (kind, trivia) + +## Design Principles + +### Console-First +- Optimized for command-line tools and external analysis +- Plain text output without HTML escaping (as of recent refactor) +- Clean JSON suitable for piping between tools + +### Flattened Structure +- Uses ID-based references instead of object nesting +- Avoids circular references in JSON serialization +- Enables efficient access patterns for external tools + +### Semantic Classification +- Groups syntax elements by role (declarations, expressions, etc.) +- Simplifies filtering and analysis for consumers +- Abstracts away SwiftSyntax implementation details + +### Preservation of Details +- Maintains source location information +- Preserves trivia (whitespace, comments) exactly +- Includes both present and missing tokens for completeness + +## Usage Example + +```swift +let code = """ + struct User { + let name: String + } + """ + +let treeNodes = SyntaxParser.parse(code: code) +// treeNodes contains the array of TreeNode objects directly +``` + +This module is primarily consumed by the `skit` command-line tool for +converting Swift source code to JSON for external analysis and tooling. diff --git a/Sources/SyntaxParser/SourceRange.swift b/Sources/SyntaxParser/SourceRange.swift new file mode 100644 index 0000000..f965f64 --- /dev/null +++ b/Sources/SyntaxParser/SourceRange.swift @@ -0,0 +1,68 @@ +// +// SourceRange.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Represents the source location range of a syntax element in the original Swift code. +/// +/// SourceRange provides line and column coordinates for both the start and end +/// positions of a syntax element. This information is crucial for tools that need +/// to map parsed elements back to their original source locations, such as: +/// - IDEs showing syntax highlighting and error locations +/// - Code analysis tools reporting issues +/// - Refactoring tools modifying specific code regions +/// +/// Coordinates use 1-based indexing to match common editor conventions. +package struct SourceRange: Codable, Equatable { + /// The line number where this syntax element begins (1-based). + package let startRow: Int + + /// The column number where this syntax element begins (1-based). + package let startColumn: Int + + /// The line number where this syntax element ends (1-based). + package let endRow: Int + + /// The column number where this syntax element ends (1-based). + package let endColumn: Int + + /// Creates a new SourceRange with the specified coordinates. + /// + /// - Parameters: + /// - startRow: Starting line number (1-based) + /// - startColumn: Starting column number (1-based) + /// - endRow: Ending line number (1-based) + /// - endColumn: Ending column number (1-based) + package init(startRow: Int, startColumn: Int, endRow: Int, endColumn: Int) { + self.startRow = startRow + self.startColumn = startColumn + self.endRow = endRow + self.endColumn = endColumn + } +} diff --git a/Sources/SyntaxParser/SyntaxParser.swift b/Sources/SyntaxParser/SyntaxParser.swift new file mode 100644 index 0000000..043947e --- /dev/null +++ b/Sources/SyntaxParser/SyntaxParser.swift @@ -0,0 +1,116 @@ +// +// SyntaxParser.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftOperators +import SwiftParser +import SwiftSyntax +import TokenVisitor + +// MARK: - Module Overview +// +// For detailed architecture documentation, see README.md in this directory. + +/// Main entry point for parsing Swift source code into TreeNode representation. +/// +/// SyntaxParser converts Swift source code into an array of TreeNode objects that represents +/// the Abstract Syntax Tree (AST). This provides direct access to the parsed syntax structure +/// for programmatic analysis and manipulation. +/// +/// The parser leverages Apple's SwiftSyntax framework to perform the actual parsing, +/// then transforms the complex SwiftSyntax AST into a simplified, flat structure +/// suitable for direct consumption by Swift code. +package enum SyntaxParser { + // MARK: - Configuration Constants + + /// Option key to enable operator precedence folding during parsing. + /// When enabled, expressions are reorganized according to Swift's operator precedence rules. + @available( + *, deprecated, + message: "Operator precedence folding is not supported in the new parse(code:) method" + ) + private static let fold = "fold" + + /// Option key to include missing/implicit tokens in the output. + /// Useful for debugging or when you need to see all syntax elements including placeholders. + @available( + *, deprecated, message: "Missing token display is not supported in the new parse(code:) method" + ) + private static let showMissing = "showmissing" + + // MARK: - Public Interface + + /// Parses Swift source code and returns an array of TreeNode objects. + /// + /// This method performs the complete parsing pipeline: + /// 1. Parses Swift source code using SwiftSyntax + /// 2. Traverses the AST to extract structure and token information + /// 3. Returns the tree nodes directly without JSON serialization + /// + /// - Parameter code: Swift source code to parse + /// - Returns: Array of TreeNode objects representing the syntax tree + package static func parse(code: String) -> [TreeNode] { + // Parse the Swift source code into a SwiftSyntax AST + let sourceFile = Parser.parse(source: code) + + return TreeNode.parseTree(from: sourceFile) + } + + /// Parses Swift source code and returns a JSON representation of its syntax tree. + /// + /// This method performs the complete parsing pipeline: + /// 1. Parses Swift source code using SwiftSyntax + /// 2. Optionally applies operator precedence folding + /// 3. Traverses the AST to extract structure and token information + /// 4. Converts the tree to JSON format suitable for external consumption + /// + /// - Parameters: + /// - code: Swift source code to parse + /// - options: Optional parsing configuration. Supported options: + /// - "fold": Apply operator precedence folding + /// - "showmissing": Include missing/implicit tokens in output + /// - Returns: SyntaxResponse containing the JSON representation + /// - Throws: JSONEncoder errors if serialization fails + @available(*, deprecated, message: "Use parse(code:) instead for direct TreeNode access") + package static func parse(code: String, options: [String] = []) throws -> SyntaxResponse { + // Parse the Swift source code into a SwiftSyntax AST + let sourceFile = Parser.parse(source: code) + + let tree = TreeNode.parseTree( + from: sourceFile, + showingMissingTokens: options.contains(showMissing) + ) + + let encoder = JSONEncoder() + let data = try encoder.encode(tree) + let json = String(decoding: data, as: UTF8.self) + + return SyntaxResponse(syntaxJSON: json) + } +} diff --git a/Sources/SyntaxParser/SyntaxResponse.swift b/Sources/SyntaxParser/SyntaxResponse.swift new file mode 100644 index 0000000..0c29b82 --- /dev/null +++ b/Sources/SyntaxParser/SyntaxResponse.swift @@ -0,0 +1,63 @@ +// +// SyntaxResponse.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Container for the final JSON representation of parsed Swift syntax. +/// +/// SyntaxResponse is the top-level result type returned by the SyntaxParser. +/// It wraps the JSON string representation of the parsed syntax tree, +/// providing a simple interface for the `skit` command-line tool and +/// other consumers to access the structured syntax data. +/// +/// The JSON contains a flat array of TreeNode objects representing the +/// complete Swift syntax tree in a format suitable for external analysis +/// tools, IDEs, and other applications that need to understand Swift code structure. +@available( + *, deprecated, message: "Use parse(code:) which returns [TreeNode] directly instead of JSON" +) +package struct SyntaxResponse: Codable { + /// JSON string representation of the parsed syntax tree. + /// Contains a serialized array of TreeNode objects with their relationships, + /// source locations, and structural information. + @available( + *, deprecated, message: "Use parse(code:) which returns [TreeNode] directly instead of JSON" + ) + package let syntaxJSON: String + + /// Creates a new SyntaxResponse with the provided JSON data. + /// + /// - Parameter syntaxJSON: The JSON string representation of the syntax tree + @available( + *, deprecated, message: "Use parse(code:) which returns [TreeNode] directly instead of JSON" + ) + package init(syntaxJSON: String) { + self.syntaxJSON = syntaxJSON + } +} diff --git a/Sources/SyntaxParser/TreeNode.swift b/Sources/SyntaxParser/TreeNode.swift new file mode 100644 index 0000000..6528010 --- /dev/null +++ b/Sources/SyntaxParser/TreeNode.swift @@ -0,0 +1,146 @@ +// +// TreeNode.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +package import SwiftSyntax +package import TokenVisitor + +/// Represents a single node in the simplified syntax tree structure. +/// +/// TreeNode is the core data structure that represents each element of the Swift AST +/// in a flat, JSON-serializable format. Each node contains essential information about +/// a syntax element including its location, type, content, and relationships. +/// +/// The tree structure is flattened using ID-based parent-child relationships rather +/// than object references, making it suitable for JSON serialization and consumption +/// by external tools. +package final class TreeNode: TreeNodeProtocol, Codable { + // MARK: - Identity and Relationships + + /// Unique identifier for this node within the tree. + /// Used to establish parent-child relationships and references. + package let id: Int + + /// ID of the parent node, if any. + /// Root nodes have no parent (nil). This creates a flat tree structure + /// suitable for JSON serialization. + package var parent: Int? + + // MARK: - Content and Metadata + + /// The text content or type name of this syntax element. + /// For tokens: the actual source text (e.g., "let", "myVariable", "42") + /// For syntax nodes: the cleaned type name (e.g., "VariableDecl", "FunctionCall") + package var text: String + + /// Source location range where this syntax element appears in the original code. + /// Provides line and column coordinates for both start and end positions. + package var range = SourceRange( + startRow: 0, + startColumn: 0, + endRow: 0, + endColumn: 0 + ) + + /// Structural properties that describe the internal organization of this syntax element. + /// Each property represents a named component (e.g., "name", "parameters", "body") + /// and may reference other nodes or contain token values. + package var structure = [StructureProperty]() + + /// Semantic classification of this syntax element. + /// Helps consumers understand the role of this node (declaration, expression, etc.). + package var type: SyntaxType + + /// Token-specific metadata, present only for leaf nodes in the syntax tree. + /// Contains detailed information about token kind, leading/trailing trivia. + package var token: Token? + + // MARK: - Initialization + + /// Creates a new TreeNode with the specified properties. + /// + /// - Parameters: + /// - id: Unique identifier for this node + /// - text: Text content or type name + /// - range: Source location range + /// - type: Semantic classification + package init(id: Int, text: String, range: SourceRange, type: SyntaxType) { + self.id = id + self.text = text + self.range = range + self.type = type + } +} + +extension TreeNode: Equatable { + package static func == (lhs: TreeNode, rhs: TreeNode) -> Bool { + lhs.id == rhs.id && lhs.parent == rhs.parent && lhs.text == rhs.text && lhs.range == rhs.range + && lhs.structure == rhs.structure && lhs.type == rhs.type && lhs.token == rhs.token + } +} + +extension TreeNode { + /// Creates a TreeNode from a SwiftSyntax node with proper initialization. + /// + /// This initializer extracts essential information from the SwiftSyntax node and + /// creates a corresponding TreeNode with cleaned class name, semantic type + /// classification, and source location information. + /// + /// - Parameters: + /// - id: Unique identifier for the new node + /// - node: The SwiftSyntax node to convert + /// - locationConverter: Converter for source positions to line/column coordinates + /// - syntaxType: The semantic classification of the node + /// - className: The cleaned class name (without "Syntax" suffix) + package convenience init( + id: Int, + from node: Syntax, + locationConverter: SourceLocationConverter, + syntaxType: SyntaxType, + className: String + ) { + // Extract source location information + let sourceRange = node.sourceRange(converter: locationConverter) + let start = sourceRange.start + let end = sourceRange.end + + // Initialize with extracted information + self.init( + id: id, + text: className, + range: SourceRange( + startRow: start.line, + startColumn: start.column, + endRow: end.line, + endColumn: end.column + ), + type: syntaxType + ) + } +} diff --git a/Sources/SyntaxKit/Parser/SyntaxResponse.swift b/Sources/TokenVisitor/String.swift similarity index 91% rename from Sources/SyntaxKit/Parser/SyntaxResponse.swift rename to Sources/TokenVisitor/String.swift index 7dbb636..4b1c943 100644 --- a/Sources/SyntaxKit/Parser/SyntaxResponse.swift +++ b/Sources/TokenVisitor/String.swift @@ -1,5 +1,5 @@ // -// SyntaxResponse.swift +// String.swift // SyntaxKit // // Created by Leo Dion. @@ -27,8 +27,6 @@ // OTHER DEALINGS IN THE SOFTWARE. // -import Foundation - -package struct SyntaxResponse: Codable { - package let syntaxJSON: String +extension String { + internal static let empty = "" } diff --git a/Sources/TokenVisitor/StructureProperty.swift b/Sources/TokenVisitor/StructureProperty.swift new file mode 100644 index 0000000..f90124d --- /dev/null +++ b/Sources/TokenVisitor/StructureProperty.swift @@ -0,0 +1,137 @@ +// +// StructureProperty.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Represents a named property within a syntax node's structure. +/// +/// StructureProperty describes the internal components of a syntax node, such as +/// the "name" property of a function declaration or the "parameters" of a function call. +/// Each property has a name and may contain either a value (for terminals) or a +/// reference to another syntax node type. +/// +/// Examples: +/// - Function declaration "name" property → StructureValue with identifier text +/// - Function declaration "body" property → Reference to "CodeBlockSyntax" +/// - Missing optional property → nil value with just the property name +package struct StructureProperty: Codable, Equatable, Sendable { + // MARK: - String Constants + + /// Property name for collection element type information. + private static let element: String = "Element" + + /// Property name for collection count information. + private static let count: String = "Count" + + /// Placeholder text for missing or nil syntax elements. + private static let nilValue: String = "nil" + + /// The name of this structural property. + /// Corresponds to SwiftSyntax property names like "name", "parameters", "body", etc. + private let name: String + + /// The value of this property, if it contains terminal data. + /// Present for tokens, literals, and other concrete values. + /// Nil for missing optional properties. + private let value: StructureValue? + + /// Reference to another syntax node type, if this property contains a nested structure. + /// Used when this property points to another syntax node rather than containing terminal data. + /// Example: "body" property might reference "CodeBlockSyntax" + private let ref: String? + + /// Creates a new StructureProperty with the specified components. + /// + /// - Parameters: + /// - name: The property name + /// - value: Terminal value data, if any + /// - ref: Reference to another syntax type, if any + internal init(name: String, value: StructureValue? = nil, ref: String? = nil) { + self.name = name + self.value = value + self.ref = ref + } + + // MARK: - Convenience Initializers + + /// Creates a StructureProperty for a missing property with a nil value indicator. + /// + /// - Parameters: + /// - name: The property name + /// - nilValue: The value to display for the nil value (will be converted to string) + internal init(nilValueWithName name: String) { + self.init(name: name, value: StructureValue(text: Self.nilValue), ref: nil) + } + + /// Creates a StructureProperty for a token value. + /// + /// - Parameters: + /// - name: The property name + /// - text: The token text + /// - kind: The token kind + private init(token name: String, text: String, kind: Any) { + self.init(name: name, value: StructureValue(text: text, kind: "\(kind)"), ref: nil) + } + + /// Creates a StructureProperty for a syntax node reference. + /// + /// - Parameters: + /// - name: The property name + /// - type: The syntax node type (will be converted to string) + internal init(reference name: String, type: Any) { + let typeString = "\(type)" + self.init(name: name, value: StructureValue(value: type), ref: typeString) + } + + /// Creates a StructureProperty for a primitive value. + /// + /// - Parameters: + /// - name: The property name + /// - value: The primitive value (will be converted to string) + internal init(primitive name: String, value: Any) { + self.init(name: name, value: StructureValue(value: value), ref: nil) + } + + internal init(token name: String, tokenSyntax: TokenSyntax) { + self.init( + token: name, + text: tokenSyntax.text, + kind: tokenSyntax.tokenKind + ) + } + + internal init(collectionWithCount count: Int) { + self.init(primitive: Self.count, value: count) + } + + internal init(elementWithType type: Any.Type) { + self.init(primitive: Self.element, value: type) + } +} diff --git a/Sources/TokenVisitor/StructureValue.swift b/Sources/TokenVisitor/StructureValue.swift new file mode 100644 index 0000000..dea1d77 --- /dev/null +++ b/Sources/TokenVisitor/StructureValue.swift @@ -0,0 +1,71 @@ +// +// StructureValue.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Contains the concrete value data for a structure property. +/// +/// StructureValue holds the actual content of a syntax element property, +/// such as the text of an identifier token or the string representation +/// of a syntax node type. It optionally includes kind information to +/// distinguish between different types of values. +/// +/// Examples: +/// - Token value: text="let", kind="keyword(SwiftSyntax.Keyword.let)" +/// - Type reference: text="VariableDeclSyntax", kind=nil +/// - Literal value: text="42", kind="integerLiteral(42)" +package struct StructureValue: Codable, Equatable, Sendable { + /// The string representation of this value. + /// Contains the actual text content or type name. + private let text: String + + /// Optional kind information that provides additional context about the value type. + /// Present for tokens to indicate their specific token kind (e.g., "keyword", "identifier"). + /// Nil for simple text values and type references. + private let kind: String? + + /// Creates a new StructureValue with the specified content. + /// + /// - Parameters: + /// - text: The string representation of the value + /// - kind: Optional kind information for additional context + internal init(text: String, kind: String? = nil) { + self.text = text + self.kind = kind + } + + /// Creates a new StructureValue from any value by performing string interpolation. + /// + /// - Parameters: + /// - value: Any value that will be converted to a string + /// - kind: Optional kind information for additional context + internal init(value: Any, kind: String? = nil) { + self.init(text: "\(value)", kind: kind) + } +} diff --git a/Sources/SyntaxKit/Parser/SyntaxParser.swift b/Sources/TokenVisitor/Syntax.swift similarity index 52% rename from Sources/SyntaxKit/Parser/SyntaxParser.swift rename to Sources/TokenVisitor/Syntax.swift index 65b0ef7..7466f55 100644 --- a/Sources/SyntaxKit/Parser/SyntaxParser.swift +++ b/Sources/TokenVisitor/Syntax.swift @@ -1,5 +1,5 @@ // -// SyntaxParser.swift +// Syntax.swift // SyntaxKit // // Created by Leo Dion. @@ -27,33 +27,35 @@ // OTHER DEALINGS IN THE SOFTWARE. // -import Foundation -import SwiftOperators -import SwiftParser import SwiftSyntax -package enum SyntaxParser { - package static func parse(code: String, options: [String] = []) throws -> SyntaxResponse { - let sourceFile = Parser.parse(source: code) +/// Extension on Syntax to provide convenient access to syntax type classification. +extension Syntax { + /// Returns the semantic classification of this syntax node. + /// + /// If the node's type conforms to `SyntaxClassifiable`, returns its static + /// `syntaxType`. Otherwise, returns `.other`. + internal var syntaxType: SyntaxType { + if let classifiable = self.syntaxNodeType as? any SyntaxClassifiable.Type { + return classifiable.syntaxType + } + return .other + } - let syntax: Syntax - if options.contains("fold") { - syntax = OperatorTable.standardOperators.foldAll(sourceFile, errorHandler: { _ in }) + /// Cleans up SwiftSyntax type names by removing the "Syntax" suffix. + /// + /// SwiftSyntax type names typically end with "Syntax" (e.g., "VariableDeclSyntax"). + /// This method removes that suffix to create more readable names for output + /// (e.g., "VariableDecl"), making the tree structure more human-friendly. + /// + /// - Returns: Cleaned class name without "Syntax" suffix + internal var cleanClassName: String { + let fullName = "\(syntaxNodeType)" + let syntaxSuffix = "Syntax" + if fullName.hasSuffix(syntaxSuffix) { + return String(fullName.dropLast(syntaxSuffix.count)) } else { - syntax = Syntax(sourceFile) + return fullName } - - let visitor = TokenVisitor( - locationConverter: SourceLocationConverter(fileName: "", tree: sourceFile), - showMissingTokens: options.contains("showmissing") - ) - _ = visitor.rewrite(syntax) - - let tree = visitor.tree - let encoder = JSONEncoder() - let data = try encoder.encode(tree) - let json = String(decoding: data, as: UTF8.self) - - return SyntaxResponse(syntaxJSON: json) } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable.swift b/Sources/TokenVisitor/SyntaxClassifiable.swift new file mode 100644 index 0000000..4c9b213 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable.swift @@ -0,0 +1,40 @@ +// +// SyntaxClassifiable.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Protocol for syntax nodes that can classify themselves by their semantic role. +/// +/// This protocol allows syntax nodes to self-identify their classification, +/// making the classification process more type-safe and extensible. +package protocol SyntaxClassifiable: Sendable { + /// Returns the semantic classification of this syntax node type. + static var syntaxType: SyntaxType { get } +} diff --git a/Sources/SyntaxKit/Parser/SourceRange.swift b/Sources/TokenVisitor/SyntaxClassifiable/AttributeListSyntax.swift similarity index 74% rename from Sources/SyntaxKit/Parser/SourceRange.swift rename to Sources/TokenVisitor/SyntaxClassifiable/AttributeListSyntax.swift index cc5dfc6..301a686 100644 --- a/Sources/SyntaxKit/Parser/SourceRange.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/AttributeListSyntax.swift @@ -1,5 +1,5 @@ // -// SourceRange.swift +// AttributeListSyntax.swift // SyntaxKit // // Created by Leo Dion. @@ -28,23 +28,12 @@ // import Foundation +import SwiftSyntax -internal struct SourceRange: Codable, Equatable { - internal let startRow: Int - internal let startColumn: Int - internal let endRow: Int - internal let endColumn: Int -} - -extension SourceRange: CustomStringConvertible { - internal var description: String { - """ - { - startRow: \(startRow) - startColumn: \(startColumn) - endRow: \(endRow) - endColumn: \(endColumn) - } - """ +/// Extension for AttributeListSyntax to conform to SyntaxClassifiable. +extension AttributeListSyntax: SyntaxClassifiable { + /// Attribute lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable/CatchClauseListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/CatchClauseListSyntax.swift new file mode 100644 index 0000000..6eaf0ab --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/CatchClauseListSyntax.swift @@ -0,0 +1,39 @@ +// +// CatchClauseListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for CatchClauseListSyntax to conform to SyntaxClassifiable. +extension CatchClauseListSyntax: SyntaxClassifiable { + /// Catch clause lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/CodeBlockItemListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/CodeBlockItemListSyntax.swift new file mode 100644 index 0000000..e6ead13 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/CodeBlockItemListSyntax.swift @@ -0,0 +1,39 @@ +// +// CodeBlockItemListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for CodeBlockItemListSyntax to conform to SyntaxClassifiable. +extension CodeBlockItemListSyntax: SyntaxClassifiable { + /// Code block item lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/ConditionElementListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/ConditionElementListSyntax.swift new file mode 100644 index 0000000..22c0b7d --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/ConditionElementListSyntax.swift @@ -0,0 +1,39 @@ +// +// ConditionElementListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for ConditionElementListSyntax to conform to SyntaxClassifiable. +extension ConditionElementListSyntax: SyntaxClassifiable { + /// Condition element lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/DeclModifierListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/DeclModifierListSyntax.swift new file mode 100644 index 0000000..f80cb3b --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/DeclModifierListSyntax.swift @@ -0,0 +1,39 @@ +// +// DeclModifierListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for DeclModifierListSyntax to conform to SyntaxClassifiable. +extension DeclModifierListSyntax: SyntaxClassifiable { + /// Declaration modifier lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/SyntaxKit/Parser/String+Extensions.swift b/Sources/TokenVisitor/SyntaxClassifiable/DeclSyntax.swift similarity index 80% rename from Sources/SyntaxKit/Parser/String+Extensions.swift rename to Sources/TokenVisitor/SyntaxClassifiable/DeclSyntax.swift index 861317a..d0ee3af 100644 --- a/Sources/SyntaxKit/Parser/String+Extensions.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/DeclSyntax.swift @@ -1,5 +1,5 @@ // -// String+Extensions.swift +// DeclSyntax.swift // SyntaxKit // // Created by Leo Dion. @@ -28,11 +28,11 @@ // import Foundation +import SwiftSyntax -extension String { - internal func replaceHTMLWhitespacesToSymbols() -> String { - self - .replacingOccurrences(of: " ", with: "") - .replacingOccurrences(of: "
", with: "") +extension DeclSyntax: SyntaxClassifiable { + /// Declarations are classified as `.decl` type. + internal static var syntaxType: SyntaxType { + .decl } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable/ExprSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/ExprSyntax.swift new file mode 100644 index 0000000..1f10ae1 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/ExprSyntax.swift @@ -0,0 +1,38 @@ +// +// ExprSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +extension ExprSyntax: SyntaxClassifiable { + /// Expressions are classified as `.expr` type. + internal static var syntaxType: SyntaxType { + .expr + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/FunctionParameterListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/FunctionParameterListSyntax.swift new file mode 100644 index 0000000..8ecd644 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/FunctionParameterListSyntax.swift @@ -0,0 +1,39 @@ +// +// FunctionParameterListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for FunctionParameterListSyntax to conform to SyntaxClassifiable. +extension FunctionParameterListSyntax: SyntaxClassifiable { + /// Function parameter lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/SyntaxKit/Parser/SyntaxType.swift b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift similarity index 87% rename from Sources/SyntaxKit/Parser/SyntaxType.swift rename to Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift index 81b9761..a5c757c 100644 --- a/Sources/SyntaxKit/Parser/SyntaxType.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift @@ -1,5 +1,5 @@ // -// SyntaxType.swift +// IdentifierPatternSyntax.swift // SyntaxKit // // Created by Leo Dion. @@ -27,13 +27,10 @@ // OTHER DEALINGS IN THE SOFTWARE. // -import Foundation +import SwiftSyntax -internal enum SyntaxType: String, Codable, Equatable { - case decl - case expr - case pattern - case type - case collection - case other +extension IdentifierPatternSyntax: SyntaxClassifiable { + static var syntaxType: SyntaxType { + .pattern + } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift new file mode 100644 index 0000000..0ffd2fb --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift @@ -0,0 +1,36 @@ +// +// IdentifierTypeSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import SwiftSyntax + +extension IdentifierTypeSyntax: SyntaxClassifiable { + static var syntaxType: SyntaxType { + .type + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/LabeledExprListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/LabeledExprListSyntax.swift new file mode 100644 index 0000000..1b15d16 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/LabeledExprListSyntax.swift @@ -0,0 +1,39 @@ +// +// LabeledExprListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for LabeledExprListSyntax to conform to SyntaxClassifiable. +extension LabeledExprListSyntax: SyntaxClassifiable { + /// Labeled expression lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/PatternBindingListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/PatternBindingListSyntax.swift new file mode 100644 index 0000000..50ae290 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/PatternBindingListSyntax.swift @@ -0,0 +1,39 @@ +// +// PatternBindingListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for PatternBindingListSyntax to conform to SyntaxClassifiable. +extension PatternBindingListSyntax: SyntaxClassifiable { + /// Pattern binding lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/PatternSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/PatternSyntax.swift new file mode 100644 index 0000000..2f26c03 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/PatternSyntax.swift @@ -0,0 +1,38 @@ +// +// PatternSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +extension PatternSyntax: SyntaxClassifiable { + /// Patterns are classified as `.pattern` type. + internal static var syntaxType: SyntaxType { + .pattern + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseItemListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseItemListSyntax.swift new file mode 100644 index 0000000..375ffcb --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseItemListSyntax.swift @@ -0,0 +1,39 @@ +// +// SwitchCaseItemListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for SwitchCaseItemListSyntax to conform to SyntaxClassifiable. +extension SwitchCaseItemListSyntax: SyntaxClassifiable { + /// Switch case item lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseListSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseListSyntax.swift new file mode 100644 index 0000000..966ed26 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/SwitchCaseListSyntax.swift @@ -0,0 +1,39 @@ +// +// SwitchCaseListSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// Extension for SwitchCaseListSyntax to conform to SyntaxClassifiable. +extension SwitchCaseListSyntax: SyntaxClassifiable { + /// Switch case lists are classified as `.collection` type. + internal static var syntaxType: SyntaxType { + .collection + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/TypeSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/TypeSyntax.swift new file mode 100644 index 0000000..9553cbd --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/TypeSyntax.swift @@ -0,0 +1,38 @@ +// +// TypeSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +extension TypeSyntax: SyntaxClassifiable { + /// Types are classified as `.type` type. + internal static var syntaxType: SyntaxType { + .type + } +} diff --git a/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift new file mode 100644 index 0000000..4371c56 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift @@ -0,0 +1,36 @@ +// +// VariableDeclSyntax.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import SwiftSyntax + +extension VariableDeclSyntax: SyntaxClassifiable { + static var syntaxType: SyntaxType { + .decl + } +} diff --git a/Sources/TokenVisitor/SyntaxType.swift b/Sources/TokenVisitor/SyntaxType.swift new file mode 100644 index 0000000..377b159 --- /dev/null +++ b/Sources/TokenVisitor/SyntaxType.swift @@ -0,0 +1,69 @@ +// +// SyntaxType.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Semantic classification of syntax elements in the Swift AST. +/// +/// SyntaxType provides a high-level categorization of syntax nodes that helps +/// consumers understand the role and purpose of each element without needing +/// to parse the detailed SwiftSyntax type names. This classification is +/// particularly useful for syntax highlighting, code analysis, and other +/// tools that need to treat different kinds of syntax elements differently. +/// +/// The classification is based on the SwiftSyntax type hierarchy and groups +/// related syntax elements into meaningful categories. +package enum SyntaxType: String, Codable, Equatable, Sendable { + /// Declaration syntax elements. + /// Includes: struct, class, enum, func, var, let, import, protocol, extension, etc. + case decl + + /// Expression syntax elements. + /// Includes: literals, function calls, property access, operators, closures, etc. + case expr + + /// Pattern syntax elements. + /// Includes: identifier patterns, tuple patterns, wildcard patterns, etc. + /// Used in variable bindings, function parameters, and pattern matching. + case pattern + + /// Type syntax elements. + /// Includes: type annotations, type references, generic parameters, etc. + case type + + /// Collection syntax elements. + /// Includes: lists, arrays, and other grouped syntax elements. + /// Special category for nodes that contain multiple child elements. + case collection + + /// Other syntax elements. + /// Includes: punctuation, keywords, comments, and structural elements + /// that don't fit into the above semantic categories. + case other +} diff --git a/Sources/TokenVisitor/Token.swift b/Sources/TokenVisitor/Token.swift new file mode 100644 index 0000000..52ed0b6 --- /dev/null +++ b/Sources/TokenVisitor/Token.swift @@ -0,0 +1,67 @@ +// +// Token.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Represents metadata for a terminal token in the syntax tree. +/// +/// Token contains detailed information about leaf nodes in the AST, +/// including the token's classification and associated trivia (whitespace, +/// comments, etc.). This information is essential for understanding the +/// exact structure and formatting of the original source code. +/// +/// Trivia includes all the "invisible" text around tokens like spaces, +/// newlines, comments, and other formatting elements that don't directly +/// participate in the Swift language grammar but are important for +/// code reconstruction and analysis. +package struct Token: Codable, Equatable, Sendable { + /// The classification of this token (e.g., "keyword", "identifier", "integerLiteral"). + /// Corresponds to SwiftSyntax TokenKind descriptions. + private let kind: String + + /// Trivia that appears before this token. + /// Includes whitespace, comments, and other non-semantic text preceding the token. + internal private(set) var leadingTrivia: String + + /// Trivia that appears after this token. + /// Includes whitespace, comments, and other non-semantic text following the token. + internal private(set) var trailingTrivia: String + + /// Creates a new Token with the specified properties. + /// + /// - Parameters: + /// - kind: The token classification + /// - leadingTrivia: Text appearing before the token + /// - trailingTrivia: Text appearing after the token + internal init(kind: String, leadingTrivia: String, trailingTrivia: String) { + self.kind = kind + self.leadingTrivia = leadingTrivia + self.trailingTrivia = trailingTrivia + } +} diff --git a/Sources/TokenVisitor/TokenVisitor.swift b/Sources/TokenVisitor/TokenVisitor.swift new file mode 100644 index 0000000..e288dfb --- /dev/null +++ b/Sources/TokenVisitor/TokenVisitor.swift @@ -0,0 +1,178 @@ +// +// TokenVisitor.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +/// AST visitor that transforms SwiftSyntax nodes into a simplified tree structure for JSON serialization. +/// +/// TokenVisitor traverses the SwiftSyntax Abstract Syntax Tree and extracts essential information +/// into a flat array of TreeNode objects. Each node contains: +/// - Semantic type classification (declaration, expression, pattern, type, etc.) +/// - Source location information (line/column ranges) +/// - Structural properties and relationships +/// - Token information for leaf nodes +/// +/// The visitor implements the SyntaxRewriter protocol to perform a depth-first traversal, +/// building a parent-child relationship between nodes using ID references rather than +/// object references (suitable for JSON serialization). +internal final class TokenVisitor: SyntaxRewriter { + // MARK: - State Management + + /// The flattened tree structure built during AST traversal. + /// Each TreeNode represents a syntax element with its metadata and relationships. + package var tree = [NodeType]() + + /// Currently active node during traversal (used to build parent-child relationships). + /// This is implicitly unwrapped because it's guaranteed to be set during normal traversal. + private var current: NodeType? + + /// Sequential ID counter for assigning unique identifiers to each tree node. + private var index = 0 + + // MARK: - Configuration + + /// Converts SwiftSyntax source positions to line/column coordinates. + package let locationConverter: SourceLocationConverter + + // MARK: - Initialization + + /// Creates a new TokenVisitor with the specified configuration. + /// + /// - Parameters: + /// - locationConverter: Converts syntax positions to line/column coordinates + /// - showMissingTokens: Whether to include missing/implicit tokens in output + package init(locationConverter: SourceLocationConverter, showMissingTokens: Bool) { + self.locationConverter = locationConverter + // Use .all view mode if showing missing tokens, otherwise only source-accurate tokens + super.init(viewMode: showMissingTokens ? .all : .sourceAccurate) + } + + // MARK: - SyntaxRewriter Overrides + + /// Called before visiting a syntax node's children. + /// + /// This method extracts essential information from each SwiftSyntax node and creates + /// a corresponding TreeNode with: + /// - Cleaned class name (removes "Syntax" suffix) + /// - Semantic type classification (declaration, expression, pattern, type, other) + /// - Source location range (line/column coordinates) + /// - Structural properties based on the node's layout + /// + /// - Parameter node: The SwiftSyntax node being visited + override internal func visitPre(_ node: Syntax) { + // Classify and extract node information using utility types + let className = node.cleanClassName + let syntaxType = node.syntaxType + + // Create tree node using convenience initializer + let treeNode = NodeType( + id: index, + from: node, + locationConverter: locationConverter, + syntaxType: syntaxType, + className: className + ) + + // Add to tree and prepare for next node + tree.append(treeNode) + index += 1 + + // Append structural information using TreeNodeProtocol extension + let allChildren = node.children(viewMode: .all) + treeNode.appendStructure(from: node, allChildren: allChildren) + + // Establish parent-child relationship + if let current { + treeNode.parent = current.id + } + current = treeNode + } + + /// Called when visiting a token (leaf node in the syntax tree). + /// + /// This method processes terminal tokens like keywords, identifiers, operators, and literals. + /// It extracts the token's text content and associated trivia (whitespace, comments, etc.). + /// + /// - Parameter token: The token being visited + /// - Returns: The unmodified token (this is a read-only transformation) + override internal func visit(_ token: TokenSyntax) -> TokenSyntax { + assert(current != nil) + + // Store the actual token text content + current?.text = token.text + + // Process leading trivia (whitespace, comments before the token) + let leadingTrivia = token.leadingTrivia.map(processTriviaPiece).joined() + + // Process trailing trivia (whitespace, comments after the token) + let trailingTrivia = token.trailingTrivia.map(processTriviaPiece).joined() + + // Create token metadata with kind information + current?.token = Token( + kind: "\(token.tokenKind)", + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia + ) + + return token + } + + /// Called after visiting a syntax node and all its children. + /// + /// This method restores the current node pointer to the parent, maintaining + /// the traversal state as we move back up the tree. + /// + /// - Parameter node: The syntax node whose children have been visited + override internal func visitPost(_ node: Syntax) { + assert(current != nil) + + // Move back to parent node, or nil if we're at the root + if let parent = current?.parent { + current = tree[parent] + } else { + current = nil + } + } + + // MARK: - Helper Methods + + /// Converts a SwiftSyntax trivia piece into its string representation. + /// + /// Trivia includes all the "invisible" elements around tokens: whitespace, + /// comments, and other formatting. This method converts each type of trivia + /// into plain text suitable for console output, preserving the original + /// formatting and content. + /// + /// - Parameter piece: The trivia piece to convert + /// - Returns: String representation of the trivia + internal func processTriviaPiece(_ piece: TriviaPiece) -> String { + piece.processedString + } +} diff --git a/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift b/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift new file mode 100644 index 0000000..035e572 --- /dev/null +++ b/Sources/TokenVisitor/TreeNodeProtocol+Extensions.swift @@ -0,0 +1,199 @@ +// +// TreeNodeProtocol+Extensions.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +package import SwiftSyntax + +extension TreeNodeProtocol { + package static func parseTree( + from sourceFile: SourceFileSyntax, + withFileName fileName: String = .defaultFileName, + showingMissingTokens: Bool = false + ) -> [Self] { + // Use raw syntax tree without precedence folding for simplicity + let syntax = Syntax(sourceFile) + + // Create visitor to traverse AST and extract structured information + let visitor = TokenVisitor( + locationConverter: SourceLocationConverter( + fileName: fileName, + tree: sourceFile + ), + showMissingTokens: false + ) + + // Traverse the syntax tree and build our simplified representation + _ = visitor.rewrite(syntax) + + // Return the tree nodes directly + return visitor.tree + } +} + +// MARK: - Structure Extraction Extensions + +extension TreeNodeProtocol { + /// Appends structural information from a SwiftSyntax node to the structure array. + /// + /// This method analyzes the node's internal structure and converts it into + /// a simplified format with named properties and values, appending them to + /// the structure array. It handles different structure types (layout, collection, + /// choices) and processes their properties according to their specific requirements. + /// + /// - Parameters: + /// - node: The SwiftSyntax node to analyze + /// - allChildren: All child nodes of the syntax node + internal func appendStructure( + from node: Syntax, + allChildren: SyntaxChildren + ) { + switch node.syntaxNodeType.structure { + case .layout(let keyPaths): + // Handle nodes with fixed structure (most syntax nodes) + appendLayoutStructure( + node: node, + keyPaths: keyPaths, + allChildren: allChildren + ) + case .collection(let syntax): + // Handle collection nodes (lists, arrays, etc.) + appendCollectionStructure( + elementType: syntax, + allChildren: allChildren + ) + case .choices: + // Handle choice nodes (union types) - no special processing needed + break + } + } + + private func appendLayoutStructure( + node: Syntax, + keyPaths: [AnyKeyPath], + allChildren: SyntaxChildren + ) { + guard let syntaxNode = node.as(node.syntaxNodeType) else { + return + } + + for keyPath in keyPaths { + appendKeyPathProperty( + keyPath: keyPath, + syntaxNode: syntaxNode, + allChildren: allChildren + ) + } + } + + private func appendKeyPathValue(_ anyValue: Any?, withName name: String) { + switch anyValue { + case let value as TokenSyntax: + // Handle token nodes (keywords, identifiers, operators, etc.) + structure.append( + StructureProperty( + token: name, + tokenSyntax: value + ) + ) + case let value as any SyntaxProtocol: + // Handle nested syntax nodes - store type reference + structure.append( + StructureProperty(reference: name, type: value.syntaxNodeType) + ) + case let value?: + // Handle primitive values + structure.append( + StructureProperty(primitive: name, value: value) + ) + case .none: + // Property exists but is nil + structure.append(StructureProperty(name: name)) + } + } + + private func appendKeyPathProperty( + keyPath: AnyKeyPath, + syntaxNode: any SyntaxProtocol, + allChildren: SyntaxChildren + ) { + guard let name = String(keyPath) else { + return + } + + // Check if this property has an actual child node + guard allChildren.contains(where: { child in child.keyPathInParent == keyPath }) else { + // Property exists but has no value - mark as nil + structure.append( + StructureProperty(nilValueWithName: name) + ) + return + } + + // Extract the actual property value + let keyPath = keyPath as AnyKeyPath + appendKeyPathValue(syntaxNode[keyPath: keyPath], withName: name) + } + + private func appendCollectionStructure( + elementType: Any.Type, + allChildren: SyntaxChildren + ) { + // Mark as collection type + type = .collection + + // Add element type information + structure.append( + StructureProperty(elementWithType: elementType) + ) + + // Add count information + structure.append( + StructureProperty(collectionWithCount: allChildren.count) + ) + } +} + +extension String { + internal static let defaultFileName = "" + + internal init?(_ keyPath: AnyKeyPath) { + let keyPathString = String(describing: keyPath) + + // Extract the last component after the last dot + if let lastDotIndex = keyPathString.lastIndex(of: ".") { + let afterDot = keyPathString[keyPathString.index(after: lastDotIndex)...] + self = String(afterDot) + } else { + // If no dots found, use the whole string + guard !keyPathString.isEmpty else { + return nil + } + self = keyPathString + } + } +} diff --git a/Sources/TokenVisitor/TreeNodeProtocol.swift b/Sources/TokenVisitor/TreeNodeProtocol.swift new file mode 100644 index 0000000..215a4be --- /dev/null +++ b/Sources/TokenVisitor/TreeNodeProtocol.swift @@ -0,0 +1,48 @@ +// +// TreeNodeProtocol.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +package import SwiftSyntax + +package protocol TreeNodeProtocol: AnyObject { + var id: Int { get } + var parent: Int? { get set } + var text: String { get set } + var token: Token? { get set } + var structure: [StructureProperty] { get set } + var type: SyntaxType { get set } + + init( + id: Int, + from node: Syntax, + locationConverter: SourceLocationConverter, + syntaxType: SyntaxType, + className: String + ) +} diff --git a/Sources/TokenVisitor/TriviaPiece.swift b/Sources/TokenVisitor/TriviaPiece.swift new file mode 100644 index 0000000..edc5491 --- /dev/null +++ b/Sources/TokenVisitor/TriviaPiece.swift @@ -0,0 +1,92 @@ +// +// TriviaPiece.swift +// SyntaxKit +// +// Created by Leo Dion. +// Copyright © 2025 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation +import SwiftSyntax + +// MARK: - TriviaPiece Extension + +extension TriviaPiece { + /// Represents the different ways a trivia piece can be processed. + private enum ProcessedTrivia { + case repeating(String, count: Int) + case text(String) + } + + /// Converts this trivia piece into a ProcessedTrivia enum, returning nil for empty cases. + /// + /// - Returns: ProcessedTrivia enum if the piece has content, nil for empty cases + private var processedTrivia: ProcessedTrivia? { + switch self { + // Text Cases (preserve text as-is) + case .lineComment(let text), + .blockComment(let text), + .docLineComment(let text), + .docBlockComment(let text), + .unexpectedText(let text): + return .text(text) + + // Repeating Value Cases (repeat characters based on count) + case .spaces(let count): + return .repeating(" ", count: count) + + case .tabs(let count): + return .repeating("\t", count: count) + + case .newlines(let count), .carriageReturns(let count), .carriageReturnLineFeeds(let count): + return .repeating("\n", count: count) + + case .backslashes(let count): + return .repeating(#"\"#, count: count) + + case .pounds(let count): + return .repeating("#", count: count) + + // Empty Cases (ignore/no-op) - return nil + case .verticalTabs, .formfeeds: + return nil + } + } + + /// Converts this trivia piece into its string representation using ProcessedTrivia. + /// + /// - Returns: String representation of the trivia, empty string for empty cases + internal var processedString: String { + guard let processed = processedTrivia else { + return "" + } + + switch processed { + case .text(let text): + return text + case .repeating(let character, let count): + return String(repeating: character, count: count) + } + } +} diff --git a/Sources/SyntaxKit/Parser/StructureValue.swift b/Sources/skit/Skit.swift similarity index 69% rename from Sources/SyntaxKit/Parser/StructureValue.swift rename to Sources/skit/Skit.swift index ac4ba50..c69237a 100644 --- a/Sources/SyntaxKit/Parser/StructureValue.swift +++ b/Sources/skit/Skit.swift @@ -1,5 +1,5 @@ // -// StructureValue.swift +// Skit.swift // SyntaxKit // // Created by Leo Dion. @@ -28,24 +28,23 @@ // import Foundation +import SyntaxParser -internal struct StructureValue: Codable, Equatable { - internal let text: String - internal let kind: String? +@main +internal enum Skit { + internal static func main() throws { + // Read Swift code from stdin + let code = String(data: FileHandle.standardInput.readDataToEndOfFile(), encoding: .utf8) ?? "" - internal init(text: String, kind: String? = nil) { - self.text = text.escapeHTML().replaceHTMLWhitespacesToSymbols() - self.kind = kind?.escapeHTML() - } -} + // Parse the code using SyntaxKit + let treeNodes = SyntaxParser.parse(code: code) + + // Convert to JSON for output + let encoder = JSONEncoder() + let data = try encoder.encode(treeNodes) + let json = String(decoding: data, as: UTF8.self) -extension StructureValue: CustomStringConvertible { - internal var description: String { - """ - { - text: \(text) - kind: \(String(describing: kind)) - } - """ + // Output the JSON + print(json) } } diff --git a/Sources/skit/main.swift b/Sources/skit/main.swift deleted file mode 100644 index b500a63..0000000 --- a/Sources/skit/main.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// main.swift -// SyntaxKit -// -// Created by Leo Dion. -// Copyright © 2025 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import Foundation -import SyntaxKit - -// Read Swift code from stdin -internal let code = - String(data: FileHandle.standardInput.readDataToEndOfFile(), encoding: .utf8) ?? "" - -do { - // Parse the code using SyntaxKit - let response = try SyntaxParser.parse(code: code, options: ["fold"]) - - // Output the JSON to stdout - print(response.syntaxJSON) -} catch { - // If there's an error, output it as JSON - let errorResponse = ["error": error.localizedDescription] - if let jsonData = try? JSONSerialization.data(withJSONObject: errorResponse), - let jsonString = String(data: jsonData, encoding: .utf8) - { - print(jsonString) - } - exit(1) -} diff --git a/TreeNodeProtocol+Extensions.swift b/TreeNodeProtocol+Extensions.swift new file mode 100644 index 0000000..0605da1 --- /dev/null +++ b/TreeNodeProtocol+Extensions.swift @@ -0,0 +1,219 @@ +// +// TreeNodeProtocol+Extensions.swift +// Lint +// +// Created by Leo Dion on 9/16/25. +// + +extension TreeNodeProtocol { + package static func parseTree( + from sourceFile: SourceFileSyntax, + withFileName fileName: String = .defaultFileName, + showingMissingTokens: Bool = false + ) -> [Self] { + // Use raw syntax tree without precedence folding for simplicity + let syntax = Syntax(sourceFile) + + // Create visitor to traverse AST and extract structured information + let visitor = TokenVisitor( + locationConverter: SourceLocationConverter( + fileName: fileName, + tree: sourceFile + ), + showMissingTokens: false + ) + + // Traverse the syntax tree and build our simplified representation + _ = visitor.rewrite(syntax) + + // Return the tree nodes directly + return visitor.tree + } +} + +// MARK: - Structure Extraction Extensions + +extension TreeNodeProtocol { + // MARK: - Structure Extraction + + /// Appends structural information from a SwiftSyntax node to the structure array. + /// + /// This method analyzes the node's internal structure and converts it into + /// a simplified format with named properties and values, appending them to + /// the structure array. It handles different structure types (layout, collection, + /// choices) and processes their properties according to their specific requirements. + /// + /// - Parameters: + /// - node: The SwiftSyntax node to analyze + /// - allChildren: All child nodes of the syntax node + package func appendStructure( + from node: Syntax, + allChildren: SyntaxChildren + ) { + switch node.syntaxNodeType.structure { + case .layout(let keyPaths): + // Handle nodes with fixed structure (most syntax nodes) + appendLayoutStructure( + node: node, + keyPaths: keyPaths, + allChildren: allChildren + ) + case .collection(let syntax): + // Handle collection nodes (lists, arrays, etc.) + appendCollectionStructure( + elementType: syntax, + allChildren: allChildren + ) + case .choices: + // Handle choice nodes (union types) - no special processing needed + break + } + } + + // MARK: - Layout Structure Appending + + /// Appends structure properties for layout-based syntax nodes. + /// + /// Layout nodes have a fixed set of named properties (like function parameters, + /// variable names, etc.). This method iterates through each property, extracts + /// its value, and appends appropriate StructureProperty entries to the structure array. + /// + /// - Parameters: + /// - node: The syntax node to process + /// - keyPaths: The layout key paths to process + /// - allChildren: All child nodes for reference checking + private func appendLayoutStructure( + node: Syntax, + keyPaths: [AnyKeyPath], + allChildren: SyntaxChildren + ) { + guard let syntaxNode = node.as(node.syntaxNodeType) else { + return + } + + for keyPath in keyPaths { + appendKeyPathProperty( + keyPath: keyPath, + syntaxNode: syntaxNode, + allChildren: allChildren + ) + } + } + + private func appendKeyPathValue(_ anyValue: Any?, withName name: String) { + switch anyValue { + case let value as TokenSyntax: + // Handle token nodes (keywords, identifiers, operators, etc.) + structure.append( + StructureProperty( + token: name, + tokenSyntax: value + ) + ) + case let value as any SyntaxProtocol: + // Handle nested syntax nodes - store type reference + structure.append( + StructureProperty(reference: name, type: value.syntaxNodeType) + ) + case let value?: + // Handle primitive values + structure.append( + StructureProperty(primitive: name, value: value) + ) + case .none: + // Property exists but is nil + structure.append(StructureProperty(name: name)) + } + } + + /// Appends a structure property for a single key path from a syntax node. + /// + /// This method handles the extraction of a single property value from a syntax node, + /// including checking for child node existence, handling different value types + /// (tokens, syntax nodes, primitives), and appending appropriate StructureProperty + /// entries to the structure array. + /// + /// - Parameters: + /// - keyPath: The key path to process + /// - syntaxNode: The syntax node to extract the value from + /// - allChildren: All child nodes for reference checking + private func appendKeyPathProperty( + keyPath: AnyKeyPath, + syntaxNode: any SyntaxProtocol, + allChildren: SyntaxChildren + ) { + guard let name = String(keyPath) else { + return + } + + // Check if this property has an actual child node + guard allChildren.contains(where: { child in child.keyPathInParent == keyPath }) else { + // Property exists but has no value - mark as nil + structure.append( + StructureProperty(nilValueWithName: name) + ) + return + } + + // Extract the actual property value + let keyPath = keyPath as AnyKeyPath + appendKeyPathValue(syntaxNode[keyPath: keyPath], withName: name) + } + + // MARK: - Collection Structure Appending + + /// Appends structure properties for collection-based syntax nodes. + /// + /// Collection nodes contain multiple elements of the same type (like parameter lists, + /// statement blocks, etc.). This method appends metadata about the collection + /// including element type and count information to the structure array. + /// + /// - Parameters: + /// - node: The syntax node to process + /// - elementType: The type of elements in the collection + /// - allChildren: All child nodes for counting + private func appendCollectionStructure( + elementType: Any.Type, + allChildren: SyntaxChildren + ) { + // Mark as collection type + type = .collection + + // Add element type information + structure.append( + StructureProperty(elementWithType: elementType) + ) + + // Add count information + structure.append( + StructureProperty(collectionWithCount: allChildren.count) + ) + } +} + +extension String { + fileprivate static let defaultFileName = "" + + /// Creates a human-readable name from a SwiftSyntax key path. + /// + /// This initializer attempts to derive a meaningful property name from a key path + /// by converting it to a string and extracting the last component. + /// + /// - Parameter keyPath: The key path to extract a name from + /// - Returns: A string representation of the property name, or nil if extraction fails + fileprivate init?(_ keyPath: AnyKeyPath) { + let keyPathString = String(describing: keyPath) + + // Extract the last component after the last dot + if let lastDotIndex = keyPathString.lastIndex(of: ".") { + let afterDot = keyPathString[keyPathString.index(after: lastDotIndex)...] + self = String(afterDot) + } else { + // If no dots found, use the whole string + guard !keyPathString.isEmpty else { + return nil + } + self = keyPathString + } + } +} From 7424ebb015132caf5a42ba5af976aa645488564a Mon Sep 17 00:00:00 2001 From: leogdion Date: Tue, 16 Sep 2025 15:24:14 -0400 Subject: [PATCH 02/10] Add SwiftSyntax LLM Documentation (#104) * Upload LLM Content for SwiftSyntax * Update Swift-Build Version --- .github/workflows/SyntaxKit.yml | 6 +- CLAUDE.md | 195 + Docs/SwiftSyntax-LLM.md | 27825 ++++++++++++++++ .../IdentifierPatternSyntax.swift | 2 +- .../IdentifierTypeSyntax.swift | 2 +- .../VariableDeclSyntax.swift | 2 +- 6 files changed, 28026 insertions(+), 6 deletions(-) create mode 100644 Docs/SwiftSyntax-LLM.md diff --git a/.github/workflows/SyntaxKit.yml b/.github/workflows/SyntaxKit.yml index 6acc7f1..5ca13c2 100644 --- a/.github/workflows/SyntaxKit.yml +++ b/.github/workflows/SyntaxKit.yml @@ -23,7 +23,7 @@ jobs: nightly: true steps: - uses: actions/checkout@v4 - - uses: brightdigit/swift-build@v1.3.0 + - uses: brightdigit/swift-build@v1.3.1 - uses: sersoft-gmbh/swift-coverage-action@v4 id: coverage-files with: @@ -50,7 +50,7 @@ jobs: swift-build: 6.1-RELEASE steps: - uses: actions/checkout@v4 - - uses: brightdigit/swift-build@v1.3.0 + - uses: brightdigit/swift-build@v1.3.1 with: windows-swift-version: ${{ matrix.swift-version }} windows-swift-build: ${{ matrix.swift-build }} @@ -130,7 +130,7 @@ jobs: - uses: actions/checkout@v4 - name: Build and Test - uses: brightdigit/swift-build@v1.3.0 + uses: brightdigit/swift-build@v1.3.1 with: scheme: ${{ env.PACKAGE_NAME }}-Package type: ${{ matrix.type }} diff --git a/CLAUDE.md b/CLAUDE.md index 4c2f4ad..d05d27b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -102,6 +102,201 @@ Sources/SyntaxKit/ - Integration tests in `Tests/SyntaxKitTests/Integration/` - Comprehensive CI/CD with GitHub Actions +## SwiftSyntax Reference + +> **Full Documentation**: [SwiftSyntax 601.0.1 Documentation](https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax) +> **Local Reference**: [docs/SwiftSyntax-LLM.md](Docs/SwiftSyntax-LLM.md) - Complete SwiftSyntax API reference (590KB) + +### Core Concepts +SwiftSyntax is Apple's source-accurate tree representation of Swift source code, enabling parsing, inspection, generation, and transformation of Swift code programmatically. + +### Key Types & Protocols + +#### Syntax Foundation +- `Syntax` - Base protocol for all syntax nodes +- `SyntaxProtocol` - Protocol all syntax nodes conform to +- `SyntaxCollection` - Collection of syntax nodes +- `SyntaxChildren` - Collection of child syntax nodes + +#### Tokens & Trivia +- `TokenSyntax` - Single token representation +- `TokenKind` - Enumerates Swift language token types +- `Trivia` - Whitespace, comments, and other non-semantic content +- `TriviaPiece` - Individual trivia element +- `SourcePresence` - Indicates if node was found in source + +#### Major Syntax Categories + +**Declarations (`DeclSyntax`)** +- `ClassDeclSyntax` - Class declarations +- `StructDeclSyntax` - Struct declarations +- `EnumDeclSyntax` - Enum declarations +- `ProtocolDeclSyntax` - Protocol declarations +- `FunctionDeclSyntax` - Function declarations +- `VariableDeclSyntax` - Variable declarations +- `ImportDeclSyntax` - Import statements +- `ExtensionDeclSyntax` - Extension declarations +- `TypeAliasDeclSyntax` - Type alias declarations +- `AssociatedTypeDeclSyntax` - Associated type declarations +- `OperatorDeclSyntax` - Operator declarations +- `PrecedenceGroupDeclSyntax` - Precedence group declarations +- `MacroDeclSyntax` - Macro declarations +- `MacroExpansionDeclSyntax` - Macro expansion declarations + +**Expressions (`ExprSyntax`)** +- `FunctionCallExprSyntax` - Function calls +- `MemberAccessExprSyntax` - Member access (dot notation) +- `SubscriptCallExprSyntax` - Subscript calls +- `BinaryOperatorExprSyntax` - Binary operators +- `PrefixOperatorExprSyntax` - Prefix operators +- `PostfixOperatorExprSyntax` - Postfix operators +- `TernaryExprSyntax` - Ternary operator expressions +- `ArrayExprSyntax` - Array literals +- `DictionaryExprSyntax` - Dictionary literals +- `StringLiteralExprSyntax` - String literals +- `IntegerLiteralExprSyntax` - Integer literals +- `FloatLiteralExprSyntax` - Float literals +- `BooleanLiteralExprSyntax` - Boolean literals +- `NilLiteralExprSyntax` - Nil literals +- `ClosureExprSyntax` - Closure expressions +- `IfExprSyntax` - If expressions +- `SwitchExprSyntax` - Switch expressions +- `TryExprSyntax` - Try expressions +- `AwaitExprSyntax` - Await expressions +- `KeyPathExprSyntax` - Key path expressions +- `RegexLiteralExprSyntax` - Regex literals + +**Statements (`StmtSyntax`)** +- `ExpressionStmtSyntax` - Expression statements +- `IfStmtSyntax` - If statements +- `GuardStmtSyntax` - Guard statements +- `WhileStmtSyntax` - While loops +- `ForStmtSyntax` - For loops +- `RepeatStmtSyntax` - Repeat-while loops +- `DoStmtSyntax` - Do statements +- `ReturnStmtSyntax` - Return statements +- `ThrowStmtSyntax` - Throw statements +- `BreakStmtSyntax` - Break statements +- `ContinueStmtSyntax` - Continue statements +- `DeferStmtSyntax` - Defer statements +- `DiscardStmtSyntax` - Discard statements +- `YieldStmtSyntax` - Yield statements + +**Types (`TypeSyntax`)** +- `IdentifierTypeSyntax` - Named types +- `ArrayTypeSyntax` - Array types +- `DictionaryTypeSyntax` - Dictionary types +- `TupleTypeSyntax` - Tuple types +- `FunctionTypeSyntax` - Function types +- `AttributedTypeSyntax` - Types with attributes +- `OptionalTypeSyntax` - Optional types +- `ImplicitlyUnwrappedOptionalTypeSyntax` - IUO types +- `CompositionTypeSyntax` - Protocol composition types +- `PackExpansionTypeSyntax` - Pack expansion types +- `PackElementTypeSyntax` - Pack element types +- `MetatypeTypeSyntax` - Metatype types + +**Patterns (`PatternSyntax`)** +- `IdentifierPatternSyntax` - Identifier patterns +- `ExpressionPatternSyntax` - Expression patterns +- `ValueBindingPatternSyntax` - Value binding patterns +- `TuplePatternSyntax` - Tuple patterns +- `WildcardPatternSyntax` - Wildcard patterns +- `IsTypePatternSyntax` - Type checking patterns + +#### Collections & Lists +- `AttributeListSyntax` - Attribute lists +- `CodeBlockItemListSyntax` - Code block items +- `MemberBlockItemListSyntax` - Member block items +- `ParameterListSyntax` - Parameter lists +- `GenericParameterListSyntax` - Generic parameter lists +- `GenericRequirementListSyntax` - Generic requirement lists +- `SwitchCaseListSyntax` - Switch case lists +- `CatchClauseListSyntax` - Catch clause lists +- `ArrayElementListSyntax` - Array element lists +- `DictionaryElementListSyntax` - Dictionary element lists + +#### Visitors & Transformers +- `SyntaxVisitor` - Base visitor class for traversing syntax trees +- `SyntaxAnyVisitor` - Generic visitor for any syntax node +- `SyntaxRewriter` - Transformer for modifying syntax trees +- `SyntaxTreeViewMode` - Controls how missing/unexpected nodes are handled + +### Common Patterns + +#### Creating Syntax Nodes +```swift +// Create a simple identifier +let identifier = TokenSyntax.identifier("myVariable") + +// Create a string literal +let stringLiteral = StringLiteralExprSyntax( + openingQuote: .stringQuoteToken(), + segments: StringLiteralSegmentListSyntax([ + StringSegmentSyntax(content: .stringSegment("Hello")) + ]), + closingQuote: .stringQuoteToken() +) + +// Create a function call +let functionCall = FunctionCallExprSyntax( + calledExpression: DeclReferenceExprSyntax( + baseName: .identifier("print") + ), + leftParen: .leftParenToken(), + arguments: LabeledExprListSyntax([ + LabeledExprSyntax(expression: stringLiteral) + ]), + rightParen: .rightParenToken() +) +``` + +#### Traversing Syntax Trees +```swift +class MyVisitor: SyntaxVisitor { + override func visit(_ node: FunctionDeclSyntax) -> SyntaxVisitorContinueKind { + print("Found function: \(node.name)") + return .visitChildren + } + + override func visit(_ node: VariableDeclSyntax) -> SyntaxVisitorContinueKind { + print("Found variable declaration") + return .visitChildren + } +} + +// Usage +let visitor = MyVisitor() +visitor.walk(syntaxTree) +``` + +#### Modifying Syntax Trees +```swift +class MyRewriter: SyntaxRewriter { + override func visit(_ node: StringLiteralExprSyntax) -> ExprSyntax { + // Transform string literals + let newContent = node.segments.map { segment in + // Modify content as needed + return segment + } + return node.with(\.segments, StringLiteralSegmentListSyntax(newContent)) + } +} + +// Usage +let rewriter = MyRewriter() +let modifiedTree = rewriter.visit(syntaxTree) +``` + +### Integration with SyntaxKit + +When working with SyntaxKit, remember: +- All `CodeBlock` implementations should generate valid SwiftSyntax nodes +- Use the appropriate SwiftSyntax types for each language construct +- Leverage SwiftSyntax's type safety for compile-time validation +- Consider using `SyntaxRewriter` for complex transformations +- Use `SyntaxVisitor` for analysis and inspection tasks + ## Task Master AI Instructions **Import Task Master's development workflow commands and guidelines, treat as if import is in the main CLAUDE.md file.** @./.taskmaster/CLAUDE.md diff --git a/Docs/SwiftSyntax-LLM.md b/Docs/SwiftSyntax-LLM.md new file mode 100644 index 0000000..ac5a8d5 --- /dev/null +++ b/Docs/SwiftSyntax-LLM.md @@ -0,0 +1,27825 @@ + + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax + +Framework + +# SwiftSyntax + +A library for working with Swift code. + +## Overview + +SwiftSyntax is a source accurate tree representation of Swift source code. It allows Swift tools to parse, inspect, generate, and transform Swift source code. + +## Topics + +### Articles + +Working with SwiftSyntax + +Learn the basics of working with Swift source code with the SwiftSyntax library. + +Updating a Macro to a New Major swift-syntax Version + +Guidance of how to version macros when a new major swift-syntax version is released. + +Raw Syntax Validation for Macro Testing + +A guide to using `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` in third-party Swift macro packages. + +Glossary + +Glossary of terms and abbreviations used in SwiftSyntax + +### Tutorials + +Introduction to SwiftSyntax + +SwiftSyntax provides the foundation for tools that inspect, manipulate, and transform Swift source code. + +### Syntax + +Syntax + +`protocol SyntaxCollection` + +### Trivia + +Trivia + +`enum TriviaPiece` + +A contiguous stretch of a single kind of trivia. The constituent part of a `Trivia` collection. + +`enum TriviaPosition` + +### Tokens + +`struct TokenSyntax` + +A Syntax node representing a single token. + +`enum TokenKind` + +Enumerates the kinds of tokens in the Swift language. + +`struct TokenSequence` + +Sequence of tokens that are part of the provided Syntax node. + +`enum SourcePresence` + +An indicator of whether a Syntax node was found or written in the source. + +### Syntax Visitors + +`class SyntaxVisitor` + +`class SyntaxAnyVisitor` + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +`class SyntaxRewriter` + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +`enum SyntaxTreeViewMode` + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +`enum SyntaxVisitorContinueKind` + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +`struct MacroDeclSyntax` + +`struct MacroExpansionDeclSyntax` + +The expansion of a freestanding macro in a position that expects a declaration. + +`struct OperatorDeclSyntax` + +A Swift `operator` declaration. + +`struct PoundSourceLocationSyntax` + +`struct PrecedenceGroupDeclSyntax` + +A Swift `precedencegroup` declaration. + +`struct ProtocolDeclSyntax` + +A `protocol` declaration + +`struct StructDeclSyntax` + +A `struct` declaration + +`struct SubscriptDeclSyntax` + +`struct TypeAliasDeclSyntax` + +`struct VariableDeclSyntax` + +Declaration of one or more variables + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +`struct DiscardAssignmentExprSyntax` + +A `_` that discards a value inside an assignment. + +`struct EditorPlaceholderExprSyntax` + +`struct FloatLiteralExprSyntax` + +`struct ForceUnwrapExprSyntax` + +`struct FunctionCallExprSyntax` + +`struct GenericSpecializationExprSyntax` + +`struct IfExprSyntax` + +`struct InOutExprSyntax` + +An expression prefixed with `&` to pass an argument to an `inout` parameter. + +`struct InfixOperatorExprSyntax` + +An infix operator call like `1 + 2`. + +`struct IntegerLiteralExprSyntax` + +`struct IsExprSyntax` + +Checks if an expression is of a given type. + +`struct KeyPathExprSyntax` + +A key path. + +`struct MacroExpansionExprSyntax` + +The expansion of a freestanding macro in a position that expects an expression. + +`struct MemberAccessExprSyntax` + +An expression that access a member like a function or a property. + +`struct NilLiteralExprSyntax` + +`struct OptionalChainingExprSyntax` + +`struct PackElementExprSyntax` + +A pack element expression spelled with `each`. + +`struct PackExpansionExprSyntax` + +A pack expansion expression spelled with `repeat`. + +`struct PatternExprSyntax` + +`struct PostfixIfConfigExprSyntax` + +`struct PostfixOperatorExprSyntax` + +`struct PrefixOperatorExprSyntax` + +A prefix operator applied to a value. + +`struct RegexLiteralExprSyntax` + +`struct SequenceExprSyntax` + +A flat list of expressions before operator folding using the `SwiftOperators` library. + +`struct SimpleStringLiteralExprSyntax` + +A simple string that can’t contain string interpolation and cannot have raw string delimiters. + +`struct StringLiteralExprSyntax` + +A string literal. + +`struct SubscriptCallExprSyntax` + +`struct SuperExprSyntax` + +`struct SwitchExprSyntax` + +A `switch` expression. + +`struct TernaryExprSyntax` + +The ternary operator with operator precedences resolved. + +`struct TryExprSyntax` + +An expression prefixed with `try`. + +`struct TupleExprSyntax` + +`struct TypeExprSyntax` + +`struct UnresolvedAsExprSyntax` + +The `as` keyword without any operands. + +`struct UnresolvedIsExprSyntax` + +The `is` keyword without any operands. + +`struct UnresolvedTernaryExprSyntax` + +The middle section of a ternary operator between `?` and `:`. + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +`struct WhileStmtSyntax` + +`struct YieldStmtSyntax` + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +`struct PackExpansionTypeSyntax` + +`struct SomeOrAnyTypeSyntax` + +`struct SuppressedTypeSyntax` + +`struct TupleTypeSyntax` + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +`struct ClosureParameterSyntax` + +`struct ClosureShorthandParameterListSyntax` + +A list of closure parameters that are not parenthesized and don’t have type annotations. + +`struct ClosureShorthandParameterSyntax` + +`struct CodeBlockItemListSyntax` + +`struct CodeBlockItemSyntax` + +A CodeBlockItem is any Syntax node that appears on its own line inside a CodeBlock. + +`struct CompositionTypeElementListSyntax` + +`struct CompositionTypeElementSyntax` + +`struct ConditionElementListSyntax` + +`struct ConditionElementSyntax` + +`struct DeclModifierListSyntax` + +`struct DeclModifierSyntax` + +`struct DeclNameArgumentListSyntax` + +`struct DeclNameArgumentSyntax` + +`struct DesignatedTypeListSyntax` + +`struct DesignatedTypeSyntax` + +`struct DictionaryElementListSyntax` + +`struct DictionaryElementSyntax` + +An element inside a dictionary literal. + +`struct DifferentiabilityArgumentListSyntax` + +`struct DifferentiabilityArgumentSyntax` + +A differentiability argument: either the “self” identifier, a function parameter name, or a function parameter index. + +`struct DocumentationAttributeArgumentListSyntax` + +The arguments of the ‘@\_documentation’ attribute + +`struct DocumentationAttributeArgumentSyntax` + +`struct EffectsAttributeArgumentListSyntax` + +The arguments of the ‘@\_effects’ attribute. These will be parsed during the SIL stage. + +`struct EnumCaseElementListSyntax` + +A collection of 0 or more `EnumCaseElementSyntax` s. + +`struct EnumCaseElementSyntax` + +An element of an enum case, containing the name of the case and, optionally, either associated values or an assignment to a raw value. + +`struct EnumCaseParameterListSyntax` + +`struct EnumCaseParameterSyntax` + +`struct ExprListSyntax` + +A list of expressions connected by operators. This list is contained by a `SequenceExprSyntax`. + +`struct FunctionParameterListSyntax` + +A list of function parameters that are type annotated and a label. The function parameters are represented by `FunctionParameterListSyntax`. + +`struct FunctionParameterSyntax` + +A function parameter + +`struct GenericArgumentListSyntax` + +`struct GenericArgumentSyntax` + +`struct GenericParameterListSyntax` + +`struct GenericParameterSyntax` + +`struct GenericRequirementListSyntax` + +`struct GenericRequirementSyntax` + +`struct IfConfigClauseListSyntax` + +`struct IfConfigClauseSyntax` + +`struct ImportPathComponentListSyntax` + +`struct ImportPathComponentSyntax` + +`struct InheritedTypeListSyntax` + +`struct InheritedTypeSyntax` + +`struct KeyPathComponentListSyntax` + +The components of a key path + +`struct KeyPathComponentSyntax` + +A single key path component + +`struct LabeledExprListSyntax` + +`struct LabeledExprSyntax` + +An expression that is prefixed by a label. + +`struct MemberBlockItemListSyntax` + +`struct MemberBlockItemSyntax` + +A member declaration of a type consisting of a declaration and an optional semicolon; + +`struct MultipleTrailingClosureElementListSyntax` + +`struct MultipleTrailingClosureElementSyntax` + +`struct ObjCSelectorPieceListSyntax` + +`struct ObjCSelectorPieceSyntax` + +A piece of an Objective-C selector. Either consisting of just an identifier for a nullary selector, an identifier and a colon for a labeled argument or just a colon for an unlabeled argument + +`struct PatternBindingListSyntax` + +`struct PatternBindingSyntax` + +Defines variables inside a variable declaration. + +`struct PlatformVersionItemListSyntax` + +`struct PlatformVersionItemSyntax` + +A single platform/version pair in an attribute, e.g. `iOS 10.1`. + +`struct PrecedenceGroupAttributeListSyntax` + +`struct PrecedenceGroupRelationSyntax` + +Specify the new precedence group’s relation to existing precedence groups. + +`struct PrecedenceGroupAssignmentSyntax` + +Specifies the precedence of an operator when used in an operation that includes optional chaining. + +`struct PrecedenceGroupAssociativitySyntax` + +Specifies how a sequence of operators with the same precedence level are grouped together in the absence of grouping parentheses. + +`struct PrecedenceGroupNameListSyntax` + +`struct PrecedenceGroupNameSyntax` + +`struct PrimaryAssociatedTypeListSyntax` + +`struct PrimaryAssociatedTypeSyntax` + +`struct SimpleStringLiteralSegmentListSyntax` + +String literal segments that only can contain non string interpolated or extended escaped strings + +`struct StringSegmentSyntax` + +A literal segment inside a string segment. + +`struct SpecializeAttributeArgumentListSyntax` + +A collection of arguments for the `@_specialize` attribute + +`struct LabeledSpecializeArgumentSyntax` + +A labeled argument for the `@_specialize` attribute like `exported: true` + +`struct SpecializeAvailabilityArgumentSyntax` + +The availability argument for the \_specialize attribute + +`struct SpecializeTargetFunctionArgumentSyntax` + +A labeled argument for the `@_specialize` attribute with a function decl value like `target: myFunc(_:)` + +`struct GenericWhereClauseSyntax` + +A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`. + +`struct StringLiteralSegmentListSyntax` + +`struct ExpressionSegmentSyntax` + +An interpolated expression inside a string literal. + +`struct SwitchCaseItemListSyntax` + +`struct SwitchCaseItemSyntax` + +`struct SwitchCaseListSyntax` + +`struct SwitchCaseSyntax` + +`struct TuplePatternElementListSyntax` + +A list of `TuplePatternElementSyntax`. + +`struct TuplePatternElementSyntax` + +An element that represents a single tuple value in `TuplePatternElementListSyntax`. + +`struct TupleTypeElementListSyntax` + +`struct TupleTypeElementSyntax` + +`struct TypeSpecifierListSyntax` + +`struct SimpleTypeSpecifierSyntax` + +A specifier that can be attached to a type to eg. mark a parameter as `inout` or `consuming` + +`struct UnexpectedNodesSyntax` + +A collection of syntax nodes that occurred in the source code but could not be used to form a valid syntax tree. + +`struct VersionComponentListSyntax` + +`struct VersionComponentSyntax` + +An element to represent a single component in a version, like `.1`. + +`struct YieldedExpressionListSyntax` + +`struct YieldedExpressionSyntax` + +### Attributes + +`struct BackDeployedAttributeArgumentsSyntax` + +A collection of arguments for the `@backDeployed` attribute + +`struct ConventionAttributeArgumentsSyntax` + +The arguments for the ‘@convention(…)’. + +`struct ConventionWitnessMethodAttributeArgumentsSyntax` + +The arguments for the ‘@convention(witness\_method: …)’. + +`struct DerivativeAttributeArgumentsSyntax` + +The arguments for the ‘@derivative(of:)’ and ‘@transpose(of:)’ attributes: the ‘of:’ label, the original declaration name, and an optional differentiability parameter list. + +`struct DifferentiabilityArgumentsSyntax` + +The differentiability arguments. + +`struct DifferentiabilityWithRespectToArgumentSyntax` + +A clause containing differentiability parameters. + +`struct DifferentiableAttributeArgumentsSyntax` + +The arguments for the `@differentiable` attribute: an optional differentiability kind, an optional differentiability parameter clause, and an optional ‘where’ clause. + +`struct DynamicReplacementAttributeArgumentsSyntax` + +The arguments for the ‘@\_dynamicReplacement’ attribute + +`struct ExposeAttributeArgumentsSyntax` + +The arguments for the ‘@\_expose’ attribute + +`struct ImplementsAttributeArgumentsSyntax` + +The arguments for the `@_implements` attribute of the form `Type, methodName(arg1Label:arg2Label:)` + +`struct OpaqueReturnTypeOfAttributeArgumentsSyntax` + +The arguments for the ‘@\_opaqueReturnTypeOf()’. + +`struct OriginallyDefinedInAttributeArgumentsSyntax` + +The arguments for the ‘@\_originallyDefinedIn’ attribute + +`struct UnavailableFromAsyncAttributeArgumentsSyntax` + +The arguments for the ‘@\_unavailableFromAsync’ attribute + +`struct UnderscorePrivateAttributeArgumentsSyntax` + +The arguments for the ‘@\_private’ attribute + +### Miscellaneous Syntax + +`struct AccessorBlockSyntax` + +`struct AccessorEffectSpecifiersSyntax` + +`struct AccessorParametersSyntax` + +`struct AvailabilityConditionSyntax` + +`struct AvailabilityLabeledArgumentSyntax` + +An argument to an `@available` attribute that consists of a label and a value, e.g. `message: "This has been deprecated"`. + +`struct ClosureCaptureClauseSyntax` + +`struct ClosureCaptureSpecifierSyntax` + +`struct ClosureParameterClauseSyntax` + +`struct ClosureSignatureSyntax` + +`struct CodeBlockSyntax` + +`struct ConformanceRequirementSyntax` + +`struct DeclModifierDetailSyntax` + +`struct DeclNameArgumentsSyntax` + +`struct DeinitializerEffectSpecifiersSyntax` + +`struct EnumCaseParameterClauseSyntax` + +`struct FunctionEffectSpecifiersSyntax` + +`struct FunctionParameterClauseSyntax` + +`struct FunctionSignatureSyntax` + +A function signature that defines the interface of the function. + +`struct GenericArgumentClauseSyntax` + +`struct GenericParameterClauseSyntax` + +The parameter clause that defines the generic parameters. + +`struct InheritanceClauseSyntax` + +`struct InitializerClauseSyntax` + +`struct KeyPathOptionalComponentSyntax` + +A key path component like `?` or `!`. + +`struct KeyPathPropertyComponentSyntax` + +A key path component like `.property` or `.1`. + +`struct KeyPathSubscriptComponentSyntax` + +A key path component like `.[17]` + +`struct LayoutRequirementSyntax` + +`struct MatchingPatternConditionSyntax` + +`struct MemberBlockSyntax` + +`struct MissingSyntax` + +In case the source code is missing a syntax node, this node stands in place of the missing node. + +`struct OperatorPrecedenceAndTypesSyntax` + +A clause to specify precedence group in infix operator declarations, and designated types in any operator declaration. + +`struct OptionalBindingConditionSyntax` + +`struct PlatformVersionSyntax` + +An argument to `@available` that restricts the availability on a certain platform to a version, e.g. `iOS 10` or `swift 3.4`. + +`struct PoundSourceLocationArgumentsSyntax` + +`struct PrimaryAssociatedTypeClauseSyntax` + +`struct ReturnClauseSyntax` + +`struct SameTypeRequirementSyntax` + +`struct SourceFileSyntax` + +`struct SwitchCaseLabelSyntax` + +`struct SwitchDefaultLabelSyntax` + +`struct ThrowsClauseSyntax` + +`struct TypeAnnotationSyntax` + +`struct TypeEffectSpecifiersSyntax` + +`struct TypeInitializerClauseSyntax` + +`struct VersionTupleSyntax` + +A version number like `1.2.0`. Only the first version component is required. There might be an arbitrary number of following components. + +`struct WhereClauseSyntax` + +`struct YieldedExpressionsClauseSyntax` + +### Traits + +`protocol BracedSyntax` + +`protocol DeclGroupSyntax` + +`protocol EffectSpecifiersSyntax` + +`protocol FreestandingMacroExpansionSyntax` + +`protocol NamedDeclSyntax` + +`protocol MissingNodeSyntax` + +Represents a layout node that is missing in the source file. + +`protocol ParenthesizedSyntax` + +`protocol WithAttributesSyntax` + +`protocol WithCodeBlockSyntax` + +`protocol WithGenericParametersSyntax` + +Syntax nodes that have generic parameters. + +`protocol WithModifiersSyntax` + +`protocol WithOptionalCodeBlockSyntax` + +`protocol WithStatementsSyntax` + +`protocol WithTrailingCommaSyntax` + +### Syntax Position + +`struct AbsolutePosition` + +An absolute position in a source file as text - the absolute utf8Offset from the start of the file. + +`typealias ByteSourceRange` Deprecated + +`struct SourceLocation` + +Represents a source location in a Swift file. + +`class SourceLocationConverter` + +Converts `AbsolutePosition` s of syntax nodes to `SourceLocation` s, and vice-versa. The `AbsolutePosition` s must be originating from nodes that are part of the same tree that was used to initialize this class. + +`struct SourceRange` + +Represents a half-open range in a Swift file. + +`struct SourceLength` + +The length a syntax node spans in the source code. From any AbsolutePosition you reach a node’s end location by adding its UTF-8 length. + +### Internals + +`protocol SyntaxProtocol` + +Provide common functionality for specialized syntax nodes. Extend this protocol to provide common functionality for all syntax nodes. + +`class SyntaxArena` + +A syntax arena owns the memory for all syntax nodes within it. + +`enum SyntaxEnum` + +Enum to exhaustively switch over all different syntax nodes. + +`protocol SyntaxHashable` + +Protocol that provides a common Hashable implementation for all syntax nodes + +`struct SyntaxIdentifier` + +Provides a stable and unique identity for `Syntax` nodes. + +### Classes + +`class ParsingSyntaxArena` + +SyntaxArena for parsing. + +### Protocols + +`protocol SyntaxChildChoices` + +Protocol for the enums nested inside `Syntax` nodes that enumerate all the possible types a child node might have. + +### Structures + +`struct Identifier` + +A canonicalized representation of an identifier that strips away backticks. + +`struct SourceEdit` + +A textual edit to the original source represented by a range and a replacement. + +`struct SyntaxCollectionIterator` + +An iterator over a `SyntaxCollection`. + +`struct TokenDiagnostic` + +If the token has an error that’s inherent to the token itself and not its surrounding structure, this defines the type of the error. `byteOffset` specifies at which offset the error occurred. + +### Functions + +An assertion that is active in DEBUG builds, just like `Swift.assert` and additionally if assertions are explicitly requested by setting the `SWIFTSYNTAX_ENABLE_ASSERTIONS` conditional compilation flag. Use this instead of `precondition` in places where the assertion has a non-trivial cost but provides little value in release builds. + +An assertion that is active in DEBUG builds, just like `Swift.assertionFailure` and additionally if assertions are explicitly requested by setting the `SWIFTSYNTAX_ENABLE_ASSERTIONS` conditional compilation flag. + +Returns the bottommost node whose subtree contains all nodes in `nodes`. + +Returns the bottommost node whose subtree contains both `lhs` and `rhs`. + +Override Swift’s `precondition` with slightly changed semantics. In release builds, it also emits the error message upon failure, like `fatalError`. It can also be disabled by setting the `SWIFTSYNTAX_DISABLE_PRECONDITION` conditional compilation flag. Note that `SWIFTSYNTAX_DISABLE_PRECONDITION` does not disable `preconditionFailure`. + +### Type Aliases + +`typealias AccessPathComponentSyntax` Deprecated + +`typealias AccessPathSyntax` + +Deprecated + +`typealias AccessorListSyntax` Deprecated + +`typealias AccessorParameterSyntax` Deprecated + +`typealias AssociatedtypeDeclSyntax` Deprecated + +`typealias AttributedSyntax` Deprecated + +`typealias AvailabilityEntrySyntax` Deprecated + +`typealias AvailabilitySpecListSyntax` Deprecated + +`typealias AvailabilityVersionRestrictionListEntrySyntax` Deprecated + +`typealias AvailabilityVersionRestrictionListSyntax` Deprecated + +`typealias AvailabilityVersionRestrictionSyntax` Deprecated + +`typealias BackDeployedAttributeSpecListSyntax` Deprecated + +`typealias CanImportExprSyntax` Deprecated + +`typealias CanImportVersionInfoSyntax` Deprecated + +`typealias CaseItemListSyntax` Deprecated + +`typealias CaseItemSyntax` Deprecated + +`typealias ClosureCaptureItemListSyntax` Deprecated + +`typealias ClosureCaptureItemSpecifierSyntax` Deprecated + +`typealias ClosureCaptureItemSyntax` Deprecated + +`typealias ClosureCaptureSignatureSyntax` Deprecated + +`typealias ClosureParamListSyntax` Deprecated + +`typealias ClosureParamSyntax` Deprecated + +`typealias ConstrainedSugarTypeSyntax` Deprecated + +`typealias DeinitEffectSpecifiersSyntax` Deprecated + +`typealias DerivativeRegistrationAttributeArgumentsSyntax` Deprecated + +`typealias DesignatedTypeElementSyntax` Deprecated + +`typealias DifferentiabilityParamListSyntax` Deprecated + +`typealias DifferentiabilityParamSyntax` Deprecated + +`typealias DifferentiabilityParamsClauseSyntax` Deprecated + +`typealias DifferentiabilityParamsSyntax` Deprecated + +`typealias DocumentationAttributeArgumentsSyntax` Deprecated + +`typealias DynamicReplacementArgumentsSyntax` Deprecated + +`typealias EffectsArgumentsSyntax` Deprecated + +`typealias EnumCaseAssociatedValueSyntax` Deprecated + +`typealias FallthroughStmtSyntax` Deprecated + +`typealias ForInStmtSyntax` Deprecated + +`typealias ForcedValueExprSyntax` Deprecated + +`typealias IdentifiedDeclSyntax` Deprecated + +`typealias IdentifierExprSyntax` Deprecated + +`typealias IncrementalEdit` Deprecated + +`typealias LabeledSpecializeEntrySyntax` Deprecated + +`typealias MemberDeclBlockSyntax` Deprecated + +`typealias MemberDeclListItemSyntax` Deprecated + +`typealias MemberDeclListSyntax` Deprecated + +`typealias MemberTypeIdentifierSyntax` Deprecated + +`typealias ModifierListSyntax` Deprecated + +`typealias MoveExprSyntax` Deprecated + +`typealias ObjCSelectorSyntax` Deprecated + +`typealias OriginallyDefinedInArgumentsSyntax` Deprecated + +`typealias PackReferenceTypeSyntax` Deprecated + +`typealias ParameterClauseSyntax` Deprecated + +`typealias PostfixUnaryExprSyntax` Deprecated + +`typealias PoundSourceLocationArgsSyntax` Deprecated + +`typealias PrecedenceGroupNameElementSyntax` Deprecated + +`typealias RepeatWhileStmtSyntax` Deprecated + +`typealias SimpleTypeIdentifierSyntax` Deprecated + +`typealias SpecializeAttributeSpecListSyntax` Deprecated + +`typealias SpecializeExprSyntax` Deprecated + +`typealias StringLiteralSegmentsSyntax` Deprecated + +`typealias SubscriptExprSyntax` Deprecated + +`typealias SuperRefExprSyntax` Deprecated + +`typealias TargetFunctionEntrySyntax` Deprecated + +`typealias TupleExprElementListSyntax` Deprecated + +`typealias TupleExprElementSyntax` Deprecated + +`typealias TypeInheritanceClauseSyntax` Deprecated + +`typealias TypeSpecifierSyntax` Deprecated + +`typealias TypealiasDeclSyntax` Deprecated + +`typealias UnavailableFromAsyncArgumentsSyntax` Deprecated + +`typealias UnresolvedPatternExprSyntax` Deprecated + +`typealias YieldExprListElementSyntax` Deprecated + +`typealias YieldExprListSyntax` Deprecated + +`typealias YieldListSyntax` Deprecated + +### Enumerations + +`enum DeclSyntaxEnum` + +Enum to exhaustively switch over all different Decl syntax nodes. + +`enum ExprSyntaxEnum` + +Enum to exhaustively switch over all different Expr syntax nodes. + +`enum Keyword` + +`enum PatternSyntaxEnum` + +Enum to exhaustively switch over all different Pattern syntax nodes. + +`enum StmtSyntaxEnum` + +Enum to exhaustively switch over all different Stmt syntax nodes. + +`enum SyntaxKind` + +Enumerates the known kinds of Syntax represented in the Syntax tree. + +`enum SyntaxNodeStructure` + +Describes the statically allowed structure of a syntax tree node. + +`enum TypeSyntaxEnum` + +Enum to exhaustively switch over all different Type syntax nodes. + +### Extended Modules + +Swift + +- SwiftSyntax +- Overview +- Topics + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/working-with-swiftsyntax + +- SwiftSyntax +- Working with SwiftSyntax + +Article + +# Working with SwiftSyntax + +Learn the basics of working with Swift source code with the SwiftSyntax library. + +## Overview + +The SwiftSyntax library provides data structures and algorithms for inspecting, processing, and manipulating Swift source code with a high-level, safe, and efficient API. The SwiftSyntax library is the foundation upon which tools like the Swift parser, swift-format, and Swift macros are built. + +## Syntax Trees + +SwiftSyntax is a library for representing Swift source code with a data structure called a _syntax tree_. The structure of a syntax tree reflects not just the relative order and position of text and whitespace in a file - its “lexical structure” - but also the relationship between nested syntactic elements and their neighbors - its “syntactic structure”. + +The syntax tree was designed with three tenets in mind: + +### Immutability + +The syntax tree is a fully immutable persistent data structure. Once created, the syntax tree never changes, and may only be modified by creating a new syntax tree. The SwiftSyntax library provides a number of APIs for modifying an existing syntax tree efficiently and safely. It does so by copying only the minimal amount of structure that has changed into the new tree. Any unchanged structure from the original tree becomes part of a shared core that is transparently wrapped by the new syntax tree. In this way, the SwiftSyntax library reuses and shares as much data as possible during syntactic transformations. This reduces the overall memory footprint and the overhead normally associated with copying large and complex data structures like syntax trees. + +Immutability also comes with the benefits of fearless concurrency. It is always safe to manipulate a syntax tree across threads. Two threads mutating the same tree will receive two independent copies of their respective modified syntax trees that will never interfere with each other. Moreover, modifications to the syntax tree do not involve locks or mutexes. + +### Source Fidelity + +The SwiftSyntax library is designed to represent not just text, but whitespace, comments, compiler directives, and otherwise invisible data like the Unicode byte order mark. Collectively, these non-syntax entities are referred to as “trivia”. The syntax tree holds on to every byte of information in the source text, and can render the original document with full accuracy and precision. This property is referred to as “source fidelity”, because the syntax tree is always a faithful recreation of the source code it was given as input. + +### Resilience + +To achieve source fidelity, both well-formed and ill-formed source code must be equally representable in the syntax tree. The syntax tree can represent two broad classes of errors: missing syntax and unexpected syntax. Missing syntax provides a spot for a syntax element that was expected by a parser or lexical analyzer but was not present in source. + +func (uhoh: Void) {} +^ Missing identifier + +Missing syntactic elements are represented in the tree as tokens with a `SourcePresence.missing` source presence. These missing tokens are just as much a part of the syntax tree as `SourcePresence.present` nodes, and can be inspected and manipulated as normal syntax. One important use-case is a “healing linter” which can examine missing nodes and fill in keywords, identifiers, and placeholders as appropriate in addition to warning about syntactic nits. + +Unexpected syntax is any superfluous text encountered by a parser or lexical analyzer. + +func four score and seven years ago(uhoh: Void) {} +^~~~~~~~~~~~~~~~~~~~~~~~~ Unexpected text + +Unexpected nodes allow parsers to gracefully recover during parsing by scanning forward in the input stream until they reach a known recovery point. The Swift parser included with the swift-syntax package uses this implementation strategy to great effect. This makes the parser resilient to a broad class of input errors that users of editors and IDEs would make during the course of an editing session. + +## Syntax Nodes + +A syntax tree is made up of elements called syntax nodes. To help categorize and organize syntax nodes, SwiftSyntax defines a hierarchy of protocols for syntax nodes. At the top of this hierarchy is the `SyntaxProtocol` protocol. To represent related categories of syntax, `SyntaxProtocol` is further refined: + +- `DeclSyntaxProtocol` for declarations like `struct` s, `class` es, `enum` s and `protocol` s. + +- `StmtSyntaxProtocol` for statements like `if`, `switch`, and `do`. + +- `ExprSyntaxProtocol` for expressions like function calls, literals, and closures + +- `PatternSyntaxProtocol` for patterns like `case (_, let x)` + +Syntax nodes form the “branches” of the syntax tree, as they are generally high-level collections of one or more syntax nodes. Taken together, these branches form the syntactic structure of the source code. This structure is used by compilers and static analyzers to process source code at a high level. + +A special kind of syntax node is a `SyntaxCollection`, which represents syntax with a variable number of children. For example, a code block value can contain zero or more statements in between a pair of braces. To represent these children, a `CodeBlockSyntax` value has a `statements` accessor that returns a `CodeBlockItemListSyntax` value. The elements of this syntax collection are `CodeBlockItemSyntax` values. + +## Syntax Tokens + +At the leaves of the syntax tree are `TokenSyntax` values. A token syntax value represents an atomic unit of syntax and any associated trivia, like an identifier and the whitespace around it. Taken together, the tokens of a syntax tree represent the lexical structure of the source code. This structure is used by linters and formatters to analyze the textual content of source code. + +## Syntax Trivia + +Trivia includes whitespace, comments, compiler directives, and erroneous source code. Trivia contributes most meaningfully to the lexical structure of a document, but often has little bearing on its syntactic structure. For this reason, tools like compilers often discard trivia during source code processing. However, maintaining trivia is important for tools like editors, IDEs, formatters, and refactoring engines. SwiftSyntax represents trivia explicitly with the `Trivia` type. Trivia associated with token syntax can be inspected with the `leadingTrivia` and `trailingTrivia` accessors. + +## Navigating the Syntax Tree + +The SwiftSyntax library provides a number of ways of traversing the syntactic structure of a syntax tree. Every syntax node includes a reference to its parent node via the `parent` accessor, and a reference to its child nodes via the `children(viewMode:)` method. The children of a syntax tree always appear in order and the associated `viewMode` allows the client to express their intent to process missing and unexpected syntax. + +Syntax nodes also contain strongly-typed APIs to access those same child nodes individually. For example, `ClassDeclSyntax` provides an `identifier` to get the name of the class, as well as `ClassDeclSyntax/members` to get the syntax node representing the braced block with its members. + +Most syntax analyzers want to work with more than one kind of syntax at a time, and traverse this syntax in a regular order starting from the root and working towards the leaves. SwiftSyntax provides a standard suite of classes and protocols for working with syntax traversals with a visitor-style API. + +A `SyntaxVisitor` can be used to walk source code from the root to its leaves. To inspect a particular kind of syntax node, a client needs to override the corresponding `visit` method accepting that kind of syntax. The visit methods are invoked as part of an in-order traversal of the syntax tree. To provide a post-order traversal, the corresponding `visitPost` methods can be overridden. + +Visitors that rewrite particular syntax nodes can be implemented as a subclass of `SyntaxRewriter`. Like a `SyntaxVisitor`, a client needs to override the corresponding `visit` method accepting the syntax node of interest, and return a rewritten syntax node as a result. + +## Modifying the Syntax Tree + +The syntax trees provided by the SwiftSyntax library are immutable. All modifications of the syntax tree are expressed as in-place updates to an existing syntax tree, and return new syntax trees. SwiftSyntax provides a set of high-level APIs for expressing these modifications. In general, data in syntax nodes can be accessed via a getter and updated with a corresponding `with*` method. For example, the name of a class can be retrieved with the `identifier` accessor, and replaced with the `ClassDeclSyntax/with(_:_:)-3exln` update function. This method returns a new `ClassDeclSyntax` value. + +## Building Syntax Trees + +The swift-syntax package provides the `SwiftParser` module to parse arbitrary source text into syntax trees. The Swift parser is appropriate for situations where code is provided by a user, or cannot otherwise by predicted ahead of time. However, there are often times when the structure of source code is known at build time. For these cases, the SwiftSyntax library provides a method for transparently interpreting string literals containing source code as syntax trees when the `SwiftSyntaxBuilder` module is also imported: + +import SwiftSyntax +import SwiftParser +import SwiftSyntaxBuilder + +// `file` is a source file syntax node containing the parsed value of the +// provided text. +let file: SourceFileSyntax = +""" +print("Hello, world!") +""" + +String processing is not limited to string literals. Further interior string interpolations can be used to parameterize the code in syntax generating functions. + +import SwiftSyntax +import SwiftParser + +return """ +class \(raw: name) {} +""" +} + +Using string literals and interpolation to build up syntax provides a fluid and natural API for building up complex syntax trees. This is generally preferred to transforming syntax trees via a chain of `with*` calls. + +## See Also + +### Articles + +Updating a Macro to a New Major swift-syntax Version + +Guidance of how to version macros when a new major swift-syntax version is released. + +Raw Syntax Validation for Macro Testing + +A guide to using `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` in third-party Swift macro packages. + +Glossary + +Glossary of terms and abbreviations used in SwiftSyntax + +- Working with SwiftSyntax +- Overview +- Syntax Trees +- Immutability +- Source Fidelity +- Resilience +- Syntax Nodes +- Syntax Tokens +- Syntax Trivia +- Navigating the Syntax Tree +- Modifying the Syntax Tree +- Building Syntax Trees +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/macro-versioning + +- SwiftSyntax +- Updating a Macro to a New Major swift-syntax Version + +Article + +# Updating a Macro to a New Major swift-syntax Version + +Guidance of how to version macros when a new major swift-syntax version is released. + +## Summary + +A macro can depend on multiple versions of swift-syntax. If it is affected by source-breaking changes in swift-syntax, it can check the version of swift-syntax it is compiling against using e.g. `#if canImport(SwiftSyntax510)`. + +## Detailed Explanation + +All the ideas described in the following apply to all packages that depend on swift-syntax, not only macros. + +For simplicity, this article assumes that 509 is the current swift-syntax version and 510 the next, but everything applies to any other major swift-syntax version update, including version jumps to e.g. 600. + +Any given version macro can depend on multiple major swift-syntax versions at once. For example, if a macro supports both swift-syntax 509 and swift-syntax 510, it may declare its dependency on swift-syntax as + +.package(url: "https://github.com/swiftlang/swift-syntax.git", "509.0.0"..<"511.0.0"), + +In order to handle breaking API changes, clients can wrap uses of such APIs in conditional compilation clauses that check the version of swift-syntax it is building against. All versions of swift-syntax ≥ 509 will include an empty `SwiftSyntaxVersion509` module, swift-syntax ≥ 510 will include both a `SwiftSyntaxVersion510` and `SwiftSyntaxVersion509` module, and so on for any new releases. This allows clients to write + +#elseif canImport(SwiftSyntax509) +// code to support swift-syntax version 509 + +#endif + +## Representation of New Syntax with Old swift-syntax Versions + +If a swift-syntax version is used that is older than the compiler’s version, then swift-syntax will not be able to represent the new syntactic structures (like new statements) in the source file because it doesn’t know about them. + +In this case, swift-syntax will represent the unknown syntactic constructs as a mixture of unexpected syntax nodes in the `unexpected*` children of the syntax nodes. Depending on the macro’s behavior this might not pose any issues. For example, if the macro adds an completion-handler alternative to an async function, it most likely doesn’t care if some statement in the body couldn’t be parsed, since it is only interested in the signature. + +## See Also + +### Articles + +Working with SwiftSyntax + +Learn the basics of working with Swift source code with the SwiftSyntax library. + +Raw Syntax Validation for Macro Testing + +A guide to using `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` in third-party Swift macro packages. + +Glossary + +Glossary of terms and abbreviations used in SwiftSyntax + +- Updating a Macro to a New Major swift-syntax Version +- Summary +- Detailed Explanation +- Representation of New Syntax with Old swift-syntax Versions +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/rawsyntaxvalidation + +- SwiftSyntax +- Raw Syntax Validation for Macro Testing + +Article + +# Raw Syntax Validation for Macro Testing + +A guide to using `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` in third-party Swift macro packages. + +## Introduction + +SwiftSyntax is designed with fault tolerance in mind. When developing macros, it’s generally robust enough to handle incorrect syntax trees without major issues. However, for developers who want to ensure they’re using the SwiftSyntax API as intended, there’s an additional validation tool available: the `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` environment variable. + +## What SWIFTSYNTAX\_ENABLE\_RAWSYNTAX\_VALIDATION does? + +This environment variable enables extra validation in SwiftSyntax during runtime. When activated, it checks: + +1. The correctness of each syntax node’s child kind. + +2. That tokens only use kinds specified in the CodeGeneration package’s syntax tree layout. + +## How to Use It + +If you decide to use this feature for testing, you can enable it by setting the environment variable when running your tests: + +SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION=true swift test + +## Example + +Consider these two syntax examples: + +Incorrect syntax: + +let asyncSpecifier: TokenSyntax = "async" + +Correct syntax: + +let asyncSpecifier: TokenSyntax = .keyword(.async) + +With raw syntax validation enabled, the incorrect syntax might produce an error like: + +Fatal error: Error validating child at index 1 of typeEffectSpecifiers: +Expected token with one of [keyword('async')] but received identifier with text 'async' + +This error helps identify that you’re using an identifier where a keyword is expected. The correct syntax uses `.keyword(.async)`, which properly specifies that ‘async’ should be treated as a keyword rather than an identifier. + +## Conclusion + +While `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` isn’t necessary for third-party macro packages, it can be a useful tool during development and testing. It helps ensure you’re using the SwiftSyntax API as intended and can catch subtle issues that might affect formatting. However, remember that it comes with a performance cost and isn’t recommended for use in production environments. + +## See Also + +### Articles + +Working with SwiftSyntax + +Learn the basics of working with Swift source code with the SwiftSyntax library. + +Updating a Macro to a New Major swift-syntax Version + +Guidance of how to version macros when a new major swift-syntax version is released. + +Glossary + +Glossary of terms and abbreviations used in SwiftSyntax + +- Raw Syntax Validation for Macro Testing +- Introduction +- What SWIFTSYNTAX\_ENABLE\_RAWSYNTAX\_VALIDATION does? +- How to Use It +- Example +- Conclusion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/glossary + +- SwiftSyntax +- Glossary + +Article + +# Glossary + +Glossary of terms and abbreviations used in SwiftSyntax + +## Abbreviations and Terms + +To avoid ongoing repetition of common long terms, SwiftSyntax uses a couple of abbreviations that are common in compiler projects. + +**Arena** See `SyntaxArena` + +**Decl** Abbreviation for _Declaration_ + +**Expr** Abbreviation for _Expression_ + +**IfConfig** Abbrevation for _If Configuration_. Refers to `#if` clauses in the source code. + +**Layout Node** A layout node can have an arbitrary number of children and provides structure to the syntax tree. All `Syntax` nodes that aren’t `TokenSyntax` are layout nodes. For example a `StructDeclSyntax` consists of, among others, of the `struct` keyword, the name and the `memberBlock`. The latter is again a layout node that contains multiple children. Layout nodes never represent any source code in the syntax tree by themselves. All source code within the syntax tree is represented by _tokens_. + +**Node** A _layout node_ or _token_ + +**RawSyntax** The underlying storage of syntax nodes. These are manually memory managed inside an _arena_. You should not need to interact with them unless contributing to swift-syntax. + +**Stmt** Abbreviation for _Statement_ + +**Token** See `TokenSyntax` + +**Trivia** See `Trivia` + +## See Also + +### Articles + +Working with SwiftSyntax + +Learn the basics of working with Swift source code with the SwiftSyntax library. + +Updating a Macro to a New Major swift-syntax Version + +Guidance of how to version macros when a new major swift-syntax version is released. + +Raw Syntax Validation for Macro Testing + +A guide to using `SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION` in third-party Swift macro packages. + +- Glossary +- Abbreviations and Terms +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/tutorials/tutorial-table-of-contents + +# Introduction to SwiftSyntax + +SwiftSyntax provides the foundation for tools that inspect, manipulate, and transform Swift source code. + +**15min** Estimated Time + +Get started + +## Chapter 1 SwiftSyntax By Example + +Explore the SwiftSyntax API by building a tool that sorts imports in a Swift file. + +1. SwiftSyntax By Example\\ +\\ +15min + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxcollection + +- SwiftSyntax +- SyntaxCollection + +Protocol + +# SyntaxCollection + +protocol SyntaxCollection : BidirectionalCollection, ExpressibleByArrayLiteral, SyntaxProtocol where Self.Element : SyntaxProtocol, Self.Index == SyntaxChildrenIndex + +SyntaxCollection.swift + +## Topics + +### Operators + +Creates a new collection by concatenating the elements of a sequence and a collection. + +Creates a new collection by concatenating the elements of a collection and a sequence. + +Appends the elements of a sequence to a range-replaceable collection. + +### Associated Types + +**Required** + +### Instance Methods + +`func append(Self.Element)` + +Adds an element to the end of the collection. + +Adds the elements of a sequence to the end of this collection. + +Creates a new collection by appending the provided syntax element to the children. + +Deprecated + +Returns a new `SyntaxCollection` that just contains the elements satisfying the given predicate. + +Returns the index of the n-th element in this collection. + +Return the index of `node` within this collection. + +`func insert(Self.Element, at: Self.Index)` + +Inserts a new element into the collection at the specified position. + +Inserts the elements of a sequence into the collection at the specified position. + +Creates a new collection by inserting the provided syntax element at the provided index in the children. + +Creates a new collection by prepending the provided syntax element to the children. + +Removes and returns the element at the specified position. + +Removes the elements in the specified subrange from the collection. + +Creates a new collection by removing the syntax element at the provided index. + +Creates a new collection by removing the first element. + +Creates a new collection by removing the last element. + +Replace the nodes in `subrange` by `newElements`. + +Creates a new collection by replacing the syntax element at the provided index. + +### Type Properties + +`static var syntaxKind: SyntaxKind` + +The `SyntaxKind` of the syntax node that conforms to `SyntaxCollection`. + +## Relationships + +### Inherits From + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Conforming Types + +- `AccessorDeclListSyntax` +- `ArrayElementListSyntax` +- `AttributeListSyntax` +- `AvailabilityArgumentListSyntax` +- `CatchClauseListSyntax` +- `CatchItemListSyntax` +- `ClosureCaptureListSyntax` +- `ClosureParameterListSyntax` +- `ClosureShorthandParameterListSyntax` +- `CodeBlockItemListSyntax` +- `CompositionTypeElementListSyntax` +- `ConditionElementListSyntax` +- `DeclModifierListSyntax` +- `DeclNameArgumentListSyntax` +- `DesignatedTypeListSyntax` +- `DictionaryElementListSyntax` +- `DifferentiabilityArgumentListSyntax` +- `DocumentationAttributeArgumentListSyntax` +- `EffectsAttributeArgumentListSyntax` +- `EnumCaseElementListSyntax` +- `EnumCaseParameterListSyntax` +- `ExprListSyntax` +- `FunctionParameterListSyntax` +- `GenericArgumentListSyntax` +- `GenericParameterListSyntax` +- `GenericRequirementListSyntax` +- `IfConfigClauseListSyntax` +- `ImportPathComponentListSyntax` +- `InheritedTypeListSyntax` +- `KeyPathComponentListSyntax` +- `LabeledExprListSyntax` +- `MemberBlockItemListSyntax` +- `MultipleTrailingClosureElementListSyntax` +- `ObjCSelectorPieceListSyntax` +- `PatternBindingListSyntax` +- `PlatformVersionItemListSyntax` +- `PrecedenceGroupAttributeListSyntax` +- `PrecedenceGroupNameListSyntax` +- `PrimaryAssociatedTypeListSyntax` +- `SimpleStringLiteralSegmentListSyntax` +- `SpecializeAttributeArgumentListSyntax` +- `StringLiteralSegmentListSyntax` +- `SwitchCaseItemListSyntax` +- `SwitchCaseListSyntax` +- `TuplePatternElementListSyntax` +- `TupleTypeElementListSyntax` +- `TypeSpecifierListSyntax` +- `UnexpectedNodesSyntax` +- `VersionComponentListSyntax` +- `YieldedExpressionListSyntax` + +## See Also + +### Syntax + +SwiftSyntax + +A library for working with Swift code. + +- SyntaxCollection +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/triviapiece + +- SwiftSyntax +- TriviaPiece + +Enumeration + +# TriviaPiece + +A contiguous stretch of a single kind of trivia. The constituent part of a `Trivia` collection. + +enum TriviaPiece + +TriviaPieces.swift + +## Overview + +For example, four spaces would be represented by `.spaces(4)` + +In general, you should deal with the actual Trivia collection instead of individual pieces whenever possible. + +## Topics + +### Enumeration Cases + +`case backslashes(Int)` + +A backslash that is at the end of a line in a multi-line string literal to escape the newline. + +`case blockComment(String)` + +A developer block comment, starting with ‘/ _’ and ending with ’_/’. + +`case carriageReturnLineFeeds(Int)` + +A newline consists of contiguous ‘\\r’ and ‘\\n’ characters. + +`case carriageReturns(Int)` + +A newline ‘\\r’ character. + +`case docBlockComment(String)` + +A documentation block comment, starting with ‘/\*\*’ and ending with ‘\*/’. + +`case docLineComment(String)` + +A documentation line comment, starting with ‘///’ and excluding the trailing newline. + +`case formfeeds(Int)` + +A form-feed ‘f’ character. + +`case lineComment(String)` + +A developer line comment, starting with ‘//’ and excluding the trailing newline. + +`case newlines(Int)` + +A newline ‘\\n’ character. + +`case pounds(Int)` + +A ‘#’ that is at the end of a line in a multi-line string literal to escape the newline. + +`case spaces(Int)` + +A space ’ ’ character. + +`case tabs(Int)` + +A tab ‘\\t’ character. + +`case unexpectedText(String)` + +Any skipped unexpected text. + +`case verticalTabs(Int)` + +A vertical tab ‘\\v’ character. + +### Instance Properties + +`var isComment: Bool` + +Returns `true` if this piece is a comment. + +`var isNewline: Bool` + +`var isSpaceOrTab: Bool` + +`var isWhitespace: Bool` + +Returns `true` if this piece is a newline, space or tab. + +`var sourceLength: SourceLength` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.Equatable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` + +## See Also + +### Trivia + +SwiftSyntax + +A library for working with Swift code. + +`enum TriviaPosition` + +- TriviaPiece +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/trivia + +- SwiftSyntax +- Trivia + +Structure + +# Trivia + +Trivia represent pieces of the source code that are not relevant to represent its semantic structure. + +struct Trivia + +Trivia.swift + +## Overview + +The standard examples of trivia are spaces, newlines and comments. + +The SwiftSyntax tree retains trivia to maintain round-tripness of the source code, ensuring that printing the entire syntax tree be rendered back into text that is byte-for-byte identical to the original source. + +Each `TokenSyntax` can have multiple `TriviaPiece` s as either leading or trailing trivia, which occur before or after the token’s content, respectively. `Trivia` represents a collection of these `TriviaPiece` s + +## Topics + +### Operators + +Concatenates two collections of `Trivia` into one collection. + +`static func += (inout Trivia, Trivia)` + +Concatenates two collections of `Trivia` into the left-hand side. + +### Initializers + +Creates Trivia with the provided underlying pieces. + +### Instance Properties + +`var byteSize: Int` + +Get the number of bytes this trivia needs to be represented as UTF-8. + +Deprecated + +`var isEmpty: Bool` + +Whether the Trivia contains no pieces. + +[`let pieces: [TriviaPiece]`](https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/trivia/pieces) + +The pieces this trivia consists of. Each `TriviaPiece` can represent multiple characters, such as an entire comment or 4 spaces. + +`var sourceLength: SourceLength` + +The length of all the pieces in this `Trivia`. + +### Instance Methods + +Creates a new `Trivia` by appending the given trivia to the end. + +Creates a new `Trivia` by appending the provided `TriviaPiece` to the end. + +Creates a new `Trivia` by merging in the given trivia. Only includes one copy of a common prefix of `self` and `trivia`. + +Creates a new `Trivia` by merging the leading and trailing `Trivia` of `triviaOf` into the end of `self`. Only includes one copy of any common prefixes. + +### Type Properties + +`static var backslash: Trivia` + +Gets a piece of trivia for #”"# characters. + +`static var carriageReturn: Trivia` + +Gets a piece of trivia for “\\r” characters. + +`static var carriageReturnLineFeed: Trivia` + +Gets a piece of trivia for “\\r\\n” characters. + +`static var formfeed: Trivia` + +Gets a piece of trivia for “\\u{c}” characters. + +`static var newline: Trivia` + +Gets a piece of trivia for “\\n” characters. + +`static var pound: Trivia` + +Gets a piece of trivia for “#” characters. + +`static var space: Trivia` + +Gets a piece of trivia for “ “ characters. + +`static var tab: Trivia` + +Gets a piece of trivia for “\\t” characters. + +`static var verticalTab: Trivia` + +Gets a piece of trivia for “\\u{b}” characters. + +### Type Methods + +Returns a piece of trivia for some number of #”"# characters. + +Returns a piece of trivia for BlockComment. + +Returns a piece of trivia for some number of “\\r\\n” characters. + +Returns a piece of trivia for some number of “\\r” characters. + +Returns a piece of trivia for DocBlockComment. + +Returns a piece of trivia for DocLineComment. + +Returns a piece of trivia for some number of “\\u{c}” characters. + +Returns a piece of trivia for LineComment. + +Returns a piece of trivia for some number of “\\n” characters. + +Returns a piece of trivia for some number of “#” characters. + +Returns a piece of trivia for some number of “ “ characters. + +Returns a piece of trivia for some number of “\\t” characters. + +Returns a piece of trivia for UnexpectedText. + +Returns a piece of trivia for some number of “\\u{b}” characters. + +## Relationships + +### Conforms To + +- `Swift.Collection` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` + +- Trivia +- Overview +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/triviaposition + +- SwiftSyntax +- TriviaPosition + +Enumeration + +# TriviaPosition + +enum TriviaPosition + +Trivia.swift + +## Topics + +### Enumeration Cases + +`case leading` + +`case trailing` + +## Relationships + +### Conforms To + +- `Swift.Equatable` +- `Swift.Hashable` + +## See Also + +### Trivia + +SwiftSyntax + +A library for working with Swift code. + +`enum TriviaPiece` + +A contiguous stretch of a single kind of trivia. The constituent part of a `Trivia` collection. + +- TriviaPosition +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tokensyntax + +- SwiftSyntax +- TokenSyntax + +Structure + +# TokenSyntax + +A Syntax node representing a single token. + +struct TokenSyntax + +TokenSyntax.swift + +## Overview + +All source code of a syntax tree is represented by tokens – layout nodes never contain any source code by themselves. + +A token consists of leading `Trivia`, i.e. whitespaces before the actual token contents, the token’s `text` and trailing `Trivia` after the token’s content. + +## Topics + +### Initializers + +If `node` is a token, return the `TokenSyntax` that represents it. Otherwise, return `nil`. + +`init(TokenKind, leadingTrivia: Trivia, trailingTrivia: Trivia, presence: SourcePresence)` + +Construct a new token with the given `kind`, `leadingTrivia`, `trailingTrivia` and `presence`. + +### Instance Properties + +`var identifier: Identifier?` + +An identifier created from `self`. + +`var isEditorPlaceholder: Bool` + +Whether the token text is an editor placeholder or not. + +`var leadingTrivia: Trivia` + +The leading trivia (spaces, newlines, etc.) associated with this token. + +`var leadingTriviaLength: SourceLength` + +The length this node’s leading trivia takes up spelled out in source. + +`var presence: SourcePresence` + +Whether the token is present or missing. + +`var text: String` + +The text of the token as written in the source code, without any trivia. + +`var tokenDiagnostic: TokenDiagnostic?` + +If the token has a lexical error, the type of the error. + +`var tokenKind: TokenKind` + +The kind of token this node represents. + +`var totalLength: SourceLength` + +The length of this node including all of its trivia. + +`var trailingTrivia: Trivia` + +The trailing trivia (spaces, newlines, etc.) associated with this token. + +`var trailingTriviaLength: SourceLength` + +The length this node’s trailing trivia takes up spelled out in source. + +`var trimmedLength: SourceLength` + +The length this node takes up spelled out in the source, excluding its leading or trailing trivia. + +### Instance Methods + +Attempts to cast the current leaf syntax node to a different specified type. + +Deprecated + +Force-casts the current leaf syntax node to a different specified type. + +Checks if the current leaf syntax node can be cast to a different specified type. + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +A token by itself has no structure, so we represent its structure by an empty layout node. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Tokens + +`enum TokenKind` + +Enumerates the kinds of tokens in the Swift language. + +`struct TokenSequence` + +Sequence of tokens that are part of the provided Syntax node. + +`enum SourcePresence` + +An indicator of whether a Syntax node was found or written in the source. + +- TokenSyntax +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tokenkind + +- SwiftSyntax +- TokenKind + +Enumeration + +# TokenKind + +Enumerates the kinds of tokens in the Swift language. + +enum TokenKind + +TokenKind.swift + +## Topics + +### Enumeration Cases + +`case arrow` + +`case atSign` + +`case backslash` + +`case backtick` + +`case binaryOperator(String)` + +`case colon` + +`case comma` + +`case dollarIdentifier(String)` + +`case ellipsis` + +`case endOfFile` + +`case equal` + +`case exclamationMark` + +`case floatLiteral(String)` + +`case identifier(String)` + +`case infixQuestionMark` + +`case integerLiteral(String)` + +`case keyword(Keyword)` + +`case leftAngle` + +`case leftBrace` + +`case leftParen` + +`case leftSquare` + +`case multilineStringQuote` + +`case period` + +`case postfixOperator(String)` + +`case postfixQuestionMark` + +`case pound` + +`case poundAvailable` + +`case poundElse` + +`case poundElseif` + +`case poundEndif` + +`case poundIf` + +`case poundSourceLocation` + +`case poundUnavailable` + +`case prefixAmpersand` + +`case prefixOperator(String)` + +`case rawStringPoundDelimiter(String)` + +`case regexLiteralPattern(String)` + +`case regexPoundDelimiter(String)` + +`case regexSlash` + +`case rightAngle` + +`case rightBrace` + +`case rightParen` + +`case rightSquare` + +`case semicolon` + +`case shebang(String)` + +`case singleQuote` + +`case stringQuote` + +`case stringSegment(String)` + +`case unknown(String)` + +`case wildcard` + +### Instance Properties + +`var isPunctuation: Bool` + +Returns `true` if the token is a Swift punctuator. + +### Type Properties + +`static var eof: TokenKind` Deprecated + +`static var leftSquareBracket: TokenKind` Deprecated + +`static var poundAvailableKeyword: TokenKind` Deprecated + +`static var poundElseKeyword: TokenKind` Deprecated + +`static var poundElseifKeyword: TokenKind` Deprecated + +`static var poundEndifKeyword: TokenKind` Deprecated + +`static var poundIfKeyword: TokenKind` Deprecated + +`static var poundSourceLocationKeyword: TokenKind` Deprecated + +`static var poundUnavailableKeyword: TokenKind` Deprecated + +`static var rightSquareBracket: TokenKind` Deprecated + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` + +## See Also + +### Tokens + +`struct TokenSyntax` + +A Syntax node representing a single token. + +`struct TokenSequence` + +Sequence of tokens that are part of the provided Syntax node. + +`enum SourcePresence` + +An indicator of whether a Syntax node was found or written in the source. + +- TokenKind +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tokensequence + +- SwiftSyntax +- TokenSequence + +Structure + +# TokenSequence + +Sequence of tokens that are part of the provided Syntax node. + +struct TokenSequence + +TokenSequence.swift + +## Topics + +### Structures + +`struct Iterator` + +Iterates over a `TokenSequence`. + +### Initializers + +`init(Syntax, viewMode: SyntaxTreeViewMode)` + +Construct a `TokenSequence` that walks all tokens in `node` in source order, recursively walking into child nodes. + +### Instance Methods + +Create an iterator that iterates over all the tokens in the sequence. + +Iterate the tokens in reverse order. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomReflectable` +- `Swift.Sendable` +- `Swift.Sequence` + +## See Also + +### Tokens + +`struct TokenSyntax` + +A Syntax node representing a single token. + +`enum TokenKind` + +Enumerates the kinds of tokens in the Swift language. + +`enum SourcePresence` + +An indicator of whether a Syntax node was found or written in the source. + +- TokenSequence +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/sourcepresence + +- SwiftSyntax +- SourcePresence + +Enumeration + +# SourcePresence + +An indicator of whether a Syntax node was found or written in the source. + +enum SourcePresence + +SourcePresence.swift + +## Overview + +A `missing` node does not mean, necessarily, that the source item is considered “implicit”, but rather that it was not found in the source. + +## Topics + +### Enumeration Cases + +`case missing` + +The syntax was expected or optional, but not found in the source. + +`case present` + +The syntax was authored by a human and found, or was generated. + +## Relationships + +### Conforms To + +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` + +## See Also + +### Tokens + +`struct TokenSyntax` + +A Syntax node representing a single token. + +`enum TokenKind` + +Enumerates the kinds of tokens in the Swift language. + +`struct TokenSequence` + +Sequence of tokens that are part of the provided Syntax node. + +- SourcePresence +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxvisitor + +- SwiftSyntax +- SyntaxVisitor + +Class + +# SyntaxVisitor + +class SyntaxVisitor + +SyntaxVisitor.swift + +## Topics + +### Initializers + +`init(viewMode: SyntaxTreeViewMode)` + +### Instance Properties + +`let viewMode: SyntaxTreeViewMode` + +### Instance Methods + +Visiting `SwitchDefaultLabelSyntax` specifically. + +Visiting `VersionTupleSyntax` specifically. + +Visiting `ArrayElementListSyntax` specifically. + +Visiting `BackDeployedAttributeArgumentsSyntax` specifically. + +Visiting `KeyPathOptionalComponentSyntax` specifically. + +Visiting `PrecedenceGroupAttributeListSyntax` specifically. + +Visiting `IfExprSyntax` specifically. + +Visiting `DoStmtSyntax` specifically. + +Visiting `EnumCaseDeclSyntax` specifically. + +Visiting `ReturnStmtSyntax` specifically. + +Visiting `ObjCSelectorPieceListSyntax` specifically. + +Visiting `TuplePatternSyntax` specifically. + +Visiting `InfixOperatorExprSyntax` specifically. + +Visiting `MissingPatternSyntax` specifically. + +Visiting `PackElementExprSyntax` specifically. + +Visiting `TupleTypeSyntax` specifically. + +Visiting `TypeAnnotationSyntax` specifically. + +Visiting `SequenceExprSyntax` specifically. + +Visiting `SwitchCaseListSyntax` specifically. + +Visiting `StringLiteralSegmentListSyntax` specifically. + +Visiting `DeclNameArgumentsSyntax` specifically. + +Visiting `KeyPathPropertyComponentSyntax` specifically. + +Visiting `DifferentiabilityArgumentListSyntax` specifically. + +Visiting `CodeBlockSyntax` specifically. + +Visiting `SuperExprSyntax` specifically. + +Visiting `MatchingPatternConditionSyntax` specifically. + +Visiting `CatchClauseSyntax` specifically. + +Visiting `LabeledExprListSyntax` specifically. + +Visiting `SwitchCaseLabelSyntax` specifically. + +Visiting `ClosureSignatureSyntax` specifically. + +Visiting `ArrowExprSyntax` specifically. + +Visiting `ThrowsClauseSyntax` specifically. + +Visiting `ClassDeclSyntax` specifically. + +Visiting `StringSegmentSyntax` specifically. + +Visiting `SubscriptDeclSyntax` specifically. + +Visiting `CatchClauseListSyntax` specifically. + +Visiting `BorrowExprSyntax` specifically. + +Visiting `FunctionTypeSyntax` specifically. + +Visiting `MemberTypeSyntax` specifically. + +Visiting `PatternExprSyntax` specifically. + +Visiting `DiscardAssignmentExprSyntax` specifically. + +Visiting `EnumCaseElementSyntax` specifically. + +Visiting `GuardStmtSyntax` specifically. + +Visiting `UnresolvedTernaryExprSyntax` specifically. + +Visiting `YieldStmtSyntax` specifically. + +Visiting `PoundSourceLocationSyntax` specifically. + +Visiting `PlatformVersionItemSyntax` specifically. + +Visiting `ConsumeExprSyntax` specifically. + +Visiting `DeclModifierDetailSyntax` specifically. + +Visiting `MacroExpansionExprSyntax` specifically. + +Visiting `CompositionTypeElementListSyntax` specifically. + +Visiting `AccessorDeclSyntax` specifically. + +Visiting `RepeatStmtSyntax` specifically. + +Visiting `MultipleTrailingClosureElementSyntax` specifically. + +Visiting `RegexLiteralExprSyntax` specifically. + +Visiting `LabeledStmtSyntax` specifically. + +Visiting `FunctionParameterClauseSyntax` specifically. + +Visiting `ConventionWitnessMethodAttributeArgumentsSyntax` specifically. + +Visiting `SimpleStringLiteralExprSyntax` specifically. + +Visiting `ClassRestrictionTypeSyntax` specifically. + +Visiting `ExpressionStmtSyntax` specifically. + +Visiting `GenericParameterListSyntax` specifically. + +Visiting `DeinitializerEffectSpecifiersSyntax` specifically. + +Visiting `DeclNameArgumentSyntax` specifically. + +Visiting `InitializerClauseSyntax` specifically. + +Visiting `CatchItemSyntax` specifically. + +Visiting `ImportPathComponentSyntax` specifically. + +Visiting `CodeBlockItemListSyntax` specifically. + +Visiting `GenericParameterSyntax` specifically. + +Visiting `InOutExprSyntax` specifically. + +Visiting `YieldedExpressionSyntax` specifically. + +Visiting `ExtensionDeclSyntax` specifically. + +Visiting `ReturnClauseSyntax` specifically. + +Visiting `FunctionSignatureSyntax` specifically. + +Visiting `DifferentiabilityWithRespectToArgumentSyntax` specifically. + +Visiting `ImportDeclSyntax` specifically. + +Visiting `CopyExprSyntax` specifically. + +Visiting `TuplePatternElementSyntax` specifically. + +Visiting `ConditionElementListSyntax` specifically. + +Visiting `PoundSourceLocationArgumentsSyntax` specifically. + +Visiting `TypeEffectSpecifiersSyntax` specifically. + +Visiting `ClosureParameterClauseSyntax` specifically. + +Visiting `KeyPathExprSyntax` specifically. + +Visiting `_CanImportVersionInfoSyntax` specifically. + +Visiting `MissingSyntax` specifically. + +Visiting `PrecedenceGroupNameListSyntax` specifically. + +Visiting `MultipleTrailingClosureElementListSyntax` specifically. + +Visiting `SubscriptCallExprSyntax` specifically. + +Visiting `DictionaryElementSyntax` specifically. + +Visiting `MetatypeTypeSyntax` specifically. + +Visiting `IsExprSyntax` specifically. + +Visiting `InheritedTypeSyntax` specifically. + +Visiting `AvailabilityConditionSyntax` specifically. + +Visiting `PrimaryAssociatedTypeSyntax` specifically. + +Visiting `DeinitializerDeclSyntax` specifically. + +Visiting `DerivativeAttributeArgumentsSyntax` specifically. + +Visiting `PostfixIfConfigExprSyntax` specifically. + +Visiting `MissingTypeSyntax` specifically. + +Visiting `AvailabilityArgumentListSyntax` specifically. + +Visiting `ClosureCaptureSpecifierSyntax` specifically. + +Visiting `DeclModifierSyntax` specifically. + +Visiting `PlatformVersionSyntax` specifically. + +Visiting `PrimaryAssociatedTypeClauseSyntax` specifically. + +Visiting `OperatorPrecedenceAndTypesSyntax` specifically. + +Visiting `AccessorBlockSyntax` specifically. + +Visiting `TupleTypeElementListSyntax` specifically. + +Visiting `FunctionEffectSpecifiersSyntax` specifically. + +Visiting `InheritedTypeListSyntax` specifically. + +Visiting `SwitchCaseSyntax` specifically. + +Visiting `LabeledSpecializeArgumentSyntax` specifically. + +Visiting `DifferentiableAttributeArgumentsSyntax` specifically. + +Visiting `EditorPlaceholderExprSyntax` specifically. + +Visiting `UnresolvedIsExprSyntax` specifically. + +Visiting `ImplicitlyUnwrappedOptionalTypeSyntax` specifically. + +Visiting `GenericRequirementSyntax` specifically. + +Visiting `KeyPathComponentListSyntax` specifically. + +Visiting `GenericWhereClauseSyntax` specifically. + +Visiting `OptionalTypeSyntax` specifically. + +Visiting `FunctionParameterListSyntax` specifically. + +Visiting `YieldedExpressionsClauseSyntax` specifically. + +Visiting `ValueBindingPatternSyntax` specifically. + +Visiting `AssignmentExprSyntax` specifically. + +Visiting `PrecedenceGroupAssociativitySyntax` specifically. + +Visiting `GenericRequirementListSyntax` specifically. + +Visiting `ExpressionSegmentSyntax` specifically. + +Visiting `MemberAccessExprSyntax` specifically. + +Visiting `GenericArgumentClauseSyntax` specifically. + +Visiting `SimpleStringLiteralSegmentListSyntax` specifically. + +Visiting `IdentifierPatternSyntax` specifically. + +Visiting `PrecedenceGroupAssignmentSyntax` specifically. + +Visiting `BreakStmtSyntax` specifically. + +Visiting `WhereClauseSyntax` specifically. + +Visiting `MacroExpansionDeclSyntax` specifically. + +Visiting `SimpleTypeSpecifierSyntax` specifically. + +Visiting `BooleanLiteralExprSyntax` specifically. + +Visiting `TypeAliasDeclSyntax` specifically. + +Visiting `PatternBindingSyntax` specifically. + +Visiting `ConventionAttributeArgumentsSyntax` specifically. + +Visiting `AwaitExprSyntax` specifically. + +Visiting `NilLiteralExprSyntax` specifically. + +Visiting `ClosureCaptureClauseSyntax` specifically. + +Visiting `ArrayTypeSyntax` specifically. + +Visiting `IdentifierTypeSyntax` specifically. + +Visiting `SwitchCaseItemSyntax` specifically. + +Visiting `GenericArgumentListSyntax` specifically. + +Visiting `MissingDeclSyntax` specifically. + +Visiting `DiscardStmtSyntax` specifically. + +Visiting `OptionalBindingConditionSyntax` specifically. + +Visiting `CodeBlockItemSyntax` specifically. + +Visiting `ClosureParameterListSyntax` specifically. + +Visiting `DocumentationAttributeArgumentListSyntax` specifically. + +Visiting `WhileStmtSyntax` specifically. + +Visiting `AttributeListSyntax` specifically. + +Visiting `DictionaryTypeSyntax` specifically. + +Visiting `VersionComponentSyntax` specifically. + +Visiting `SwitchCaseItemListSyntax` specifically. + +Visiting `UnresolvedAsExprSyntax` specifically. + +Visiting `ImplementsAttributeArgumentsSyntax` specifically. + +Visiting `TuplePatternElementListSyntax` specifically. + +Visiting `TypeInitializerClauseSyntax` specifically. + +Visiting `ProtocolDeclSyntax` specifically. + +Visiting `_CanImportExprSyntax` specifically. + +Visiting `AvailabilityLabeledArgumentSyntax` specifically. + +Visiting `EnumCaseElementListSyntax` specifically. + +Visiting `UnexpectedNodesSyntax` specifically. + +Visiting `TypeSpecifierListSyntax` specifically. + +Visiting `EnumCaseParameterSyntax` specifically. + +Visiting `SwitchExprSyntax` specifically. + +Visiting `FunctionParameterSyntax` specifically. + +Visiting `IntegerLiteralExprSyntax` specifically. + +Visiting `VersionComponentListSyntax` specifically. + +Visiting `AsExprSyntax` specifically. + +Visiting `IsTypePatternSyntax` specifically. + +Visiting `UnderscorePrivateAttributeArgumentsSyntax` specifically. + +Visiting `DynamicReplacementAttributeArgumentsSyntax` specifically. + +Visiting `ActorDeclSyntax` specifically. + +Visiting `CatchItemListSyntax` specifically. + +Visiting `SomeOrAnyTypeSyntax` specifically. + +Visiting `DeclNameArgumentListSyntax` specifically. + +Visiting `ArrayElementSyntax` specifically. + +Visiting `ClosureShorthandParameterListSyntax` specifically. + +Visiting `LabeledExprSyntax` specifically. + +Visiting `ClosureCaptureListSyntax` specifically. + +Visiting `MissingStmtSyntax` specifically. + +Visiting `ExpressionPatternSyntax` specifically. + +Visiting `PatternBindingListSyntax` specifically. + +Visiting `PrecedenceGroupDeclSyntax` specifically. + +Visiting `MacroDeclSyntax` specifically. + +Visiting `PrimaryAssociatedTypeListSyntax` specifically. + +Visiting `SpecializeAvailabilityArgumentSyntax` specifically. + +Visiting `SpecializeAttributeArgumentListSyntax` specifically. + +Visiting `PrecedenceGroupNameSyntax` specifically. + +Visiting `OperatorDeclSyntax` specifically. + +Visiting `MissingExprSyntax` specifically. + +Visiting `SpecializeTargetFunctionArgumentSyntax` specifically. + +Visiting `ConformanceRequirementSyntax` specifically. + +Visiting `YieldedExpressionListSyntax` specifically. + +Visiting `ExposeAttributeArgumentsSyntax` specifically. + +Visiting `PackElementTypeSyntax` specifically. + +Visiting `FunctionDeclSyntax` specifically. + +Visiting `TokenSyntax` specifically. + +Visiting `EnumCaseParameterClauseSyntax` specifically. + +Visiting `ImportPathComponentListSyntax` specifically. + +Visiting `LayoutRequirementSyntax` specifically. + +Visiting `PostfixOperatorExprSyntax` specifically. + +Visiting `EditorPlaceholderDeclSyntax` specifically. + +Visiting `PackExpansionTypeSyntax` specifically. + +Visiting `PrefixOperatorExprSyntax` specifically. + +Visiting `GenericParameterClauseSyntax` specifically. + +Visiting `DeferStmtSyntax` specifically. + +Visiting `TupleExprSyntax` specifically. + +Visiting `DocumentationAttributeArgumentSyntax` specifically. + +Visiting `TupleTypeElementSyntax` specifically. + +Visiting `ObjCSelectorPieceSyntax` specifically. + +Visiting `ExprListSyntax` specifically. + +Visiting `OpaqueReturnTypeOfAttributeArgumentsSyntax` specifically. + +Visiting `ThrowStmtSyntax` specifically. + +Visiting `ForceUnwrapExprSyntax` specifically. + +Visiting `TypeExprSyntax` specifically. + +Visiting `IfConfigClauseSyntax` specifically. + +Visiting `ClosureParameterSyntax` specifically. + +Visiting `DesignatedTypeListSyntax` specifically. + +Visiting `AccessorEffectSpecifiersSyntax` specifically. + +Visiting `DictionaryExprSyntax` specifically. + +Visiting `IfConfigClauseListSyntax` specifically. + +Visiting `TernaryExprSyntax` specifically. + +Visiting `OriginallyDefinedInAttributeArgumentsSyntax` specifically. + +Visiting `ClosureShorthandParameterSyntax` specifically. + +Visiting `AccessorDeclListSyntax` specifically. + +Visiting `NamedOpaqueReturnTypeSyntax` specifically. + +Visiting `DeclModifierListSyntax` specifically. + +Visiting `ClosureExprSyntax` specifically. + +Visiting `ConditionElementSyntax` specifically. + +Visiting `ForStmtSyntax` specifically. + +Visiting `EnumCaseParameterListSyntax` specifically. + +Visiting `MemberBlockItemSyntax` specifically. + +Visiting `FunctionCallExprSyntax` specifically. + +Visiting `TryExprSyntax` specifically. + +Visiting `EnumDeclSyntax` specifically. + +Visiting `BinaryOperatorExprSyntax` specifically. + +Visiting `VariableDeclSyntax` specifically. + +Visiting `FloatLiteralExprSyntax` specifically. + +Visiting `ClosureCaptureSyntax` specifically. + +Visiting `EffectsAttributeArgumentListSyntax` specifically. + +Visiting `AvailabilityArgumentSyntax` specifically. + +Visiting `CompositionTypeSyntax` specifically. + +Visiting `ArrayExprSyntax` specifically. + +Visiting `AttributedTypeSyntax` specifically. + +Visiting `MemberBlockItemListSyntax` specifically. + +Visiting `DesignatedTypeSyntax` specifically. + +Visiting `AccessorParametersSyntax` specifically. + +Visiting `DifferentiabilityArgumentsSyntax` specifically. + +Visiting `AttributeSyntax` specifically. + +Visiting `GenericSpecializationExprSyntax` specifically. + +Visiting `PrecedenceGroupRelationSyntax` specifically. + +Visiting `SuppressedTypeSyntax` specifically. + +Visiting `KeyPathSubscriptComponentSyntax` specifically. + +Visiting `PlatformVersionItemListSyntax` specifically. + +Visiting `FallThroughStmtSyntax` specifically. + +Visiting `IfConfigDeclSyntax` specifically. + +Visiting `MemberBlockSyntax` specifically. + +Visiting `OptionalChainingExprSyntax` specifically. + +Visiting `StringLiteralExprSyntax` specifically. + +Visiting `DeclReferenceExprSyntax` specifically. + +Visiting `PackExpansionExprSyntax` specifically. + +Visiting `WildcardPatternSyntax` specifically. + +Visiting `DifferentiabilityArgumentSyntax` specifically. + +Visiting `SourceFileSyntax` specifically. + +Visiting `SameTypeRequirementSyntax` specifically. + +Visiting `UnavailableFromAsyncAttributeArgumentsSyntax` specifically. + +Visiting `KeyPathComponentSyntax` specifically. + +Visiting `InheritanceClauseSyntax` specifically. + +Visiting `GenericArgumentSyntax` specifically. + +Visiting `CompositionTypeElementSyntax` specifically. + +Visiting `StructDeclSyntax` specifically. + +Visiting `AssociatedTypeDeclSyntax` specifically. + +Visiting `DictionaryElementListSyntax` specifically. + +Visiting `InitializerDeclSyntax` specifically. + +Visiting `ContinueStmtSyntax` specifically. + +`func visitPost(AvailabilityConditionSyntax)` + +The function called after visiting `AvailabilityConditionSyntax` and its descendants. + +`func visitPost(MatchingPatternConditionSyntax)` + +The function called after visiting `MatchingPatternConditionSyntax` and its descendants. + +`func visitPost(PackElementExprSyntax)` + +The function called after visiting `PackElementExprSyntax` and its descendants. + +`func visitPost(DoStmtSyntax)` + +The function called after visiting `DoStmtSyntax` and its descendants. + +`func visitPost(TupleTypeSyntax)` + +The function called after visiting `TupleTypeSyntax` and its descendants. + +`func visitPost(ConventionAttributeArgumentsSyntax)` + +The function called after visiting `ConventionAttributeArgumentsSyntax` and its descendants. + +`func visitPost(StringLiteralExprSyntax)` + +The function called after visiting `StringLiteralExprSyntax` and its descendants. + +`func visitPost(StringLiteralSegmentListSyntax)` + +The function called after visiting `StringLiteralSegmentListSyntax` and its descendants. + +`func visitPost(DictionaryExprSyntax)` + +The function called after visiting `DictionaryExprSyntax` and its descendants. + +`func visitPost(MissingSyntax)` + +The function called after visiting `MissingSyntax` and its descendants. + +`func visitPost(FunctionSignatureSyntax)` + +The function called after visiting `FunctionSignatureSyntax` and its descendants. + +`func visitPost(DifferentiabilityArgumentsSyntax)` + +The function called after visiting `DifferentiabilityArgumentsSyntax` and its descendants. + +`func visitPost(GenericParameterSyntax)` + +The function called after visiting `GenericParameterSyntax` and its descendants. + +`func visitPost(SimpleStringLiteralExprSyntax)` + +The function called after visiting `SimpleStringLiteralExprSyntax` and its descendants. + +`func visitPost(TypeSpecifierListSyntax)` + +The function called after visiting `TypeSpecifierListSyntax` and its descendants. + +`func visitPost(DeclNameArgumentSyntax)` + +The function called after visiting `DeclNameArgumentSyntax` and its descendants. + +`func visitPost(MissingStmtSyntax)` + +The function called after visiting `MissingStmtSyntax` and its descendants. + +`func visitPost(DeferStmtSyntax)` + +The function called after visiting `DeferStmtSyntax` and its descendants. + +`func visitPost(BooleanLiteralExprSyntax)` + +The function called after visiting `BooleanLiteralExprSyntax` and its descendants. + +`func visitPost(DerivativeAttributeArgumentsSyntax)` + +The function called after visiting `DerivativeAttributeArgumentsSyntax` and its descendants. + +`func visitPost(SourceFileSyntax)` + +The function called after visiting `SourceFileSyntax` and its descendants. + +`func visitPost(RegexLiteralExprSyntax)` + +The function called after visiting `RegexLiteralExprSyntax` and its descendants. + +`func visitPost(BackDeployedAttributeArgumentsSyntax)` + +The function called after visiting `BackDeployedAttributeArgumentsSyntax` and its descendants. + +`func visitPost(FunctionCallExprSyntax)` + +The function called after visiting `FunctionCallExprSyntax` and its descendants. + +`func visitPost(CatchClauseSyntax)` + +The function called after visiting `CatchClauseSyntax` and its descendants. + +`func visitPost(ConsumeExprSyntax)` + +The function called after visiting `ConsumeExprSyntax` and its descendants. + +`func visitPost(CompositionTypeElementSyntax)` + +The function called after visiting `CompositionTypeElementSyntax` and its descendants. + +`func visitPost(DeclModifierSyntax)` + +The function called after visiting `DeclModifierSyntax` and its descendants. + +`func visitPost(GenericArgumentClauseSyntax)` + +The function called after visiting `GenericArgumentClauseSyntax` and its descendants. + +`func visitPost(SwitchCaseListSyntax)` + +The function called after visiting `SwitchCaseListSyntax` and its descendants. + +`func visitPost(ClosureCaptureSpecifierSyntax)` + +The function called after visiting `ClosureCaptureSpecifierSyntax` and its descendants. + +`func visitPost(PostfixIfConfigExprSyntax)` + +The function called after visiting `PostfixIfConfigExprSyntax` and its descendants. + +`func visitPost(PrecedenceGroupDeclSyntax)` + +The function called after visiting `PrecedenceGroupDeclSyntax` and its descendants. + +`func visitPost(WhileStmtSyntax)` + +The function called after visiting `WhileStmtSyntax` and its descendants. + +`func visitPost(CatchItemSyntax)` + +The function called after visiting `CatchItemSyntax` and its descendants. + +`func visitPost(DynamicReplacementAttributeArgumentsSyntax)` + +The function called after visiting `DynamicReplacementAttributeArgumentsSyntax` and its descendants. + +`func visitPost(DeclNameArgumentListSyntax)` + +The function called after visiting `DeclNameArgumentListSyntax` and its descendants. + +`func visitPost(PatternBindingSyntax)` + +The function called after visiting `PatternBindingSyntax` and its descendants. + +`func visitPost(InitializerDeclSyntax)` + +The function called after visiting `InitializerDeclSyntax` and its descendants. + +`func visitPost(PrimaryAssociatedTypeListSyntax)` + +The function called after visiting `PrimaryAssociatedTypeListSyntax` and its descendants. + +`func visitPost(InitializerClauseSyntax)` + +The function called after visiting `InitializerClauseSyntax` and its descendants. + +`func visitPost(AvailabilityLabeledArgumentSyntax)` + +The function called after visiting `AvailabilityLabeledArgumentSyntax` and its descendants. + +`func visitPost(BinaryOperatorExprSyntax)` + +The function called after visiting `BinaryOperatorExprSyntax` and its descendants. + +`func visitPost(SwitchCaseSyntax)` + +The function called after visiting `SwitchCaseSyntax` and its descendants. + +`func visitPost(AwaitExprSyntax)` + +The function called after visiting `AwaitExprSyntax` and its descendants. + +`func visitPost(MemberBlockItemSyntax)` + +The function called after visiting `MemberBlockItemSyntax` and its descendants. + +`func visitPost(SwitchDefaultLabelSyntax)` + +The function called after visiting `SwitchDefaultLabelSyntax` and its descendants. + +`func visitPost(UnresolvedIsExprSyntax)` + +The function called after visiting `UnresolvedIsExprSyntax` and its descendants. + +`func visitPost(GenericArgumentListSyntax)` + +The function called after visiting `GenericArgumentListSyntax` and its descendants. + +`func visitPost(IfExprSyntax)` + +The function called after visiting `IfExprSyntax` and its descendants. + +`func visitPost(ReturnStmtSyntax)` + +The function called after visiting `ReturnStmtSyntax` and its descendants. + +`func visitPost(PostfixOperatorExprSyntax)` + +The function called after visiting `PostfixOperatorExprSyntax` and its descendants. + +`func visitPost(SubscriptDeclSyntax)` + +The function called after visiting `SubscriptDeclSyntax` and its descendants. + +`func visitPost(TypeInitializerClauseSyntax)` + +The function called after visiting `TypeInitializerClauseSyntax` and its descendants. + +`func visitPost(SimpleTypeSpecifierSyntax)` + +The function called after visiting `SimpleTypeSpecifierSyntax` and its descendants. + +`func visitPost(SameTypeRequirementSyntax)` + +The function called after visiting `SameTypeRequirementSyntax` and its descendants. + +`func visitPost(PrecedenceGroupAttributeListSyntax)` + +The function called after visiting `PrecedenceGroupAttributeListSyntax` and its descendants. + +`func visitPost(ForStmtSyntax)` + +The function called after visiting `ForStmtSyntax` and its descendants. + +`func visitPost(ClosureParameterListSyntax)` + +The function called after visiting `ClosureParameterListSyntax` and its descendants. + +`func visitPost(AvailabilityArgumentSyntax)` + +The function called after visiting `AvailabilityArgumentSyntax` and its descendants. + +`func visitPost(DifferentiabilityArgumentListSyntax)` + +The function called after visiting `DifferentiabilityArgumentListSyntax` and its descendants. + +`func visitPost(MacroExpansionDeclSyntax)` + +The function called after visiting `MacroExpansionDeclSyntax` and its descendants. + +`func visitPost(PlatformVersionItemListSyntax)` + +The function called after visiting `PlatformVersionItemListSyntax` and its descendants. + +`func visitPost(TryExprSyntax)` + +The function called after visiting `TryExprSyntax` and its descendants. + +`func visitPost(_CanImportVersionInfoSyntax)` + +The function called after visiting `_CanImportVersionInfoSyntax` and its descendants. + +`func visitPost(IdentifierPatternSyntax)` + +The function called after visiting `IdentifierPatternSyntax` and its descendants. + +`func visitPost(ArrayExprSyntax)` + +The function called after visiting `ArrayExprSyntax` and its descendants. + +`func visitPost(CatchItemListSyntax)` + +The function called after visiting `CatchItemListSyntax` and its descendants. + +`func visitPost(GenericSpecializationExprSyntax)` + +The function called after visiting `GenericSpecializationExprSyntax` and its descendants. + +`func visitPost(DifferentiabilityWithRespectToArgumentSyntax)` + +The function called after visiting `DifferentiabilityWithRespectToArgumentSyntax` and its descendants. + +`func visitPost(PatternExprSyntax)` + +The function called after visiting `PatternExprSyntax` and its descendants. + +`func visitPost(SuperExprSyntax)` + +The function called after visiting `SuperExprSyntax` and its descendants. + +`func visitPost(IdentifierTypeSyntax)` + +The function called after visiting `IdentifierTypeSyntax` and its descendants. + +`func visitPost(EnumCaseParameterClauseSyntax)` + +The function called after visiting `EnumCaseParameterClauseSyntax` and its descendants. + +`func visitPost(ExpressionPatternSyntax)` + +The function called after visiting `ExpressionPatternSyntax` and its descendants. + +`func visitPost(MemberBlockSyntax)` + +The function called after visiting `MemberBlockSyntax` and its descendants. + +`func visitPost(ArrayTypeSyntax)` + +The function called after visiting `ArrayTypeSyntax` and its descendants. + +`func visitPost(ImportPathComponentListSyntax)` + +The function called after visiting `ImportPathComponentListSyntax` and its descendants. + +`func visitPost(SwitchCaseLabelSyntax)` + +The function called after visiting `SwitchCaseLabelSyntax` and its descendants. + +`func visitPost(OperatorDeclSyntax)` + +The function called after visiting `OperatorDeclSyntax` and its descendants. + +`func visitPost(AttributeListSyntax)` + +The function called after visiting `AttributeListSyntax` and its descendants. + +`func visitPost(AssignmentExprSyntax)` + +The function called after visiting `AssignmentExprSyntax` and its descendants. + +`func visitPost(TernaryExprSyntax)` + +The function called after visiting `TernaryExprSyntax` and its descendants. + +`func visitPost(TypeExprSyntax)` + +The function called after visiting `TypeExprSyntax` and its descendants. + +`func visitPost(TuplePatternSyntax)` + +The function called after visiting `TuplePatternSyntax` and its descendants. + +`func visitPost(ClassRestrictionTypeSyntax)` + +The function called after visiting `ClassRestrictionTypeSyntax` and its descendants. + +`func visitPost(PrecedenceGroupRelationSyntax)` + +The function called after visiting `PrecedenceGroupRelationSyntax` and its descendants. + +`func visitPost(ContinueStmtSyntax)` + +The function called after visiting `ContinueStmtSyntax` and its descendants. + +`func visitPost(ExprListSyntax)` + +The function called after visiting `ExprListSyntax` and its descendants. + +`func visitPost(ConventionWitnessMethodAttributeArgumentsSyntax)` + +The function called after visiting `ConventionWitnessMethodAttributeArgumentsSyntax` and its descendants. + +`func visitPost(DictionaryTypeSyntax)` + +The function called after visiting `DictionaryTypeSyntax` and its descendants. + +`func visitPost(GenericArgumentSyntax)` + +The function called after visiting `GenericArgumentSyntax` and its descendants. + +`func visitPost(TuplePatternElementListSyntax)` + +The function called after visiting `TuplePatternElementListSyntax` and its descendants. + +`func visitPost(LayoutRequirementSyntax)` + +The function called after visiting `LayoutRequirementSyntax` and its descendants. + +`func visitPost(TypeEffectSpecifiersSyntax)` + +The function called after visiting `TypeEffectSpecifiersSyntax` and its descendants. + +`func visitPost(KeyPathOptionalComponentSyntax)` + +The function called after visiting `KeyPathOptionalComponentSyntax` and its descendants. + +`func visitPost(ConditionElementSyntax)` + +The function called after visiting `ConditionElementSyntax` and its descendants. + +`func visitPost(MultipleTrailingClosureElementSyntax)` + +The function called after visiting `MultipleTrailingClosureElementSyntax` and its descendants. + +`func visitPost(FunctionEffectSpecifiersSyntax)` + +The function called after visiting `FunctionEffectSpecifiersSyntax` and its descendants. + +`func visitPost(ConditionElementListSyntax)` + +The function called after visiting `ConditionElementListSyntax` and its descendants. + +`func visitPost(PoundSourceLocationArgumentsSyntax)` + +The function called after visiting `PoundSourceLocationArgumentsSyntax` and its descendants. + +`func visitPost(MissingDeclSyntax)` + +The function called after visiting `MissingDeclSyntax` and its descendants. + +`func visitPost(GenericWhereClauseSyntax)` + +The function called after visiting `GenericWhereClauseSyntax` and its descendants. + +`func visitPost(ForceUnwrapExprSyntax)` + +The function called after visiting `ForceUnwrapExprSyntax` and its descendants. + +`func visitPost(ClosureShorthandParameterListSyntax)` + +The function called after visiting `ClosureShorthandParameterListSyntax` and its descendants. + +`func visitPost(ReturnClauseSyntax)` + +The function called after visiting `ReturnClauseSyntax` and its descendants. + +`func visitPost(OptionalTypeSyntax)` + +The function called after visiting `OptionalTypeSyntax` and its descendants. + +`func visitPost(IsExprSyntax)` + +The function called after visiting `IsExprSyntax` and its descendants. + +`func visitPost(YieldedExpressionListSyntax)` + +The function called after visiting `YieldedExpressionListSyntax` and its descendants. + +`func visitPost(DiscardAssignmentExprSyntax)` + +The function called after visiting `DiscardAssignmentExprSyntax` and its descendants. + +`func visitPost(PrecedenceGroupNameSyntax)` + +The function called after visiting `PrecedenceGroupNameSyntax` and its descendants. + +`func visitPost(VersionTupleSyntax)` + +The function called after visiting `VersionTupleSyntax` and its descendants. + +`func visitPost(PrimaryAssociatedTypeClauseSyntax)` + +The function called after visiting `PrimaryAssociatedTypeClauseSyntax` and its descendants. + +`func visitPost(RepeatStmtSyntax)` + +The function called after visiting `RepeatStmtSyntax` and its descendants. + +`func visitPost(PrecedenceGroupAssignmentSyntax)` + +The function called after visiting `PrecedenceGroupAssignmentSyntax` and its descendants. + +`func visitPost(NilLiteralExprSyntax)` + +The function called after visiting `NilLiteralExprSyntax` and its descendants. + +`func visitPost(EnumDeclSyntax)` + +The function called after visiting `EnumDeclSyntax` and its descendants. + +`func visitPost(SuppressedTypeSyntax)` + +The function called after visiting `SuppressedTypeSyntax` and its descendants. + +`func visitPost(MissingTypeSyntax)` + +The function called after visiting `MissingTypeSyntax` and its descendants. + +`func visitPost(YieldStmtSyntax)` + +The function called after visiting `YieldStmtSyntax` and its descendants. + +`func visitPost(KeyPathExprSyntax)` + +The function called after visiting `KeyPathExprSyntax` and its descendants. + +`func visitPost(PackExpansionExprSyntax)` + +The function called after visiting `PackExpansionExprSyntax` and its descendants. + +`func visitPost(MacroDeclSyntax)` + +The function called after visiting `MacroDeclSyntax` and its descendants. + +`func visitPost(ProtocolDeclSyntax)` + +The function called after visiting `ProtocolDeclSyntax` and its descendants. + +`func visitPost(ArrayElementListSyntax)` + +The function called after visiting `ArrayElementListSyntax` and its descendants. + +`func visitPost(DeclReferenceExprSyntax)` + +The function called after visiting `DeclReferenceExprSyntax` and its descendants. + +`func visitPost(AccessorParametersSyntax)` + +The function called after visiting `AccessorParametersSyntax` and its descendants. + +`func visitPost(TuplePatternElementSyntax)` + +The function called after visiting `TuplePatternElementSyntax` and its descendants. + +`func visitPost(EnumCaseParameterSyntax)` + +The function called after visiting `EnumCaseParameterSyntax` and its descendants. + +`func visitPost(TypeAliasDeclSyntax)` + +The function called after visiting `TypeAliasDeclSyntax` and its descendants. + +`func visitPost(CompositionTypeElementListSyntax)` + +The function called after visiting `CompositionTypeElementListSyntax` and its descendants. + +`func visitPost(ArrayElementSyntax)` + +The function called after visiting `ArrayElementSyntax` and its descendants. + +`func visitPost(StructDeclSyntax)` + +The function called after visiting `StructDeclSyntax` and its descendants. + +`func visitPost(InheritedTypeSyntax)` + +The function called after visiting `InheritedTypeSyntax` and its descendants. + +`func visitPost(CompositionTypeSyntax)` + +The function called after visiting `CompositionTypeSyntax` and its descendants. + +`func visitPost(DeinitializerDeclSyntax)` + +The function called after visiting `DeinitializerDeclSyntax` and its descendants. + +`func visitPost(SubscriptCallExprSyntax)` + +The function called after visiting `SubscriptCallExprSyntax` and its descendants. + +`func visitPost(MemberTypeSyntax)` + +The function called after visiting `MemberTypeSyntax` and its descendants. + +`func visitPost(NamedOpaqueReturnTypeSyntax)` + +The function called after visiting `NamedOpaqueReturnTypeSyntax` and its descendants. + +`func visitPost(SwitchCaseItemListSyntax)` + +The function called after visiting `SwitchCaseItemListSyntax` and its descendants. + +`func visitPost(ClosureParameterClauseSyntax)` + +The function called after visiting `ClosureParameterClauseSyntax` and its descendants. + +`func visitPost(DeclNameArgumentsSyntax)` + +The function called after visiting `DeclNameArgumentsSyntax` and its descendants. + +`func visitPost(VersionComponentSyntax)` + +The function called after visiting `VersionComponentSyntax` and its descendants. + +`func visitPost(ClosureCaptureClauseSyntax)` + +The function called after visiting `ClosureCaptureClauseSyntax` and its descendants. + +`func visitPost(CodeBlockSyntax)` + +The function called after visiting `CodeBlockSyntax` and its descendants. + +`func visitPost(PlatformVersionItemSyntax)` + +The function called after visiting `PlatformVersionItemSyntax` and its descendants. + +`func visitPost(PlatformVersionSyntax)` + +The function called after visiting `PlatformVersionSyntax` and its descendants. + +`func visitPost(ClosureCaptureSyntax)` + +The function called after visiting `ClosureCaptureSyntax` and its descendants. + +`func visitPost(LabeledStmtSyntax)` + +The function called after visiting `LabeledStmtSyntax` and its descendants. + +`func visitPost(WhereClauseSyntax)` + +The function called after visiting `WhereClauseSyntax` and its descendants. + +`func visitPost(CodeBlockItemSyntax)` + +The function called after visiting `CodeBlockItemSyntax` and its descendants. + +`func visitPost(GuardStmtSyntax)` + +The function called after visiting `GuardStmtSyntax` and its descendants. + +`func visitPost(FloatLiteralExprSyntax)` + +The function called after visiting `FloatLiteralExprSyntax` and its descendants. + +`func visitPost(TokenSyntax)` + +The function called after visiting the node and its descendants. + +`func visitPost(ImportPathComponentSyntax)` + +The function called after visiting `ImportPathComponentSyntax` and its descendants. + +`func visitPost(PackExpansionTypeSyntax)` + +The function called after visiting `PackExpansionTypeSyntax` and its descendants. + +`func visitPost(ImportDeclSyntax)` + +The function called after visiting `ImportDeclSyntax` and its descendants. + +`func visitPost(EditorPlaceholderExprSyntax)` + +The function called after visiting `EditorPlaceholderExprSyntax` and its descendants. + +`func visitPost(UnresolvedAsExprSyntax)` + +The function called after visiting `UnresolvedAsExprSyntax` and its descendants. + +`func visitPost(InOutExprSyntax)` + +The function called after visiting `InOutExprSyntax` and its descendants. + +`func visitPost(GenericRequirementSyntax)` + +The function called after visiting `GenericRequirementSyntax` and its descendants. + +`func visitPost(MissingPatternSyntax)` + +The function called after visiting `MissingPatternSyntax` and its descendants. + +`func visitPost(SpecializeTargetFunctionArgumentSyntax)` + +The function called after visiting `SpecializeTargetFunctionArgumentSyntax` and its descendants. + +`func visitPost(InfixOperatorExprSyntax)` + +The function called after visiting `InfixOperatorExprSyntax` and its descendants. + +`func visitPost(OptionalChainingExprSyntax)` + +The function called after visiting `OptionalChainingExprSyntax` and its descendants. + +`func visitPost(OperatorPrecedenceAndTypesSyntax)` + +The function called after visiting `OperatorPrecedenceAndTypesSyntax` and its descendants. + +`func visitPost(ClosureShorthandParameterSyntax)` + +The function called after visiting `ClosureShorthandParameterSyntax` and its descendants. + +`func visitPost(KeyPathComponentListSyntax)` + +The function called after visiting `KeyPathComponentListSyntax` and its descendants. + +`func visitPost(AssociatedTypeDeclSyntax)` + +The function called after visiting `AssociatedTypeDeclSyntax` and its descendants. + +`func visitPost(BreakStmtSyntax)` + +The function called after visiting `BreakStmtSyntax` and its descendants. + +`func visitPost(GenericParameterClauseSyntax)` + +The function called after visiting `GenericParameterClauseSyntax` and its descendants. + +`func visitPost(ClosureSignatureSyntax)` + +The function called after visiting `ClosureSignatureSyntax` and its descendants. + +`func visitPost(UnderscorePrivateAttributeArgumentsSyntax)` + +The function called after visiting `UnderscorePrivateAttributeArgumentsSyntax` and its descendants. + +`func visitPost(ClosureParameterSyntax)` + +The function called after visiting `ClosureParameterSyntax` and its descendants. + +`func visitPost(DesignatedTypeListSyntax)` + +The function called after visiting `DesignatedTypeListSyntax` and its descendants. + +`func visitPost(MemberAccessExprSyntax)` + +The function called after visiting `MemberAccessExprSyntax` and its descendants. + +`func visitPost(AccessorDeclSyntax)` + +The function called after visiting `AccessorDeclSyntax` and its descendants. + +`func visitPost(StringSegmentSyntax)` + +The function called after visiting `StringSegmentSyntax` and its descendants. + +`func visitPost(SpecializeAvailabilityArgumentSyntax)` + +The function called after visiting `SpecializeAvailabilityArgumentSyntax` and its descendants. + +`func visitPost(AttributeSyntax)` + +The function called after visiting `AttributeSyntax` and its descendants. + +`func visitPost(EditorPlaceholderDeclSyntax)` + +The function called after visiting `EditorPlaceholderDeclSyntax` and its descendants. + +`func visitPost(MissingExprSyntax)` + +The function called after visiting `MissingExprSyntax` and its descendants. + +`func visitPost(TupleTypeElementSyntax)` + +The function called after visiting `TupleTypeElementSyntax` and its descendants. + +`func visitPost(KeyPathPropertyComponentSyntax)` + +The function called after visiting `KeyPathPropertyComponentSyntax` and its descendants. + +`func visitPost(InheritanceClauseSyntax)` + +The function called after visiting `InheritanceClauseSyntax` and its descendants. + +`func visitPost(FunctionParameterSyntax)` + +The function called after visiting `FunctionParameterSyntax` and its descendants. + +`func visitPost(VariableDeclSyntax)` + +The function called after visiting `VariableDeclSyntax` and its descendants. + +`func visitPost(IfConfigClauseListSyntax)` + +The function called after visiting `IfConfigClauseListSyntax` and its descendants. + +`func visitPost(GenericRequirementListSyntax)` + +The function called after visiting `GenericRequirementListSyntax` and its descendants. + +`func visitPost(ImplicitlyUnwrappedOptionalTypeSyntax)` + +The function called after visiting `ImplicitlyUnwrappedOptionalTypeSyntax` and its descendants. + +`func visitPost(ClosureCaptureListSyntax)` + +The function called after visiting `ClosureCaptureListSyntax` and its descendants. + +`func visitPost(DeinitializerEffectSpecifiersSyntax)` + +The function called after visiting `DeinitializerEffectSpecifiersSyntax` and its descendants. + +`func visitPost(AttributedTypeSyntax)` + +The function called after visiting `AttributedTypeSyntax` and its descendants. + +`func visitPost(InheritedTypeListSyntax)` + +The function called after visiting `InheritedTypeListSyntax` and its descendants. + +`func visitPost(AccessorBlockSyntax)` + +The function called after visiting `AccessorBlockSyntax` and its descendants. + +`func visitPost(CopyExprSyntax)` + +The function called after visiting `CopyExprSyntax` and its descendants. + +`func visitPost(ObjCSelectorPieceListSyntax)` + +The function called after visiting `ObjCSelectorPieceListSyntax` and its descendants. + +`func visitPost(ThrowsClauseSyntax)` + +The function called after visiting `ThrowsClauseSyntax` and its descendants. + +`func visitPost(TupleTypeElementListSyntax)` + +The function called after visiting `TupleTypeElementListSyntax` and its descendants. + +`func visitPost(EnumCaseElementListSyntax)` + +The function called after visiting `EnumCaseElementListSyntax` and its descendants. + +`func visitPost(ImplementsAttributeArgumentsSyntax)` + +The function called after visiting `ImplementsAttributeArgumentsSyntax` and its descendants. + +`func visitPost(PackElementTypeSyntax)` + +The function called after visiting `PackElementTypeSyntax` and its descendants. + +`func visitPost(FunctionParameterListSyntax)` + +The function called after visiting `FunctionParameterListSyntax` and its descendants. + +`func visitPost(ObjCSelectorPieceSyntax)` + +The function called after visiting `ObjCSelectorPieceSyntax` and its descendants. + +`func visitPost(DeclModifierDetailSyntax)` + +The function called after visiting `DeclModifierDetailSyntax` and its descendants. + +`func visitPost(DeclModifierListSyntax)` + +The function called after visiting `DeclModifierListSyntax` and its descendants. + +`func visitPost(UnexpectedNodesSyntax)` + +The function called after visiting `UnexpectedNodesSyntax` and its descendants. + +`func visitPost(ActorDeclSyntax)` + +The function called after visiting `ActorDeclSyntax` and its descendants. + +`func visitPost(EffectsAttributeArgumentListSyntax)` + +The function called after visiting `EffectsAttributeArgumentListSyntax` and its descendants. + +`func visitPost(WildcardPatternSyntax)` + +The function called after visiting `WildcardPatternSyntax` and its descendants. + +`func visitPost(KeyPathComponentSyntax)` + +The function called after visiting `KeyPathComponentSyntax` and its descendants. + +`func visitPost(AccessorDeclListSyntax)` + +The function called after visiting `AccessorDeclListSyntax` and its descendants. + +`func visitPost(SomeOrAnyTypeSyntax)` + +The function called after visiting `SomeOrAnyTypeSyntax` and its descendants. + +`func visitPost(FunctionTypeSyntax)` + +The function called after visiting `FunctionTypeSyntax` and its descendants. + +`func visitPost(EnumCaseElementSyntax)` + +The function called after visiting `EnumCaseElementSyntax` and its descendants. + +`func visitPost(ArrowExprSyntax)` + +The function called after visiting `ArrowExprSyntax` and its descendants. + +`func visitPost(DocumentationAttributeArgumentListSyntax)` + +The function called after visiting `DocumentationAttributeArgumentListSyntax` and its descendants. + +`func visitPost(MetatypeTypeSyntax)` + +The function called after visiting `MetatypeTypeSyntax` and its descendants. + +`func visitPost(IsTypePatternSyntax)` + +The function called after visiting `IsTypePatternSyntax` and its descendants. + +`func visitPost(GenericParameterListSyntax)` + +The function called after visiting `GenericParameterListSyntax` and its descendants. + +`func visitPost(_CanImportExprSyntax)` + +The function called after visiting `_CanImportExprSyntax` and its descendants. + +`func visitPost(DocumentationAttributeArgumentSyntax)` + +The function called after visiting `DocumentationAttributeArgumentSyntax` and its descendants. + +`func visitPost(ClosureExprSyntax)` + +The function called after visiting `ClosureExprSyntax` and its descendants. + +`func visitPost(LabeledExprListSyntax)` + +The function called after visiting `LabeledExprListSyntax` and its descendants. + +`func visitPost(TupleExprSyntax)` + +The function called after visiting `TupleExprSyntax` and its descendants. + +`func visitPost(LabeledSpecializeArgumentSyntax)` + +The function called after visiting `LabeledSpecializeArgumentSyntax` and its descendants. + +`func visitPost(DifferentiableAttributeArgumentsSyntax)` + +The function called after visiting `DifferentiableAttributeArgumentsSyntax` and its descendants. + +`func visitPost(OptionalBindingConditionSyntax)` + +The function called after visiting `OptionalBindingConditionSyntax` and its descendants. + +`func visitPost(SwitchCaseItemSyntax)` + +The function called after visiting `SwitchCaseItemSyntax` and its descendants. + +`func visitPost(IntegerLiteralExprSyntax)` + +The function called after visiting `IntegerLiteralExprSyntax` and its descendants. + +`func visitPost(IfConfigClauseSyntax)` + +The function called after visiting `IfConfigClauseSyntax` and its descendants. + +`func visitPost(VersionComponentListSyntax)` + +The function called after visiting `VersionComponentListSyntax` and its descendants. + +`func visitPost(ConformanceRequirementSyntax)` + +The function called after visiting `ConformanceRequirementSyntax` and its descendants. + +`func visitPost(SpecializeAttributeArgumentListSyntax)` + +The function called after visiting `SpecializeAttributeArgumentListSyntax` and its descendants. + +`func visitPost(SequenceExprSyntax)` + +The function called after visiting `SequenceExprSyntax` and its descendants. + +`func visitPost(EnumCaseDeclSyntax)` + +The function called after visiting `EnumCaseDeclSyntax` and its descendants. + +`func visitPost(BorrowExprSyntax)` + +The function called after visiting `BorrowExprSyntax` and its descendants. + +`func visitPost(ExtensionDeclSyntax)` + +The function called after visiting `ExtensionDeclSyntax` and its descendants. + +`func visitPost(UnavailableFromAsyncAttributeArgumentsSyntax)` + +The function called after visiting `UnavailableFromAsyncAttributeArgumentsSyntax` and its descendants. + +`func visitPost(KeyPathSubscriptComponentSyntax)` + +The function called after visiting `KeyPathSubscriptComponentSyntax` and its descendants. + +`func visitPost(MultipleTrailingClosureElementListSyntax)` + +The function called after visiting `MultipleTrailingClosureElementListSyntax` and its descendants. + +`func visitPost(SimpleStringLiteralSegmentListSyntax)` + +The function called after visiting `SimpleStringLiteralSegmentListSyntax` and its descendants. + +`func visitPost(AsExprSyntax)` + +The function called after visiting `AsExprSyntax` and its descendants. + +`func visitPost(EnumCaseParameterListSyntax)` + +The function called after visiting `EnumCaseParameterListSyntax` and its descendants. + +`func visitPost(FallThroughStmtSyntax)` + +The function called after visiting `FallThroughStmtSyntax` and its descendants. + +`func visitPost(PrecedenceGroupNameListSyntax)` + +The function called after visiting `PrecedenceGroupNameListSyntax` and its descendants. + +`func visitPost(OpaqueReturnTypeOfAttributeArgumentsSyntax)` + +The function called after visiting `OpaqueReturnTypeOfAttributeArgumentsSyntax` and its descendants. + +`func visitPost(AccessorEffectSpecifiersSyntax)` + +The function called after visiting `AccessorEffectSpecifiersSyntax` and its descendants. + +`func visitPost(PatternBindingListSyntax)` + +The function called after visiting `PatternBindingListSyntax` and its descendants. + +`func visitPost(ExpressionStmtSyntax)` + +The function called after visiting `ExpressionStmtSyntax` and its descendants. + +`func visitPost(FunctionDeclSyntax)` + +The function called after visiting `FunctionDeclSyntax` and its descendants. + +`func visitPost(ClassDeclSyntax)` + +The function called after visiting `ClassDeclSyntax` and its descendants. + +`func visitPost(AvailabilityArgumentListSyntax)` + +The function called after visiting `AvailabilityArgumentListSyntax` and its descendants. + +`func visitPost(ThrowStmtSyntax)` + +The function called after visiting `ThrowStmtSyntax` and its descendants. + +`func visitPost(CatchClauseListSyntax)` + +The function called after visiting `CatchClauseListSyntax` and its descendants. + +`func visitPost(UnresolvedTernaryExprSyntax)` + +The function called after visiting `UnresolvedTernaryExprSyntax` and its descendants. + +`func visitPost(YieldedExpressionsClauseSyntax)` + +The function called after visiting `YieldedExpressionsClauseSyntax` and its descendants. + +`func visitPost(IfConfigDeclSyntax)` + +The function called after visiting `IfConfigDeclSyntax` and its descendants. + +`func visitPost(DiscardStmtSyntax)` + +The function called after visiting `DiscardStmtSyntax` and its descendants. + +`func visitPost(SwitchExprSyntax)` + +The function called after visiting `SwitchExprSyntax` and its descendants. + +`func visitPost(DifferentiabilityArgumentSyntax)` + +The function called after visiting `DifferentiabilityArgumentSyntax` and its descendants. + +`func visitPost(PrimaryAssociatedTypeSyntax)` + +The function called after visiting `PrimaryAssociatedTypeSyntax` and its descendants. + +`func visitPost(OriginallyDefinedInAttributeArgumentsSyntax)` + +The function called after visiting `OriginallyDefinedInAttributeArgumentsSyntax` and its descendants. + +`func visitPost(MacroExpansionExprSyntax)` + +The function called after visiting `MacroExpansionExprSyntax` and its descendants. + +`func visitPost(TypeAnnotationSyntax)` + +The function called after visiting `TypeAnnotationSyntax` and its descendants. + +`func visitPost(FunctionParameterClauseSyntax)` + +The function called after visiting `FunctionParameterClauseSyntax` and its descendants. + +`func visitPost(DesignatedTypeSyntax)` + +The function called after visiting `DesignatedTypeSyntax` and its descendants. + +`func visitPost(ValueBindingPatternSyntax)` + +The function called after visiting `ValueBindingPatternSyntax` and its descendants. + +`func visitPost(LabeledExprSyntax)` + +The function called after visiting `LabeledExprSyntax` and its descendants. + +`func visitPost(ExpressionSegmentSyntax)` + +The function called after visiting `ExpressionSegmentSyntax` and its descendants. + +`func visitPost(PrefixOperatorExprSyntax)` + +The function called after visiting `PrefixOperatorExprSyntax` and its descendants. + +`func visitPost(MemberBlockItemListSyntax)` + +The function called after visiting `MemberBlockItemListSyntax` and its descendants. + +`func visitPost(PrecedenceGroupAssociativitySyntax)` + +The function called after visiting `PrecedenceGroupAssociativitySyntax` and its descendants. + +`func visitPost(DictionaryElementSyntax)` + +The function called after visiting `DictionaryElementSyntax` and its descendants. + +`func visitPost(DictionaryElementListSyntax)` + +The function called after visiting `DictionaryElementListSyntax` and its descendants. + +`func visitPost(CodeBlockItemListSyntax)` + +The function called after visiting `CodeBlockItemListSyntax` and its descendants. + +`func visitPost(PoundSourceLocationSyntax)` + +The function called after visiting `PoundSourceLocationSyntax` and its descendants. + +`func visitPost(ExposeAttributeArgumentsSyntax)` + +The function called after visiting `ExposeAttributeArgumentsSyntax` and its descendants. + +`func visitPost(YieldedExpressionSyntax)` + +The function called after visiting `YieldedExpressionSyntax` and its descendants. + +`func walk(some SyntaxProtocol)` + +Walk all nodes of the given syntax tree, calling the corresponding `visit` function for every node that is being visited. + +## Relationships + +### Inherited By + +- `SyntaxAnyVisitor` + +## See Also + +### Syntax Visitors + +`class SyntaxAnyVisitor` + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +`class SyntaxRewriter` + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +`enum SyntaxTreeViewMode` + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +`enum SyntaxVisitorContinueKind` + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +- SyntaxVisitor +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxanyvisitor + +- SwiftSyntax +- SyntaxAnyVisitor + +Class + +# SyntaxAnyVisitor + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +class SyntaxAnyVisitor + +SyntaxAnyVisitor.swift + +## Overview + +This subclass of `SyntaxVisitor` is slower than the type-specific visitation of `SyntaxVisitor`. Use `SyntaxAnyVisitor` if the `visitAny(_)` function would be useful to have, otherwise inherit from `SyntaxVisitor`. + +This works by overriding the type-specific visit function that delegate to `visitAny(_)`. A subclass that provides a custom type-specific visit function, should also call `visitAny(_)` in its implementation, if calling `visitAny` is needed: + +struct MyVisitor: SyntaxAnyVisitor { + +visitAny(token) +} +} + +## Topics + +### Instance Methods + +`func visitAnyPost(Syntax)` + +The function called after visiting the node and its descendants. + +`func visitPost(SpecializeAttributeArgumentListSyntax)` + +`func visitPost(PrefixOperatorExprSyntax)` + +`func visitPost(FallThroughStmtSyntax)` + +`func visitPost(OperatorPrecedenceAndTypesSyntax)` + +`func visitPost(PlatformVersionItemSyntax)` + +`func visitPost(DeinitializerEffectSpecifiersSyntax)` + +`func visitPost(ClosureCaptureSpecifierSyntax)` + +`func visitPost(ClosureShorthandParameterListSyntax)` + +`func visitPost(SwitchCaseSyntax)` + +`func visitPost(SameTypeRequirementSyntax)` + +`func visitPost(InitializerDeclSyntax)` + +`func visitPost(ExpressionPatternSyntax)` + +`func visitPost(ClassRestrictionTypeSyntax)` + +`func visitPost(AvailabilityArgumentSyntax)` + +`func visitPost(ImportPathComponentListSyntax)` + +`func visitPost(EnumCaseDeclSyntax)` + +`func visitPost(FunctionCallExprSyntax)` + +`func visitPost(FloatLiteralExprSyntax)` + +`func visitPost(MultipleTrailingClosureElementListSyntax)` + +`func visitPost(FunctionParameterSyntax)` + +`func visitPost(AccessorEffectSpecifiersSyntax)` + +`func visitPost(PrecedenceGroupAttributeListSyntax)` + +`func visitPost(GenericWhereClauseSyntax)` + +`func visitPost(OptionalTypeSyntax)` + +`func visitPost(TuplePatternSyntax)` + +`func visitPost(InheritanceClauseSyntax)` + +`func visitPost(DeclNameArgumentListSyntax)` + +`func visitPost(ReturnClauseSyntax)` + +`func visitPost(ContinueStmtSyntax)` + +`func visitPost(ImplementsAttributeArgumentsSyntax)` + +`func visitPost(FunctionTypeSyntax)` + +`func visitPost(MissingExprSyntax)` + +`func visitPost(EffectsAttributeArgumentListSyntax)` + +`func visitPost(GenericArgumentSyntax)` + +`func visitPost(ExprListSyntax)` + +`func visitPost(DesignatedTypeSyntax)` + +`func visitPost(StringSegmentSyntax)` + +`func visitPost(IsTypePatternSyntax)` + +`func visitPost(SuppressedTypeSyntax)` + +`func visitPost(PostfixOperatorExprSyntax)` + +`func visitPost(PoundSourceLocationArgumentsSyntax)` + +`func visitPost(OptionalChainingExprSyntax)` + +`func visitPost(ThrowStmtSyntax)` + +`func visitPost(FunctionParameterListSyntax)` + +`func visitPost(ClosureParameterListSyntax)` + +`func visitPost(GenericRequirementListSyntax)` + +`func visitPost(IsExprSyntax)` + +`func visitPost(EnumCaseParameterListSyntax)` + +`func visitPost(ArrayElementSyntax)` + +`func visitPost(CodeBlockSyntax)` + +`func visitPost(KeyPathOptionalComponentSyntax)` + +`func visitPost(DifferentiabilityArgumentsSyntax)` + +`func visitPost(FunctionParameterClauseSyntax)` + +`func visitPost(CopyExprSyntax)` + +`func visitPost(ObjCSelectorPieceSyntax)` + +`func visitPost(SimpleTypeSpecifierSyntax)` + +`func visitPost(ForStmtSyntax)` + +`func visitPost(RepeatStmtSyntax)` + +`func visitPost(PlatformVersionItemListSyntax)` + +`func visitPost(SuperExprSyntax)` + +`func visitPost(DeclReferenceExprSyntax)` + +`func visitPost(WildcardPatternSyntax)` + +`func visitPost(UnderscorePrivateAttributeArgumentsSyntax)` + +`func visitPost(CatchClauseSyntax)` + +`func visitPost(DictionaryTypeSyntax)` + +`func visitPost(OriginallyDefinedInAttributeArgumentsSyntax)` + +`func visitPost(NamedOpaqueReturnTypeSyntax)` + +`func visitPost(TypeAliasDeclSyntax)` + +`func visitPost(KeyPathExprSyntax)` + +`func visitPost(AvailabilityLabeledArgumentSyntax)` + +`func visitPost(PatternBindingListSyntax)` + +`func visitPost(CatchItemListSyntax)` + +`func visitPost(LabeledExprSyntax)` + +`func visitPost(UnavailableFromAsyncAttributeArgumentsSyntax)` + +`func visitPost(PackElementExprSyntax)` + +`func visitPost(StringLiteralSegmentListSyntax)` + +`func visitPost(BooleanLiteralExprSyntax)` + +`func visitPost(UnexpectedNodesSyntax)` + +`func visitPost(ArrayElementListSyntax)` + +`func visitPost(ExposeAttributeArgumentsSyntax)` + +`func visitPost(YieldedExpressionListSyntax)` + +`func visitPost(VersionComponentListSyntax)` + +`func visitPost(MacroExpansionDeclSyntax)` + +`func visitPost(SequenceExprSyntax)` + +`func visitPost(ExpressionSegmentSyntax)` + +`func visitPost(InitializerClauseSyntax)` + +`func visitPost(SwitchCaseItemSyntax)` + +`func visitPost(CompositionTypeSyntax)` + +`func visitPost(GenericParameterListSyntax)` + +`func visitPost(BreakStmtSyntax)` + +`func visitPost(RegexLiteralExprSyntax)` + +`func visitPost(ArrayTypeSyntax)` + +`func visitPost(TupleTypeElementSyntax)` + +`func visitPost(UnresolvedIsExprSyntax)` + +`func visitPost(OpaqueReturnTypeOfAttributeArgumentsSyntax)` + +`func visitPost(PlatformVersionSyntax)` + +`func visitPost(EditorPlaceholderExprSyntax)` + +`func visitPost(DeclNameArgumentsSyntax)` + +`func visitPost(SimpleStringLiteralSegmentListSyntax)` + +`func visitPost(PrimaryAssociatedTypeClauseSyntax)` + +`func visitPost(ReturnStmtSyntax)` + +`func visitPost(TypeEffectSpecifiersSyntax)` + +`func visitPost(_CanImportExprSyntax)` + +`func visitPost(ArrowExprSyntax)` + +`func visitPost(VariableDeclSyntax)` + +`func visitPost(ClosureCaptureSyntax)` + +`func visitPost(TypeSpecifierListSyntax)` + +`func visitPost(TokenSyntax)` + +`func visitPost(AccessorDeclSyntax)` + +`func visitPost(ClosureExprSyntax)` + +`func visitPost(ArrayExprSyntax)` + +`func visitPost(DocumentationAttributeArgumentListSyntax)` + +`func visitPost(GenericRequirementSyntax)` + +`func visitPost(BackDeployedAttributeArgumentsSyntax)` + +`func visitPost(DictionaryElementListSyntax)` + +`func visitPost(MultipleTrailingClosureElementSyntax)` + +`func visitPost(PatternBindingSyntax)` + +`func visitPost(IfConfigDeclSyntax)` + +`func visitPost(DeferStmtSyntax)` + +`func visitPost(PrecedenceGroupRelationSyntax)` + +`func visitPost(PostfixIfConfigExprSyntax)` + +`func visitPost(ThrowsClauseSyntax)` + +`func visitPost(WhereClauseSyntax)` + +`func visitPost(MissingDeclSyntax)` + +`func visitPost(YieldStmtSyntax)` + +`func visitPost(ImportDeclSyntax)` + +`func visitPost(AsExprSyntax)` + +`func visitPost(BinaryOperatorExprSyntax)` + +`func visitPost(DictionaryElementSyntax)` + +`func visitPost(PrimaryAssociatedTypeSyntax)` + +`func visitPost(ConventionWitnessMethodAttributeArgumentsSyntax)` + +`func visitPost(CatchItemSyntax)` + +`func visitPost(_CanImportVersionInfoSyntax)` + +`func visitPost(LabeledSpecializeArgumentSyntax)` + +`func visitPost(IntegerLiteralExprSyntax)` + +`func visitPost(NilLiteralExprSyntax)` + +`func visitPost(KeyPathSubscriptComponentSyntax)` + +`func visitPost(InheritedTypeListSyntax)` + +`func visitPost(UnresolvedTernaryExprSyntax)` + +`func visitPost(SwitchExprSyntax)` + +`func visitPost(DifferentiabilityArgumentSyntax)` + +`func visitPost(TernaryExprSyntax)` + +`func visitPost(FunctionEffectSpecifiersSyntax)` + +`func visitPost(FunctionDeclSyntax)` + +`func visitPost(IdentifierPatternSyntax)` + +`func visitPost(IdentifierTypeSyntax)` + +`func visitPost(CompositionTypeElementSyntax)` + +`func visitPost(EnumCaseParameterClauseSyntax)` + +`func visitPost(InfixOperatorExprSyntax)` + +`func visitPost(MemberAccessExprSyntax)` + +`func visitPost(GenericParameterSyntax)` + +`func visitPost(MacroDeclSyntax)` + +`func visitPost(AvailabilityConditionSyntax)` + +`func visitPost(ConventionAttributeArgumentsSyntax)` + +`func visitPost(PackExpansionExprSyntax)` + +`func visitPost(ClosureSignatureSyntax)` + +`func visitPost(AwaitExprSyntax)` + +`func visitPost(DynamicReplacementAttributeArgumentsSyntax)` + +`func visitPost(InOutExprSyntax)` + +`func visitPost(ClassDeclSyntax)` + +`func visitPost(TupleExprSyntax)` + +`func visitPost(LayoutRequirementSyntax)` + +`func visitPost(SourceFileSyntax)` + +`func visitPost(SubscriptDeclSyntax)` + +`func visitPost(ConformanceRequirementSyntax)` + +`func visitPost(ForceUnwrapExprSyntax)` + +`func visitPost(PrecedenceGroupNameSyntax)` + +`func visitPost(AccessorDeclListSyntax)` + +`func visitPost(SwitchDefaultLabelSyntax)` + +`func visitPost(DeclModifierSyntax)` + +`func visitPost(DerivativeAttributeArgumentsSyntax)` + +`func visitPost(AccessorBlockSyntax)` + +`func visitPost(ImportPathComponentSyntax)` + +`func visitPost(MetatypeTypeSyntax)` + +`func visitPost(PrecedenceGroupAssignmentSyntax)` + +`func visitPost(TypeExprSyntax)` + +`func visitPost(GenericParameterClauseSyntax)` + +`func visitPost(ClosureParameterSyntax)` + +`func visitPost(SwitchCaseListSyntax)` + +`func visitPost(IfExprSyntax)` + +`func visitPost(ClosureShorthandParameterSyntax)` + +`func visitPost(StructDeclSyntax)` + +`func visitPost(LabeledExprListSyntax)` + +`func visitPost(MemberBlockItemListSyntax)` + +`func visitPost(TryExprSyntax)` + +`func visitPost(TupleTypeSyntax)` + +`func visitPost(PrecedenceGroupAssociativitySyntax)` + +`func visitPost(ClosureCaptureListSyntax)` + +`func visitPost(StringLiteralExprSyntax)` + +`func visitPost(MemberTypeSyntax)` + +`func visitPost(DifferentiabilityWithRespectToArgumentSyntax)` + +`func visitPost(IfConfigClauseSyntax)` + +`func visitPost(TuplePatternElementListSyntax)` + +`func visitPost(OperatorDeclSyntax)` + +`func visitPost(AccessorParametersSyntax)` + +`func visitPost(CodeBlockItemListSyntax)` + +`func visitPost(VersionTupleSyntax)` + +`func visitPost(CompositionTypeElementListSyntax)` + +`func visitPost(ValueBindingPatternSyntax)` + +`func visitPost(DeclModifierDetailSyntax)` + +`func visitPost(GenericArgumentListSyntax)` + +`func visitPost(GuardStmtSyntax)` + +`func visitPost(DifferentiabilityArgumentListSyntax)` + +`func visitPost(PrecedenceGroupDeclSyntax)` + +`func visitPost(KeyPathPropertyComponentSyntax)` + +`func visitPost(AttributedTypeSyntax)` + +`func visitPost(FunctionSignatureSyntax)` + +`func visitPost(EnumCaseElementSyntax)` + +`func visitPost(PrimaryAssociatedTypeListSyntax)` + +`func visitPost(ConsumeExprSyntax)` + +`func visitPost(SwitchCaseLabelSyntax)` + +`func visitPost(DiscardStmtSyntax)` + +`func visitPost(MemberBlockSyntax)` + +`func visitPost(AttributeListSyntax)` + +`func visitPost(VersionComponentSyntax)` + +`func visitPost(DesignatedTypeListSyntax)` + +`func visitPost(MissingStmtSyntax)` + +`func visitPost(PackExpansionTypeSyntax)` + +`func visitPost(GenericSpecializationExprSyntax)` + +`func visitPost(MissingPatternSyntax)` + +`func visitPost(DictionaryExprSyntax)` + +`func visitPost(SimpleStringLiteralExprSyntax)` + +`func visitPost(TupleTypeElementListSyntax)` + +`func visitPost(TypeAnnotationSyntax)` + +`func visitPost(TypeInitializerClauseSyntax)` + +`func visitPost(MacroExpansionExprSyntax)` + +`func visitPost(ActorDeclSyntax)` + +`func visitPost(AvailabilityArgumentListSyntax)` + +`func visitPost(ClosureParameterClauseSyntax)` + +`func visitPost(SubscriptCallExprSyntax)` + +`func visitPost(InheritedTypeSyntax)` + +`func visitPost(GenericArgumentClauseSyntax)` + +`func visitPost(AttributeSyntax)` + +`func visitPost(PrecedenceGroupNameListSyntax)` + +`func visitPost(EnumCaseParameterSyntax)` + +`func visitPost(OptionalBindingConditionSyntax)` + +`func visitPost(CodeBlockItemSyntax)` + +`func visitPost(EnumDeclSyntax)` + +`func visitPost(DeinitializerDeclSyntax)` + +`func visitPost(CatchClauseListSyntax)` + +`func visitPost(IfConfigClauseListSyntax)` + +`func visitPost(DoStmtSyntax)` + +`func visitPost(MissingTypeSyntax)` + +`func visitPost(AssignmentExprSyntax)` + +`func visitPost(ConditionElementSyntax)` + +`func visitPost(ConditionElementListSyntax)` + +`func visitPost(ExpressionStmtSyntax)` + +`func visitPost(ProtocolDeclSyntax)` + +`func visitPost(DiscardAssignmentExprSyntax)` + +`func visitPost(PatternExprSyntax)` + +`func visitPost(KeyPathComponentSyntax)` + +`func visitPost(EditorPlaceholderDeclSyntax)` + +`func visitPost(YieldedExpressionSyntax)` + +`func visitPost(PoundSourceLocationSyntax)` + +`func visitPost(ClosureCaptureClauseSyntax)` + +`func visitPost(ImplicitlyUnwrappedOptionalTypeSyntax)` + +`func visitPost(SpecializeAvailabilityArgumentSyntax)` + +`func visitPost(MissingSyntax)` + +`func visitPost(LabeledStmtSyntax)` + +`func visitPost(SpecializeTargetFunctionArgumentSyntax)` + +`func visitPost(DeclModifierListSyntax)` + +`func visitPost(DifferentiableAttributeArgumentsSyntax)` + +`func visitPost(BorrowExprSyntax)` + +`func visitPost(KeyPathComponentListSyntax)` + +`func visitPost(UnresolvedAsExprSyntax)` + +`func visitPost(AssociatedTypeDeclSyntax)` + +`func visitPost(SwitchCaseItemListSyntax)` + +`func visitPost(ObjCSelectorPieceListSyntax)` + +`func visitPost(WhileStmtSyntax)` + +`func visitPost(DeclNameArgumentSyntax)` + +`func visitPost(SomeOrAnyTypeSyntax)` + +`func visitPost(YieldedExpressionsClauseSyntax)` + +`func visitPost(ExtensionDeclSyntax)` + +`func visitPost(DocumentationAttributeArgumentSyntax)` + +`func visitPost(MemberBlockItemSyntax)` + +`func visitPost(MatchingPatternConditionSyntax)` + +`func visitPost(PackElementTypeSyntax)` + +`func visitPost(EnumCaseElementListSyntax)` + +`func visitPost(TuplePatternElementSyntax)` + +## Relationships + +### Inherits From + +- `SyntaxVisitor` + +## See Also + +### Syntax Visitors + +`class SyntaxVisitor` + +`class SyntaxRewriter` + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +`enum SyntaxTreeViewMode` + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +`enum SyntaxVisitorContinueKind` + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +- SyntaxAnyVisitor +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntax + +- SwiftSyntax +- Syntax + +Structure + +# Syntax + +A Syntax node represents a tree of nodes with tokens at the leaves. Each node has accessors for its known children, and allows efficient iteration over the children through its `children` property. + +struct Syntax + +Syntax.swift + +## Topics + +### Operators + +Returns `true` if `rhs` and `lhs` have the same ID. + +### Initializers + +`init(some SyntaxProtocol)` + +Create a `Syntax` node from a specialized syntax node. + +`init?(fromProtocol: (any SyntaxProtocol)?)` + +Same as `init(fromProtocol:)` but returns `nil` if `syntax` is `nil`. + +`init(fromProtocol: any SyntaxProtocol)` + +Creates a new `Syntax` node from any node that conforms to `SyntaxProtocol`. + +### Instance Properties + +`var endPosition: AbsolutePosition` + +The end position of this node, including its trivia. + +`var endPositionBeforeTrailingTrivia: AbsolutePosition` + +The end position of this node’s content, before any trailing trivia. + +`var id: SyntaxIdentifier` + +`var parent: Syntax?` + +`var position: AbsolutePosition` + +The position of the start of this node’s leading trivia + +`var positionAfterSkippingLeadingTrivia: AbsolutePosition` + +The position of the start of this node’s content, skipping its trivia + +`var root: Syntax` + +[`var syntaxTextBytes: [UInt8]`](https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntax/syntaxtextbytes) + +Retrieve the syntax text as an array of bytes that models the input source even in the presence of invalid UTF-8. + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all syntax nodes. + +Return the non-type erased version of this syntax node if it conforms to PatternSyntaxProtocol. Otherwise return nil. + +Return the non-type erased version of this syntax node if it conforms to TypeSyntaxProtocol. Otherwise return nil. + +Return the non-type erased version of this syntax node if it conforms to DeclSyntaxProtocol. Otherwise return nil. + +Return the non-type erased version of this syntax node if it conforms to ExprSyntaxProtocol. Otherwise return nil. + +Return the non-type erased version of this syntax node if it conforms to StmtSyntaxProtocol. Otherwise return nil. + +Return the non-type erased version of this syntax node. Note that this will incur an existential conversion. + +The ending location, in the provided file, of this Syntax node. + +`func hash(into: inout Hasher)` + +Add the hash value of this node’s ID to `hasher`. + +Check whether the non-type erased version of this syntax node conforms to DeclSyntaxProtocol. + +Check whether the non-type erased version of this syntax node conforms to StmtSyntaxProtocol. + +Check whether the non-type erased version of this syntax node conforms to PatternSyntaxProtocol. + +Syntax nodes always conform to SyntaxProtocol. This API is just added for consistency. Note that this will incur an existential conversion. + +Deprecated + +Check whether the non-type erased version of this syntax node conforms to ExprSyntaxProtocol. + +Check whether the non-type erased version of this syntax node conforms to TypeSyntaxProtocol. + +The source range, in the provided file, of this Syntax node. + +The starting location, in the provided file, of this Syntax node. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Identifiable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +- Syntax +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxrewriter + +- SwiftSyntax +- SyntaxRewriter + +Class + +# SyntaxRewriter + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +class SyntaxRewriter + +SyntaxRewriter.swift + +## Topics + +### Initializers + +`init(viewMode: SyntaxTreeViewMode)` + +### Instance Properties + +`let viewMode: SyntaxTreeViewMode` + +### Instance Methods + +Rewrite `node`, keeping its parent unless `detach` is `true`. + +Visit a `MissingExprSyntax`. + +Visit a `SuperExprSyntax`. + +Visit a `AccessorDeclSyntax`. + +Visit a `PrecedenceGroupNameSyntax`. + +Visit a `AccessorParametersSyntax`. + +Visit a `ArrayTypeSyntax`. + +Visit a `UnresolvedIsExprSyntax`. + +Visit a `MissingPatternSyntax`. + +Visit a `TypeInitializerClauseSyntax`. + +Visit a `CatchClauseSyntax`. + +Visit a `UnavailableFromAsyncAttributeArgumentsSyntax`. + +Visit a `KeyPathSubscriptComponentSyntax`. + +Visit a `ForceUnwrapExprSyntax`. + +Visit a `ArrayElementListSyntax`. + +Visit a `TupleTypeElementListSyntax`. + +Visit a `TryExprSyntax`. + +Visit a `ExpressionStmtSyntax`. + +Visit a `SwitchCaseSyntax`. + +Visit a `SwitchCaseItemListSyntax`. + +Visit a `InitializerClauseSyntax`. + +Visit a `DifferentiabilityArgumentListSyntax`. + +Visit a `TuplePatternElementListSyntax`. + +Visit any StmtSyntax node. + +Visit a `MemberAccessExprSyntax`. + +Visit a `SpecializeAttributeArgumentListSyntax`. + +Visit a `SuppressedTypeSyntax`. + +Visit a `DeclReferenceExprSyntax`. + +Visit a `IsTypePatternSyntax`. + +Visit a `CatchItemListSyntax`. + +Visit a `InheritedTypeListSyntax`. + +Visit a `IntegerLiteralExprSyntax`. + +Visit a `OptionalTypeSyntax`. + +Visit a `IfExprSyntax`. + +Visit a `NamedOpaqueReturnTypeSyntax`. + +Visit a `DictionaryElementListSyntax`. + +Visit a `AwaitExprSyntax`. + +Visit a `GenericWhereClauseSyntax`. + +Visit a `KeyPathPropertyComponentSyntax`. + +Visit a `TupleTypeSyntax`. + +Visit a `SimpleStringLiteralSegmentListSyntax`. + +Visit a `GuardStmtSyntax`. + +Visit a `_CanImportVersionInfoSyntax`. + +Visit a `LabeledExprSyntax`. + +Visit a `CopyExprSyntax`. + +Visit any TypeSyntax node. + +Visit a `FunctionEffectSpecifiersSyntax`. + +Visit a `OperatorPrecedenceAndTypesSyntax`. + +Visit a `AvailabilityConditionSyntax`. + +Visit a `ClosureCaptureSyntax`. + +Visit a `KeyPathComponentListSyntax`. + +Visit a `SimpleStringLiteralExprSyntax`. + +Visit a `WhileStmtSyntax`. + +Visit a `ConformanceRequirementSyntax`. + +Visit a `DocumentationAttributeArgumentSyntax`. + +Visit a `KeyPathComponentSyntax`. + +Visit a `SwitchCaseListSyntax`. + +Visit a `GenericParameterClauseSyntax`. + +Visit a `MemberBlockSyntax`. + +Visit a `DiscardStmtSyntax`. + +Visit a `EditorPlaceholderDeclSyntax`. + +Visit a `DynamicReplacementAttributeArgumentsSyntax`. + +Visit a `InitializerDeclSyntax`. + +Visit a `MacroDeclSyntax`. + +Visit a `TokenSyntax`. + +Visit a `RepeatStmtSyntax`. + +Visit a `TypeEffectSpecifiersSyntax`. + +Visit a `MissingStmtSyntax`. + +Visit a `SwitchCaseLabelSyntax`. + +Visit a `ExprListSyntax`. + +Visit a `OptionalChainingExprSyntax`. + +Visit a `FunctionDeclSyntax`. + +Visit a `SequenceExprSyntax`. + +Visit a `UnresolvedTernaryExprSyntax`. + +Visit a `ClassRestrictionTypeSyntax`. + +Visit a `AsExprSyntax`. + +Visit a `_CanImportExprSyntax`. + +Visit a `InfixOperatorExprSyntax`. + +Visit a `FallThroughStmtSyntax`. + +Visit a `ConditionElementSyntax`. + +Visit a `ImportPathComponentListSyntax`. + +Visit a `ActorDeclSyntax`. + +Visit a `ObjCSelectorPieceListSyntax`. + +Visit a `PackExpansionTypeSyntax`. + +Visit a `DictionaryTypeSyntax`. + +Visit a `MissingTypeSyntax`. + +Visit a `PatternBindingListSyntax`. + +Visit a `AvailabilityArgumentListSyntax`. + +Visit a `MatchingPatternConditionSyntax`. + +Visit a `StringSegmentSyntax`. + +Visit a `AccessorDeclListSyntax`. + +Visit a `GenericSpecializationExprSyntax`. + +Visit a `DeclModifierSyntax`. + +Visit a `CatchItemSyntax`. + +Visit a `AccessorEffectSpecifiersSyntax`. + +Visit a `PackElementTypeSyntax`. + +Visit a `IdentifierPatternSyntax`. + +Visit a `ArrowExprSyntax`. + +Visit a `ProtocolDeclSyntax`. + +Visit a `ConventionWitnessMethodAttributeArgumentsSyntax`. + +Visit a `LabeledStmtSyntax`. + +Visit a `CompositionTypeSyntax`. + +Visit a `ClosureCaptureListSyntax`. + +Visit a `PatternBindingSyntax`. + +Visit a `GenericArgumentClauseSyntax`. + +Visit a `TypeExprSyntax`. + +Visit a `VersionTupleSyntax`. + +Visit a `YieldStmtSyntax`. + +Visit a `ArrayExprSyntax`. + +Visit a `SwitchExprSyntax`. + +Visit a `FunctionCallExprSyntax`. + +Visit a `EnumCaseParameterClauseSyntax`. + +Visit a `PackExpansionExprSyntax`. + +Visit a `AssociatedTypeDeclSyntax`. + +Visit a `DifferentiabilityArgumentSyntax`. + +Visit a `PrimaryAssociatedTypeClauseSyntax`. + +Visit a `EnumDeclSyntax`. + +Visit a `YieldedExpressionsClauseSyntax`. + +Visit a `ClosureSignatureSyntax`. + +Visit a `ReturnClauseSyntax`. + +Visit a `ClosureParameterListSyntax`. + +Visit a `PrecedenceGroupAssignmentSyntax`. + +Visit a `ArrayElementSyntax`. + +Visit a `EnumCaseParameterSyntax`. + +Visit a `StructDeclSyntax`. + +Visit a `DifferentiabilityArgumentsSyntax`. + +Visit a `DeclModifierDetailSyntax`. + +Visit a `BorrowExprSyntax`. + +Visit a `ClosureShorthandParameterSyntax`. + +Visit a `GenericParameterSyntax`. + +Visit a `EnumCaseElementListSyntax`. + +Visit a `FunctionTypeSyntax`. + +Visit a `InheritanceClauseSyntax`. + +Visit a `DeclNameArgumentsSyntax`. + +Visit a `KeyPathExprSyntax`. + +Visit a `YieldedExpressionListSyntax`. + +Visit a `DiscardAssignmentExprSyntax`. + +Visit a `ThrowsClauseSyntax`. + +Visit a `LabeledSpecializeArgumentSyntax`. + +Visit a `CodeBlockSyntax`. + +Visit a `LayoutRequirementSyntax`. + +Visit a `IdentifierTypeSyntax`. + +Visit a `DifferentiableAttributeArgumentsSyntax`. + +Visit a `MacroExpansionExprSyntax`. + +Visit a `MetatypeTypeSyntax`. + +Visit a `PoundSourceLocationArgumentsSyntax`. + +Visit a `TypeAnnotationSyntax`. + +Visit a `ImplementsAttributeArgumentsSyntax`. + +Visit a `SomeOrAnyTypeSyntax`. + +Visit a `InheritedTypeSyntax`. + +Visit a `FunctionParameterListSyntax`. + +Visit a `GenericArgumentSyntax`. + +Visit a `PostfixIfConfigExprSyntax`. + +Visit a `WildcardPatternSyntax`. + +Visit a `DesignatedTypeListSyntax`. + +Visit a `SimpleTypeSpecifierSyntax`. + +Visit a `BooleanLiteralExprSyntax`. + +Visit a `ConsumeExprSyntax`. + +Visit a `ConventionAttributeArgumentsSyntax`. + +Visit a `LabeledExprListSyntax`. + +Visit a `AttributeSyntax`. + +Visit a `AccessorBlockSyntax`. + +Visit a `OpaqueReturnTypeOfAttributeArgumentsSyntax`. + +Visit a `ExtensionDeclSyntax`. + +Visit a `PrecedenceGroupAssociativitySyntax`. + +Visit a `PrecedenceGroupNameListSyntax`. + +Visit a `SameTypeRequirementSyntax`. + +Visit a `FunctionSignatureSyntax`. + +Visit a `SubscriptDeclSyntax`. + +Visit a `VariableDeclSyntax`. + +Visit a `CompositionTypeElementListSyntax`. + +Visit a `ExpressionSegmentSyntax`. + +Visit a `MissingDeclSyntax`. + +Visit a `AssignmentExprSyntax`. + +Visit a `MultipleTrailingClosureElementListSyntax`. + +Visit a `PatternExprSyntax`. + +Visit a `ImportDeclSyntax`. + +Visit a `PrecedenceGroupRelationSyntax`. + +Visit a `ClosureParameterSyntax`. + +Visit a `UnexpectedNodesSyntax`. + +Visit a `ThrowStmtSyntax`. + +Visit any ExprSyntax node. + +Visit a `MacroExpansionDeclSyntax`. + +Visit a `DeclModifierListSyntax`. + +Visit a `ClosureShorthandParameterListSyntax`. + +Visit a `ImportPathComponentSyntax`. + +Visit a `EffectsAttributeArgumentListSyntax`. + +Visit a `DeinitializerEffectSpecifiersSyntax`. + +Visit a `FunctionParameterSyntax`. + +Visit a `VersionComponentSyntax`. + +Visit a `ClassDeclSyntax`. + +Visit a `CodeBlockItemSyntax`. + +Visit a `DeinitializerDeclSyntax`. + +Visit a `PoundSourceLocationSyntax`. + +Visit a `TuplePatternSyntax`. + +Visit a `ValueBindingPatternSyntax`. + +Visit a `BreakStmtSyntax`. + +Visit a `ClosureParameterClauseSyntax`. + +Visit a `PackElementExprSyntax`. + +Visit a `ConditionElementListSyntax`. + +Visit a `AvailabilityLabeledArgumentSyntax`. + +Visit a `DocumentationAttributeArgumentListSyntax`. + +Visit a `DeferStmtSyntax`. + +Visit a `ClosureCaptureSpecifierSyntax`. + +Visit a `SubscriptCallExprSyntax`. + +Visit a `SpecializeTargetFunctionArgumentSyntax`. + +Visit a `KeyPathOptionalComponentSyntax`. + +Visit a `ImplicitlyUnwrappedOptionalTypeSyntax`. + +Visit a `ClosureExprSyntax`. + +Visit a `BackDeployedAttributeArgumentsSyntax`. + +Visit a `CatchClauseListSyntax`. + +Visit a `GenericParameterListSyntax`. + +Visit a `EnumCaseDeclSyntax`. + +Visit a `TernaryExprSyntax`. + +Visit a `AvailabilityArgumentSyntax`. + +Visit a `MultipleTrailingClosureElementSyntax`. + +Visit a `DesignatedTypeSyntax`. + +Visit a `SpecializeAvailabilityArgumentSyntax`. + +Visit a `PlatformVersionSyntax`. + +Visit a `BinaryOperatorExprSyntax`. + +Visit a `IfConfigDeclSyntax`. + +Visit a `DictionaryExprSyntax`. + +Visit a `SourceFileSyntax`. + +Visit a `TypeSpecifierListSyntax`. + +Visit a `MissingSyntax`. + +Visit a `UnderscorePrivateAttributeArgumentsSyntax`. + +Visit any DeclSyntax node. + +Visit a `GenericArgumentListSyntax`. + +Visit a `SwitchDefaultLabelSyntax`. + +Visit any Syntax node. + +Deprecated + +Visit a `ClosureCaptureClauseSyntax`. + +Visit a `TuplePatternElementSyntax`. + +Visit a `GenericRequirementListSyntax`. + +Visit a `MemberBlockItemSyntax`. + +Visit a `PrefixOperatorExprSyntax`. + +Visit a `ContinueStmtSyntax`. + +Visit a `DoStmtSyntax`. + +Visit a `CodeBlockItemListSyntax`. + +Visit a `InOutExprSyntax`. + +Visit a `PrimaryAssociatedTypeListSyntax`. + +Visit a `AttributedTypeSyntax`. + +Visit a `SwitchCaseItemSyntax`. + +Visit a `ExpressionPatternSyntax`. + +Visit a `TypeAliasDeclSyntax`. + +Visit a `OperatorDeclSyntax`. + +Visit a `WhereClauseSyntax`. + +Visit a `DerivativeAttributeArgumentsSyntax`. + +Visit a `TupleTypeElementSyntax`. + +Visit a `DeclNameArgumentListSyntax`. + +Visit a `MemberBlockItemListSyntax`. + +Visit a `IfConfigClauseListSyntax`. + +Visit a `ReturnStmtSyntax`. + +Visit a `OptionalBindingConditionSyntax`. + +Visit a `PrimaryAssociatedTypeSyntax`. + +Visit a `MemberTypeSyntax`. + +Visit a `RegexLiteralExprSyntax`. + +Visit a `ForStmtSyntax`. + +Visit a `AttributeListSyntax`. + +Visit a `PrecedenceGroupAttributeListSyntax`. + +Visit a `TupleExprSyntax`. + +Visit a `StringLiteralExprSyntax`. + +Visit a `DictionaryElementSyntax`. + +Visit a `EditorPlaceholderExprSyntax`. + +Visit a `GenericRequirementSyntax`. + +Visit a `YieldedExpressionSyntax`. + +Visit a `DeclNameArgumentSyntax`. + +Visit a `NilLiteralExprSyntax`. + +Visit a `ObjCSelectorPieceSyntax`. + +Visit a `StringLiteralSegmentListSyntax`. + +Visit a `PostfixOperatorExprSyntax`. + +Visit a `OriginallyDefinedInAttributeArgumentsSyntax`. + +Visit a `IsExprSyntax`. + +Visit a `VersionComponentListSyntax`. + +Visit a `EnumCaseParameterListSyntax`. + +Visit a `EnumCaseElementSyntax`. + +Visit a `FloatLiteralExprSyntax`. + +Visit a `PrecedenceGroupDeclSyntax`. + +Visit a `DifferentiabilityWithRespectToArgumentSyntax`. + +Visit a `PlatformVersionItemSyntax`. + +Visit a `UnresolvedAsExprSyntax`. + +Visit a `CompositionTypeElementSyntax`. + +Visit a `PlatformVersionItemListSyntax`. + +Visit a `FunctionParameterClauseSyntax`. + +Visit a `ExposeAttributeArgumentsSyntax`. + +Visit a `IfConfigClauseSyntax`. + +Visit any PatternSyntax node. + +Override point to choose custom visitation dispatch instead of the specialized `visit(_:)` methods. Use this instead of those methods if you intend to dynamically dispatch rewriting behavior. + +`func visitPost(Syntax)` + +The function called after visiting the node and its descendants. + +`func visitPre(Syntax)` + +The function called before visiting the node and its descendants. + +## See Also + +### Syntax Visitors + +`class SyntaxVisitor` + +`class SyntaxAnyVisitor` + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +`enum SyntaxTreeViewMode` + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +`enum SyntaxVisitorContinueKind` + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +- SyntaxRewriter +- Topics +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxtreeviewmode + +- SwiftSyntax +- SyntaxTreeViewMode + +Enumeration + +# SyntaxTreeViewMode + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +enum SyntaxTreeViewMode + +SyntaxTreeViewMode.swift + +## Topics + +### Enumeration Cases + +`case all` + +Both missing and unexpected nodes will be traversed. + +`case fixedUp` + +Views the syntax tree with fixes applied, that is missing nodes will be visited but unexpected nodes will be skipped. This views the tree in a way that’s closer to being syntactical correct and should be used for structural analysis of the syntax tree. + +`case sourceAccurate` + +Visit the tree in a way that reproduces the original source code. Missing nodes will not be visited, unexpected nodes will be visited. This mode is useful for source code transformations like a formatter. + +## Relationships + +### Conforms To + +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` + +## See Also + +### Syntax Visitors + +`class SyntaxVisitor` + +`class SyntaxAnyVisitor` + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +`class SyntaxRewriter` + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +`enum SyntaxVisitorContinueKind` + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +- SyntaxTreeViewMode +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxvisitorcontinuekind + +- SwiftSyntax +- SyntaxVisitorContinueKind + +Enumeration + +# SyntaxVisitorContinueKind + +The enum describes how the `SyntaxVisitor` should continue after visiting the current node. + +enum SyntaxVisitorContinueKind + +SyntaxVisitor.swift + +## Topics + +### Enumeration Cases + +`case skipChildren` + +The visitor should avoid visiting the descendants of the current node. + +`case visitChildren` + +The visitor should visit the descendants of the current node. + +## Relationships + +### Conforms To + +- `Swift.Equatable` +- `Swift.Hashable` + +## See Also + +### Syntax Visitors + +`class SyntaxVisitor` + +`class SyntaxAnyVisitor` + +A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values. + +`class SyntaxRewriter` + +/ Automatically generated by generate-swift-syntax / Do not edit directly! + +`enum SyntaxTreeViewMode` + +Specifies how missing and unexpected nodes should be handled when traversing a syntax tree. + +`struct ReversedTokenSequence` + +Reverse sequence of tokens that are part of the provided Syntax node. + +- SyntaxVisitorContinueKind +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/reversedtokensequence + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declsyntax + +- SwiftSyntax +- DeclSyntax + +Structure + +# DeclSyntax + +struct DeclSyntax + +SyntaxBaseNodes.swift + +### Subtypes + +- `AccessorDeclSyntax` + +- `ActorDeclSyntax` + +- `AssociatedTypeDeclSyntax` + +- `ClassDeclSyntax` + +- `DeinitializerDeclSyntax` + +- `EditorPlaceholderDeclSyntax` + +- `EnumCaseDeclSyntax` + +- `EnumDeclSyntax` + +- `ExtensionDeclSyntax` + +- `FunctionDeclSyntax` + +- `IfConfigDeclSyntax` + +- `ImportDeclSyntax` + +- `InitializerDeclSyntax` + +- `MacroDeclSyntax` + +- `MacroExpansionDeclSyntax` + +- `MissingDeclSyntax` + +- `OperatorDeclSyntax` + +- `PoundSourceLocationSyntax` + +- `PrecedenceGroupDeclSyntax` + +- `ProtocolDeclSyntax` + +- `StructDeclSyntax` + +- `SubscriptDeclSyntax` + +- `TypeAliasDeclSyntax` + +- `VariableDeclSyntax` + +## Topics + +### Initializers + +`init?((some DeclSyntaxProtocol)?)` + +Create a `DeclSyntax` node from a specialized optional syntax node. + +`init?(some SyntaxProtocol)` + +`init(some DeclSyntaxProtocol)` + +Create a `DeclSyntax` node from a specialized syntax node. + +`init?(fromProtocol: (any DeclSyntaxProtocol)?)` + +`init(fromProtocol: any DeclSyntaxProtocol)` + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all Decl syntax nodes. + +Return the non-type erased version of this syntax node. + +Syntax nodes always conform to `DeclSyntaxProtocol`. This API is just added for consistency. + +Deprecated + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Declarations + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- DeclSyntax +- Subtypes +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declsyntaxprotocol + +- SwiftSyntax +- DeclSyntaxProtocol + +Protocol + +# DeclSyntaxProtocol + +Protocol to which all `DeclSyntax` nodes conform. + +protocol DeclSyntaxProtocol : SyntaxProtocol + +SyntaxBaseNodes.swift + +## Overview + +Extension point to add common methods to all `DeclSyntax` nodes. + +## Topics + +### Instance Methods + +Attempts to upcast the current syntax node to its base node type ( `DeclSyntax`). + +Deprecated + +Attempts to cast the current syntax node to a given node type from the a base node protocol hierarchy other than `DeclSyntaxProtocol`. + +Attempts to cast the current syntax node to a given specialized syntax type. + +Force-casts the current syntax node to a given node type from a base node protocol hierarchy other than `DeclSyntaxProtocol`. + +Force-casts the current syntax node to a given specialized syntax type. + +Force-upcast the current syntax node to its base node type ( `DeclSyntax`). + +Checks if the current syntax node can be cast to a given specialized syntax type. + +Checks if the current syntax node can be upcast to its base node type ( `DeclSyntax`). + +Checks if the current syntax node can be cast to a given node type from a base node protocol hierarchy other than `DeclSyntaxProtocol`. + +## Relationships + +### Inherits From + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Inherited By + +- `DeclGroupSyntax` + +### Conforming Types + +- `AccessorDeclSyntax` +- `ActorDeclSyntax` +- `AssociatedTypeDeclSyntax` +- `ClassDeclSyntax` +- `DeclSyntax` +- `DeinitializerDeclSyntax` +- `EditorPlaceholderDeclSyntax` +- `EnumCaseDeclSyntax` +- `EnumDeclSyntax` +- `ExtensionDeclSyntax` +- `FunctionDeclSyntax` +- `IfConfigDeclSyntax` +- `ImportDeclSyntax` +- `InitializerDeclSyntax` +- `MacroDeclSyntax` +- `MacroExpansionDeclSyntax` +- `MissingDeclSyntax` +- `OperatorDeclSyntax` +- `PoundSourceLocationSyntax` +- `PrecedenceGroupDeclSyntax` +- `ProtocolDeclSyntax` +- `StructDeclSyntax` +- `SubscriptDeclSyntax` +- `TypeAliasDeclSyntax` +- `VariableDeclSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- DeclSyntaxProtocol +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/missingdeclsyntax + +- SwiftSyntax +- MissingDeclSyntax + +Structure + +# MissingDeclSyntax + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +struct MissingDeclSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(attributes: AttributeListSyntax, modifiers: DeclModifierListSyntax, arena: SyntaxArena)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +If there were standalone attributes without a declaration to attach them to, the `MissingDeclSyntax` will contain these. + +`var modifiers: DeclModifierListSyntax` + +If there were standalone modifiers without a declaration to attach them to, the `MissingDeclSyntax` will contain these. + +`var placeholder: TokenSyntax` + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndPlaceholder: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `MissingNodeSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- MissingDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/accessordeclsyntax + +- SwiftSyntax +- AccessorDeclSyntax + +Structure + +# AccessorDeclSyntax + +struct AccessorDeclSyntax + +SyntaxNodesAB.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifier`: `DeclModifierSyntax`? + +- `accessorSpecifier`: ( `get` \| `set` \| `didSet` \| `willSet` \| `unsafeAddress` \| `addressWithOwner` \| `addressWithNativeOwner` \| `unsafeMutableAddress` \| `mutableAddressWithOwner` \| `mutableAddressWithNativeOwner` \| `_read` \| `read` \| `_modify` \| `modify` \| `init`) + +- `parameters`: `AccessorParametersSyntax`? + +- `effectSpecifiers`: `AccessorEffectSpecifiersSyntax`? + +- `body`: `CodeBlockSyntax`? + +### Contained in + +- `AccessorDeclListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifier: DeclModifierSyntax?, UnexpectedNodesSyntax?, accessorKind: TokenSyntax, UnexpectedNodesSyntax?, parameter: AccessorParametersSyntax?, UnexpectedNodesSyntax?, effectSpecifiers: AccessorEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifier: DeclModifierSyntax?, UnexpectedNodesSyntax?, accessorSpecifier: TokenSyntax, UnexpectedNodesSyntax?, parameters: AccessorParametersSyntax?, UnexpectedNodesSyntax?, effectSpecifiers: AccessorEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var accessorKind: TokenSyntax` Deprecated + +`var accessorSpecifier: TokenSyntax` + +`var attributes: AttributeListSyntax` + +`var body: CodeBlockSyntax?` + +`var effectSpecifiers: AccessorEffectSpecifiersSyntax?` + +`var modifier: DeclModifierSyntax?` + +`var parameter: AccessorParametersSyntax?` Deprecated + +`var parameters: AccessorParametersSyntax?` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAccessorKindAndParameter: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenAccessorSpecifierAndParameters: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEffectSpecifiersAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifierAndAccessorKind: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenModifierAndAccessorSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenParameterAndEffectSpecifiers: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenParametersAndEffectSpecifiers: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithOptionalCodeBlockSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- AccessorDeclSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/actordeclsyntax + +- SwiftSyntax +- ActorDeclSyntax + +Structure + +# ActorDeclSyntax + +struct ActorDeclSyntax + +SyntaxNodesAB.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `actorKeyword`: `actor` + +- `genericParameterClause`: `GenericParameterClauseSyntax`? + +- `inheritanceClause`: `InheritanceClauseSyntax`? + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +- `memberBlock`: `MemberBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, actorKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, actorKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var actorKeyword: TokenSyntax` + +The `actor` keyword. + +`var attributes: AttributeListSyntax` + +`var genericParameterClause: GenericParameterClauseSyntax?` + +The parameter clause that defines the generic parameters. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`. + +`var identifier: TokenSyntax` Deprecated + +`var inheritanceClause: InheritanceClauseSyntax?` + +`var memberBlock: MemberBlockSyntax` + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the actor declaration. + +`var name: TokenSyntax` + +The name of the actor. If the name matches a reserved keyword use backticks to escape it. + +`var unexpectedAfterMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenActorKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenActorKeywordAndName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParameterClauseAndInheritanceClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericWhereClauseAndMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndGenericParameterClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritanceClauseAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndActorKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericParameterClause: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclGroupSyntax` +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithGenericParametersSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- ActorDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/associatedtypedeclsyntax-swift.struct + +- SwiftSyntax +- AssociatedTypeDeclSyntax + +Structure + +# AssociatedTypeDeclSyntax + +An `associatedtype` declaration + +struct AssociatedTypeDeclSyntax + +SyntaxNodesAB.swift + +## Overview + +An example of an associatedtype declaration is + +associatedtype Item + +An associated type declaration may contain a type initializer clause which represents a default type assignment for the associated type. + +associatedtype Item = Int + +An associated type declaration may be declared with an inheritance clause which specifies the required conformances. + +associatedtype Iterator: IteratorProtocol + +A generic where clause may be present, here is an example which shows an associated type containing an inheritance clauses and a generic where clause. + +associatedtype Iterator: IteratorProtocol where Iterator.Element == Item + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `associatedtypeKeyword`: `associatedtype` + +- `inheritanceClause`: `InheritanceClauseSyntax`? + +- `initializer`: `TypeInitializerClauseSyntax`? + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, associatedtypeKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, initializer: TypeInitializerClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, associatedtypeKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, initializer: TypeInitializerClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var associatedtypeKeyword: TokenSyntax` + +The `associatedtype` keyword for this declaration. + +`var attributes: AttributeListSyntax` + +Attributes attached to the associated type declaration. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +The `where` clause that applies to the generic parameters of this associated type declaration. + +`var identifier: TokenSyntax` Deprecated + +`var inheritanceClause: InheritanceClauseSyntax?` + +The inheritance clause describing conformances for this associated type declaration. + +`var initializer: TypeInitializerClauseSyntax?` + +The type initializer clause for this associated type declaration which represents a default type assignment for the associated type. + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the associated type declaration. + +`var name: TokenSyntax` + +The name of this associated type. + +`var unexpectedAfterGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAssociatedtypeKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenAssociatedtypeKeywordAndName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndInheritanceClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritanceClauseAndInitializer: UnexpectedNodesSyntax?` + +`var unexpectedBetweenInitializerAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndAssociatedtypeKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndInheritanceClause: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- AssociatedTypeDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/classdeclsyntax + +- SwiftSyntax +- ClassDeclSyntax + +Structure + +# ClassDeclSyntax + +A `class` declaration + +struct ClassDeclSyntax + +SyntaxNodesC.swift + +## Overview + +An example of a class declaration is + +class SomeClass { +let someMember: String + +init(someMember: String) { +self.someMember = someMember +} + +func foo() { +print(someMember) +} + +return 1 +} +} + +A class declaration may be declared without any members. + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `classKeyword`: `class` + +- `genericParameterClause`: `GenericParameterClauseSyntax`? + +- `inheritanceClause`: `InheritanceClauseSyntax`? + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +- `memberBlock`: `MemberBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, classKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, classKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes attached to the class declaration, such as an `@available` attribute. + +`var classKeyword: TokenSyntax` + +The `class` keyword for this declaration. + +`var genericParameterClause: GenericParameterClauseSyntax?` + +The generic parameters, if any, of the class declaration. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +The `where` clause that applies to the generic parameters of this class declaration. + +`var identifier: TokenSyntax` Deprecated + +`var inheritanceClause: InheritanceClauseSyntax?` + +The inheritance clause describing one or more conformances for this class declaration. + +`var memberBlock: MemberBlockSyntax` + +The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn’t guaranteed to be a complete list of members for this type. + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the class declaration. + +`var name: TokenSyntax` + +The name of the class. + +`var unexpectedAfterMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenClassKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenClassKeywordAndName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParameterClauseAndInheritanceClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericWhereClauseAndMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndGenericParameterClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritanceClauseAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndClassKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericParameterClause: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclGroupSyntax` +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithGenericParametersSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- ClassDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/deinitializerdeclsyntax + +- SwiftSyntax +- DeinitializerDeclSyntax + +Structure + +# DeinitializerDeclSyntax + +A `deinit` declaration + +struct DeinitializerDeclSyntax + +SyntaxNodesD.swift + +## Overview + +An example of a deinitializer is + +deinit { +} + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `deinitKeyword`: `deinit` + +- `effectSpecifiers`: `DeinitializerEffectSpecifiersSyntax`? + +- `body`: `CodeBlockSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, deinitKeyword: TokenSyntax, UnexpectedNodesSyntax?, effectSpecifiers: DeinitializerEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes that are attached to the deinitializer. + +`var body: CodeBlockSyntax?` + +The deinitializer’s body. + +`var deinitKeyword: TokenSyntax` + +The `deinit` keyword. + +`var effectSpecifiers: DeinitializerEffectSpecifiersSyntax?` + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the deinitializer. + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDeinitKeywordAndEffectSpecifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEffectSpecifiersAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndDeinitKeyword: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` +- `WithOptionalCodeBlockSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- DeinitializerDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/editorplaceholderdeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumcasedeclsyntax + +- SwiftSyntax +- EnumCaseDeclSyntax + +Structure + +# EnumCaseDeclSyntax + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +struct EnumCaseDeclSyntax + +SyntaxNodesEF.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `caseKeyword`: `case` + +- `elements`: `EnumCaseElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, caseKeyword: TokenSyntax, UnexpectedNodesSyntax?, elements: EnumCaseElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +The attributes applied to the case declaration. + +`var caseKeyword: TokenSyntax` + +The `case` keyword for this case. + +`var elements: EnumCaseElementListSyntax` + +The elements this case declares. + +`var modifiers: DeclModifierListSyntax` + +The declaration modifiers applied to the case declaration. + +`var unexpectedAfterElements: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCaseKeywordAndElements: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndCaseKeyword: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `elements` collection. + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- EnumCaseDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumdeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/extensiondeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/functiondeclsyntax + +- SwiftSyntax +- FunctionDeclSyntax + +Structure + +# FunctionDeclSyntax + +A Swift `func` declaration. + +struct FunctionDeclSyntax + +SyntaxNodesEF.swift + +### Example + +A func declaration may be declared without any parameter. + +func foo() { + +} + +A func declaration with multiple parameters. + +func bar(_ arg1: Int, _ arg2: Int) { + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `funcKeyword`: `func` + +- `genericParameterClause`: `GenericParameterClauseSyntax`? + +- `signature`: `FunctionSignatureSyntax` + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +- `body`: `CodeBlockSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, funcKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, signature: FunctionSignatureSyntax, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, funcKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, signature: FunctionSignatureSyntax, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes that are attached to the function declaration. + +`var body: CodeBlockSyntax?` + +The function’s body. + +`var funcKeyword: TokenSyntax` + +The `func` keyword. + +`var genericParameterClause: GenericParameterClauseSyntax?` + +The parameter clause that defines the generic parameters. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`. + +`var identifier: TokenSyntax` Deprecated + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the function declaration. + +`var name: TokenSyntax` + +The name of the function. If the name matches a reserved keyword use backticks to escape it. + +`var signature: FunctionSignatureSyntax` + +A function signature that defines the interface of the function. + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFuncKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenFuncKeywordAndName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParameterClauseAndSignature: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericWhereClauseAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndGenericParameterClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenModifiersAndFuncKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericParameterClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSignatureAndGenericWhereClause: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithGenericParametersSyntax` +- `WithModifiersSyntax` +- `WithOptionalCodeBlockSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- FunctionDeclSyntax +- Example +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/ifconfigdeclsyntax + +- SwiftSyntax +- IfConfigDeclSyntax + +Structure + +# IfConfigDeclSyntax + +struct IfConfigDeclSyntax + +SyntaxNodesGHI.swift + +### Children + +- `clauses`: `IfConfigClauseListSyntax` + +- `poundEndif`: `#endif` + +### Contained in + +- `AttributeListSyntax` + +- `PostfixIfConfigExprSyntax`. `config` + +- `SwitchCaseListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, clauses: IfConfigClauseListSyntax, UnexpectedNodesSyntax?, poundEndif: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var clauses: IfConfigClauseListSyntax` + +`var poundEndif: TokenSyntax` + +`var unexpectedAfterPoundEndif: UnexpectedNodesSyntax?` + +`var unexpectedBeforeClauses: UnexpectedNodesSyntax?` + +`var unexpectedBetweenClausesAndPoundEndif: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `clauses` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct ImportDeclSyntax` + +An `import` declaration + +`struct InitializerDeclSyntax` + +An `init` declaration + +- IfConfigDeclSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/importdeclsyntax + +- SwiftSyntax +- ImportDeclSyntax + +Structure + +# ImportDeclSyntax + +An `import` declaration + +struct ImportDeclSyntax + +SyntaxNodesGHI.swift + +## Overview + +An example of an import declaration is + +import Foundation + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `importKeyword`: `import` + +- `importKindSpecifier`: ( `typealias` \| `struct` \| `class` \| `enum` \| `protocol` \| `var` \| `let` \| `func` \| `inout`)? + +- `path`: `ImportPathComponentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, importKeyword: TokenSyntax, UnexpectedNodesSyntax?, importKindSpecifier: TokenSyntax?, UnexpectedNodesSyntax?, path: ImportPathComponentListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, importTok: TokenSyntax, UnexpectedNodesSyntax?, importKind: TokenSyntax?, UnexpectedNodesSyntax?, path: ImportPathComponentListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes attached to the import declaration, for example `@testable`. + +`var importKeyword: TokenSyntax` + +The `import` keyword for this declaration. + +`var importKind: TokenSyntax?` Deprecated + +`var importKindSpecifier: TokenSyntax?` + +The kind of declaration being imported. + +`var importTok: TokenSyntax` Deprecated + +`var modifiers: DeclModifierListSyntax` + +Modifiers that are attached to the import declaration. Currently, no modifiers are supported by Swift. + +`var path: ImportPathComponentListSyntax` + +The path to the module, submodule or symbol being imported. + +`var unexpectedAfterPath: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenImportKeywordAndImportKindSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenImportKindAndPath: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenImportKindSpecifierAndPath: UnexpectedNodesSyntax?` + +`var unexpectedBetweenImportTokAndImportKind: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenModifiersAndImportKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax?` Deprecated + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +Adds the provided `element` to the node’s `path` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct InitializerDeclSyntax` + +An `init` declaration + +- ImportDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/initializerdeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/macrodeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/macroexpansiondeclsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/operatordeclsyntax + +- SwiftSyntax +- OperatorDeclSyntax + +Structure + +# OperatorDeclSyntax + +A Swift `operator` declaration. + +struct OperatorDeclSyntax + +SyntaxNodesOP.swift + +### Children + +- `fixitySpecifier`: ( `prefix` \| `postfix` \| `infix`) + +- `operatorKeyword`: `operator` + +- `operatorPrecedenceAndTypes`: `OperatorPrecedenceAndTypesSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, fixity: TokenSyntax, UnexpectedNodesSyntax?, operatorKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, operatorPrecedenceAndTypes: OperatorPrecedenceAndTypesSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, fixitySpecifier: TokenSyntax, UnexpectedNodesSyntax?, operatorKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, operatorPrecedenceAndTypes: OperatorPrecedenceAndTypesSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var fixity: TokenSyntax` Deprecated + +`var fixitySpecifier: TokenSyntax` + +The fixity applied to the ‘operator’ declaration. + +`var identifier: TokenSyntax` Deprecated + +`var name: TokenSyntax` + +`var operatorKeyword: TokenSyntax` + +`var operatorPrecedenceAndTypes: OperatorPrecedenceAndTypesSyntax?` + +Optionally specify a precedence group and designated types. + +`var unexpectedAfterOperatorPrecedenceAndTypes: UnexpectedNodesSyntax?` + +`var unexpectedBeforeFixity: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeFixitySpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFixityAndOperatorKeyword: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenFixitySpecifierAndOperatorKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndOperatorPrecedenceAndTypes: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenNameAndOperatorPrecedenceAndTypes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOperatorKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOperatorKeywordAndName: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- OperatorDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/poundsourcelocationsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/precedencegroupdeclsyntax + +- SwiftSyntax +- PrecedenceGroupDeclSyntax + +Structure + +# PrecedenceGroupDeclSyntax + +A Swift `precedencegroup` declaration. + +struct PrecedenceGroupDeclSyntax + +SyntaxNodesOP.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `precedencegroupKeyword`: `precedencegroup` + +- `leftBrace`: `{` + +- `groupAttributes`: `PrecedenceGroupAttributeListSyntax` + +- `rightBrace`: `}` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, precedencegroupKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, leftBrace: TokenSyntax, UnexpectedNodesSyntax?, groupAttributes: PrecedenceGroupAttributeListSyntax, UnexpectedNodesSyntax?, rightBrace: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, precedencegroupKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, leftBrace: TokenSyntax, UnexpectedNodesSyntax?, groupAttributes: PrecedenceGroupAttributeListSyntax, UnexpectedNodesSyntax?, rightBrace: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +The attributes applied to the ‘precedencegroup’ declaration. + +`var groupAttributes: PrecedenceGroupAttributeListSyntax` + +The characteristics of this precedence group. + +`var identifier: TokenSyntax` Deprecated + +`var leftBrace: TokenSyntax` + +`var modifiers: DeclModifierListSyntax` + +The declaration modifiers applied to the ‘precedencegroup’ declaration. + +`var name: TokenSyntax` + +The name of this precedence group. + +`var precedencegroupKeyword: TokenSyntax` + +`var rightBrace: TokenSyntax` + +`var unexpectedAfterRightBrace: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGroupAttributesAndRightBrace: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndLeftBrace: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftBraceAndGroupAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndPrecedencegroupKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndLeftBrace: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPrecedencegroupKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenPrecedencegroupKeywordAndName: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `groupAttributes` collection. + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `BracedSyntax` +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- PrecedenceGroupDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/protocoldeclsyntax + +- SwiftSyntax +- ProtocolDeclSyntax + +Structure + +# ProtocolDeclSyntax + +A `protocol` declaration + +struct ProtocolDeclSyntax + +SyntaxNodesOP.swift + +## Overview + +An example of a protocol declaration is + +protocol Example { +var isValid: Bool { get } +} + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `protocolKeyword`: `protocol` + +- `primaryAssociatedTypeClause`: `PrimaryAssociatedTypeClauseSyntax`? + +- `inheritanceClause`: `InheritanceClauseSyntax`? + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +- `memberBlock`: `MemberBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, protocolKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, primaryAssociatedTypeClause: PrimaryAssociatedTypeClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, protocolKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, primaryAssociatedTypeClause: PrimaryAssociatedTypeClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes attached to the protocol declaration, such as an `@available` attribute. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +The `where` clause that applies to the generic parameters of this protocol declaration. + +`var identifier: TokenSyntax` Deprecated + +`var inheritanceClause: InheritanceClauseSyntax?` + +The inheritance clause describing one or more conformances for this protocol declaration. + +`var memberBlock: MemberBlockSyntax` + +The members of the protocol declaration. + +`var modifiers: DeclModifierListSyntax` + +Modifiers attached to the protocol declaration, such as `public`. + +`var name: TokenSyntax` + +The name of the protocol. + +`var primaryAssociatedTypeClause: PrimaryAssociatedTypeClauseSyntax?` + +The primary associated type for the protocol. + +`var protocolKeyword: TokenSyntax` + +The `protocol` keyword for this declaration. + +`var unexpectedAfterMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericWhereClauseAndMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndPrimaryAssociatedTypeClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritanceClauseAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndProtocolKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndPrimaryAssociatedTypeClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPrimaryAssociatedTypeClauseAndInheritanceClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenProtocolKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenProtocolKeywordAndName: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclGroupSyntax` +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- ProtocolDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/structdeclsyntax + +- SwiftSyntax +- StructDeclSyntax + +Structure + +# StructDeclSyntax + +A `struct` declaration + +struct StructDeclSyntax + +SyntaxNodesQRS.swift + +## Overview + +An example of a struct declaration is + +struct SomeStruct { +let someMember: String +var anotherMember: Int + +func foo() { +print(someMember) +} + +mutating func bar() { +anotherMember = 42 +} +} + +A struct declaration may be declared without any members. + +struct EmptyStruct { + +} + +A struct declaration may include a type inheritance clause listing one or more protocols the struct conforms to. + +The example below uses Hashable and Equatable protocols whose members are automatically synthesized by the compiler if the struct contains stored members that are themselves `Hashable` and `Equatable`. + +struct AdvancedStruct: Hashable, Equatable { +let someMember: String +var anotherMember: Int +} + +A struct declaration may include a generic parameter clause as well as a generic where clause. + +var items: [Element] = [] + +mutating func push(_ item: Element) { +items.append(item) +} + +return items.removeLast() +} +} + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `structKeyword`: `struct` + +- `genericParameterClause`: `GenericParameterClauseSyntax`? + +- `inheritanceClause`: `InheritanceClauseSyntax`? + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +- `memberBlock`: `MemberBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, structKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, structKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, inheritanceClause: InheritanceClauseSyntax?, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, memberBlock: MemberBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes that are attached to the struct declaration. + +`var genericParameterClause: GenericParameterClauseSyntax?` + +The generic parameters, if any, of the struct declaration. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +The `where` clause that applies to the generic parameters of this struct declaration. + +`var identifier: TokenSyntax` Deprecated + +`var inheritanceClause: InheritanceClauseSyntax?` + +The struct declaration inheritance clause describing one or more conformances for this struct declaration. + +`var memberBlock: MemberBlockSyntax` + +The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn’t guaranteed to be a complete list of members for this type. + +`var modifiers: DeclModifierListSyntax` + +Modifiers like `public` that are attached to the struct declaration. + +`var name: TokenSyntax` + +Declares the name of this struct. If the name matches a reserved keyword use backticks to escape it. + +`var structKeyword: TokenSyntax` + +The `struct` keyword for this declaration. + +`var unexpectedAfterMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParameterClauseAndInheritanceClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericWhereClauseAndMemberBlock: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndGenericParameterClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritanceClauseAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndStructKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericParameterClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenStructKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenStructKeywordAndName: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclGroupSyntax` +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithGenericParametersSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- StructDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/subscriptdeclsyntax + +Has it really been five years since Swift Package Index launched? Read our anniversary blog post! + +#### 404 - Not Found + +If you were expecting to find a page here, please raise an issue. + +From here, you'll want to go to the home page or search for a package. + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/typealiasdeclsyntax-swift.struct + +- SwiftSyntax +- TypeAliasDeclSyntax + +Structure + +# TypeAliasDeclSyntax + +struct TypeAliasDeclSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `typealiasKeyword`: `typealias` + +- `genericParameterClause`: `GenericParameterClauseSyntax`? + +- `initializer`: `TypeInitializerClauseSyntax` + +- `genericWhereClause`: `GenericWhereClauseSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, typealiasKeyword: TokenSyntax, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, initializer: TypeInitializerClauseSyntax, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, typealiasKeyword: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax?, UnexpectedNodesSyntax?, initializer: TypeInitializerClauseSyntax, UnexpectedNodesSyntax?, genericWhereClause: GenericWhereClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +`var genericParameterClause: GenericParameterClauseSyntax?` + +The parameter clause that defines the generic parameters. + +`var genericWhereClause: GenericWhereClauseSyntax?` + +A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`. + +`var identifier: TokenSyntax` Deprecated + +`var initializer: TypeInitializerClauseSyntax` + +`var modifiers: DeclModifierListSyntax` + +`var name: TokenSyntax` + +`var typealiasKeyword: TokenSyntax` + +`var unexpectedAfterGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParameterClauseAndInitializer: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndGenericParameterClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInitializerAndGenericWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndTypealiasKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericParameterClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypealiasKeywordAndIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenTypealiasKeywordAndName: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `NamedDeclSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithGenericParametersSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- TypeAliasDeclSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/variabledeclsyntax + +- SwiftSyntax +- VariableDeclSyntax + +Structure + +# VariableDeclSyntax + +Declaration of one or more variables + +struct VariableDeclSyntax + +SyntaxNodesTUVWXYZ.swift + +## Overview + +The core of a variable declaration consists of a binding specifier ( `let` or `var`), followed by any number of pattern bindings, which define the variables. + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `bindingSpecifier`: ( `let` \| `var` \| `inout` \| `_mutating` \| `_borrowing` \| `_consuming`) + +- `bindings`: `PatternBindingListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, bindingKeyword: TokenSyntax, UnexpectedNodesSyntax?, bindings: PatternBindingListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, bindingSpecifier: TokenSyntax, UnexpectedNodesSyntax?, bindings: PatternBindingListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +`var bindingKeyword: TokenSyntax` Deprecated + +`var bindingSpecifier: TokenSyntax` + +The specifier that defines the type of the variables declared ( `let` or `var`). + +`var bindings: PatternBindingListSyntax` + +The pattern bindings that define the actual variables. + +`var modifiers: DeclModifierListSyntax` + +Modifiers modifiers applied to the variable declaration. + +`var unexpectedAfterBindings: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBindingKeywordAndBindings: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenBindingSpecifierAndBindings: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndBindingKeyword: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenModifiersAndBindingSpecifier: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `bindings` collection. + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `DeclSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` + +## See Also + +### Declarations + +`struct DeclSyntax` + +`protocol DeclSyntaxProtocol` + +Protocol to which all `DeclSyntax` nodes conform. + +`struct MissingDeclSyntax` + +In case the source code is missing a declaration, this node stands in place of the missing declaration. + +`struct AccessorDeclSyntax` + +`struct ActorDeclSyntax` + +`struct AssociatedTypeDeclSyntax` + +An `associatedtype` declaration + +`struct ClassDeclSyntax` + +A `class` declaration + +`struct DeinitializerDeclSyntax` + +A `deinit` declaration + +`struct EditorPlaceholderDeclSyntax` + +`struct EnumCaseDeclSyntax` + +A `case` declaration of a Swift `enum`. It can have 1 or more `EnumCaseElement` s inside, each declaring a different case of the enum. + +`struct EnumDeclSyntax` + +A Swift `enum` declaration. + +`struct ExtensionDeclSyntax` + +An `extension` declaration. + +`struct FunctionDeclSyntax` + +A Swift `func` declaration. + +`struct IfConfigDeclSyntax` + +`struct ImportDeclSyntax` + +An `import` declaration + +- VariableDeclSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/exprsyntax + +- SwiftSyntax +- ExprSyntax + +Structure + +# ExprSyntax + +struct ExprSyntax + +SyntaxBaseNodes.swift + +### Subtypes + +- `ArrayExprSyntax` + +- `ArrowExprSyntax` + +- `AsExprSyntax` + +- `AssignmentExprSyntax` + +- `AwaitExprSyntax` + +- `BinaryOperatorExprSyntax` + +- `BooleanLiteralExprSyntax` + +- `BorrowExprSyntax` + +- `ClosureExprSyntax` + +- `ConsumeExprSyntax` + +- `CopyExprSyntax` + +- `DeclReferenceExprSyntax` + +- `DictionaryExprSyntax` + +- `DiscardAssignmentExprSyntax` + +- `EditorPlaceholderExprSyntax` + +- `FloatLiteralExprSyntax` + +- `ForceUnwrapExprSyntax` + +- `FunctionCallExprSyntax` + +- `GenericSpecializationExprSyntax` + +- `IfExprSyntax` + +- `InOutExprSyntax` + +- `InfixOperatorExprSyntax` + +- `IntegerLiteralExprSyntax` + +- `IsExprSyntax` + +- `KeyPathExprSyntax` + +- `MacroExpansionExprSyntax` + +- `MemberAccessExprSyntax` + +- `MissingExprSyntax` + +- `NilLiteralExprSyntax` + +- `OptionalChainingExprSyntax` + +- `PackElementExprSyntax` + +- `PackExpansionExprSyntax` + +- `PatternExprSyntax` + +- `PostfixIfConfigExprSyntax` + +- `PostfixOperatorExprSyntax` + +- `PrefixOperatorExprSyntax` + +- `RegexLiteralExprSyntax` + +- `SequenceExprSyntax` + +- `SimpleStringLiteralExprSyntax` + +- `StringLiteralExprSyntax` + +- `SubscriptCallExprSyntax` + +- `SuperExprSyntax` + +- `SwitchExprSyntax` + +- `TernaryExprSyntax` + +- `TryExprSyntax` + +- `TupleExprSyntax` + +- `TypeExprSyntax` + +- `UnresolvedAsExprSyntax` + +- `UnresolvedIsExprSyntax` + +- `UnresolvedTernaryExprSyntax` + +## Topics + +### Initializers + +`init?((some ExprSyntaxProtocol)?)` + +Create a `ExprSyntax` node from a specialized optional syntax node. + +`init(some ExprSyntaxProtocol)` + +Create a `ExprSyntax` node from a specialized syntax node. + +`init?(some SyntaxProtocol)` + +`init(fromProtocol: any ExprSyntaxProtocol)` + +`init?(fromProtocol: (any ExprSyntaxProtocol)?)` + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all Expr syntax nodes. + +Return the non-type erased version of this syntax node. + +Syntax nodes always conform to `ExprSyntaxProtocol`. This API is just added for consistency. + +Deprecated + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ExprSyntax +- Subtypes +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/exprsyntaxprotocol + +- SwiftSyntax +- ExprSyntaxProtocol + +Protocol + +# ExprSyntaxProtocol + +Protocol to which all `ExprSyntax` nodes conform. + +protocol ExprSyntaxProtocol : SyntaxProtocol + +SyntaxBaseNodes.swift + +## Overview + +Extension point to add common methods to all `ExprSyntax` nodes. + +## Topics + +### Instance Methods + +Attempts to cast the current syntax node to a given specialized syntax type. + +Attempts to cast the current syntax node to a given node type from the a base node protocol hierarchy other than `ExprSyntaxProtocol`. + +Deprecated + +Attempts to upcast the current syntax node to its base node type ( `ExprSyntax`). + +Force-casts the current syntax node to a given specialized syntax type. + +Force-upcast the current syntax node to its base node type ( `ExprSyntax`). + +Force-casts the current syntax node to a given node type from a base node protocol hierarchy other than `ExprSyntaxProtocol`. + +Checks if the current syntax node can be cast to a given node type from a base node protocol hierarchy other than `ExprSyntaxProtocol`. + +Checks if the current syntax node can be upcast to its base node type ( `ExprSyntax`). + +Checks if the current syntax node can be cast to a given specialized syntax type. + +## Relationships + +### Inherits From + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Conforming Types + +- `ArrayExprSyntax` +- `ArrowExprSyntax` +- `AsExprSyntax` +- `AssignmentExprSyntax` +- `AwaitExprSyntax` +- `BinaryOperatorExprSyntax` +- `BooleanLiteralExprSyntax` +- `BorrowExprSyntax` +- `ClosureExprSyntax` +- `ConsumeExprSyntax` +- `CopyExprSyntax` +- `DeclReferenceExprSyntax` +- `DictionaryExprSyntax` +- `DiscardAssignmentExprSyntax` +- `EditorPlaceholderExprSyntax` +- `ExprSyntax` +- `FloatLiteralExprSyntax` +- `ForceUnwrapExprSyntax` +- `FunctionCallExprSyntax` +- `GenericSpecializationExprSyntax` +- `IfExprSyntax` +- `InOutExprSyntax` +- `InfixOperatorExprSyntax` +- `IntegerLiteralExprSyntax` +- `IsExprSyntax` +- `KeyPathExprSyntax` +- `MacroExpansionExprSyntax` +- `MemberAccessExprSyntax` +- `MissingExprSyntax` +- `NilLiteralExprSyntax` +- `OptionalChainingExprSyntax` +- `PackElementExprSyntax` +- `PackExpansionExprSyntax` +- `PatternExprSyntax` +- `PostfixIfConfigExprSyntax` +- `PostfixOperatorExprSyntax` +- `PrefixOperatorExprSyntax` +- `RegexLiteralExprSyntax` +- `SequenceExprSyntax` +- `SimpleStringLiteralExprSyntax` +- `StringLiteralExprSyntax` +- `SubscriptCallExprSyntax` +- `SuperExprSyntax` +- `SwitchExprSyntax` +- `TernaryExprSyntax` +- `TryExprSyntax` +- `TupleExprSyntax` +- `TypeExprSyntax` +- `UnresolvedAsExprSyntax` +- `UnresolvedIsExprSyntax` +- `UnresolvedTernaryExprSyntax` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ExprSyntaxProtocol +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/missingexprsyntax + +- SwiftSyntax +- MissingExprSyntax + +Structure + +# MissingExprSyntax + +In case the source code is missing an expression, this node stands in place of the missing expression. + +struct MissingExprSyntax + +SyntaxNodesJKLMN.swift + +## Topics + +### Initializers + +`init()` + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var placeholder: TokenSyntax` + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforePlaceholder: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `MissingNodeSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- MissingExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/arrayexprsyntax + +- SwiftSyntax +- ArrayExprSyntax + +Structure + +# ArrayExprSyntax + +An array literal. + +struct ArrayExprSyntax + +SyntaxNodesAB.swift + +### Children + +- `leftSquare`: ``\ +\ +- `elements`: [`ArrayElementListSyntax`\ +\ +- `rightSquare`: `]` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquare: TokenSyntax, UnexpectedNodesSyntax?, elements: ArrayElementListSyntax, UnexpectedNodesSyntax?, rightSquare: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, elements: ArrayElementListSyntax, UnexpectedNodesSyntax?, rightSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var elements: ArrayElementListSyntax` + +`var leftSquare: TokenSyntax` + +`var leftSquareBracket: TokenSyntax` Deprecated + +`var rightSquare: TokenSyntax` + +`var rightSquareBracket: TokenSyntax` Deprecated + +`var unexpectedAfterRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedAfterRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLeftSquare: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenElementsAndRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElementsAndRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftSquareAndElements: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftSquareBracketAndElements: UnexpectedNodesSyntax?` Deprecated + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ArrayExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/arrowexprsyntax + +- SwiftSyntax +- ArrowExprSyntax + +Structure + +# ArrowExprSyntax + +The arrow when a type is used at a position that syntactically expectes an expression. + +struct ArrowExprSyntax + +SyntaxNodesAB.swift + +### Examples + +This represents the arrow in + +### Children + +- `effectSpecifiers`: `TypeEffectSpecifiersSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, effectSpecifiers: TypeEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, arrow: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, effectSpecifiers: TypeEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, arrowToken: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var arrow: TokenSyntax` + +`var arrowToken: TokenSyntax` Deprecated + +`var effectSpecifiers: TypeEffectSpecifiersSyntax?` + +`var unexpectedAfterArrow: UnexpectedNodesSyntax?` + +`var unexpectedAfterArrowToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeEffectSpecifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEffectSpecifiersAndArrow: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEffectSpecifiersAndArrowToken: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ArrowExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/asexprsyntax + +- SwiftSyntax +- AsExprSyntax + +Structure + +# AsExprSyntax + +The cast of an expressison to a different type. + +struct AsExprSyntax + +SyntaxNodesAB.swift + +### Examples + +dog as Animal + +myPet as? Dog + +### Children + +- `expression`: `ExprSyntax` + +- `asKeyword`: `as` + +- `questionOrExclamationMark`: ( `?` \| `!`)? + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, asKeyword: TokenSyntax, UnexpectedNodesSyntax?, questionOrExclamationMark: TokenSyntax?, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, asTok: TokenSyntax, UnexpectedNodesSyntax?, questionOrExclamationMark: TokenSyntax?, UnexpectedNodesSyntax?, typeName: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var asKeyword: TokenSyntax` + +`var asTok: TokenSyntax` Deprecated + +`var expression: ExprSyntax` + +`var questionOrExclamationMark: TokenSyntax?` + +`var type: TypeSyntax` + +`var typeName: TypeSyntax` Deprecated + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedAfterTypeName: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAsKeywordAndQuestionOrExclamationMark: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAsTokAndQuestionOrExclamationMark: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenExpressionAndAsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndAsTok: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenQuestionOrExclamationMarkAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenQuestionOrExclamationMarkAndTypeName: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- AsExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/assignmentexprsyntax + +- SwiftSyntax +- AssignmentExprSyntax + +Structure + +# AssignmentExprSyntax + +struct AssignmentExprSyntax + +SyntaxNodesAB.swift + +### Children + +- `equal`: `=` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, assignToken: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, equal: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var assignToken: TokenSyntax` Deprecated + +`var equal: TokenSyntax` + +`var unexpectedAfterAssignToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterEqual: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAssignToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeEqual: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- AssignmentExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/awaitexprsyntax + +- SwiftSyntax +- AwaitExprSyntax + +Structure + +# AwaitExprSyntax + +struct AwaitExprSyntax + +SyntaxNodesAB.swift + +### Children + +- `awaitKeyword`: `await` + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, awaitKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var awaitKeyword: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAwaitKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAwaitKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- AwaitExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/binaryoperatorexprsyntax + +- SwiftSyntax +- BinaryOperatorExprSyntax + +Structure + +# BinaryOperatorExprSyntax + +An operator like `+` or `-`. + +struct BinaryOperatorExprSyntax + +SyntaxNodesAB.swift + +## Overview + +This node represents the binary operator itself. It can occur inside a `SequenceExprSyntax` after parsing and will be the `operator` child of an `InfixOperatorExprSyntax` after folding operator using the `SwiftOperators` library. + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, operator: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, operatorToken: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +``var `operator`: TokenSyntax`` + +`var operatorToken: TokenSyntax` Deprecated + +`var unexpectedAfterOperator: UnexpectedNodesSyntax?` + +`var unexpectedAfterOperatorToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeOperator: UnexpectedNodesSyntax?` + +`var unexpectedBeforeOperatorToken: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- BinaryOperatorExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/booleanliteralexprsyntax + +- SwiftSyntax +- BooleanLiteralExprSyntax + +Structure + +# BooleanLiteralExprSyntax + +struct BooleanLiteralExprSyntax + +SyntaxNodesAB.swift + +### Children + +- `literal`: ( `true` \| `false`) + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, booleanLiteral: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, literal: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var booleanLiteral: TokenSyntax` Deprecated + +`var literal: TokenSyntax` + +`var unexpectedAfterBooleanLiteral: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterLiteral: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBooleanLiteral: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLiteral: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- BooleanLiteralExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/borrowexprsyntax + +- SwiftSyntax +- BorrowExprSyntax + +Structure + +# BorrowExprSyntax + +struct BorrowExprSyntax + +SyntaxNodesAB.swift + +### Children + +- `borrowKeyword`: ( `_borrow` \| `borrow`) + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, borrowKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var borrowKeyword: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBorrowKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBorrowKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- BorrowExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closureexprsyntax + +- SwiftSyntax +- ClosureExprSyntax + +Structure + +# ClosureExprSyntax + +struct ClosureExprSyntax + +SyntaxNodesC.swift + +### Children + +- `leftBrace`: `{` + +- `signature`: `ClosureSignatureSyntax`? + +- `statements`: `CodeBlockItemListSyntax` + +- `rightBrace`: `}` + +### Contained in + +- `FunctionCallExprSyntax`. `trailingClosure` + +- `MacroExpansionDeclSyntax`. `trailingClosure` + +- `MacroExpansionExprSyntax`. `trailingClosure` + +- `MultipleTrailingClosureElementSyntax`. `closure` + +- `SubscriptCallExprSyntax`. `trailingClosure` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftBrace: TokenSyntax, UnexpectedNodesSyntax?, signature: ClosureSignatureSyntax?, UnexpectedNodesSyntax?, statements: CodeBlockItemListSyntax, UnexpectedNodesSyntax?, rightBrace: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var leftBrace: TokenSyntax` + +`var rightBrace: TokenSyntax` + +`var signature: ClosureSignatureSyntax?` + +`var statements: CodeBlockItemListSyntax` + +`var unexpectedAfterRightBrace: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftBrace: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftBraceAndSignature: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSignatureAndStatements: UnexpectedNodesSyntax?` + +`var unexpectedBetweenStatementsAndRightBrace: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `statements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `BracedSyntax` +- `ExprSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithStatementsSyntax` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ClosureExprSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/consumeexprsyntax + +- SwiftSyntax +- ConsumeExprSyntax + +Structure + +# ConsumeExprSyntax + +struct ConsumeExprSyntax + +SyntaxNodesC.swift + +### Children + +- `consumeKeyword`: ( `_move` \| `consume`) + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, consumeKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, moveKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var consumeKeyword: TokenSyntax` + +`var expression: ExprSyntax` + +`var moveKeyword: TokenSyntax` Deprecated + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeConsumeKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeMoveKeyword: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenConsumeKeywordAndExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenMoveKeywordAndExpression: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- ConsumeExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/copyexprsyntax + +- SwiftSyntax +- CopyExprSyntax + +Structure + +# CopyExprSyntax + +struct CopyExprSyntax + +SyntaxNodesC.swift + +### Children + +- `copyKeyword`: `copy` + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, copyKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var copyKeyword: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeCopyKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCopyKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct DeclReferenceExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- CopyExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declreferenceexprsyntax + +- SwiftSyntax +- DeclReferenceExprSyntax + +Structure + +# DeclReferenceExprSyntax + +struct DeclReferenceExprSyntax + +SyntaxNodesD.swift + +### Children + +- `argumentNames`: `DeclNameArgumentsSyntax`? + +### Contained in + +- `DynamicReplacementAttributeArgumentsSyntax`. `declName` + +- `ImplementsAttributeArgumentsSyntax`. `declName` + +- `KeyPathPropertyComponentSyntax`. `declName` + +- `MemberAccessExprSyntax`. `declName` + +- `SpecializeTargetFunctionArgumentSyntax`. `declName` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, baseName: TokenSyntax, UnexpectedNodesSyntax?, argumentNames: DeclNameArgumentsSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, declNameArguments: DeclNameArgumentsSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var argumentNames: DeclNameArgumentsSyntax?` + +`var baseName: TokenSyntax` + +`var declNameArguments: DeclNameArgumentsSyntax?` Deprecated + +`var identifier: TokenSyntax` Deprecated + +`var unexpectedAfterArgumentNames: UnexpectedNodesSyntax?` + +`var unexpectedAfterDeclNameArguments: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeBaseName: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenBaseNameAndArgumentNames: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIdentifierAndDeclNameArguments: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DictionaryExprSyntax` + +A dictionary literal + +- DeclReferenceExprSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/dictionaryexprsyntax + +- SwiftSyntax +- DictionaryExprSyntax + +Structure + +# DictionaryExprSyntax + +A dictionary literal + +struct DictionaryExprSyntax + +SyntaxNodesD.swift + +### Children + +- `leftSquare`: ``\ +\ +- `content`: ( `:` \| [`DictionaryElementListSyntax`)\ +\ +- `rightSquare`: `]` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquare: TokenSyntax, UnexpectedNodesSyntax?, content: DictionaryExprSyntax.Content, UnexpectedNodesSyntax?, rightSquare: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var content: DictionaryExprSyntax.Content` + +`var leftSquare: TokenSyntax` + +`var rightSquare: TokenSyntax` + +`var unexpectedAfterRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenContentAndRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftSquareAndContent: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Content` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- DictionaryExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/discardassignmentexprsyntax + +- SwiftSyntax +- DiscardAssignmentExprSyntax + +Structure + +# DiscardAssignmentExprSyntax + +A `_` that discards a value inside an assignment. + +struct DiscardAssignmentExprSyntax + +SyntaxNodesD.swift + +### Examples + +_ = 42 + +if case .foo(_) = myValue + +### Children + +- `wildcard`: `_` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, wildcard: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var unexpectedAfterWildcard: UnexpectedNodesSyntax?` + +`var unexpectedBeforeWildcard: UnexpectedNodesSyntax?` + +`var wildcard: TokenSyntax` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- DiscardAssignmentExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/editorplaceholderexprsyntax + +- SwiftSyntax +- EditorPlaceholderExprSyntax + +Structure + +# EditorPlaceholderExprSyntax + +struct EditorPlaceholderExprSyntax + +SyntaxNodesEF.swift + +## Overview + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var identifier: TokenSyntax` Deprecated + +`var placeholder: TokenSyntax` + +`var unexpectedAfterIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforePlaceholder: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- EditorPlaceholderExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/floatliteralexprsyntax + +- SwiftSyntax +- FloatLiteralExprSyntax + +Structure + +# FloatLiteralExprSyntax + +struct FloatLiteralExprSyntax + +SyntaxNodesEF.swift + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, floatingDigits: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, literal: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var floatingDigits: TokenSyntax` Deprecated + +`var literal: TokenSyntax` + +`var representedLiteralValue: Double?` + +A computed property representing the floating-point value parsed from the associated `literal.text` property. + +`var unexpectedAfterFloatingDigits: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterLiteral: UnexpectedNodesSyntax?` + +`var unexpectedBeforeFloatingDigits: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLiteral: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- FloatLiteralExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/forceunwrapexprsyntax + +- SwiftSyntax +- ForceUnwrapExprSyntax + +Structure + +# ForceUnwrapExprSyntax + +struct ForceUnwrapExprSyntax + +SyntaxNodesEF.swift + +### Children + +- `expression`: `ExprSyntax` + +- `exclamationMark`: `!` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, exclamationMark: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var exclamationMark: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExclamationMark: UnexpectedNodesSyntax?` + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndExclamationMark: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- ForceUnwrapExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/functioncallexprsyntax + +- SwiftSyntax +- FunctionCallExprSyntax + +Structure + +# FunctionCallExprSyntax + +struct FunctionCallExprSyntax + +SyntaxNodesEF.swift + +### Children + +- `calledExpression`: `ExprSyntax` + +- `leftParen`: `(`? + +- `arguments`: `LabeledExprListSyntax` + +- `rightParen`: `)`? + +- `trailingClosure`: `ClosureExprSyntax`? + +- `additionalTrailingClosures`: `MultipleTrailingClosureElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, calledExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, argumentList: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, calledExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, arguments: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax` + +`var argumentList: LabeledExprListSyntax` Deprecated + +`var arguments: LabeledExprListSyntax` + +`var calledExpression: ExprSyntax` + +`var leftParen: TokenSyntax?` + +`var rightParen: TokenSyntax?` + +`var trailingClosure: ClosureExprSyntax?` + +`var unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +`var unexpectedBeforeCalledExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenArgumentListAndRightParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCalledExpressionAndLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndArgumentList: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndArguments: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `additionalTrailingClosures` collection. + +Deprecated + +Adds the provided `element` to the node’s `arguments` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- FunctionCallExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericspecializationexprsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/ifexprsyntax + +- SwiftSyntax +- IfExprSyntax + +Structure + +# IfExprSyntax + +struct IfExprSyntax + +SyntaxNodesGHI.swift + +### Children + +- `ifKeyword`: `if` + +- `conditions`: `ConditionElementListSyntax` + +- `body`: `CodeBlockSyntax` + +- `elseKeyword`: `else`? + +- `elseBody`: ( `IfExprSyntax` \| `CodeBlockSyntax`)? + +### Contained in + +- `IfExprSyntax`. `elseBody` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, ifKeyword: TokenSyntax, UnexpectedNodesSyntax?, conditions: ConditionElementListSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, elseKeyword: TokenSyntax?, UnexpectedNodesSyntax?, elseBody: IfExprSyntax.ElseBody?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var conditions: ConditionElementListSyntax` + +`var elseBody: IfExprSyntax.ElseBody?` + +`var elseKeyword: TokenSyntax?` + +`var ifKeyword: TokenSyntax` + +`var unexpectedAfterElseBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIfKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBodyAndElseKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionsAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElseKeywordAndElseBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIfKeywordAndConditions: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `conditions` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum ElseBody` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- IfExprSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/inoutexprsyntax + +- SwiftSyntax +- InOutExprSyntax + +Structure + +# InOutExprSyntax + +An expression prefixed with `&` to pass an argument to an `inout` parameter. + +struct InOutExprSyntax + +SyntaxNodesGHI.swift + +### Children + +- `ampersand`: `&` + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, ampersand: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var ampersand: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAmpersand: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAmpersandAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- InOutExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/infixoperatorexprsyntax + +- SwiftSyntax +- InfixOperatorExprSyntax + +Structure + +# InfixOperatorExprSyntax + +An infix operator call like `1 + 2`. + +struct InfixOperatorExprSyntax + +SyntaxNodesGHI.swift + +## Overview + +### Children + +- `leftOperand`: `ExprSyntax` + +- `operator`: `ExprSyntax` + +- `rightOperand`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftOperand: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, operator: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, rightOperand: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftOperand: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, operatorOperand: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, rightOperand: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var leftOperand: ExprSyntax` + +``var `operator`: ExprSyntax`` + +`var operatorOperand: ExprSyntax` Deprecated + +`var rightOperand: ExprSyntax` + +`var unexpectedAfterRightOperand: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftOperand: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftOperandAndOperator: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftOperandAndOperatorOperand: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOperatorAndRightOperand: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOperatorOperandAndRightOperand: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- InfixOperatorExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/integerliteralexprsyntax + +- SwiftSyntax +- IntegerLiteralExprSyntax + +Structure + +# IntegerLiteralExprSyntax + +struct IntegerLiteralExprSyntax + +SyntaxNodesGHI.swift + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, digits: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, literal: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var digits: TokenSyntax` Deprecated + +`var literal: TokenSyntax` + +`var radix: IntegerLiteralExprSyntax.Radix` + +`var representedLiteralValue: Int?` + +A computed property representing the integer value parsed from the associated `literal.text` property, considering the specified radix. + +`var unexpectedAfterDigits: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterLiteral: UnexpectedNodesSyntax?` + +`var unexpectedBeforeDigits: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLiteral: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Radix` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- IntegerLiteralExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/isexprsyntax + +- SwiftSyntax +- IsExprSyntax + +Structure + +# IsExprSyntax + +Checks if an expression is of a given type. + +struct IsExprSyntax + +SyntaxNodesGHI.swift + +## Overview + +An example of an `is` expression is + +value is Double + +### Children + +- `expression`: `ExprSyntax` + +- `isKeyword`: `is` + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, isKeyword: TokenSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, isTok: TokenSyntax, UnexpectedNodesSyntax?, typeName: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var expression: ExprSyntax` + +The expression which will be checked to determine whether it can be cast to a specific type. + +`var isKeyword: TokenSyntax` + +The `is` keyword for this expression. + +`var isTok: TokenSyntax` Deprecated + +`var type: TypeSyntax` + +The type against which the expression will be checked to see if the expression can be cast to it. + +`var typeName: TypeSyntax` Deprecated + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedAfterTypeName: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndIsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndIsTok: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenIsKeywordAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIsTokAndTypeName: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- IsExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/keypathexprsyntax + +- SwiftSyntax +- KeyPathExprSyntax + +Structure + +# KeyPathExprSyntax + +A key path. + +struct KeyPathExprSyntax + +SyntaxNodesJKLMN.swift + +### Examples + +\a.b[2].a + +### Children + +- `backslash`: `\` + +- `root`: `TypeSyntax`? + +- `components`: `KeyPathComponentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, backslash: TokenSyntax, UnexpectedNodesSyntax?, root: (some TypeSyntaxProtocol)?, UnexpectedNodesSyntax?, components: KeyPathComponentListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var backslash: TokenSyntax` + +`var components: KeyPathComponentListSyntax` + +`var root: TypeSyntax?` + +`var unexpectedAfterComponents: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBackslash: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBackslashAndRoot: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRootAndComponents: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `components` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- KeyPathExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/macroexpansionexprsyntax + +- SwiftSyntax +- MacroExpansionExprSyntax + +Structure + +# MacroExpansionExprSyntax + +The expansion of a freestanding macro in a position that expects an expression. + +struct MacroExpansionExprSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `pound`: `#` + +- `genericArgumentClause`: `GenericArgumentClauseSyntax`? + +- `leftParen`: `(`? + +- `arguments`: `LabeledExprListSyntax` + +- `rightParen`: `)`? + +- `trailingClosure`: `ClosureExprSyntax`? + +- `additionalTrailingClosures`: `MultipleTrailingClosureElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, pound: TokenSyntax, UnexpectedNodesSyntax?, macroName: TokenSyntax, UnexpectedNodesSyntax?, genericArgumentClause: GenericArgumentClauseSyntax?, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, arguments: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, poundToken: TokenSyntax, UnexpectedNodesSyntax?, macro: TokenSyntax, UnexpectedNodesSyntax?, genericArguments: GenericArgumentClauseSyntax?, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, argumentList: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax` + +`var argumentList: LabeledExprListSyntax` Deprecated + +`var arguments: LabeledExprListSyntax` + +`var genericArgumentClause: GenericArgumentClauseSyntax?` + +`var genericArguments: GenericArgumentClauseSyntax?` Deprecated + +`var leftParen: TokenSyntax?` + +`var macro: TokenSyntax` Deprecated + +`var macroName: TokenSyntax` + +`var pound: TokenSyntax` + +The `#` sign. + +`var poundToken: TokenSyntax` Deprecated + +`var rightParen: TokenSyntax?` + +`var trailingClosure: ClosureExprSyntax?` + +`var unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +`var unexpectedBeforePound: UnexpectedNodesSyntax?` + +`var unexpectedBeforePoundToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentListAndRightParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericArgumentClauseAndLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericArgumentsAndLeftParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndArgumentList: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndArguments: UnexpectedNodesSyntax?` + +`var unexpectedBetweenMacroAndGenericArguments: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenMacroNameAndGenericArgumentClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPoundAndMacroName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPoundTokenAndMacro: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenRightParenAndTrailingClosure: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `additionalTrailingClosures` collection. + +Deprecated + +Adds the provided `element` to the node’s `arguments` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `FreestandingMacroExpansionSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- MacroExpansionExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/memberaccessexprsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/nilliteralexprsyntax + +- SwiftSyntax +- NilLiteralExprSyntax + +Structure + +# NilLiteralExprSyntax + +struct NilLiteralExprSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `nilKeyword`: `nil` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, nilKeyword: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var nilKeyword: TokenSyntax` + +`var unexpectedAfterNilKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeNilKeyword: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- NilLiteralExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/optionalchainingexprsyntax + +- SwiftSyntax +- OptionalChainingExprSyntax + +Structure + +# OptionalChainingExprSyntax + +struct OptionalChainingExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `expression`: `ExprSyntax` + +- `questionMark`: `?` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, questionMark: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax` + +`var questionMark: TokenSyntax` + +`var unexpectedAfterQuestionMark: UnexpectedNodesSyntax?` + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndQuestionMark: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- OptionalChainingExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/packelementexprsyntax + +- SwiftSyntax +- PackElementExprSyntax + +Structure + +# PackElementExprSyntax + +A pack element expression spelled with `each`. + +struct PackElementExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `eachKeyword`: `each` + +- `pack`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, eachKeyword: TokenSyntax, UnexpectedNodesSyntax?, pack: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, eachKeyword: TokenSyntax, UnexpectedNodesSyntax?, packRefExpr: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var eachKeyword: TokenSyntax` + +`var pack: ExprSyntax` + +`var packRefExpr: ExprSyntax` Deprecated + +`var unexpectedAfterPack: UnexpectedNodesSyntax?` + +`var unexpectedAfterPackRefExpr: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeEachKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEachKeywordAndPack: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEachKeywordAndPackRefExpr: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PackElementExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/packexpansionexprsyntax + +- SwiftSyntax +- PackExpansionExprSyntax + +Structure + +# PackExpansionExprSyntax + +A pack expansion expression spelled with `repeat`. + +struct PackExpansionExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `repeatKeyword`: `repeat` + +- `repetitionPattern`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, repeatKeyword: TokenSyntax, UnexpectedNodesSyntax?, patternExpr: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, repeatKeyword: TokenSyntax, UnexpectedNodesSyntax?, repetitionPattern: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var patternExpr: ExprSyntax` Deprecated + +`var repeatKeyword: TokenSyntax` + +`var repetitionPattern: ExprSyntax` + +`var unexpectedAfterPatternExpr: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterRepetitionPattern: UnexpectedNodesSyntax?` + +`var unexpectedBeforeRepeatKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRepeatKeywordAndPatternExpr: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenRepeatKeywordAndRepetitionPattern: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PackExpansionExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/patternexprsyntax + +- SwiftSyntax +- PatternExprSyntax + +Structure + +# PatternExprSyntax + +struct PatternExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `pattern`: `PatternSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, pattern: some PatternSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var pattern: PatternSyntax` + +`var unexpectedAfterPattern: UnexpectedNodesSyntax?` + +`var unexpectedBeforePattern: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PatternExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/postfixifconfigexprsyntax + +- SwiftSyntax +- PostfixIfConfigExprSyntax + +Structure + +# PostfixIfConfigExprSyntax + +struct PostfixIfConfigExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `base`: `ExprSyntax`? + +- `config`: `IfConfigDeclSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, base: (some ExprSyntaxProtocol)?, UnexpectedNodesSyntax?, config: IfConfigDeclSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var base: ExprSyntax?` + +`var config: IfConfigDeclSyntax` + +`var unexpectedAfterConfig: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBase: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBaseAndConfig: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PostfixIfConfigExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/postfixoperatorexprsyntax + +- SwiftSyntax +- PostfixOperatorExprSyntax + +Structure + +# PostfixOperatorExprSyntax + +struct PostfixOperatorExprSyntax + +SyntaxNodesOP.swift + +### Children + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, operator: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, operatorToken: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var expression: ExprSyntax` + +``var `operator`: TokenSyntax`` + +`var operatorToken: TokenSyntax` Deprecated + +`var unexpectedAfterOperator: UnexpectedNodesSyntax?` + +`var unexpectedAfterOperatorToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndOperator: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndOperatorToken: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PostfixOperatorExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/prefixoperatorexprsyntax + +- SwiftSyntax +- PrefixOperatorExprSyntax + +Structure + +# PrefixOperatorExprSyntax + +A prefix operator applied to a value. + +struct PrefixOperatorExprSyntax + +SyntaxNodesOP.swift + +### Examples + +-x + +### Children + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, operator: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, operatorToken: TokenSyntax, UnexpectedNodesSyntax?, postfixExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var expression: ExprSyntax` + +``var `operator`: TokenSyntax`` + +`var operatorToken: TokenSyntax` Deprecated + +`var postfixExpression: ExprSyntax` Deprecated + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedAfterPostfixExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeOperator: UnexpectedNodesSyntax?` + +`var unexpectedBeforeOperatorToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOperatorAndExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOperatorTokenAndPostfixExpression: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- PrefixOperatorExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/regexliteralexprsyntax + +- SwiftSyntax +- RegexLiteralExprSyntax + +Structure + +# RegexLiteralExprSyntax + +struct RegexLiteralExprSyntax + +SyntaxNodesQRS.swift + +### Children + +- `openingSlash`: `/` + +- `closingSlash`: `/` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, openingPounds: TokenSyntax?, UnexpectedNodesSyntax?, openSlash: TokenSyntax, UnexpectedNodesSyntax?, regexPattern: TokenSyntax, UnexpectedNodesSyntax?, closeSlash: TokenSyntax, UnexpectedNodesSyntax?, closingPounds: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, openingPounds: TokenSyntax?, UnexpectedNodesSyntax?, openingSlash: TokenSyntax, UnexpectedNodesSyntax?, regex: TokenSyntax, UnexpectedNodesSyntax?, closingSlash: TokenSyntax, UnexpectedNodesSyntax?, closingPounds: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var closeSlash: TokenSyntax` Deprecated + +`var closingPounds: TokenSyntax?` + +`var closingSlash: TokenSyntax` + +`var openSlash: TokenSyntax` Deprecated + +`var openingPounds: TokenSyntax?` + +`var openingSlash: TokenSyntax` + +`var regex: TokenSyntax` + +`var regexPattern: TokenSyntax` Deprecated + +`var unexpectedAfterClosingPounds: UnexpectedNodesSyntax?` + +`var unexpectedBeforeOpeningPounds: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCloseSlashAndClosingPounds: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenClosingSlashAndClosingPounds: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOpenSlashAndRegexPattern: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOpeningPoundsAndOpenSlash: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOpeningPoundsAndOpeningSlash: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOpeningSlashAndRegex: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRegexAndClosingSlash: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRegexPatternAndCloseSlash: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- RegexLiteralExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/sequenceexprsyntax + +- SwiftSyntax +- SequenceExprSyntax + +Structure + +# SequenceExprSyntax + +A flat list of expressions before operator folding using the `SwiftOperators` library. + +struct SequenceExprSyntax + +SyntaxNodesQRS.swift + +### Examples + +1 + 2 + 3 + +### Children + +- `elements`: `ExprListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, elements: ExprListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var elements: ExprListSyntax` + +`var unexpectedAfterElements: UnexpectedNodesSyntax?` + +`var unexpectedBeforeElements: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- SequenceExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/simplestringliteralexprsyntax + +- SwiftSyntax +- SimpleStringLiteralExprSyntax + +Structure + +# SimpleStringLiteralExprSyntax + +A simple string that can’t contain string interpolation and cannot have raw string delimiters. + +struct SimpleStringLiteralExprSyntax + +SyntaxNodesQRS.swift + +### Children + +- `openingQuote`: ( `"` \| `"""`) + +- `segments`: `SimpleStringLiteralSegmentListSyntax` + +- `closingQuote`: ( `"` \| `"""`) + +### Contained in + +- `AvailabilityLabeledArgumentSyntax`. `value` + +- `PoundSourceLocationArgumentsSyntax`. `fileName` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, openingQuote: TokenSyntax, UnexpectedNodesSyntax?, segments: SimpleStringLiteralSegmentListSyntax, UnexpectedNodesSyntax?, closingQuote: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var closingQuote: TokenSyntax` + +Close quote for the string literal + +`var openingQuote: TokenSyntax` + +Open quote for the string literal + +`var segments: SimpleStringLiteralSegmentListSyntax` + +String content + +`var unexpectedAfterClosingQuote: UnexpectedNodesSyntax?` + +`var unexpectedBeforeOpeningQuote: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOpeningQuoteAndSegments: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSegmentsAndClosingQuote: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `segments` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- SimpleStringLiteralExprSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/stringliteralexprsyntax + +- SwiftSyntax +- StringLiteralExprSyntax + +Structure + +# StringLiteralExprSyntax + +A string literal. + +struct StringLiteralExprSyntax + +SyntaxNodesQRS.swift + +### Examples + +"Hello \(userName())!" + +### Children + +- `openingQuote`: ( `"` \| `"""` \| `'`) + +- `segments`: `StringLiteralSegmentListSyntax` + +- `closingQuote`: ( `"` \| `"""` \| `'`) + +### Contained in + +- `AttributeSyntax`. `arguments` + +- `ConventionAttributeArgumentsSyntax`. `cTypeString` + +- `DocumentationAttributeArgumentSyntax`. `value` + +- `ExposeAttributeArgumentsSyntax`. `cxxName` + +- `OpaqueReturnTypeOfAttributeArgumentsSyntax`. `mangledName` + +- `OriginallyDefinedInAttributeArgumentsSyntax`. `moduleName` + +- `UnavailableFromAsyncAttributeArgumentsSyntax`. `message` + +- `UnderscorePrivateAttributeArgumentsSyntax`. `filename` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, openDelimiter: TokenSyntax?, UnexpectedNodesSyntax?, openQuote: TokenSyntax, UnexpectedNodesSyntax?, segments: StringLiteralSegmentListSyntax, UnexpectedNodesSyntax?, closeQuote: TokenSyntax, UnexpectedNodesSyntax?, closeDelimiter: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, openingPounds: TokenSyntax?, UnexpectedNodesSyntax?, openingQuote: TokenSyntax, UnexpectedNodesSyntax?, segments: StringLiteralSegmentListSyntax, UnexpectedNodesSyntax?, closingQuote: TokenSyntax, UnexpectedNodesSyntax?, closingPounds: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var closeDelimiter: TokenSyntax?` Deprecated + +`var closeQuote: TokenSyntax` Deprecated + +`var closingPounds: TokenSyntax?` + +`var closingQuote: TokenSyntax` + +`var openDelimiter: TokenSyntax?` Deprecated + +`var openQuote: TokenSyntax` Deprecated + +`var openingPounds: TokenSyntax?` + +`var openingQuote: TokenSyntax` + +`var segments: StringLiteralSegmentListSyntax` + +`var unexpectedAfterCloseDelimiter: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterClosingPounds: UnexpectedNodesSyntax?` + +`var unexpectedBeforeOpenDelimiter: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeOpeningPounds: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCloseQuoteAndCloseDelimiter: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenClosingQuoteAndClosingPounds: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOpenDelimiterAndOpenQuote: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOpenQuoteAndSegments: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenOpeningPoundsAndOpeningQuote: UnexpectedNodesSyntax?` + +`var unexpectedBetweenOpeningQuoteAndSegments: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSegmentsAndCloseQuote: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenSegmentsAndClosingQuote: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `segments` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- StringLiteralExprSyntax +- Examples +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/subscriptcallexprsyntax + +- SwiftSyntax +- SubscriptCallExprSyntax + +Structure + +# SubscriptCallExprSyntax + +struct SubscriptCallExprSyntax + +SyntaxNodesQRS.swift + +### Children + +- `calledExpression`: `ExprSyntax` + +- `leftSquare`: ``\ +\ +- `arguments`: [`LabeledExprListSyntax`\ +\ +- `rightSquare`: `]` + +- `trailingClosure`: `ClosureExprSyntax`? + +- `additionalTrailingClosures`: `MultipleTrailingClosureElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, calledExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftBracket: TokenSyntax, UnexpectedNodesSyntax?, argumentList: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightBracket: TokenSyntax, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, calledExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftSquare: TokenSyntax, UnexpectedNodesSyntax?, arguments: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightSquare: TokenSyntax, UnexpectedNodesSyntax?, trailingClosure: ClosureExprSyntax?, UnexpectedNodesSyntax?, additionalTrailingClosures: MultipleTrailingClosureElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax` + +`var argumentList: LabeledExprListSyntax` Deprecated + +`var arguments: LabeledExprListSyntax` + +`var calledExpression: ExprSyntax` + +`var leftBracket: TokenSyntax` Deprecated + +`var leftSquare: TokenSyntax` + +`var rightBracket: TokenSyntax` Deprecated + +`var rightSquare: TokenSyntax` + +`var trailingClosure: ClosureExprSyntax?` + +`var unexpectedAfterAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +`var unexpectedBeforeCalledExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenArgumentListAndRightBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentsAndRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCalledExpressionAndLeftBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenCalledExpressionAndLeftSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftBracketAndArgumentList: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftSquareAndArguments: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRightBracketAndTrailingClosure: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenRightSquareAndTrailingClosure: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `additionalTrailingClosures` collection. + +Deprecated + +Adds the provided `element` to the node’s `arguments` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- SubscriptCallExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/superexprsyntax + +- SwiftSyntax +- SuperExprSyntax + +Structure + +# SuperExprSyntax + +struct SuperExprSyntax + +SyntaxNodesQRS.swift + +### Children + +- `superKeyword`: `super` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, superKeyword: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var superKeyword: TokenSyntax` + +`var unexpectedAfterSuperKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeSuperKeyword: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- SuperExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/switchexprsyntax + +- SwiftSyntax +- SwitchExprSyntax + +Structure + +# SwitchExprSyntax + +A `switch` expression. + +struct SwitchExprSyntax + +SyntaxNodesQRS.swift + +### Examples + +This represents the switch expression in + +switch self.foo { +} + +A switch ecpression may be declared without any cases. + +### Children + +- `switchKeyword`: `switch` + +- `subject`: `ExprSyntax` + +- `leftBrace`: `{` + +- `cases`: `SwitchCaseListSyntax` + +- `rightBrace`: `}` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, switchKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftBrace: TokenSyntax, UnexpectedNodesSyntax?, cases: SwitchCaseListSyntax, UnexpectedNodesSyntax?, rightBrace: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, switchKeyword: TokenSyntax, UnexpectedNodesSyntax?, subject: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, leftBrace: TokenSyntax, UnexpectedNodesSyntax?, cases: SwitchCaseListSyntax, UnexpectedNodesSyntax?, rightBrace: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var cases: SwitchCaseListSyntax` + +The switch’s body that contains all possible cases. + +`var expression: ExprSyntax` Deprecated + +`var leftBrace: TokenSyntax` + +The brace introducing the switch body. + +`var rightBrace: TokenSyntax` + +The brace closing the switch body. + +`var subject: ExprSyntax` + +The expression to switch over. + +`var switchKeyword: TokenSyntax` + +The `switch` keyword. + +`var unexpectedAfterRightBrace: UnexpectedNodesSyntax?` + +`var unexpectedBeforeSwitchKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCasesAndRightBrace: UnexpectedNodesSyntax?` + +`var unexpectedBetweenExpressionAndLeftBrace: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftBraceAndCases: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSubjectAndLeftBrace: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSwitchKeywordAndExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenSwitchKeywordAndSubject: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `cases` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `BracedSyntax` +- `ExprSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- SwitchExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/ternaryexprsyntax + +- SwiftSyntax +- TernaryExprSyntax + +Structure + +# TernaryExprSyntax + +The ternary operator with operator precedences resolved. + +struct TernaryExprSyntax + +SyntaxNodesTUVWXYZ.swift + +### Examples + +a ? 1 : 0 + +### Children + +- `condition`: `ExprSyntax` + +- `questionMark`: `?` + +- `thenExpression`: `ExprSyntax` + +- `colon`: `:` + +- `elseExpression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, condition: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, questionMark: TokenSyntax, UnexpectedNodesSyntax?, thenExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, elseExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, conditionExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, questionMark: TokenSyntax, UnexpectedNodesSyntax?, firstChoice: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colonMark: TokenSyntax, UnexpectedNodesSyntax?, secondChoice: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var colon: TokenSyntax` + +`var colonMark: TokenSyntax` Deprecated + +`var condition: ExprSyntax` + +`var conditionExpression: ExprSyntax` Deprecated + +`var elseExpression: ExprSyntax` + +`var firstChoice: ExprSyntax` Deprecated + +`var questionMark: TokenSyntax` + +`var secondChoice: ExprSyntax` Deprecated + +`var thenExpression: ExprSyntax` + +`var unexpectedAfterElseExpression: UnexpectedNodesSyntax?` + +`var unexpectedAfterSecondChoice: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeCondition: UnexpectedNodesSyntax?` + +`var unexpectedBeforeConditionExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenColonAndElseExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonMarkAndSecondChoice: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenConditionAndQuestionMark: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionExpressionAndQuestionMark: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenFirstChoiceAndColonMark: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenQuestionMarkAndFirstChoice: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenQuestionMarkAndThenExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenThenExpressionAndColon: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- TernaryExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tryexprsyntax + +- SwiftSyntax +- TryExprSyntax + +Structure + +# TryExprSyntax + +An expression prefixed with `try`. + +struct TryExprSyntax + +SyntaxNodesTUVWXYZ.swift + +### Examples + +try foo() + +try? foo() + +try! foo() + +### Children + +- `tryKeyword`: `try` + +- `questionOrExclamationMark`: ( `?` \| `!`)? + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, tryKeyword: TokenSyntax, UnexpectedNodesSyntax?, questionOrExclamationMark: TokenSyntax?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax` + +`var questionOrExclamationMark: TokenSyntax?` + +`var tryKeyword: TokenSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeTryKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenQuestionOrExclamationMarkAndExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTryKeywordAndQuestionOrExclamationMark: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- TryExprSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tupleexprsyntax + +- SwiftSyntax +- TupleExprSyntax + +Structure + +# TupleExprSyntax + +struct TupleExprSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `leftParen`: `(` + +- `elements`: `LabeledExprListSyntax` + +- `rightParen`: `)` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, elementList: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, elements: LabeledExprListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var elementList: LabeledExprListSyntax` Deprecated + +`var elements: LabeledExprListSyntax` + +`var leftParen: TokenSyntax` + +`var rightParen: TokenSyntax` + +`var unexpectedAfterRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElementListAndRightParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenElementsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndElementList: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndElements: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `ParenthesizedSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- TupleExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/typeexprsyntax + +- SwiftSyntax +- TypeExprSyntax + +Structure + +# TypeExprSyntax + +struct TypeExprSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var type: TypeSyntax` + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedBeforeType: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- TypeExprSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/unresolvedasexprsyntax + +- SwiftSyntax +- UnresolvedAsExprSyntax + +Structure + +# UnresolvedAsExprSyntax + +The `as` keyword without any operands. + +struct UnresolvedAsExprSyntax + +SyntaxNodesTUVWXYZ.swift + +## Overview + +### Children + +- `asKeyword`: `as` + +- `questionOrExclamationMark`: ( `?` \| `!`)? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, asKeyword: TokenSyntax, UnexpectedNodesSyntax?, questionOrExclamationMark: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, asTok: TokenSyntax, UnexpectedNodesSyntax?, questionOrExclamationMark: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var asKeyword: TokenSyntax` + +`var asTok: TokenSyntax` Deprecated + +`var questionOrExclamationMark: TokenSyntax?` + +`var unexpectedAfterQuestionOrExclamationMark: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAsTok: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenAsKeywordAndQuestionOrExclamationMark: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAsTokAndQuestionOrExclamationMark: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- UnresolvedAsExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/unresolvedisexprsyntax + +- SwiftSyntax +- UnresolvedIsExprSyntax + +Structure + +# UnresolvedIsExprSyntax + +The `is` keyword without any operands. + +struct UnresolvedIsExprSyntax + +SyntaxNodesTUVWXYZ.swift + +## Overview + +### Children + +- `isKeyword`: `is` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, isKeyword: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, isTok: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var isKeyword: TokenSyntax` + +`var isTok: TokenSyntax` Deprecated + +`var unexpectedAfterIsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedAfterIsTok: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeIsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIsTok: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- UnresolvedIsExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/unresolvedternaryexprsyntax + +- SwiftSyntax +- UnresolvedTernaryExprSyntax + +Structure + +# UnresolvedTernaryExprSyntax + +The middle section of a ternary operator between `?` and `:`. + +struct UnresolvedTernaryExprSyntax + +SyntaxNodesTUVWXYZ.swift + +## Overview + +### Children + +- `questionMark`: `?` + +- `thenExpression`: `ExprSyntax` + +- `colon`: `:` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, questionMark: TokenSyntax, UnexpectedNodesSyntax?, firstChoice: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colonMark: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, questionMark: TokenSyntax, UnexpectedNodesSyntax?, thenExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var colon: TokenSyntax` + +`var colonMark: TokenSyntax` Deprecated + +`var firstChoice: ExprSyntax` Deprecated + +`var questionMark: TokenSyntax` + +`var thenExpression: ExprSyntax` + +`var unexpectedAfterColon: UnexpectedNodesSyntax?` + +`var unexpectedAfterColonMark: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeQuestionMark: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFirstChoiceAndColonMark: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenQuestionMarkAndFirstChoice: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenQuestionMarkAndThenExpression: UnexpectedNodesSyntax?` + +`var unexpectedBetweenThenExpressionAndColon: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ExprSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Expressions + +`struct ExprSyntax` + +`protocol ExprSyntaxProtocol` + +Protocol to which all `ExprSyntax` nodes conform. + +`struct MissingExprSyntax` + +In case the source code is missing an expression, this node stands in place of the missing expression. + +`struct ArrayExprSyntax` + +An array literal. + +`struct ArrowExprSyntax` + +The arrow when a type is used at a position that syntactically expectes an expression. + +`struct AsExprSyntax` + +The cast of an expressison to a different type. + +`struct AssignmentExprSyntax` + +`struct AwaitExprSyntax` + +`struct BinaryOperatorExprSyntax` + +An operator like `+` or `-`. + +`struct BooleanLiteralExprSyntax` + +`struct BorrowExprSyntax` + +`struct ClosureExprSyntax` + +`struct ConsumeExprSyntax` + +`struct CopyExprSyntax` + +`struct DeclReferenceExprSyntax` + +- UnresolvedTernaryExprSyntax +- Overview +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/patternsyntax + +- SwiftSyntax +- PatternSyntax + +Structure + +# PatternSyntax + +struct PatternSyntax + +SyntaxBaseNodes.swift + +### Subtypes + +- `ExpressionPatternSyntax` + +- `IdentifierPatternSyntax` + +- `IsTypePatternSyntax` + +- `MissingPatternSyntax` + +- `TuplePatternSyntax` + +- `ValueBindingPatternSyntax` + +- `WildcardPatternSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init?((some PatternSyntaxProtocol)?)` + +Create a `PatternSyntax` node from a specialized optional syntax node. + +`init(some PatternSyntaxProtocol)` + +Create a `PatternSyntax` node from a specialized syntax node. + +`init?(fromProtocol: (any PatternSyntaxProtocol)?)` + +`init(fromProtocol: any PatternSyntaxProtocol)` + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all Pattern syntax nodes. + +Return the non-type erased version of this syntax node. + +Syntax nodes always conform to `PatternSyntaxProtocol`. This API is just added for consistency. + +Deprecated + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- PatternSyntax +- Subtypes +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/patternsyntaxprotocol + +- SwiftSyntax +- PatternSyntaxProtocol + +Protocol + +# PatternSyntaxProtocol + +Protocol to which all `PatternSyntax` nodes conform. + +protocol PatternSyntaxProtocol : SyntaxProtocol + +SyntaxBaseNodes.swift + +## Overview + +Extension point to add common methods to all `PatternSyntax` nodes. + +## Topics + +### Instance Methods + +Attempts to upcast the current syntax node to its base node type ( `PatternSyntax`). + +Deprecated + +Attempts to cast the current syntax node to a given specialized syntax type. + +Attempts to cast the current syntax node to a given node type from the a base node protocol hierarchy other than `PatternSyntaxProtocol`. + +Force-upcast the current syntax node to its base node type ( `PatternSyntax`). + +Force-casts the current syntax node to a given node type from a base node protocol hierarchy other than `PatternSyntaxProtocol`. + +Force-casts the current syntax node to a given specialized syntax type. + +Checks if the current syntax node can be cast to a given specialized syntax type. + +Checks if the current syntax node can be upcast to its base node type ( `PatternSyntax`). + +Checks if the current syntax node can be cast to a given node type from a base node protocol hierarchy other than `PatternSyntaxProtocol`. + +## Relationships + +### Inherits From + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Conforming Types + +- `ExpressionPatternSyntax` +- `IdentifierPatternSyntax` +- `IsTypePatternSyntax` +- `MissingPatternSyntax` +- `PatternSyntax` +- `TuplePatternSyntax` +- `ValueBindingPatternSyntax` +- `WildcardPatternSyntax` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- PatternSyntaxProtocol +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/missingpatternsyntax + +- SwiftSyntax +- MissingPatternSyntax + +Structure + +# MissingPatternSyntax + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +struct MissingPatternSyntax + +SyntaxNodesJKLMN.swift + +## Topics + +### Initializers + +`init()` + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var placeholder: TokenSyntax` + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforePlaceholder: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `MissingNodeSyntax` +- `PatternSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- MissingPatternSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/expressionpatternsyntax + +- SwiftSyntax +- ExpressionPatternSyntax + +Structure + +# ExpressionPatternSyntax + +A pattern that contains an `ExprSyntaxProtocol`. + +struct ExpressionPatternSyntax + +SyntaxNodesEF.swift + +### Examples + +Patterns can be used in switch cases like the following example: + +switch raw.kind { +case .expressionPattern: +return true +default: +return false +} + +### Children + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- ExpressionPatternSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/identifierpatternsyntax + +- SwiftSyntax +- IdentifierPatternSyntax + +Structure + +# IdentifierPatternSyntax + +A pattern that contains a `TokenSyntax`. + +struct IdentifierPatternSyntax + +SyntaxNodesGHI.swift + +### Examples + +`IdentifierPatternSyntax` can be used in simplple variable declarations. For example `a` in the exmaple: + +let a = 1 + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var identifier: TokenSyntax` + +`var unexpectedAfterIdentifier: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIdentifier: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- IdentifierPatternSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/istypepatternsyntax + +- SwiftSyntax +- IsTypePatternSyntax + +Structure + +# IsTypePatternSyntax + +struct IsTypePatternSyntax + +SyntaxNodesGHI.swift + +### Children + +- `isKeyword`: `is` + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, isKeyword: TokenSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var isKeyword: TokenSyntax` + +`var type: TypeSyntax` + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIsKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenIsKeywordAndType: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- IsTypePatternSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tuplepatternsyntax + +- SwiftSyntax +- TuplePatternSyntax + +Structure + +# TuplePatternSyntax + +A pattern that contains a list of other pattern. + +struct TuplePatternSyntax + +SyntaxNodesTUVWXYZ.swift + +### Examples + +`TuplePatternSyntax` can be used in more complex variable declarations. For example `(x, y)` in the example: + +let (x, y) = (1, 2) + +### Children + +- `leftParen`: `(` + +- `elements`: `TuplePatternElementListSyntax` + +- `rightParen`: `)` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, elements: TuplePatternElementListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var elements: TuplePatternElementListSyntax` + +`var leftParen: TokenSyntax` + +The parent introducing the tuple. + +`var rightParen: TokenSyntax` + +The paren closing the tuple. + +`var unexpectedAfterRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElementsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndElements: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ParenthesizedSyntax` +- `PatternSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct ValueBindingPatternSyntax` + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- TuplePatternSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/valuebindingpatternsyntax + +- SwiftSyntax +- ValueBindingPatternSyntax + +Structure + +# ValueBindingPatternSyntax + +struct ValueBindingPatternSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `bindingSpecifier`: ( `let` \| `var` \| `inout` \| `_mutating` \| `_borrowing` \| `_consuming` \| `borrowing`) + +- `pattern`: `PatternSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, bindingKeyword: TokenSyntax, UnexpectedNodesSyntax?, valuePattern: some PatternSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, bindingSpecifier: TokenSyntax, UnexpectedNodesSyntax?, pattern: some PatternSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var bindingKeyword: TokenSyntax` Deprecated + +`var bindingSpecifier: TokenSyntax` + +`var pattern: PatternSyntax` + +`var unexpectedAfterPattern: UnexpectedNodesSyntax?` + +`var unexpectedAfterValuePattern: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeBindingKeyword: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeBindingSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBindingKeywordAndValuePattern: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenBindingSpecifierAndPattern: UnexpectedNodesSyntax?` + +`var valuePattern: PatternSyntax` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct WildcardPatternSyntax` + +A pattern that represent a wildcard. + +- ValueBindingPatternSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/wildcardpatternsyntax + +- SwiftSyntax +- WildcardPatternSyntax + +Structure + +# WildcardPatternSyntax + +A pattern that represent a wildcard. + +struct WildcardPatternSyntax + +SyntaxNodesTUVWXYZ.swift + +### Examples + +`WildcardPatternSyntax` matches and ignores any value. For example `_` in the example: + +for _ in 1...3 { +// ... +} + +### Children + +- `wildcard`: `_` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, wildcard: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, wildcard: TokenSyntax, UnexpectedNodesSyntax?, typeAnnotation: TypeAnnotationSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var typeAnnotation: TypeAnnotationSyntax?` Deprecated + +`var unexpectedAfterTypeAnnotation: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterWildcard: UnexpectedNodesSyntax?` + +`var unexpectedBeforeWildcard: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWildcardAndTypeAnnotation: UnexpectedNodesSyntax?` Deprecated + +`var wildcard: TokenSyntax` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `PatternSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Patterns + +`struct PatternSyntax` + +`protocol PatternSyntaxProtocol` + +Protocol to which all `PatternSyntax` nodes conform. + +`struct MissingPatternSyntax` + +In case the source code is missing a pattern, this node stands in place of the missing pattern. + +`struct ExpressionPatternSyntax` + +A pattern that contains an `ExprSyntaxProtocol`. + +`struct IdentifierPatternSyntax` + +A pattern that contains a `TokenSyntax`. + +`struct IsTypePatternSyntax` + +`struct TuplePatternSyntax` + +A pattern that contains a list of other pattern. + +`struct ValueBindingPatternSyntax` + +- WildcardPatternSyntax +- Examples +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/stmtsyntax + +- SwiftSyntax +- StmtSyntax + +Structure + +# StmtSyntax + +struct StmtSyntax + +SyntaxBaseNodes.swift + +### Subtypes + +- `BreakStmtSyntax` + +- `ContinueStmtSyntax` + +- `DeferStmtSyntax` + +- `DiscardStmtSyntax` + +- `DoStmtSyntax` + +- `ExpressionStmtSyntax` + +- `FallThroughStmtSyntax` + +- `ForStmtSyntax` + +- `GuardStmtSyntax` + +- `LabeledStmtSyntax` + +- `MissingStmtSyntax` + +- `RepeatStmtSyntax` + +- `ReturnStmtSyntax` + +- `ThrowStmtSyntax` + +- `WhileStmtSyntax` + +- `YieldStmtSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(some StmtSyntaxProtocol)` + +Create a `StmtSyntax` node from a specialized syntax node. + +`init?((some StmtSyntaxProtocol)?)` + +Create a `StmtSyntax` node from a specialized optional syntax node. + +`init(fromProtocol: any StmtSyntaxProtocol)` + +`init?(fromProtocol: (any StmtSyntaxProtocol)?)` + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all Stmt syntax nodes. + +Return the non-type erased version of this syntax node. + +Syntax nodes always conform to `StmtSyntaxProtocol`. This API is just added for consistency. + +Deprecated + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- StmtSyntax +- Subtypes +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/stmtsyntaxprotocol + +- SwiftSyntax +- StmtSyntaxProtocol + +Protocol + +# StmtSyntaxProtocol + +Protocol to which all `StmtSyntax` nodes conform. + +protocol StmtSyntaxProtocol : SyntaxProtocol + +SyntaxBaseNodes.swift + +## Overview + +Extension point to add common methods to all `StmtSyntax` nodes. + +## Topics + +### Instance Methods + +Attempts to cast the current syntax node to a given node type from the a base node protocol hierarchy other than `StmtSyntaxProtocol`. + +Deprecated + +Attempts to upcast the current syntax node to its base node type ( `StmtSyntax`). + +Attempts to cast the current syntax node to a given specialized syntax type. + +Force-casts the current syntax node to a given node type from a base node protocol hierarchy other than `StmtSyntaxProtocol`. + +Force-casts the current syntax node to a given specialized syntax type. + +Force-upcast the current syntax node to its base node type ( `StmtSyntax`). + +Checks if the current syntax node can be upcast to its base node type ( `StmtSyntax`). + +Checks if the current syntax node can be cast to a given node type from a base node protocol hierarchy other than `StmtSyntaxProtocol`. + +Checks if the current syntax node can be cast to a given specialized syntax type. + +## Relationships + +### Inherits From + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Conforming Types + +- `BreakStmtSyntax` +- `ContinueStmtSyntax` +- `DeferStmtSyntax` +- `DiscardStmtSyntax` +- `DoStmtSyntax` +- `ExpressionStmtSyntax` +- `FallThroughStmtSyntax` +- `ForStmtSyntax` +- `GuardStmtSyntax` +- `LabeledStmtSyntax` +- `MissingStmtSyntax` +- `RepeatStmtSyntax` +- `ReturnStmtSyntax` +- `StmtSyntax` +- `ThrowStmtSyntax` +- `WhileStmtSyntax` +- `YieldStmtSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- StmtSyntaxProtocol +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/missingstmtsyntax + +- SwiftSyntax +- MissingStmtSyntax + +Structure + +# MissingStmtSyntax + +In case the source code is missing a statement, this node stands in place of the missing statement. + +struct MissingStmtSyntax + +SyntaxNodesJKLMN.swift + +## Topics + +### Initializers + +`init()` + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var placeholder: TokenSyntax` + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforePlaceholder: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `MissingNodeSyntax` +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- MissingStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/breakstmtsyntax + +- SwiftSyntax +- BreakStmtSyntax + +Structure + +# BreakStmtSyntax + +struct BreakStmtSyntax + +SyntaxNodesAB.swift + +### Children + +- `breakKeyword`: `break` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, breakKeyword: TokenSyntax, UnexpectedNodesSyntax?, label: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var breakKeyword: TokenSyntax` + +`var label: TokenSyntax?` + +`var unexpectedAfterLabel: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBreakKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBreakKeywordAndLabel: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- BreakStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/continuestmtsyntax + +- SwiftSyntax +- ContinueStmtSyntax + +Structure + +# ContinueStmtSyntax + +struct ContinueStmtSyntax + +SyntaxNodesC.swift + +### Children + +- `continueKeyword`: `continue` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, continueKeyword: TokenSyntax, UnexpectedNodesSyntax?, label: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var continueKeyword: TokenSyntax` + +`var label: TokenSyntax?` + +`var unexpectedAfterLabel: UnexpectedNodesSyntax?` + +`var unexpectedBeforeContinueKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenContinueKeywordAndLabel: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- ContinueStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/deferstmtsyntax + +- SwiftSyntax +- DeferStmtSyntax + +Structure + +# DeferStmtSyntax + +struct DeferStmtSyntax + +SyntaxNodesD.swift + +### Children + +- `deferKeyword`: `defer` + +- `body`: `CodeBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, deferKeyword: TokenSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var deferKeyword: TokenSyntax` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeDeferKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDeferKeywordAndBody: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- DeferStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/discardstmtsyntax + +- SwiftSyntax +- DiscardStmtSyntax + +Structure + +# DiscardStmtSyntax + +struct DiscardStmtSyntax + +SyntaxNodesD.swift + +### Children + +- `discardKeyword`: `discard` + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, discardKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var discardKeyword: TokenSyntax` + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeDiscardKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDiscardKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- DiscardStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/dostmtsyntax + +- SwiftSyntax +- DoStmtSyntax + +Structure + +# DoStmtSyntax + +struct DoStmtSyntax + +SyntaxNodesD.swift + +### Children + +- `doKeyword`: `do` + +- `throwsClause`: `ThrowsClauseSyntax`? + +- `body`: `CodeBlockSyntax` + +- `catchClauses`: `CatchClauseListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, doKeyword: TokenSyntax, UnexpectedNodesSyntax?, throwsClause: ThrowsClauseSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, catchClauses: CatchClauseListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var catchClauses: CatchClauseListSyntax` + +`var doKeyword: TokenSyntax` + +`var throwsClause: ThrowsClauseSyntax?` + +The clause specifying the type of errors thrown from the ‘do’ block. + +`var unexpectedAfterCatchClauses: UnexpectedNodesSyntax?` + +`var unexpectedBeforeDoKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBodyAndCatchClauses: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDoKeywordAndThrowsClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenThrowsClauseAndBody: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `catchClauses` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- DoStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/expressionstmtsyntax + +- SwiftSyntax +- ExpressionStmtSyntax + +Structure + +# ExpressionStmtSyntax + +struct ExpressionStmtSyntax + +SyntaxNodesEF.swift + +### Children + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- ExpressionStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/fallthroughstmtsyntax-swift.struct + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/forstmtsyntax + +- SwiftSyntax +- ForStmtSyntax + +Structure + +# ForStmtSyntax + +struct ForStmtSyntax + +SyntaxNodesEF.swift + +### Children + +- `forKeyword`: `for` + +- `tryKeyword`: `try`? + +- `awaitKeyword`: `await`? + +- `caseKeyword`: `case`? + +- `pattern`: `PatternSyntax` + +- `typeAnnotation`: `TypeAnnotationSyntax`? + +- `inKeyword`: `in` + +- `sequence`: `ExprSyntax` + +- `whereClause`: `WhereClauseSyntax`? + +- `body`: `CodeBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, forKeyword: TokenSyntax, UnexpectedNodesSyntax?, tryKeyword: TokenSyntax?, UnexpectedNodesSyntax?, awaitKeyword: TokenSyntax?, UnexpectedNodesSyntax?, caseKeyword: TokenSyntax?, UnexpectedNodesSyntax?, pattern: some PatternSyntaxProtocol, UnexpectedNodesSyntax?, typeAnnotation: TypeAnnotationSyntax?, UnexpectedNodesSyntax?, inKeyword: TokenSyntax, UnexpectedNodesSyntax?, sequence: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, whereClause: WhereClauseSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, forKeyword: TokenSyntax, UnexpectedNodesSyntax?, tryKeyword: TokenSyntax?, UnexpectedNodesSyntax?, awaitKeyword: TokenSyntax?, UnexpectedNodesSyntax?, caseKeyword: TokenSyntax?, UnexpectedNodesSyntax?, pattern: some PatternSyntaxProtocol, UnexpectedNodesSyntax?, typeAnnotation: TypeAnnotationSyntax?, UnexpectedNodesSyntax?, inKeyword: TokenSyntax, UnexpectedNodesSyntax?, sequenceExpr: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, whereClause: WhereClauseSyntax?, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var awaitKeyword: TokenSyntax?` + +`var body: CodeBlockSyntax` + +`var caseKeyword: TokenSyntax?` + +`var forKeyword: TokenSyntax` + +`var inKeyword: TokenSyntax` + +`var pattern: PatternSyntax` + +`var sequence: ExprSyntax` + +`var sequenceExpr: ExprSyntax` Deprecated + +`var tryKeyword: TokenSyntax?` + +`var typeAnnotation: TypeAnnotationSyntax?` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeForKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAwaitKeywordAndCaseKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCaseKeywordAndPattern: UnexpectedNodesSyntax?` + +`var unexpectedBetweenForKeywordAndTryKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenInKeywordAndSequence: UnexpectedNodesSyntax?` + +`var unexpectedBetweenInKeywordAndSequenceExpr: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenPatternAndTypeAnnotation: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSequenceAndWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSequenceExprAndWhereClause: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenTryKeywordAndAwaitKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypeAnnotationAndInKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWhereClauseAndBody: UnexpectedNodesSyntax?` + +`var whereClause: WhereClauseSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- ForStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/guardstmtsyntax + +- SwiftSyntax +- GuardStmtSyntax + +Structure + +# GuardStmtSyntax + +struct GuardStmtSyntax + +SyntaxNodesGHI.swift + +### Children + +- `guardKeyword`: `guard` + +- `conditions`: `ConditionElementListSyntax` + +- `elseKeyword`: `else` + +- `body`: `CodeBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, guardKeyword: TokenSyntax, UnexpectedNodesSyntax?, conditions: ConditionElementListSyntax, UnexpectedNodesSyntax?, elseKeyword: TokenSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var conditions: ConditionElementListSyntax` + +`var elseKeyword: TokenSyntax` + +`var guardKeyword: TokenSyntax` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeGuardKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionsAndElseKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElseKeywordAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGuardKeywordAndConditions: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `conditions` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- GuardStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/labeledstmtsyntax + +- SwiftSyntax +- LabeledStmtSyntax + +Structure + +# LabeledStmtSyntax + +struct LabeledStmtSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `colon`: `:` + +- `statement`: `StmtSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, label: TokenSyntax, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, statement: some StmtSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, labelName: TokenSyntax, UnexpectedNodesSyntax?, labelColon: TokenSyntax, UnexpectedNodesSyntax?, statement: some StmtSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var colon: TokenSyntax` + +`var label: TokenSyntax` + +`var labelColon: TokenSyntax` Deprecated + +`var labelName: TokenSyntax` Deprecated + +`var statement: StmtSyntax` + +`var unexpectedAfterStatement: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLabel: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLabelName: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenColonAndStatement: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLabelAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLabelColonAndStatement: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLabelNameAndLabelColon: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- LabeledStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/repeatstmtsyntax + +- SwiftSyntax +- RepeatStmtSyntax + +Structure + +# RepeatStmtSyntax + +struct RepeatStmtSyntax + +SyntaxNodesQRS.swift + +### Children + +- `repeatKeyword`: `repeat` + +- `body`: `CodeBlockSyntax` + +- `whileKeyword`: `while` + +- `condition`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, repeatKeyword: TokenSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, whileKeyword: TokenSyntax, UnexpectedNodesSyntax?, condition: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var condition: ExprSyntax` + +`var repeatKeyword: TokenSyntax` + +`var unexpectedAfterCondition: UnexpectedNodesSyntax?` + +`var unexpectedBeforeRepeatKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBodyAndWhileKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRepeatKeywordAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWhileKeywordAndCondition: UnexpectedNodesSyntax?` + +`var whileKeyword: TokenSyntax` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct ReturnStmtSyntax` + +`struct ThrowStmtSyntax` + +- RepeatStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/returnstmtsyntax + +- SwiftSyntax +- ReturnStmtSyntax + +Structure + +# ReturnStmtSyntax + +struct ReturnStmtSyntax + +SyntaxNodesQRS.swift + +### Children + +- `returnKeyword`: `return` + +- `expression`: `ExprSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, returnKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: (some ExprSyntaxProtocol)?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax?` + +`var returnKeyword: TokenSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeReturnKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenReturnKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ThrowStmtSyntax` + +- ReturnStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/throwstmtsyntax + +- SwiftSyntax +- ThrowStmtSyntax + +Structure + +# ThrowStmtSyntax + +struct ThrowStmtSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `throwKeyword`: `throw` + +- `expression`: `ExprSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, throwKeyword: TokenSyntax, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var expression: ExprSyntax` + +`var throwKeyword: TokenSyntax` + +`var unexpectedAfterExpression: UnexpectedNodesSyntax?` + +`var unexpectedBeforeThrowKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenThrowKeywordAndExpression: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +- ThrowStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/whilestmtsyntax + +- SwiftSyntax +- WhileStmtSyntax + +Structure + +# WhileStmtSyntax + +struct WhileStmtSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `whileKeyword`: `while` + +- `conditions`: `ConditionElementListSyntax` + +- `body`: `CodeBlockSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, whileKeyword: TokenSyntax, UnexpectedNodesSyntax?, conditions: ConditionElementListSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var conditions: ConditionElementListSyntax` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeWhileKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionsAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWhileKeywordAndConditions: UnexpectedNodesSyntax?` + +`var whileKeyword: TokenSyntax` + +### Instance Methods + +Adds the provided `element` to the node’s `conditions` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +- WhileStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/yieldstmtsyntax + +- SwiftSyntax +- YieldStmtSyntax + +Structure + +# YieldStmtSyntax + +struct YieldStmtSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `yieldKeyword`: `yield` + +- `yieldedExpressions`: ( `YieldedExpressionsClauseSyntax` \| `ExprSyntax`) + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, yieldKeyword: TokenSyntax, UnexpectedNodesSyntax?, yieldedExpressions: YieldStmtSyntax.YieldedExpressions, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, yieldKeyword: TokenSyntax, UnexpectedNodesSyntax?, yields: YieldStmtSyntax.YieldedExpressions, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var unexpectedAfterYieldedExpressions: UnexpectedNodesSyntax?` + +`var unexpectedAfterYields: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeYieldKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenYieldKeywordAndYieldedExpressions: UnexpectedNodesSyntax?` + +`var unexpectedBetweenYieldKeywordAndYields: UnexpectedNodesSyntax?` Deprecated + +`var yieldKeyword: TokenSyntax` + +`var yieldedExpressions: YieldStmtSyntax.YieldedExpressions` + +`var yields: YieldStmtSyntax.YieldedExpressions` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum YieldedExpressions` + +## Relationships + +### Conforms To + +- `StmtSyntaxProtocol` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Statements + +`struct StmtSyntax` + +`protocol StmtSyntaxProtocol` + +Protocol to which all `StmtSyntax` nodes conform. + +`struct MissingStmtSyntax` + +In case the source code is missing a statement, this node stands in place of the missing statement. + +`struct BreakStmtSyntax` + +`struct ContinueStmtSyntax` + +`struct DeferStmtSyntax` + +`struct DiscardStmtSyntax` + +`struct DoStmtSyntax` + +`struct ExpressionStmtSyntax` + +`struct FallThroughStmtSyntax` + +`struct ForStmtSyntax` + +`struct GuardStmtSyntax` + +`struct LabeledStmtSyntax` + +`struct RepeatStmtSyntax` + +`struct ReturnStmtSyntax` + +- YieldStmtSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/typesyntax + +- SwiftSyntax +- TypeSyntax + +Structure + +# TypeSyntax + +struct TypeSyntax + +SyntaxBaseNodes.swift + +### Subtypes + +- `ArrayTypeSyntax` + +- `AttributedTypeSyntax` + +- `ClassRestrictionTypeSyntax` + +- `CompositionTypeSyntax` + +- `DictionaryTypeSyntax` + +- `FunctionTypeSyntax` + +- `IdentifierTypeSyntax` + +- `ImplicitlyUnwrappedOptionalTypeSyntax` + +- `MemberTypeSyntax` + +- `MetatypeTypeSyntax` + +- `MissingTypeSyntax` + +- `NamedOpaqueReturnTypeSyntax` + +- `OptionalTypeSyntax` + +- `PackElementTypeSyntax` + +- `PackExpansionTypeSyntax` + +- `SomeOrAnyTypeSyntax` + +- `SuppressedTypeSyntax` + +- `TupleTypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(some TypeSyntaxProtocol)` + +Create a `TypeSyntax` node from a specialized syntax node. + +`init?((some TypeSyntaxProtocol)?)` + +Create a `TypeSyntax` node from a specialized optional syntax node. + +`init(fromProtocol: any TypeSyntaxProtocol)` + +`init?(fromProtocol: (any TypeSyntaxProtocol)?)` + +### Instance Methods + +Get an enum that can be used to exhaustively switch over all Type syntax nodes. + +Return the non-type erased version of this syntax node. + +Syntax nodes always conform to `TypeSyntaxProtocol`. This API is just added for consistency. + +Deprecated + +### Type Properties + +`static var structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- TypeSyntax +- Subtypes +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/typesyntaxprotocol + +- SwiftSyntax +- TypeSyntaxProtocol + +Protocol + +# TypeSyntaxProtocol + +Protocol to which all `TypeSyntax` nodes conform. + +protocol TypeSyntaxProtocol : SyntaxProtocol + +SyntaxBaseNodes.swift + +## Overview + +Extension point to add common methods to all `TypeSyntax` nodes. + +## Topics + +### Instance Methods + +Attempts to cast the current syntax node to a given node type from the a base node protocol hierarchy other than `TypeSyntaxProtocol`. + +Deprecated + +Attempts to upcast the current syntax node to its base node type ( `TypeSyntax`). + +Attempts to cast the current syntax node to a given specialized syntax type. + +Force-casts the current syntax node to a given specialized syntax type. + +Force-upcast the current syntax node to its base node type ( `TypeSyntax`). + +Force-casts the current syntax node to a given node type from a base node protocol hierarchy other than `TypeSyntaxProtocol`. + +Checks if the current syntax node can be cast to a given specialized syntax type. + +Checks if the current syntax node can be cast to a given node type from a base node protocol hierarchy other than `TypeSyntaxProtocol`. + +Checks if the current syntax node can be upcast to its base node type ( `TypeSyntax`). + +## Relationships + +### Inherits From + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxProtocol` + +### Conforming Types + +- `ArrayTypeSyntax` +- `AttributedTypeSyntax` +- `ClassRestrictionTypeSyntax` +- `CompositionTypeSyntax` +- `DictionaryTypeSyntax` +- `FunctionTypeSyntax` +- `IdentifierTypeSyntax` +- `ImplicitlyUnwrappedOptionalTypeSyntax` +- `MemberTypeSyntax` +- `MetatypeTypeSyntax` +- `MissingTypeSyntax` +- `NamedOpaqueReturnTypeSyntax` +- `OptionalTypeSyntax` +- `PackElementTypeSyntax` +- `PackExpansionTypeSyntax` +- `SomeOrAnyTypeSyntax` +- `SuppressedTypeSyntax` +- `TupleTypeSyntax` +- `TypeSyntax` + +## See Also + +### Types + +`struct TypeSyntax` + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- TypeSyntaxProtocol +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/missingtypesyntax + +- SwiftSyntax +- MissingTypeSyntax + +Structure + +# MissingTypeSyntax + +In case the source code is missing a type, this node stands in place of the missing type. + +struct MissingTypeSyntax + +SyntaxNodesJKLMN.swift + +## Topics + +### Initializers + +`init()` + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, placeholder: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var placeholder: TokenSyntax` + +`var unexpectedAfterPlaceholder: UnexpectedNodesSyntax?` + +`var unexpectedBeforePlaceholder: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `MissingNodeSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- MissingTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/arraytypesyntax + +- SwiftSyntax +- ArrayTypeSyntax + +Structure + +# ArrayTypeSyntax + +struct ArrayTypeSyntax + +SyntaxNodesAB.swift + +### Children + +- `leftSquare`: ``\ +\ +- `element`: [`TypeSyntax`\ +\ +- `rightSquare`: `]` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquare: TokenSyntax, UnexpectedNodesSyntax?, element: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, rightSquare: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, elementType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, rightSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var element: TypeSyntax` + +`var elementType: TypeSyntax` Deprecated + +`var leftSquare: TokenSyntax` + +`var leftSquareBracket: TokenSyntax` Deprecated + +`var rightSquare: TokenSyntax` + +`var rightSquareBracket: TokenSyntax` Deprecated + +`var unexpectedAfterRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedAfterRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLeftSquare: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenElementAndRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElementTypeAndRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftSquareAndElement: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftSquareBracketAndElementType: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- ArrayTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/attributedtypesyntax + +- SwiftSyntax +- AttributedTypeSyntax + +Structure + +# AttributedTypeSyntax + +struct AttributedTypeSyntax + +SyntaxNodesAB.swift + +### Children + +- `specifiers`: `TypeSpecifierListSyntax` + +- `attributes`: `AttributeListSyntax` + +- `baseType`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, specifier: TokenSyntax?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, specifiers: TypeSpecifierListSyntax, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +A list of attributes that can be attached to the type, such as `@escaping`. + +`var baseType: TypeSyntax` + +The type to with the specifiers and attributes are applied. + +`var specifier: TokenSyntax?` Deprecated + +`var specifiers: TypeSpecifierListSyntax` + +A list of specifiers that can be attached to the type, such as `inout`, `isolated`, or `consuming`. + +`var unexpectedAfterBaseType: UnexpectedNodesSyntax?` + +`var unexpectedBeforeSpecifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeSpecifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndBaseType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSpecifierAndAttributes: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenSpecifiersAndAttributes: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `specifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` +- `WithAttributesSyntax` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- AttributedTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/classrestrictiontypesyntax + +- SwiftSyntax +- ClassRestrictionTypeSyntax + +Structure + +# ClassRestrictionTypeSyntax + +struct ClassRestrictionTypeSyntax + +SyntaxNodesC.swift + +### Children + +- `classKeyword`: `class` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, classKeyword: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var classKeyword: TokenSyntax` + +`var unexpectedAfterClassKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBeforeClassKeyword: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- ClassRestrictionTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/compositiontypesyntax + +- SwiftSyntax +- CompositionTypeSyntax + +Structure + +# CompositionTypeSyntax + +struct CompositionTypeSyntax + +SyntaxNodesC.swift + +### Children + +- `elements`: `CompositionTypeElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, elements: CompositionTypeElementListSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var elements: CompositionTypeElementListSyntax` + +`var unexpectedAfterElements: UnexpectedNodesSyntax?` + +`var unexpectedBeforeElements: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- CompositionTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/dictionarytypesyntax + +- SwiftSyntax +- DictionaryTypeSyntax + +Structure + +# DictionaryTypeSyntax + +struct DictionaryTypeSyntax + +SyntaxNodesD.swift + +### Children + +- `leftSquare`: ``\ +\ +- `key`: [`TypeSyntax`\ +\ +- `colon`: `:`\ +\ +- `value`: `TypeSyntax`\ +\ +- `rightSquare`: `]` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquare: TokenSyntax, UnexpectedNodesSyntax?, key: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, value: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, rightSquare: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, keyType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, valueType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, rightSquareBracket: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var colon: TokenSyntax` + +`var key: TypeSyntax` + +`var keyType: TypeSyntax` Deprecated + +`var leftSquare: TokenSyntax` + +`var leftSquareBracket: TokenSyntax` Deprecated + +`var rightSquare: TokenSyntax` + +`var rightSquareBracket: TokenSyntax` Deprecated + +`var unexpectedAfterRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedAfterRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeLeftSquare: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenColonAndValue: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndValueType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenKeyAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenKeyTypeAndColon: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftSquareAndKey: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftSquareBracketAndKeyType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenValueAndRightSquare: UnexpectedNodesSyntax?` + +`var unexpectedBetweenValueTypeAndRightSquareBracket: UnexpectedNodesSyntax?` Deprecated + +`var value: TypeSyntax` + +`var valueType: TypeSyntax` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- DictionaryTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/functiontypesyntax + +- SwiftSyntax +- FunctionTypeSyntax + +Structure + +# FunctionTypeSyntax + +struct FunctionTypeSyntax + +SyntaxNodesEF.swift + +### Children + +- `leftParen`: `(` + +- `parameters`: `TupleTypeElementListSyntax` + +- `rightParen`: `)` + +- `effectSpecifiers`: `TypeEffectSpecifiersSyntax`? + +- `returnClause`: `ReturnClauseSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, arguments: TupleTypeElementListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, effectSpecifiers: TypeEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, output: ReturnClauseSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, parameters: TupleTypeElementListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, effectSpecifiers: TypeEffectSpecifiersSyntax?, UnexpectedNodesSyntax?, returnClause: ReturnClauseSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var arguments: TupleTypeElementListSyntax` Deprecated + +`var effectSpecifiers: TypeEffectSpecifiersSyntax?` + +`var leftParen: TokenSyntax` + +`var output: ReturnClauseSyntax` Deprecated + +`var parameters: TupleTypeElementListSyntax` + +`var returnClause: ReturnClauseSyntax` + +`var rightParen: TokenSyntax` + +`var unexpectedAfterOutput: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterReturnClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenEffectSpecifiersAndOutput: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenEffectSpecifiersAndReturnClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndArguments: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndParameters: UnexpectedNodesSyntax?` + +`var unexpectedBetweenParametersAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRightParenAndEffectSpecifiers: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `parameters` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ParenthesizedSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- FunctionTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/identifiertypesyntax + +- SwiftSyntax +- IdentifierTypeSyntax + +Structure + +# IdentifierTypeSyntax + +struct IdentifierTypeSyntax + +SyntaxNodesGHI.swift + +### Children + +- `genericArgumentClause`: `GenericArgumentClauseSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericArgumentClause: GenericArgumentClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var genericArgumentClause: GenericArgumentClauseSyntax?` + +`var name: TokenSyntax` + +`var unexpectedAfterGenericArgumentClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericArgumentClause: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- IdentifierTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/implicitlyunwrappedoptionaltypesyntax + +- SwiftSyntax +- ImplicitlyUnwrappedOptionalTypeSyntax + +Structure + +# ImplicitlyUnwrappedOptionalTypeSyntax + +struct ImplicitlyUnwrappedOptionalTypeSyntax + +SyntaxNodesGHI.swift + +### Children + +- `wrappedType`: `TypeSyntax` + +- `exclamationMark`: `!` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, wrappedType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, exclamationMark: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var exclamationMark: TokenSyntax` + +`var unexpectedAfterExclamationMark: UnexpectedNodesSyntax?` + +`var unexpectedBeforeWrappedType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWrappedTypeAndExclamationMark: UnexpectedNodesSyntax?` + +`var wrappedType: TypeSyntax` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- ImplicitlyUnwrappedOptionalTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/membertypesyntax + +- SwiftSyntax +- MemberTypeSyntax + +Structure + +# MemberTypeSyntax + +struct MemberTypeSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `baseType`: `TypeSyntax` + +- `period`: `.` + +- `genericArgumentClause`: `GenericArgumentClauseSyntax`? + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, period: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, genericArgumentClause: GenericArgumentClauseSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var baseType: TypeSyntax` + +`var genericArgumentClause: GenericArgumentClauseSyntax?` + +`var name: TokenSyntax` + +`var period: TokenSyntax` + +`var unexpectedAfterGenericArgumentClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBaseType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBaseTypeAndPeriod: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndGenericArgumentClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPeriodAndName: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- MemberTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/metatypetypesyntax + +- SwiftSyntax +- MetatypeTypeSyntax + +Structure + +# MetatypeTypeSyntax + +struct MetatypeTypeSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `baseType`: `TypeSyntax` + +- `period`: `.` + +- `metatypeSpecifier`: ( `Type` \| `Protocol`) + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, period: TokenSyntax, UnexpectedNodesSyntax?, metatypeSpecifier: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, period: TokenSyntax, UnexpectedNodesSyntax?, typeOrProtocol: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var baseType: TypeSyntax` + +`var metatypeSpecifier: TokenSyntax` + +`var period: TokenSyntax` + +`var typeOrProtocol: TokenSyntax` Deprecated + +`var unexpectedAfterMetatypeSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedAfterTypeOrProtocol: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeBaseType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBaseTypeAndPeriod: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPeriodAndMetatypeSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPeriodAndTypeOrProtocol: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- MetatypeTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/namedopaquereturntypesyntax + +- SwiftSyntax +- NamedOpaqueReturnTypeSyntax + +Structure + +# NamedOpaqueReturnTypeSyntax + +struct NamedOpaqueReturnTypeSyntax + +SyntaxNodesJKLMN.swift + +### Children + +- `genericParameterClause`: `GenericParameterClauseSyntax` + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, genericParameterClause: GenericParameterClauseSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, genericParameters: GenericParameterClauseSyntax, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var baseType: TypeSyntax` Deprecated + +`var genericParameterClause: GenericParameterClauseSyntax` + +The parameter clause that defines the generic parameters. + +`var genericParameters: GenericParameterClauseSyntax` Deprecated + +`var type: TypeSyntax` + +`var unexpectedAfterBaseType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedBeforeGenericParameterClause: UnexpectedNodesSyntax?` + +`var unexpectedBeforeGenericParameters: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenGenericParameterClauseAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenGenericParametersAndBaseType: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct OptionalTypeSyntax` + +`struct PackElementTypeSyntax` + +- NamedOpaqueReturnTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/optionaltypesyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/packelementtypesyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/packexpansiontypesyntax + +- SwiftSyntax +- PackExpansionTypeSyntax + +Structure + +# PackExpansionTypeSyntax + +struct PackExpansionTypeSyntax + +SyntaxNodesOP.swift + +### Children + +- `repeatKeyword`: `repeat` + +- `repetitionPattern`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, repeatKeyword: TokenSyntax, UnexpectedNodesSyntax?, patternType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, repeatKeyword: TokenSyntax, UnexpectedNodesSyntax?, repetitionPattern: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var patternType: TypeSyntax` Deprecated + +`var repeatKeyword: TokenSyntax` + +`var repetitionPattern: TypeSyntax` + +`var unexpectedAfterPatternType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterRepetitionPattern: UnexpectedNodesSyntax?` + +`var unexpectedBeforeRepeatKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRepeatKeywordAndPatternType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenRepeatKeywordAndRepetitionPattern: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +- PackExpansionTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/someoranytypesyntax + +- SwiftSyntax +- SomeOrAnyTypeSyntax + +Structure + +# SomeOrAnyTypeSyntax + +struct SomeOrAnyTypeSyntax + +SyntaxNodesQRS.swift + +### Children + +- `someOrAnySpecifier`: ( `some` \| `any`) + +- `constraint`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, someOrAnySpecifier: TokenSyntax, UnexpectedNodesSyntax?, baseType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, someOrAnySpecifier: TokenSyntax, UnexpectedNodesSyntax?, constraint: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var baseType: TypeSyntax` Deprecated + +`var constraint: TypeSyntax` + +`var someOrAnySpecifier: TokenSyntax` + +`var unexpectedAfterBaseType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterConstraint: UnexpectedNodesSyntax?` + +`var unexpectedBeforeSomeOrAnySpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSomeOrAnySpecifierAndBaseType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenSomeOrAnySpecifierAndConstraint: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +- SomeOrAnyTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/suppressedtypesyntax + +- SwiftSyntax +- SuppressedTypeSyntax + +Structure + +# SuppressedTypeSyntax + +struct SuppressedTypeSyntax + +SyntaxNodesQRS.swift + +### Children + +- `type`: `TypeSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, withoutTilde: TokenSyntax, UnexpectedNodesSyntax?, patternType: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, withoutTilde: TokenSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var patternType: TypeSyntax` Deprecated + +`var type: TypeSyntax` + +`var unexpectedAfterPatternType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedAfterType: UnexpectedNodesSyntax?` + +`var unexpectedBeforeWithoutTilde: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWithoutTildeAndPatternType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenWithoutTildeAndType: UnexpectedNodesSyntax?` + +`var withoutTilde: TokenSyntax` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +- SuppressedTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/tupletypesyntax + +- SwiftSyntax +- TupleTypeSyntax + +Structure + +# TupleTypeSyntax + +struct TupleTypeSyntax + +SyntaxNodesTUVWXYZ.swift + +### Children + +- `leftParen`: `(` + +- `elements`: `TupleTypeElementListSyntax` + +- `rightParen`: `)` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leftParen: TokenSyntax, UnexpectedNodesSyntax?, elements: TupleTypeElementListSyntax, UnexpectedNodesSyntax?, rightParen: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var elements: TupleTypeElementListSyntax` + +`var leftParen: TokenSyntax` + +`var rightParen: TokenSyntax` + +`var unexpectedAfterRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenElementsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndElements: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `elements` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `ParenthesizedSyntax` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `TypeSyntaxProtocol` + +## See Also + +### Types + +`struct TypeSyntax` + +`protocol TypeSyntaxProtocol` + +Protocol to which all `TypeSyntax` nodes conform. + +`struct MissingTypeSyntax` + +In case the source code is missing a type, this node stands in place of the missing type. + +`struct ArrayTypeSyntax` + +`struct AttributedTypeSyntax` + +`struct ClassRestrictionTypeSyntax` + +`struct CompositionTypeSyntax` + +`struct DictionaryTypeSyntax` + +`struct FunctionTypeSyntax` + +`struct IdentifierTypeSyntax` + +`struct ImplicitlyUnwrappedOptionalTypeSyntax` + +`struct MemberTypeSyntax` + +`struct MetatypeTypeSyntax` + +`struct NamedOpaqueReturnTypeSyntax` + +`struct OptionalTypeSyntax` + +- TupleTypeSyntax +- Children +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxchildren + +- SwiftSyntax +- SyntaxChildren + +Structure + +# SyntaxChildren + +Collection that contains the present child `Syntax` nodes of the given node. + +struct SyntaxChildren + +SyntaxChildren.swift + +## Topics + +### Instance Properties + +`var endIndex: SyntaxChildrenIndex` + +The index that’s one after the last element in the collection. + +`var startIndex: SyntaxChildrenIndex` + +The index of the first child in this collection. + +### Instance Methods + +The index for the child that’s after the child at `index`. + +The index for the child that’s before the child at `index`. + +Return the index of `node` within this collection. + +### Subscripts + +The syntax node at the given `index` + +### Type Aliases + +`typealias Element` + +`SyntaxChildren` contains `Syntax` nodes. + +`typealias Index` + +`SyntaxChildren` is indexed by `SyntaxChildrenIndex`. + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.Sendable` +- `Swift.Sequence` + +## See Also + +### Collections + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- SyntaxChildren +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/syntaxchildrenindex + +- SwiftSyntax +- SyntaxChildrenIndex + +Structure + +# SyntaxChildrenIndex + +An index in a syntax children collection. + +struct SyntaxChildrenIndex + +SyntaxChildren.swift + +## Topics + +### Operators + +Returns `true` if `lhs` occurs before `rhs`. + +### Initializers + +`init(nilLiteral: ())` + +Construct the `endIndex` of a `SyntaxChildren` collection. + +## Relationships + +### Conforms To + +- `Swift.Comparable` +- `Swift.Equatable` +- `Swift.ExpressibleByNilLiteral` +- `Swift.Hashable` +- `Swift.Sendable` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- SyntaxChildrenIndex +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/accessordecllistsyntax + +- SwiftSyntax +- AccessorDeclListSyntax + +Structure + +# AccessorDeclListSyntax + +struct AccessorDeclListSyntax + +SyntaxCollections.swift + +### Children + +`AccessorDeclSyntax` `*` + +### Contained in + +- `AccessorBlockSyntax`. `accessors` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- AccessorDeclListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/arrayelementlistsyntax + +- SwiftSyntax +- ArrayElementListSyntax + +Structure + +# ArrayElementListSyntax + +struct ArrayElementListSyntax + +SyntaxCollections.swift + +### Children + +`ArrayElementSyntax` `*` + +### Contained in + +- `ArrayExprSyntax`. `elements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- ArrayElementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/arrayelementsyntax + + + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/attributelistsyntax + +- SwiftSyntax +- AttributeListSyntax + +Structure + +# AttributeListSyntax + +A list of attributes that can be attached to a declaration. + +struct AttributeListSyntax + +SyntaxCollections.swift + +## Overview + +An element in this collection can either be an attribute itself or an `IfConfigDeclSyntax` that contains attributes. This is because attributes can be added conditional on compilcation conditions, for example. + +#if !DISABLE_DEPRECATIONS +@available(*, deprecated) +#endif +func myFunction() {} + +### Children + +( `AttributeSyntax` \| `IfConfigDeclSyntax`) `*` + +### Contained in + +- `AccessorDeclSyntax`. `attributes` + +- `ActorDeclSyntax`. `attributes` + +- `AssociatedTypeDeclSyntax`. `attributes` + +- `AttributedTypeSyntax`. `attributes` + +- `ClassDeclSyntax`. `attributes` + +- `ClosureParameterSyntax`. `attributes` + +- `ClosureSignatureSyntax`. `attributes` + +- `DeinitializerDeclSyntax`. `attributes` + +- `EditorPlaceholderDeclSyntax`. `attributes` + +- `EnumCaseDeclSyntax`. `attributes` + +- `EnumDeclSyntax`. `attributes` + +- `ExtensionDeclSyntax`. `attributes` + +- `FunctionDeclSyntax`. `attributes` + +- `FunctionParameterSyntax`. `attributes` + +- `GenericParameterSyntax`. `attributes` + +- `IfConfigClauseSyntax`. `elements` + +- `ImportDeclSyntax`. `attributes` + +- `InitializerDeclSyntax`. `attributes` + +- `MacroDeclSyntax`. `attributes` + +- `MacroExpansionDeclSyntax`. `attributes` + +- `MissingDeclSyntax`. `attributes` + +- `PrecedenceGroupDeclSyntax`. `attributes` + +- `ProtocolDeclSyntax`. `attributes` + +- `StructDeclSyntax`. `attributes` + +- `SubscriptDeclSyntax`. `attributes` + +- `TypeAliasDeclSyntax`. `attributes` + +- `VariableDeclSyntax`. `attributes` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +### Enumerations + +`enum Element` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- AttributeListSyntax +- Overview +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/attributesyntax + +- SwiftSyntax +- AttributeSyntax + +Structure + +# AttributeSyntax + +An `@` attribute. + +struct AttributeSyntax + +SyntaxNodesAB.swift + +### Children + +- `atSign`: `@` + +- `attributeName`: `TypeSyntax` + +- `leftParen`: `(`? + +- `arguments`: ( `LabeledExprListSyntax` \| `TokenSyntax` \| `StringLiteralExprSyntax` \| `AvailabilityArgumentListSyntax` \| `SpecializeAttributeArgumentListSyntax` \| `ObjCSelectorPieceListSyntax` \| `ImplementsAttributeArgumentsSyntax` \| `DifferentiableAttributeArgumentsSyntax` \| `DerivativeAttributeArgumentsSyntax` \| `BackDeployedAttributeArgumentsSyntax` \| `ConventionAttributeArgumentsSyntax` \| `ConventionWitnessMethodAttributeArgumentsSyntax` \| `OpaqueReturnTypeOfAttributeArgumentsSyntax` \| `ExposeAttributeArgumentsSyntax` \| `OriginallyDefinedInAttributeArgumentsSyntax` \| `UnderscorePrivateAttributeArgumentsSyntax` \| `DynamicReplacementAttributeArgumentsSyntax` \| `UnavailableFromAsyncAttributeArgumentsSyntax` \| `EffectsAttributeArgumentListSyntax` \| `DocumentationAttributeArgumentListSyntax`)? + +- `rightParen`: `)`? + +### Contained in + +- `AttributeListSyntax` + +- `SwitchCaseSyntax`. `attribute` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, atSign: TokenSyntax, UnexpectedNodesSyntax?, attributeName: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, arguments: AttributeSyntax.Arguments?, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, atSignToken: TokenSyntax, UnexpectedNodesSyntax?, attributeName: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, leftParen: TokenSyntax?, UnexpectedNodesSyntax?, argument: AttributeSyntax.Arguments?, UnexpectedNodesSyntax?, rightParen: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var argument: AttributeSyntax.Arguments?` Deprecated + +`var arguments: AttributeSyntax.Arguments?` + +The arguments of the attribute. + +`var atSign: TokenSyntax` + +The `@` sign. + +`var atSignToken: TokenSyntax` Deprecated + +`var attributeName: TypeSyntax` + +The name of the attribute. + +`var leftParen: TokenSyntax?` + +If the attribute takes arguments, the opening parenthesis. + +`var rightParen: TokenSyntax?` + +If the attribute takes arguments, the closing parenthesis. + +`var unexpectedAfterRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAtSign: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAtSignToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentAndRightParen: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAtSignAndAttributeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAtSignTokenAndAttributeName: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenAttributeNameAndLeftParen: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeftParenAndArgument: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenLeftParenAndArguments: UnexpectedNodesSyntax?` + +### Type Aliases + +`typealias Argument` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Arguments` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- AttributeSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/availabilityargumentlistsyntax + +- SwiftSyntax +- AvailabilityArgumentListSyntax + +Structure + +# AvailabilityArgumentListSyntax + +struct AvailabilityArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`AvailabilityArgumentSyntax` `*` + +### Contained in + +- `AttributeSyntax`. `arguments` + +- `AvailabilityConditionSyntax`. `availabilityArguments` + +- `SpecializeAvailabilityArgumentSyntax`. `availabilityArguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- AvailabilityArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/availabilityargumentsyntax + +- SwiftSyntax +- AvailabilityArgumentSyntax + +Structure + +# AvailabilityArgumentSyntax + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +struct AvailabilityArgumentSyntax + +SyntaxNodesAB.swift + +### Children + +- `trailingComma`: `,`? + +### Contained in + +- `AvailabilityArgumentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, argument: AvailabilityArgumentSyntax.Argument, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, entry: AvailabilityArgumentSyntax.Argument, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var argument: AvailabilityArgumentSyntax.Argument` + +The actual argument. + +`var entry: AvailabilityArgumentSyntax.Argument` Deprecated + +`var trailingComma: TokenSyntax?` + +A trailing comma if the argument is followed by another argument. + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeArgument: UnexpectedNodesSyntax?` + +`var unexpectedBeforeEntry: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEntryAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +### Type Aliases + +`typealias Entry` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Argument` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- AvailabilityArgumentSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/catchclauselistsyntax + +- SwiftSyntax +- CatchClauseListSyntax + +Structure + +# CatchClauseListSyntax + +struct CatchClauseListSyntax + +SyntaxCollections.swift + +### Children + +`CatchClauseSyntax` `*` + +### Contained in + +- `DoStmtSyntax`. `catchClauses` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- CatchClauseListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/catchclausesyntax + +- SwiftSyntax +- CatchClauseSyntax + +Structure + +# CatchClauseSyntax + +struct CatchClauseSyntax + +SyntaxNodesC.swift + +### Children + +- `catchKeyword`: `catch` + +- `catchItems`: `CatchItemListSyntax` + +- `body`: `CodeBlockSyntax` + +### Contained in + +- `CatchClauseListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, catchKeyword: TokenSyntax, UnexpectedNodesSyntax?, catchItems: CatchItemListSyntax, UnexpectedNodesSyntax?, body: CodeBlockSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: CodeBlockSyntax` + +`var catchItems: CatchItemListSyntax` + +`var catchKeyword: TokenSyntax` + +`var unexpectedAfterBody: UnexpectedNodesSyntax?` + +`var unexpectedBeforeCatchKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCatchItemsAndBody: UnexpectedNodesSyntax?` + +`var unexpectedBetweenCatchKeywordAndCatchItems: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `catchItems` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithCodeBlockSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- CatchClauseSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/catchitemlistsyntax + +- SwiftSyntax +- CatchItemListSyntax + +Structure + +# CatchItemListSyntax + +struct CatchItemListSyntax + +SyntaxCollections.swift + +### Children + +`CatchItemSyntax` `*` + +### Contained in + +- `CatchClauseSyntax`. `catchItems` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- CatchItemListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/catchitemsyntax + +- SwiftSyntax +- CatchItemSyntax + +Structure + +# CatchItemSyntax + +struct CatchItemSyntax + +SyntaxNodesC.swift + +### Children + +- `pattern`: `PatternSyntax`? + +- `whereClause`: `WhereClauseSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `CatchItemListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, pattern: (some PatternSyntaxProtocol)?, UnexpectedNodesSyntax?, whereClause: WhereClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var pattern: PatternSyntax?` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforePattern: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPatternAndWhereClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenWhereClauseAndTrailingComma: UnexpectedNodesSyntax?` + +`var whereClause: WhereClauseSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- CatchItemSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closurecapturelistsyntax + +- SwiftSyntax +- ClosureCaptureListSyntax + +Structure + +# ClosureCaptureListSyntax + +struct ClosureCaptureListSyntax + +SyntaxCollections.swift + +### Children + +`ClosureCaptureSyntax` `*` + +### Contained in + +- `ClosureCaptureClauseSyntax`. `items` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureSyntax` + +`struct ClosureParameterListSyntax` + +- ClosureCaptureListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closurecapturesyntax + +- SwiftSyntax +- ClosureCaptureSyntax + +Structure + +# ClosureCaptureSyntax + +struct ClosureCaptureSyntax + +SyntaxNodesC.swift + +### Children + +- `specifier`: `ClosureCaptureSpecifierSyntax`? + +- `initializer`: `InitializerClauseSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `ClosureCaptureListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, specifier: ClosureCaptureSpecifierSyntax?, UnexpectedNodesSyntax?, name: TokenSyntax?, UnexpectedNodesSyntax?, equal: TokenSyntax?, UnexpectedNodesSyntax?, expression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, specifier: ClosureCaptureSpecifierSyntax?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, initializer: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, specifier: ClosureCaptureSpecifierSyntax?, name: TokenSyntax, equal: TokenSyntax, expression: some ExprSyntaxProtocol, trailingComma: TokenSyntax?, trailingTrivia: Trivia?)` + +Creates a `ClosureCaptureSyntax` with a `name`, and automatically adds an `equal` token to it since the name is non-optional. + +Deprecated + +### Instance Properties + +`var assignToken: TokenSyntax?` Deprecated + +`var equal: TokenSyntax?` Deprecated + +`var expression: ExprSyntax` Deprecated + +`var initializer: InitializerClauseSyntax?` + +`var name: TokenSyntax` + +`var specifier: ClosureCaptureSpecifierSyntax?` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAssignTokenAndExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenEqualAndExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenExpressionAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInitializerAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndAssignToken: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenNameAndEqual: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenNameAndInitializer: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSpecifierAndName: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureParameterListSyntax` + +- ClosureCaptureSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closureparameterlistsyntax + +- SwiftSyntax +- ClosureParameterListSyntax + +Structure + +# ClosureParameterListSyntax + +struct ClosureParameterListSyntax + +SyntaxCollections.swift + +### Children + +`ClosureParameterSyntax` `*` + +### Contained in + +- `ClosureParameterClauseSyntax`. `parameters` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ClosureParameterListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closureparametersyntax + +- SwiftSyntax +- ClosureParameterSyntax + +Structure + +# ClosureParameterSyntax + +struct ClosureParameterSyntax + +SyntaxNodesC.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `colon`: `:`? + +- `type`: `TypeSyntax`? + +- `ellipsis`: `...`? + +- `trailingComma`: `,`? + +### Contained in + +- `ClosureParameterListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, firstName: TokenSyntax, UnexpectedNodesSyntax?, secondName: TokenSyntax?, UnexpectedNodesSyntax?, colon: TokenSyntax?, UnexpectedNodesSyntax?, type: (some TypeSyntaxProtocol)?, UnexpectedNodesSyntax?, ellipsis: TokenSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +`var colon: TokenSyntax?` + +The colon separating the parameter’s name and type. + +`var ellipsis: TokenSyntax?` + +If the parameter is variadic, `...` to indicate that. + +`var firstName: TokenSyntax` + +The label of this parameter that will be used when the closure is called. + +`var modifiers: DeclModifierListSyntax` + +`var secondName: TokenSyntax?` + +If this is specified, it is the name by which the parameter can be referenced inside the closure body. If it is `nil`, the closure parameter is referenced by the first name. + +`var trailingComma: TokenSyntax?` + +If the parameter is followed by another parameter, the comma separating them. + +`var type: TypeSyntax?` + +The type of the parameter. + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEllipsisAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSecondNameAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypeAndEllipsis: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ClosureParameterSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closureshorthandparameterlistsyntax + +- SwiftSyntax +- ClosureShorthandParameterListSyntax + +Structure + +# ClosureShorthandParameterListSyntax + +A list of closure parameters that are not parenthesized and don’t have type annotations. + +struct ClosureShorthandParameterListSyntax + +SyntaxCollections.swift + +## Overview + +If the closure parameters are parenthesized, they can also carry type annotations. In that case, the closure parameters are represented by `ClosureParameterListSyntax`. + +### Examples + +let closure = { a, b in +return a + b +} + +### Children + +`ClosureShorthandParameterSyntax` `*` + +### Contained in + +- `ClosureSignatureSyntax`. `parameterClause` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ClosureShorthandParameterListSyntax +- Overview +- Examples +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/closureshorthandparametersyntax + +- SwiftSyntax +- ClosureShorthandParameterSyntax + +Structure + +# ClosureShorthandParameterSyntax + +struct ClosureShorthandParameterSyntax + +SyntaxNodesC.swift + +### Children + +- `trailingComma`: `,`? + +### Contained in + +- `ClosureShorthandParameterListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var name: TokenSyntax` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndTrailingComma: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ClosureShorthandParameterSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/codeblockitemlistsyntax + +- SwiftSyntax +- CodeBlockItemListSyntax + +Structure + +# CodeBlockItemListSyntax + +struct CodeBlockItemListSyntax + +SyntaxCollections.swift + +### Children + +`CodeBlockItemSyntax` `*` + +### Contained in + +- `AccessorBlockSyntax`. `accessors` + +- `ClosureExprSyntax`. `statements` + +- `CodeBlockSyntax`. `statements` + +- `IfConfigClauseSyntax`. `elements` + +- `SourceFileSyntax`. `statements` + +- `SwitchCaseSyntax`. `statements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- CodeBlockItemListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/codeblockitemsyntax + +- SwiftSyntax +- CodeBlockItemSyntax + +Structure + +# CodeBlockItemSyntax + +A CodeBlockItem is any Syntax node that appears on its own line inside a CodeBlock. + +struct CodeBlockItemSyntax + +SyntaxNodesC.swift + +### Children + +- `item`: ( `DeclSyntax` \| `StmtSyntax` \| `ExprSyntax`) + +- `semicolon`: `;`? + +### Contained in + +- `CodeBlockItemListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, item: CodeBlockItemSyntax.Item, UnexpectedNodesSyntax?, semicolon: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var item: CodeBlockItemSyntax.Item` + +The underlying node inside the code block. + +`var semicolon: TokenSyntax?` + +If present, the trailing semicolon at the end of the item. + +`var unexpectedAfterSemicolon: UnexpectedNodesSyntax?` + +`var unexpectedBeforeItem: UnexpectedNodesSyntax?` + +`var unexpectedBetweenItemAndSemicolon: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Item` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- CodeBlockItemSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/compositiontypeelementlistsyntax + +- SwiftSyntax +- CompositionTypeElementListSyntax + +Structure + +# CompositionTypeElementListSyntax + +struct CompositionTypeElementListSyntax + +SyntaxCollections.swift + +### Children + +`CompositionTypeElementSyntax` `*` + +### Contained in + +- `CompositionTypeSyntax`. `elements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- CompositionTypeElementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/compositiontypeelementsyntax + +- SwiftSyntax +- CompositionTypeElementSyntax + +Structure + +# CompositionTypeElementSyntax + +struct CompositionTypeElementSyntax + +SyntaxNodesC.swift + +### Children + +- `type`: `TypeSyntax` + +- `ampersand`: `TokenSyntax`? + +### Contained in + +- `CompositionTypeElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, ampersand: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var ampersand: TokenSyntax?` + +`var type: TypeSyntax` + +`var unexpectedAfterAmpersand: UnexpectedNodesSyntax?` + +`var unexpectedBeforeType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypeAndAmpersand: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- CompositionTypeElementSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/conditionelementlistsyntax + +- SwiftSyntax +- ConditionElementListSyntax + +Structure + +# ConditionElementListSyntax + +struct ConditionElementListSyntax + +SyntaxCollections.swift + +### Children + +`ConditionElementSyntax` `*` + +### Contained in + +- `GuardStmtSyntax`. `conditions` + +- `IfExprSyntax`. `conditions` + +- `WhileStmtSyntax`. `conditions` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ConditionElementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/conditionelementsyntax + +- SwiftSyntax +- ConditionElementSyntax + +Structure + +# ConditionElementSyntax + +struct ConditionElementSyntax + +SyntaxNodesC.swift + +### Children + +- `condition`: ( `ExprSyntax` \| `AvailabilityConditionSyntax` \| `MatchingPatternConditionSyntax` \| `OptionalBindingConditionSyntax`) + +- `trailingComma`: `,`? + +### Contained in + +- `ConditionElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, condition: ConditionElementSyntax.Condition, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var condition: ConditionElementSyntax.Condition` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeCondition: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionAndTrailingComma: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Condition` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ConditionElementSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declmodifierlistsyntax + +- SwiftSyntax +- DeclModifierListSyntax + +Structure + +# DeclModifierListSyntax + +struct DeclModifierListSyntax + +SyntaxCollections.swift + +### Children + +`DeclModifierSyntax` `*` + +### Contained in + +- `ActorDeclSyntax`. `modifiers` + +- `AssociatedTypeDeclSyntax`. `modifiers` + +- `ClassDeclSyntax`. `modifiers` + +- `ClosureParameterSyntax`. `modifiers` + +- `DeinitializerDeclSyntax`. `modifiers` + +- `EditorPlaceholderDeclSyntax`. `modifiers` + +- `EnumCaseDeclSyntax`. `modifiers` + +- `EnumCaseParameterSyntax`. `modifiers` + +- `EnumDeclSyntax`. `modifiers` + +- `ExtensionDeclSyntax`. `modifiers` + +- `FunctionDeclSyntax`. `modifiers` + +- `FunctionParameterSyntax`. `modifiers` + +- `ImportDeclSyntax`. `modifiers` + +- `InitializerDeclSyntax`. `modifiers` + +- `MacroDeclSyntax`. `modifiers` + +- `MacroExpansionDeclSyntax`. `modifiers` + +- `MissingDeclSyntax`. `modifiers` + +- `PrecedenceGroupDeclSyntax`. `modifiers` + +- `ProtocolDeclSyntax`. `modifiers` + +- `StructDeclSyntax`. `modifiers` + +- `SubscriptDeclSyntax`. `modifiers` + +- `TypeAliasDeclSyntax`. `modifiers` + +- `VariableDeclSyntax`. `modifiers` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DeclModifierListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declmodifiersyntax + +- SwiftSyntax +- DeclModifierSyntax + +Structure + +# DeclModifierSyntax + +struct DeclModifierSyntax + +SyntaxNodesD.swift + +### Children + +- `name`: ( `__consuming` \| `__setter_access` \| `_const` \| `_local` \| `actor` \| `async` \| `borrowing` \| `class` \| `consuming` \| `convenience` \| `distributed` \| `dynamic` \| `fileprivate` \| `final` \| `indirect` \| `infix` \| `internal` \| `isolated` \| `lazy` \| `mutating` \| `nonisolated` \| `nonmutating` \| `open` \| `optional` \| `override` \| `package` \| `postfix` \| `prefix` \| `private` \| `public` \| `reasync` \| `required` \| `static` \| `unowned` \| `weak` \| `sending`) + +- `detail`: `DeclModifierDetailSyntax`? + +### Contained in + +- `AccessorDeclSyntax`. `modifier` + +- `DeclModifierListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, detail: DeclModifierDetailSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var detail: DeclModifierDetailSyntax?` + +`var name: TokenSyntax` + +`var unexpectedAfterDetail: UnexpectedNodesSyntax?` + +`var unexpectedBeforeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndDetail: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DeclModifierSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declnameargumentlistsyntax + +- SwiftSyntax +- DeclNameArgumentListSyntax + +Structure + +# DeclNameArgumentListSyntax + +struct DeclNameArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`DeclNameArgumentSyntax` `*` + +### Contained in + +- `DeclNameArgumentsSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DeclNameArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/declnameargumentsyntax + +- SwiftSyntax +- DeclNameArgumentSyntax + +Structure + +# DeclNameArgumentSyntax + +struct DeclNameArgumentSyntax + +SyntaxNodesD.swift + +### Children + +- `name`: `TokenSyntax` + +- `colon`: `:` + +### Contained in + +- `DeclNameArgumentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var colon: TokenSyntax` + +`var name: TokenSyntax` + +`var unexpectedAfterColon: UnexpectedNodesSyntax?` + +`var unexpectedBeforeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndColon: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DeclNameArgumentSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/designatedtypelistsyntax + +- SwiftSyntax +- DesignatedTypeListSyntax + +Structure + +# DesignatedTypeListSyntax + +struct DesignatedTypeListSyntax + +SyntaxCollections.swift + +### Children + +`DesignatedTypeSyntax` `*` + +### Contained in + +- `OperatorPrecedenceAndTypesSyntax`. `designatedTypes` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DesignatedTypeListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/designatedtypesyntax + +- SwiftSyntax +- DesignatedTypeSyntax + +Structure + +# DesignatedTypeSyntax + +struct DesignatedTypeSyntax + +SyntaxNodesD.swift + +### Children + +- `leadingComma`: `,` + +- `name`: `TokenSyntax` + +### Contained in + +- `DesignatedTypeListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, leadingComma: TokenSyntax, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var leadingComma: TokenSyntax` + +`var name: TokenSyntax` + +`var unexpectedAfterName: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLeadingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLeadingCommaAndName: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DesignatedTypeSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/dictionaryelementlistsyntax + +- SwiftSyntax +- DictionaryElementListSyntax + +Structure + +# DictionaryElementListSyntax + +struct DictionaryElementListSyntax + +SyntaxCollections.swift + +### Children + +`DictionaryElementSyntax` `*` + +### Contained in + +- `DictionaryExprSyntax`. `content` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DictionaryElementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/dictionaryelementsyntax + +- SwiftSyntax +- DictionaryElementSyntax + +Structure + +# DictionaryElementSyntax + +An element inside a dictionary literal. + +struct DictionaryElementSyntax + +SyntaxNodesD.swift + +### Children + +- `key`: `ExprSyntax` + +- `colon`: `:` + +- `value`: `ExprSyntax` + +- `trailingComma`: `,`? + +### Contained in + +- `DictionaryElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, key: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, value: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, keyExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, valueExpression: some ExprSyntaxProtocol, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var colon: TokenSyntax` + +`var key: ExprSyntax` + +`var keyExpression: ExprSyntax` Deprecated + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeKey: UnexpectedNodesSyntax?` + +`var unexpectedBeforeKeyExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenColonAndValue: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndValueExpression: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenKeyAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenKeyExpressionAndColon: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenValueAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenValueExpressionAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +`var value: ExprSyntax` + +`var valueExpression: ExprSyntax` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DictionaryElementSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/differentiabilityargumentlistsyntax + +- SwiftSyntax +- DifferentiabilityArgumentListSyntax + +Structure + +# DifferentiabilityArgumentListSyntax + +struct DifferentiabilityArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`DifferentiabilityArgumentSyntax` `*` + +### Contained in + +- `DifferentiabilityArgumentsSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DifferentiabilityArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/differentiabilityargumentsyntax + +- SwiftSyntax +- DifferentiabilityArgumentSyntax + +Structure + +# DifferentiabilityArgumentSyntax + +A differentiability argument: either the “self” identifier, a function parameter name, or a function parameter index. + +struct DifferentiabilityArgumentSyntax + +SyntaxNodesD.swift + +### Children + +- `trailingComma`: `,`? + +### Contained in + +- `DifferentiabilityArgumentListSyntax` + +- `DifferentiabilityWithRespectToArgumentSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, argument: TokenSyntax, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, parameter: TokenSyntax, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var argument: TokenSyntax` + +`var parameter: TokenSyntax` Deprecated + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeArgument: UnexpectedNodesSyntax?` + +`var unexpectedBeforeParameter: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenParameterAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DifferentiabilityArgumentSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/documentationattributeargumentlistsyntax + +- SwiftSyntax +- DocumentationAttributeArgumentListSyntax + +Structure + +# DocumentationAttributeArgumentListSyntax + +The arguments of the ‘@\_documentation’ attribute + +struct DocumentationAttributeArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`DocumentationAttributeArgumentSyntax` `*` + +### Contained in + +- `AttributeSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DocumentationAttributeArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/documentationattributeargumentsyntax + +- SwiftSyntax +- DocumentationAttributeArgumentSyntax + +Structure + +# DocumentationAttributeArgumentSyntax + +struct DocumentationAttributeArgumentSyntax + +SyntaxNodesD.swift + +### Children + +- `label`: ( `visibility` \| `metadata`) + +- `colon`: `:` + +- `trailingComma`: `,`? + +### Contained in + +- `DocumentationAttributeArgumentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, label: TokenSyntax, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, value: DocumentationAttributeArgumentSyntax.Value, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var colon: TokenSyntax` + +`var label: TokenSyntax` + +`var trailingComma: TokenSyntax?` + +A trailing comma if this argument is followed by another one + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeLabel: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndValue: UnexpectedNodesSyntax?` + +`var unexpectedBetweenLabelAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenValueAndTrailingComma: UnexpectedNodesSyntax?` + +`var value: DocumentationAttributeArgumentSyntax.Value` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Value` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- DocumentationAttributeArgumentSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/effectsattributeargumentlistsyntax + +- SwiftSyntax +- EffectsAttributeArgumentListSyntax + +Structure + +# EffectsAttributeArgumentListSyntax + +The arguments of the ‘@\_effects’ attribute. These will be parsed during the SIL stage. + +struct EffectsAttributeArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`TokenSyntax` `*` + +### Contained in + +- `AttributeSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- EffectsAttributeArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumcaseelementlistsyntax + +- SwiftSyntax +- EnumCaseElementListSyntax + +Structure + +# EnumCaseElementListSyntax + +A collection of 0 or more `EnumCaseElementSyntax` s. + +struct EnumCaseElementListSyntax + +SyntaxCollections.swift + +### Children + +`EnumCaseElementSyntax` `*` + +### Contained in + +- `EnumCaseDeclSyntax`. `elements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- EnumCaseElementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumcaseelementsyntax + +- SwiftSyntax +- EnumCaseElementSyntax + +Structure + +# EnumCaseElementSyntax + +An element of an enum case, containing the name of the case and, optionally, either associated values or an assignment to a raw value. + +struct EnumCaseElementSyntax + +SyntaxNodesEF.swift + +### Children + +- `parameterClause`: `EnumCaseParameterClauseSyntax`? + +- `rawValue`: `InitializerClauseSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `EnumCaseElementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, identifier: TokenSyntax, UnexpectedNodesSyntax?, associatedValue: EnumCaseParameterClauseSyntax?, UnexpectedNodesSyntax?, rawValue: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, parameterClause: EnumCaseParameterClauseSyntax?, UnexpectedNodesSyntax?, rawValue: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var associatedValue: EnumCaseParameterClauseSyntax?` Deprecated + +`var identifier: TokenSyntax` Deprecated + +`var name: TokenSyntax` + +The name of this case. + +`var parameterClause: EnumCaseParameterClauseSyntax?` + +The set of associated values of the case. + +`var rawValue: InitializerClauseSyntax?` + +The raw value of this enum element, if present. + +`var trailingComma: TokenSyntax?` + +The trailing comma of this element, if the case has multiple elements. + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeIdentifier: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAssociatedValueAndRawValue: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenIdentifierAndAssociatedValue: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenNameAndParameterClause: UnexpectedNodesSyntax?` + +`var unexpectedBetweenParameterClauseAndRawValue: UnexpectedNodesSyntax?` + +`var unexpectedBetweenRawValueAndTrailingComma: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- EnumCaseElementSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumcaseparameterlistsyntax + +- SwiftSyntax +- EnumCaseParameterListSyntax + +Structure + +# EnumCaseParameterListSyntax + +struct EnumCaseParameterListSyntax + +SyntaxCollections.swift + +### Children + +`EnumCaseParameterSyntax` `*` + +### Contained in + +- `EnumCaseParameterClauseSyntax`. `parameters` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- EnumCaseParameterListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/enumcaseparametersyntax + +- SwiftSyntax +- EnumCaseParameterSyntax + +Structure + +# EnumCaseParameterSyntax + +struct EnumCaseParameterSyntax + +SyntaxNodesEF.swift + +### Children + +- `modifiers`: `DeclModifierListSyntax` + +- `colon`: `:`? + +- `type`: `TypeSyntax` + +- `defaultValue`: `InitializerClauseSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `EnumCaseParameterListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, firstName: TokenSyntax?, UnexpectedNodesSyntax?, secondName: TokenSyntax?, UnexpectedNodesSyntax?, colon: TokenSyntax?, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, defaultArgument: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, firstName: TokenSyntax?, UnexpectedNodesSyntax?, secondName: TokenSyntax?, UnexpectedNodesSyntax?, colon: TokenSyntax?, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, defaultValue: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, modifiers: DeclModifierListSyntax, firstName: TokenSyntax, secondName: TokenSyntax?, colon: TokenSyntax, type: some TypeSyntaxProtocol, defaultValue: InitializerClauseSyntax?, trailingComma: TokenSyntax?, trailingTrivia: Trivia?)` + +Creates an `EnumCaseParameterSyntax` with a `firstName`, and automatically adds a `colon` to it. + +### Instance Properties + +`var colon: TokenSyntax?` + +If the parameter has a label, the colon separating the label from the type. + +`var defaultArgument: InitializerClauseSyntax?` Deprecated + +`var defaultValue: InitializerClauseSyntax?` + +If the parameter has a default value, the initializer clause describing the default value. + +`var firstName: TokenSyntax?` + +`var modifiers: DeclModifierListSyntax` + +`var secondName: TokenSyntax?` + +`var trailingComma: TokenSyntax?` + +If the parameter is followed by another parameter, the comma separating them. + +`var type: TypeSyntax` + +The parameter’s type. + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDefaultArgumentAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenDefaultValueAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSecondNameAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypeAndDefaultArgument: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenTypeAndDefaultValue: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `modifiers` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithModifiersSyntax` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- EnumCaseParameterSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/exprlistsyntax + +- SwiftSyntax +- ExprListSyntax + +Structure + +# ExprListSyntax + +A list of expressions connected by operators. This list is contained by a `SequenceExprSyntax`. + +struct ExprListSyntax + +SyntaxCollections.swift + +### Children + +`ExprSyntax` `*` + +### Contained in + +- `SequenceExprSyntax`. `elements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ExprListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/functionparameterlistsyntax + +- SwiftSyntax +- FunctionParameterListSyntax + +Structure + +# FunctionParameterListSyntax + +A list of function parameters that are type annotated and a label. The function parameters are represented by `FunctionParameterListSyntax`. + +struct FunctionParameterListSyntax + +SyntaxCollections.swift + +### Example + +func foo(bar: Int, baz: Int) { + +} + +### Children + +`FunctionParameterSyntax` `*` + +### Contained in + +- `FunctionParameterClauseSyntax`. `parameters` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- FunctionParameterListSyntax +- Example +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/functionparametersyntax + +- SwiftSyntax +- FunctionParameterSyntax + +Structure + +# FunctionParameterSyntax + +A function parameter + +struct FunctionParameterSyntax + +SyntaxNodesEF.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `modifiers`: `DeclModifierListSyntax` + +- `colon`: `:` + +- `type`: `TypeSyntax` + +- `ellipsis`: `...`? + +- `defaultValue`: `InitializerClauseSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `FunctionParameterListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, firstName: TokenSyntax, UnexpectedNodesSyntax?, secondName: TokenSyntax?, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, ellipsis: TokenSyntax?, UnexpectedNodesSyntax?, defaultArgument: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, modifiers: DeclModifierListSyntax, UnexpectedNodesSyntax?, firstName: TokenSyntax, UnexpectedNodesSyntax?, secondName: TokenSyntax?, UnexpectedNodesSyntax?, colon: TokenSyntax, UnexpectedNodesSyntax?, type: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, ellipsis: TokenSyntax?, UnexpectedNodesSyntax?, defaultValue: InitializerClauseSyntax?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +Attributes that are attached to the parameter. + +`var colon: TokenSyntax` + +The colon separating the label from the type. + +`var defaultArgument: InitializerClauseSyntax?` Deprecated + +`var defaultValue: InitializerClauseSyntax?` + +If the parameter has a default value, the expression describing the default value. + +`var ellipsis: TokenSyntax?` + +If the parameter is variadic, `...` to indicate that. + +`var firstName: TokenSyntax` + +The label of this parameter that will be used when the function is called. + +`var modifiers: DeclModifierListSyntax` + +Modifiers that are attached to the parameter. + +`var secondName: TokenSyntax?` + +If this is specified, it is the name by which the parameter can be referenced inside the function body. + +`var trailingComma: TokenSyntax?` + +If the parameter is followed by another parameter, the comma separating them. + +`var type: TypeSyntax` + +The parameter’s type. + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndModifiers: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenDefaultArgumentAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenDefaultValueAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEllipsisAndDefaultArgument: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenEllipsisAndDefaultValue: UnexpectedNodesSyntax?` + +`var unexpectedBetweenFirstNameAndSecondName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenModifiersAndFirstName: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSecondNameAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenTypeAndEllipsis: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +Adds the provided `element` to the node’s `modifiers` collection. + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithModifiersSyntax` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- FunctionParameterSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericargumentlistsyntax + +- SwiftSyntax +- GenericArgumentListSyntax + +Structure + +# GenericArgumentListSyntax + +struct GenericArgumentListSyntax + +SyntaxCollections.swift + +### Children + +`GenericArgumentSyntax` `*` + +### Contained in + +- `GenericArgumentClauseSyntax`. `arguments` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericArgumentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericargumentsyntax + +- SwiftSyntax +- GenericArgumentSyntax + +Structure + +# GenericArgumentSyntax + +struct GenericArgumentSyntax + +SyntaxNodesGHI.swift + +### Children + +- `argument`: ( `TypeSyntax` \| `ExprSyntax`) + +- `trailingComma`: `,`? + +### Contained in + +- `GenericArgumentListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, argument: some TypeSyntaxProtocol, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, argument: GenericArgumentSyntax.Argument, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, argumentType: GenericArgumentSyntax.Argument, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +### Instance Properties + +`var argument: GenericArgumentSyntax.Argument` + +The argument type for a generic argument. This can either be a regular type argument or an expression for value generics. + +`var argumentType: GenericArgumentSyntax.Argument` Deprecated + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeArgument: UnexpectedNodesSyntax?` + +`var unexpectedBeforeArgumentType: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenArgumentAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenArgumentTypeAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Argument` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericArgumentSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericparameterlistsyntax + +- SwiftSyntax +- GenericParameterListSyntax + +Structure + +# GenericParameterListSyntax + +struct GenericParameterListSyntax + +SyntaxCollections.swift + +### Children + +`GenericParameterSyntax` `*` + +### Contained in + +- `GenericParameterClauseSyntax`. `parameters` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericParameterListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericparametersyntax + +- SwiftSyntax +- GenericParameterSyntax + +Structure + +# GenericParameterSyntax + +struct GenericParameterSyntax + +SyntaxNodesGHI.swift + +### Children + +- `attributes`: `AttributeListSyntax` + +- `specifier`: ( `each` \| `let`)? + +- `colon`: `:`? + +- `inheritedType`: `TypeSyntax`? + +- `trailingComma`: `,`? + +### Contained in + +- `GenericParameterListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, eachKeyword: TokenSyntax?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, colon: TokenSyntax?, UnexpectedNodesSyntax?, inheritedType: (some TypeSyntaxProtocol)?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, attributes: AttributeListSyntax, UnexpectedNodesSyntax?, specifier: TokenSyntax?, UnexpectedNodesSyntax?, name: TokenSyntax, UnexpectedNodesSyntax?, colon: TokenSyntax?, UnexpectedNodesSyntax?, inheritedType: (some TypeSyntaxProtocol)?, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var attributes: AttributeListSyntax` + +`var colon: TokenSyntax?` + +`var eachKeyword: TokenSyntax?` Deprecated + +`var inheritedType: TypeSyntax?` + +`var name: TokenSyntax` + +`var specifier: TokenSyntax?` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeAttributes: UnexpectedNodesSyntax?` + +`var unexpectedBetweenAttributesAndEachKeyword: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenAttributesAndSpecifier: UnexpectedNodesSyntax?` + +`var unexpectedBetweenColonAndInheritedType: UnexpectedNodesSyntax?` + +`var unexpectedBetweenEachKeywordAndName: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenInheritedTypeAndTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBetweenNameAndColon: UnexpectedNodesSyntax?` + +`var unexpectedBetweenSpecifierAndName: UnexpectedNodesSyntax?` + +### Instance Methods + +Adds the provided `element` to the node’s `attributes` collection. + +Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithAttributesSyntax` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericParameterSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericrequirementlistsyntax + +- SwiftSyntax +- GenericRequirementListSyntax + +Structure + +# GenericRequirementListSyntax + +struct GenericRequirementListSyntax + +SyntaxCollections.swift + +### Children + +`GenericRequirementSyntax` `*` + +### Contained in + +- `GenericWhereClauseSyntax`. `requirements` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericRequirementListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/genericrequirementsyntax + +- SwiftSyntax +- GenericRequirementSyntax + +Structure + +# GenericRequirementSyntax + +struct GenericRequirementSyntax + +SyntaxNodesGHI.swift + +### Children + +- `requirement`: ( `SameTypeRequirementSyntax` \| `ConformanceRequirementSyntax` \| `LayoutRequirementSyntax`) + +- `trailingComma`: `,`? + +### Contained in + +- `GenericRequirementListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, body: GenericRequirementSyntax.Requirement, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` Deprecated + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, requirement: GenericRequirementSyntax.Requirement, UnexpectedNodesSyntax?, trailingComma: TokenSyntax?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var body: GenericRequirementSyntax.Requirement` Deprecated + +`var requirement: GenericRequirementSyntax.Requirement` + +`var trailingComma: TokenSyntax?` + +`var unexpectedAfterTrailingComma: UnexpectedNodesSyntax?` + +`var unexpectedBeforeBody: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBeforeRequirement: UnexpectedNodesSyntax?` + +`var unexpectedBetweenBodyAndTrailingComma: UnexpectedNodesSyntax?` Deprecated + +`var unexpectedBetweenRequirementAndTrailingComma: UnexpectedNodesSyntax?` + +### Type Aliases + +`typealias Body` Deprecated + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Requirement` + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` +- `WithTrailingCommaSyntax` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- GenericRequirementSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/ifconfigclauselistsyntax + +- SwiftSyntax +- IfConfigClauseListSyntax + +Structure + +# IfConfigClauseListSyntax + +struct IfConfigClauseListSyntax + +SyntaxCollections.swift + +### Children + +`IfConfigClauseSyntax` `*` + +### Contained in + +- `IfConfigDeclSyntax`. `clauses` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- IfConfigClauseListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/ifconfigclausesyntax + +- SwiftSyntax +- IfConfigClauseSyntax + +Structure + +# IfConfigClauseSyntax + +struct IfConfigClauseSyntax + +SyntaxNodesGHI.swift + +### Children + +- `poundKeyword`: ( `#if` \| `#elseif` \| `#else`) + +- `condition`: `ExprSyntax`? + +- `elements`: ( `CodeBlockItemListSyntax` \| `SwitchCaseListSyntax` \| `MemberBlockItemListSyntax` \| `ExprSyntax` \| `AttributeListSyntax`)? + +### Contained in + +- `IfConfigClauseListSyntax` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +`init(leadingTrivia: Trivia?, UnexpectedNodesSyntax?, poundKeyword: TokenSyntax, UnexpectedNodesSyntax?, condition: (some ExprSyntaxProtocol)?, UnexpectedNodesSyntax?, elements: IfConfigClauseSyntax.Elements?, UnexpectedNodesSyntax?, trailingTrivia: Trivia?)` + +### Instance Properties + +`var condition: ExprSyntax?` + +`var elements: IfConfigClauseSyntax.Elements?` + +`var poundKeyword: TokenSyntax` + +`var unexpectedAfterElements: UnexpectedNodesSyntax?` + +`var unexpectedBeforePoundKeyword: UnexpectedNodesSyntax?` + +`var unexpectedBetweenConditionAndElements: UnexpectedNodesSyntax?` + +`var unexpectedBetweenPoundKeywordAndCondition: UnexpectedNodesSyntax?` + +### Type Properties + +`static let structure: SyntaxNodeStructure` + +### Enumerations + +`enum Elements` + +## Relationships + +### Conforms To + +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.TextOutputStreamable` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- IfConfigClauseSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/swiftlang/swift-syntax/601.0.1/documentation/swiftsyntax/importpathcomponentlistsyntax + +- SwiftSyntax +- ImportPathComponentListSyntax + +Structure + +# ImportPathComponentListSyntax + +struct ImportPathComponentListSyntax + +SyntaxCollections.swift + +### Children + +`ImportPathComponentSyntax` `*` + +### Contained in + +- `ImportDeclSyntax`. `path` + +## Topics + +### Initializers + +`init?(some SyntaxProtocol)` + +### Type Aliases + +`typealias Element` + +### Type Properties + +`static let syntaxKind: SyntaxKind` + +## Relationships + +### Conforms To + +- `Swift.BidirectionalCollection` +- `Swift.Collection` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomReflectable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.Sequence` +- `Swift.TextOutputStreamable` +- `SyntaxCollection` +- `SyntaxHashable` +- `SyntaxProtocol` + +## See Also + +### Collections + +`struct SyntaxChildren` + +Collection that contains the present child `Syntax` nodes of the given node. + +`struct SyntaxChildrenIndex` + +An index in a syntax children collection. + +`struct AccessorDeclListSyntax` + +`struct ArrayElementListSyntax` + +`struct ArrayElementSyntax` + +An element inside an array literal. + +`struct AttributeListSyntax` + +A list of attributes that can be attached to a declaration. + +`struct AttributeSyntax` + +An `@` attribute. + +`struct AvailabilityArgumentListSyntax` + +`struct AvailabilityArgumentSyntax` + +A single argument to an `@available` argument like `*`, `iOS 10.1`, or `message: "This has been deprecated"`. + +`struct CatchClauseListSyntax` + +`struct CatchClauseSyntax` + +`struct CatchItemListSyntax` + +`struct CatchItemSyntax` + +`struct ClosureCaptureListSyntax` + +`struct ClosureCaptureSyntax` + +- ImportPathComponentListSyntax +- Children +- Contained in +- Topics +- Relationships +- See Also + +| +| + +--- + diff --git a/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift index a5c757c..813e961 100644 --- a/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierPatternSyntax.swift @@ -30,7 +30,7 @@ import SwiftSyntax extension IdentifierPatternSyntax: SyntaxClassifiable { - static var syntaxType: SyntaxType { + internal static var syntaxType: SyntaxType { .pattern } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift index 0ffd2fb..cb37f9c 100644 --- a/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/IdentifierTypeSyntax.swift @@ -30,7 +30,7 @@ import SwiftSyntax extension IdentifierTypeSyntax: SyntaxClassifiable { - static var syntaxType: SyntaxType { + internal static var syntaxType: SyntaxType { .type } } diff --git a/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift b/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift index 4371c56..3554138 100644 --- a/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift +++ b/Sources/TokenVisitor/SyntaxClassifiable/VariableDeclSyntax.swift @@ -30,7 +30,7 @@ import SwiftSyntax extension VariableDeclSyntax: SyntaxClassifiable { - static var syntaxType: SyntaxType { + internal static var syntaxType: SyntaxType { .decl } } From 18c1e25903e8658707adf2fd1414eb20c25e9b92 Mon Sep 17 00:00:00 2001 From: leogdion Date: Tue, 16 Sep 2025 17:12:01 -0400 Subject: [PATCH 03/10] Delete TreeNodeProtocol+Extensions.swift --- TreeNodeProtocol+Extensions.swift | 219 ------------------------------ 1 file changed, 219 deletions(-) delete mode 100644 TreeNodeProtocol+Extensions.swift diff --git a/TreeNodeProtocol+Extensions.swift b/TreeNodeProtocol+Extensions.swift deleted file mode 100644 index 0605da1..0000000 --- a/TreeNodeProtocol+Extensions.swift +++ /dev/null @@ -1,219 +0,0 @@ -// -// TreeNodeProtocol+Extensions.swift -// Lint -// -// Created by Leo Dion on 9/16/25. -// - -extension TreeNodeProtocol { - package static func parseTree( - from sourceFile: SourceFileSyntax, - withFileName fileName: String = .defaultFileName, - showingMissingTokens: Bool = false - ) -> [Self] { - // Use raw syntax tree without precedence folding for simplicity - let syntax = Syntax(sourceFile) - - // Create visitor to traverse AST and extract structured information - let visitor = TokenVisitor( - locationConverter: SourceLocationConverter( - fileName: fileName, - tree: sourceFile - ), - showMissingTokens: false - ) - - // Traverse the syntax tree and build our simplified representation - _ = visitor.rewrite(syntax) - - // Return the tree nodes directly - return visitor.tree - } -} - -// MARK: - Structure Extraction Extensions - -extension TreeNodeProtocol { - // MARK: - Structure Extraction - - /// Appends structural information from a SwiftSyntax node to the structure array. - /// - /// This method analyzes the node's internal structure and converts it into - /// a simplified format with named properties and values, appending them to - /// the structure array. It handles different structure types (layout, collection, - /// choices) and processes their properties according to their specific requirements. - /// - /// - Parameters: - /// - node: The SwiftSyntax node to analyze - /// - allChildren: All child nodes of the syntax node - package func appendStructure( - from node: Syntax, - allChildren: SyntaxChildren - ) { - switch node.syntaxNodeType.structure { - case .layout(let keyPaths): - // Handle nodes with fixed structure (most syntax nodes) - appendLayoutStructure( - node: node, - keyPaths: keyPaths, - allChildren: allChildren - ) - case .collection(let syntax): - // Handle collection nodes (lists, arrays, etc.) - appendCollectionStructure( - elementType: syntax, - allChildren: allChildren - ) - case .choices: - // Handle choice nodes (union types) - no special processing needed - break - } - } - - // MARK: - Layout Structure Appending - - /// Appends structure properties for layout-based syntax nodes. - /// - /// Layout nodes have a fixed set of named properties (like function parameters, - /// variable names, etc.). This method iterates through each property, extracts - /// its value, and appends appropriate StructureProperty entries to the structure array. - /// - /// - Parameters: - /// - node: The syntax node to process - /// - keyPaths: The layout key paths to process - /// - allChildren: All child nodes for reference checking - private func appendLayoutStructure( - node: Syntax, - keyPaths: [AnyKeyPath], - allChildren: SyntaxChildren - ) { - guard let syntaxNode = node.as(node.syntaxNodeType) else { - return - } - - for keyPath in keyPaths { - appendKeyPathProperty( - keyPath: keyPath, - syntaxNode: syntaxNode, - allChildren: allChildren - ) - } - } - - private func appendKeyPathValue(_ anyValue: Any?, withName name: String) { - switch anyValue { - case let value as TokenSyntax: - // Handle token nodes (keywords, identifiers, operators, etc.) - structure.append( - StructureProperty( - token: name, - tokenSyntax: value - ) - ) - case let value as any SyntaxProtocol: - // Handle nested syntax nodes - store type reference - structure.append( - StructureProperty(reference: name, type: value.syntaxNodeType) - ) - case let value?: - // Handle primitive values - structure.append( - StructureProperty(primitive: name, value: value) - ) - case .none: - // Property exists but is nil - structure.append(StructureProperty(name: name)) - } - } - - /// Appends a structure property for a single key path from a syntax node. - /// - /// This method handles the extraction of a single property value from a syntax node, - /// including checking for child node existence, handling different value types - /// (tokens, syntax nodes, primitives), and appending appropriate StructureProperty - /// entries to the structure array. - /// - /// - Parameters: - /// - keyPath: The key path to process - /// - syntaxNode: The syntax node to extract the value from - /// - allChildren: All child nodes for reference checking - private func appendKeyPathProperty( - keyPath: AnyKeyPath, - syntaxNode: any SyntaxProtocol, - allChildren: SyntaxChildren - ) { - guard let name = String(keyPath) else { - return - } - - // Check if this property has an actual child node - guard allChildren.contains(where: { child in child.keyPathInParent == keyPath }) else { - // Property exists but has no value - mark as nil - structure.append( - StructureProperty(nilValueWithName: name) - ) - return - } - - // Extract the actual property value - let keyPath = keyPath as AnyKeyPath - appendKeyPathValue(syntaxNode[keyPath: keyPath], withName: name) - } - - // MARK: - Collection Structure Appending - - /// Appends structure properties for collection-based syntax nodes. - /// - /// Collection nodes contain multiple elements of the same type (like parameter lists, - /// statement blocks, etc.). This method appends metadata about the collection - /// including element type and count information to the structure array. - /// - /// - Parameters: - /// - node: The syntax node to process - /// - elementType: The type of elements in the collection - /// - allChildren: All child nodes for counting - private func appendCollectionStructure( - elementType: Any.Type, - allChildren: SyntaxChildren - ) { - // Mark as collection type - type = .collection - - // Add element type information - structure.append( - StructureProperty(elementWithType: elementType) - ) - - // Add count information - structure.append( - StructureProperty(collectionWithCount: allChildren.count) - ) - } -} - -extension String { - fileprivate static let defaultFileName = "" - - /// Creates a human-readable name from a SwiftSyntax key path. - /// - /// This initializer attempts to derive a meaningful property name from a key path - /// by converting it to a string and extracting the last component. - /// - /// - Parameter keyPath: The key path to extract a name from - /// - Returns: A string representation of the property name, or nil if extraction fails - fileprivate init?(_ keyPath: AnyKeyPath) { - let keyPathString = String(describing: keyPath) - - // Extract the last component after the last dot - if let lastDotIndex = keyPathString.lastIndex(of: ".") { - let afterDot = keyPathString[keyPathString.index(after: lastDotIndex)...] - self = String(afterDot) - } else { - // If no dots found, use the whole string - guard !keyPathString.isEmpty else { - return nil - } - self = keyPathString - } - } -} From a25ba38b7391f1d3d1b5b0b4119aa920c12d0c24 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 8 Feb 2026 21:53:30 -0500 Subject: [PATCH 04/10] Add skit-analyze implementation plan and dependencies - Add comprehensive plan for skit-analyze CLI tool (Docs/skit-analyze-plan.md) - Tool will auto-generate updated SyntaxKit library from DSL specifications - Uses Claude API to analyze gaps and generate implementation code - Add ConfigKeyKit to Sources/ for configuration management - Add swift-configuration documentation for reference - Input: folder with dsl.swift + expected.swift (AST auto-generated) - Output: updated SyntaxKit library ready to build Co-Authored-By: Claude Sonnet 4.5 --- ...ation-1.0.0-documentation-configuration.md | 13333 ++++++++++++++++ Docs/skit-analyze-plan.md | 954 ++ Sources/ConfigKeyKit/Command.swift | 61 + .../ConfigKeyKit/CommandConfiguration.swift | 39 + Sources/ConfigKeyKit/CommandLineParser.swift | 74 + Sources/ConfigKeyKit/CommandRegistry.swift | 88 + .../ConfigKeyKit/CommandRegistryError.swift | 42 + Sources/ConfigKeyKit/ConfigKey+Bool.swift | 72 + Sources/ConfigKeyKit/ConfigKey+Debug.swift | 36 + Sources/ConfigKeyKit/ConfigKey.swift | 113 + Sources/ConfigKeyKit/ConfigKeySource.swift | 39 + Sources/ConfigKeyKit/ConfigurationKey.swift | 40 + .../ConfigKeyKit/ConfigurationParseable.swift | 54 + Sources/ConfigKeyKit/NamingStyle.swift | 38 + .../OptionalConfigKey+Debug.swift | 36 + Sources/ConfigKeyKit/OptionalConfigKey.swift | 103 + .../ConfigKeyKit/StandardNamingStyle.swift | 53 + 17 files changed, 15175 insertions(+) create mode 100644 .claude/https_-swiftpackageindex.com-apple-swift-configuration-1.0.0-documentation-configuration.md create mode 100644 Docs/skit-analyze-plan.md create mode 100644 Sources/ConfigKeyKit/Command.swift create mode 100644 Sources/ConfigKeyKit/CommandConfiguration.swift create mode 100644 Sources/ConfigKeyKit/CommandLineParser.swift create mode 100644 Sources/ConfigKeyKit/CommandRegistry.swift create mode 100644 Sources/ConfigKeyKit/CommandRegistryError.swift create mode 100644 Sources/ConfigKeyKit/ConfigKey+Bool.swift create mode 100644 Sources/ConfigKeyKit/ConfigKey+Debug.swift create mode 100644 Sources/ConfigKeyKit/ConfigKey.swift create mode 100644 Sources/ConfigKeyKit/ConfigKeySource.swift create mode 100644 Sources/ConfigKeyKit/ConfigurationKey.swift create mode 100644 Sources/ConfigKeyKit/ConfigurationParseable.swift create mode 100644 Sources/ConfigKeyKit/NamingStyle.swift create mode 100644 Sources/ConfigKeyKit/OptionalConfigKey+Debug.swift create mode 100644 Sources/ConfigKeyKit/OptionalConfigKey.swift create mode 100644 Sources/ConfigKeyKit/StandardNamingStyle.swift diff --git a/.claude/https_-swiftpackageindex.com-apple-swift-configuration-1.0.0-documentation-configuration.md b/.claude/https_-swiftpackageindex.com-apple-swift-configuration-1.0.0-documentation-configuration.md new file mode 100644 index 0000000..d3c4c9b --- /dev/null +++ b/.claude/https_-swiftpackageindex.com-apple-swift-configuration-1.0.0-documentation-configuration.md @@ -0,0 +1,13333 @@ + + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration + +Library + +# Configuration + +A Swift library for reading configuration in applications and libraries. + +## Overview + +Swift Configuration defines an abstraction between configuration _readers_ and _providers_. + +Applications and libraries _read_ configuration through a consistent API, while the actual _provider_ is set up once at the application’s entry point. + +For example, to read the timeout configuration value for an HTTP client, check out the following examples using different providers: + +# Environment variables: +HTTP_TIMEOUT=30 +let provider = EnvironmentVariablesProvider() +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +# Program invoked with: +program --http-timeout 30 +let provider = CommandLineArgumentsProvider() +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +{ +"http": { +"timeout": 30 +} +} + +filePath: "/etc/config.json" +) +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +{ +"http": { +"timeout": 30 +} +} + +filePath: "/etc/config.json" +) +// Omitted: Add `provider` to a ServiceGroup +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +http: +timeout: 30 + +filePath: "/etc/config.yaml" +) +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +http: +timeout: 30 + +filePath: "/etc/config.yaml" +) +// Omitted: Add `provider` to a ServiceGroup +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +/ +|-- run +|-- secrets +|-- http-timeout + +Contents of the file `/run/secrets/http-timeout`: `30`. + +let provider = try await DirectoryFilesProvider( +directoryPath: "/run/secrets" +) +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +// Environment variables consulted first, then JSON. +let primaryProvider = EnvironmentVariablesProvider() + +filePath: "/etc/config.json" +) +let config = ConfigReader(providers: [\ +primaryProvider,\ +secondaryProvider\ +]) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 +let provider = InMemoryProvider(values: [\ +"http.timeout": 30,\ +]) +let config = ConfigReader(provider: provider) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print(httpTimeout) // prints 30 + +For a selection of more detailed examples, read through Example use cases. + +For a video introduction, check out our talk on YouTube. + +These providers can be combined to form a hierarchy, for details check out Provider hierarchy. + +### Quick start + +Add the dependency to your `Package.swift`: + +.package(url: "https://github.com/apple/swift-configuration", from: "1.0.0") + +Add the library dependency to your target: + +.product(name: "Configuration", package: "swift-configuration") + +Import and use in your code: + +import Configuration + +let config = ConfigReader(provider: EnvironmentVariablesProvider()) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) +print("The HTTP timeout is: \(httpTimeout)") + +### Package traits + +This package offers additional integrations you can enable using package traits. To enable an additional trait on the package, update the package dependency: + +.package( +url: "https://github.com/apple/swift-configuration", +from: "1.0.0", ++ traits: [.defaults, "YAML"] +) + +Available traits: + +- **`JSON`** (default): Adds support for `JSONSnapshot`, which enables using `FileProvider` and `ReloadingFileProvider` with JSON files. + +- **`Logging`** (opt-in): Adds support for `AccessLogger`, a way to emit access events into a Swift Log `Logger`. + +- **`Reloading`** (opt-in): Adds support for `ReloadingFileProvider`, which provides auto-reloading capability for file-based configuration. + +- **`CommandLineArguments`** (opt-in): Adds support for `CommandLineArgumentsProvider` for parsing command line arguments. + +- **`YAML`** (opt-in): Adds support for `YAMLSnapshot`, which enables using `FileProvider` and `ReloadingFileProvider` with YAML files. + +### Supported platforms and minimum versions + +The library is supported on Apple platforms and Linux. + +| Component | macOS | Linux | iOS | tvOS | watchOS | visionOS | +| --- | --- | --- | --- | --- | --- | --- | +| Configuration | ✅ 15+ | ✅ | ✅ 18+ | ✅ 18+ | ✅ 11+ | ✅ 2+ | + +#### Three access patterns + +The library provides three distinct ways to read configuration values: + +- **Get**: Synchronously return the current value available locally, in memory: + +let timeout = config.int(forKey: "http.timeout", default: 60) + +- **Fetch**: Asynchronously get the most up-to-date value from disk or a remote server: + +let timeout = try await config.fetchInt(forKey: "http.timeout", default: 60) + +- **Watch**: Receive updates when a configuration value changes: + +try await config.watchInt(forKey: "http.timeout", default: 60) { updates in +for try await timeout in updates { +print("HTTP timeout updated to: \(timeout)") +} +} + +For detailed guidance on when to use each access pattern, see Choosing the access pattern. Within each of the access patterns, the library offers different reader methods that reflect your needs of optional, default, and required configuration parameters. To understand the choices available, see Choosing reader methods. + +#### Providers + +The library includes comprehensive built-in provider support: + +- Environment variables: `EnvironmentVariablesProvider` + +- Command-line arguments: `CommandLineArgumentsProvider` + +- JSON file: `FileProvider` and `ReloadingFileProvider` with `JSONSnapshot` + +- YAML file: `FileProvider` and `ReloadingFileProvider` with `YAMLSnapshot` + +- Directory of files: `DirectoryFilesProvider` + +- In-memory: `InMemoryProvider` and `MutableInMemoryProvider` + +- Key transforming: `KeyMappingProvider` + +You can also implement a custom `ConfigProvider`. + +#### Provider hierarchy + +In addition to using providers individually, you can create fallback behavior using an array of providers. The first provider that returns a non-nil value wins. + +The following example shows a provider hierarchy where environment variables take precedence over command line arguments, a JSON file, and in-memory defaults: + +// Create a hierarchy of providers with fallback behavior. +let config = ConfigReader(providers: [\ +// First, check environment variables.\ +EnvironmentVariablesProvider(),\ +// Then, check command-line options.\ +CommandLineArgumentsProvider(),\ +// Then, check a JSON config file.\ + +// Finally, fall \ +]) + +// Uses the first provider that has a value for "http.timeout". +let timeout = config.int(forKey: "http.timeout", default: 15) + +#### Hot reloading + +Long-running services can periodically reload configuration with `ReloadingFileProvider`: + +// Omitted: add provider to a ServiceGroup +let config = ConfigReader(provider: provider) + +Read Using reloading providers for details on how to receive updates as configuration changes. + +#### Namespacing and scoped readers + +The built-in namespacing of `ConfigKey` interprets `"http.timeout"` as an array of two components: `"http"` and `"timeout"`. The following example uses `scoped(to:)` to create a namespaced reader with the key `"http"`, to allow reads to use the shorter key `"timeout"`: + +Consider the following JSON configuration: + +{ +"http": { +"timeout": 60 +} +} +// Create the root reader. +let config = ConfigReader(provider: provider) + +// Create a scoped reader for HTTP settings. +let httpConfig = config.scoped(to: "http") + +// Now you can access values with shorter keys. +// Equivalent to reading "http.timeout" on the root reader. +let timeout = httpConfig.int(forKey: "timeout") + +#### Debugging and troubleshooting + +Debugging with `AccessReporter` makes it possible to log all accesses to a config reader: + +let logger = Logger(label: "config") +let config = ConfigReader( +provider: provider, +accessReporter: AccessLogger(logger: logger) +) +// Now all configuration access is logged, with secret values redacted + +You can also add the following environment variable, and emit log accesses into a file without any code changes: + +CONFIG_ACCESS_LOG_FILE=/var/log/myapp/config-access.log + +and then read the file: + +tail -f /var/log/myapp/config-access.log + +Check out the built-in `AccessLogger`, `FileAccessLogger`, and Troubleshooting and access reporting. + +#### Secrets handling + +The library provides built-in support for handling sensitive configuration values securely: + +// Mark sensitive values as secrets to prevent them from appearing in logs +let privateKey = try snapshot.requiredString(forKey: "mtls.privateKey", isSecret: true) +let optionalAPIToken = config.string(forKey: "api.token", isSecret: true) + +When values are marked as secrets, they are automatically redacted from access logs and debugging output. Read Handling secrets correctly for guidance on best practices for secrets management. + +#### Consistent snapshots + +Retrieve related values from a consistent snapshot using `ConfigSnapshotReader`, which you get by calling `snapshot()`. + +This ensures that multiple values are read from a single snapshot inside each provider, even when using providers that update their internal values. For example by downloading new data periodically: + +let config = /* a reader with one or more providers that change values over time */ +let snapshot = config.snapshot() +let certificate = try snapshot.requiredString(forKey: "mtls.certificate") +let privateKey = try snapshot.requiredString(forKey: "mtls.privateKey", isSecret: true) +// `certificate` and `privateKey` are guaranteed to come from the same snapshot in the provider + +#### Extensible ecosystem + +Any package can implement a `ConfigProvider`, making the ecosystem extensible for custom configuration sources. + +## Topics + +### Essentials + +Configuring applications + +Provide flexible and consistent configuration for your application. + +Configuring libraries + +Provide a consistent and flexible way to configure your library. + +Example use cases + +Review common use cases with ready-to-copy code samples. + +Adopting best practices + +Follow these principles to make your code easily configurable and composable with other libraries. + +### Readers and providers + +`struct ConfigReader` + +A type that provides read-only access to configuration values from underlying providers. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigSnapshotReader` + +A container type for reading config values from snapshots. + +Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +### Configuration keys + +`struct ConfigKey` + +A configuration key representing a relative path to a configuration value. + +`struct AbsoluteConfigKey` + +A configuration key that represents an absolute path to a configuration value. + +`enum ConfigContextValue` + +A value that can be stored in a configuration context. + +### Troubleshooting and access reporting + +Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +`protocol AccessReporter` + +A type that receives and processes configuration access events. + +`class AccessLogger` + +An access reporter that logs configuration access events using the Swift Log API. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct AccessEvent` + +An event that captures information about accessing a configuration value. + +`struct BroadcastingAccessReporter` + +An access reporter that forwards events to multiple other reporters. + +### Value conversion + +`protocol ExpressibleByConfigString` + +A protocol for types that can be initialized from configuration string values. + +`protocol ConfigBytesFromStringDecoder` + +A protocol for decoding string configuration values into byte arrays. + +`struct ConfigBytesFromBase64StringDecoder` + +A decoder that converts base64-encoded strings into byte arrays. + +`struct ConfigBytesFromHexStringDecoder` + +A decoder that converts hexadecimal-encoded strings into byte arrays. + +### Contributing + +Developing Swift Configuration + +Learn about tools and conventions used to develop the Swift Configuration package. + +Collaborate on API changes to Swift Configuration by writing a proposal. + +### Extended Modules + +Foundation + +SystemPackage + +- Configuration +- Overview +- Quick start +- Package traits +- Supported platforms and minimum versions +- Key features +- Topics + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/handling-secrets-correctly + +- Configuration +- Handling secrets correctly + +Article + +# Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +## Overview + +Swift Configuration provides built-in support for marking sensitive values as secrets. Secret values are automatically redacted by access reporters to prevent accidental disclosure of API keys, passwords, and other sensitive information. + +### Marking values as secret when reading + +Use the `isSecret` parameter on any configuration reader method to mark a value as secret: + +let config = ConfigReader(provider: provider) + +// Mark sensitive values as secret +let apiKey = try config.requiredString( +forKey: "api.key", +isSecret: true +) +let dbPassword = config.string( +forKey: "database.password", +isSecret: true +) + +// Regular values don't need the parameter +let serverPort = try config.requiredInt(forKey: "server.port") +let logLevel = config.string( +forKey: "log.level", +default: "info" +) + +This works with all access patterns and method variants: + +// Works with fetch and watch too +let latestKey = try await config.fetchRequiredString( +forKey: "api.key", +isSecret: true +) + +try await config.watchString( +forKey: "api.key", +isSecret: true +) { updates in +for await key in updates { +// Handle secret key updates +} +} + +### Provider-level secret specification + +Use `SecretsSpecifier` to automatically mark values as secret based on keys or content when creating providers: + +#### Mark all values as secret + +The following example marks all configuration read by the `DirectoryFilesProvider` as secret: + +let provider = DirectoryFilesProvider( +directoryPath: "/run/secrets", +secretsSpecifier: .all +) + +#### Mark specific keys as secret + +The following example marks three specific keys from a provider as secret: + +let provider = EnvironmentVariablesProvider( +secretsSpecifier: .specific(["API_KEY", "DATABASE_PASSWORD", "JWT_SECRET"]) +) + +#### Dynamic secret detection + +The following example marks keys as secret based on the closure you provide. In this case, keys that contain `password`, `secret`, or `token` are all marked as secret: + +filePath: "/etc/config.json", +secretsSpecifier: .dynamic { key, value in +key.lowercased().contains("password") || +key.lowercased().contains("secret") || +key.lowercased().contains("token") +} +) + +#### No secret values + +The following example asserts that none of the values returned from the provider are considered secret: + +filePath: "/etc/config.json", +secretsSpecifier: .none +) + +### For provider implementors + +When implementing a custom `ConfigProvider`, use the `ConfigValue` type’s `isSecret` property: + +// Create a secret value +let secretValue = ConfigValue("sensitive-data", isSecret: true) + +// Create a regular value +let regularValue = ConfigValue("public-data", isSecret: false) + +Set the `isSecret` property to `true` when your provider knows the values are read from a secrets store and must not be logged. + +### How secret values are protected + +Secret values are automatically handled by: + +- **`AccessLogger`** and **`FileAccessLogger`**: Redact secret values in logs. + +print(provider) + +### Best practices + +1. **Mark all sensitive data as secret**: API keys, passwords, tokens, private keys, connection strings. + +2. **Use provider-level specification** when you know which keys are always secret. + +3. **Use reader-level marking** for context-specific secrets or when the same key might be secret in some contexts but not others. + +4. **Be conservative**: When in doubt, mark values as secret. It’s safer than accidentally leaking sensitive data. + +For additional guidance on configuration security and overall best practices, see Adopting best practices. To debug issues with secret redaction in access logs, check out Troubleshooting and access reporting. When selecting between required, optional, and default method variants for secret values, refer to Choosing reader methods. + +## See Also + +### Readers and providers + +`struct ConfigReader` + +A type that provides read-only access to configuration values from underlying providers. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigSnapshotReader` + +A container type for reading config values from snapshots. + +Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +- Handling secrets correctly +- Overview +- Marking values as secret when reading +- Provider-level secret specification +- For provider implementors +- How secret values are protected +- Best practices +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot + +- Configuration +- YAMLSnapshot + +Class + +# YAMLSnapshot + +A snapshot of configuration values parsed from YAML data. + +final class YAMLSnapshot + +YAMLSnapshot.swift + +## Mentioned in + +Using reloading providers + +## Overview + +This class represents a point-in-time view of configuration values. It handles the conversion from YAML types to configuration value types. + +## Usage + +Use with `FileProvider` or `ReloadingFileProvider`: + +let config = ConfigReader(provider: provider) + +## Topics + +### Creating a YAML snapshot + +`convenience init(data: RawSpan, providerName: String, parsingOptions: YAMLSnapshot.ParsingOptions) throws` + +`struct ParsingOptions` + +Custom input configuration for YAML snapshot creation. + +### Snapshot configuration + +`protocol FileConfigSnapshot` + +A protocol for configuration snapshots created from file data. + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +### Instance Properties + +`let providerName: String` + +The name of the provider that created this snapshot. + +## Relationships + +### Conforms To + +- `ConfigSnapshot` +- `FileConfigSnapshot` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- YAMLSnapshot +- Mentioned in +- Overview +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configurationtesting + +Library + +# ConfigurationTesting + +A set of testing utilities for Swift Configuration adopters. + +## Overview + +This testing library adds a Swift Testing-based `ConfigProvider` compatibility suite, recommended for implementors of custom configuration providers. + +## Topics + +### Structures + +`struct ProviderCompatTest` + +A comprehensive test suite for validating `ConfigProvider` implementations. + +- ConfigurationTesting +- Overview +- Topics + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accesslogger + +- Configuration +- AccessLogger + +Class + +# AccessLogger + +An access reporter that logs configuration access events using the Swift Log API. + +final class AccessLogger + +AccessLogger.swift + +## Mentioned in + +Handling secrets correctly + +Troubleshooting and access reporting + +Configuring libraries + +## Overview + +This reporter integrates with the Swift Log library to provide structured logging of configuration accesses. Each configuration access generates a log entry with detailed metadata about the operation, making it easy to track configuration usage and debug issues. + +## Package traits + +This type is guarded by the `Logging` package trait. + +## Usage + +Create an access logger and pass it to your configuration reader: + +import Logging + +let logger = Logger(label: "config.access") +let accessLogger = AccessLogger(logger: logger, level: .info) +let config = ConfigReader( +provider: EnvironmentVariablesProvider(), +accessReporter: accessLogger +) + +## Log format + +Each access event generates a structured log entry with metadata including: + +- `kind`: The type of access operation (get, fetch, watch). + +- `key`: The configuration key that was accessed. + +- `location`: The source code location where the access occurred. + +- `value`: The resolved configuration value (redacted for secrets). + +- `counter`: An incrementing counter for tracking access frequency. + +- Provider-specific information for each provider in the hierarchy. + +## Topics + +### Creating an access logger + +`init(logger: Logger, level: Logger.Level, message: Logger.Message)` + +Creates a new access logger that reports configuration access events. + +## Relationships + +### Conforms To + +- `AccessReporter` +- `Swift.Copyable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +`protocol AccessReporter` + +A type that receives and processes configuration access events. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct AccessEvent` + +An event that captures information about accessing a configuration value. + +`struct BroadcastingAccessReporter` + +An access reporter that forwards events to multiple other reporters. + +- AccessLogger +- Mentioned in +- Overview +- Package traits +- Usage +- Log format +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider + +- Configuration +- ReloadingFileProvider + +Class + +# ReloadingFileProvider + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +ReloadingFileProvider.swift + +## Mentioned in + +Using reloading providers + +Choosing the access pattern + +Troubleshooting and access reporting + +## Overview + +`ReloadingFileProvider` is a generic file-based configuration provider that monitors a configuration file for changes and automatically reloads the data when the file is modified. This provider works with different file formats by using different snapshot types that conform to `FileConfigSnapshot`. + +## Usage + +Create a reloading provider by specifying the snapshot type and file path: + +// Using with a JSON snapshot and a custom poll interval + +filePath: "/etc/config.json", +pollInterval: .seconds(30) +) + +// Using with a YAML snapshot + +filePath: "/etc/config.yaml" +) + +## Service integration + +This provider implements the `Service` protocol and must be run within a `ServiceGroup` to enable automatic reloading: + +let serviceGroup = ServiceGroup(services: [provider], logger: logger) +try await serviceGroup.run() + +The provider monitors the file by polling at the specified interval (default: 15 seconds) and notifies any active watchers when changes are detected. + +## Configuration from a reader + +You can also initialize the provider using a configuration reader: + +let envConfig = ConfigReader(provider: EnvironmentVariablesProvider()) + +This expects a `filePath` key in the configuration that specifies the path to the file. For a full list of configuration keys, check out `init(snapshotType:parsingOptions:config:)`. + +## File monitoring + +The provider detects changes by monitoring both file timestamps and symlink target changes. When a change is detected, it reloads the file and notifies all active watchers of the updated configuration values. + +## Topics + +### Creating a reloading file provider + +`convenience init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, filePath: FilePath, allowMissing: Bool, pollInterval: Duration, logger: Logger, metrics: any MetricsFactory) async throws` + +Creates a reloading file provider that monitors the specified file path. + +`convenience init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, config: ConfigReader, logger: Logger, metrics: any MetricsFactory) async throws` + +Creates a reloading file provider using configuration from a reader. + +### Service lifecycle + +`func run() async throws` + +### Monitoring file changes + +`protocol FileConfigSnapshot` + +A protocol for configuration snapshots created from file data. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +### Instance Properties + +`let providerName: String` + +The human-readable name of the provider. + +## Relationships + +### Conforms To + +- `ConfigProvider` +Conforms when `Snapshot` conforms to `FileConfigSnapshot`. + +- `ServiceLifecycle.Service` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- ReloadingFileProvider +- Mentioned in +- Overview +- Usage +- Service integration +- Configuration from a reader +- File monitoring +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot + +- Configuration +- JSONSnapshot + +Structure + +# JSONSnapshot + +A snapshot of configuration values parsed from JSON data. + +struct JSONSnapshot + +JSONSnapshot.swift + +## Mentioned in + +Example use cases + +Using reloading providers + +## Overview + +This structure represents a point-in-time view of configuration values. It handles the conversion from JSON types to configuration value types. + +## Usage + +Use with `FileProvider` or `ReloadingFileProvider`: + +let config = ConfigReader(provider: provider) + +## Topics + +### Creating a JSON snapshot + +`init(data: RawSpan, providerName: String, parsingOptions: JSONSnapshot.ParsingOptions) throws` + +`struct ParsingOptions` + +Parsing options for JSON snapshot creation. + +### Snapshot configuration + +`protocol FileConfigSnapshot` + +A protocol for configuration snapshots created from file data. + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +### Instance Properties + +`let providerName: String` + +The name of the provider that created this snapshot. + +## Relationships + +### Conforms To + +- `ConfigSnapshot` +- `FileConfigSnapshot` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- JSONSnapshot +- Mentioned in +- Overview +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider + +- Configuration +- FileProvider + +Structure + +# FileProvider + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +FileProvider.swift + +## Mentioned in + +Example use cases + +Troubleshooting and access reporting + +## Overview + +`FileProvider` is a generic file-based configuration provider that works with different file formats by using different snapshot types that conform to `FileConfigSnapshot`. This allows for a unified interface for reading JSON, YAML, or other structured configuration files. + +## Usage + +Create a provider by specifying the snapshot type and file path: + +// Using with a JSON snapshot + +filePath: "/etc/config.json" +) + +// Using with a YAML snapshot + +filePath: "/etc/config.yaml" +) + +The provider reads the file once during initialization and creates an immutable snapshot of the configuration values. For auto-reloading behavior, use `ReloadingFileProvider`. + +## Configuration from a reader + +You can also initialize the provider using a configuration reader that specifies the file path through environment variables or other configuration sources: + +let envConfig = ConfigReader(provider: EnvironmentVariablesProvider()) + +This expects a `filePath` key in the configuration that specifies the path to the file. For a full list of configuration keys, check out `init(snapshotType:parsingOptions:config:)`. + +## Topics + +### Creating a file provider + +`init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, filePath: FilePath, allowMissing: Bool) async throws` + +Creates a file provider that reads from the specified file path. + +`init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, config: ConfigReader) async throws` + +Creates a file provider using a file path from a configuration reader. + +### Reading configuration files + +`protocol FileConfigSnapshot` + +A protocol for configuration snapshots created from file data. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +## Relationships + +### Conforms To + +- `ConfigProvider` +Conforms when `Snapshot` conforms to `FileConfigSnapshot`. + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- FileProvider +- Mentioned in +- Overview +- Usage +- Configuration from a reader +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/example-use-cases + +- Configuration +- Example use cases + +Article + +# Example use cases + +Review common use cases with ready-to-copy code samples. + +## Overview + +For complete working examples with step-by-step instructions, see the Examples directory in the repository. + +### Reading from environment variables + +Use `EnvironmentVariablesProvider` to read configuration values from environment variables where your app launches. The following example creates a `ConfigReader` with an environment variable provider, and reads the key `server.port`, providing a default value of `8080`: + +import Configuration + +let config = ConfigReader(provider: EnvironmentVariablesProvider()) +let port = config.int(forKey: "server.port", default: 8080) + +The default environment key encoder uses an underscore to separate key components, making the environment variable name above `SERVER_PORT`. + +### Reading from a JSON configuration file + +You can store multiple configuration values together in a JSON file and read them from the fileystem using `FileProvider` with `JSONSnapshot`. The following example creates a `ConfigReader` for a JSON file at the path `/etc/config.json`, and reads a url and port number collected as properties of the `database` JSON object: + +let config = ConfigReader( + +) + +// Access nested values using dot notation. +let databaseURL = config.string(forKey: "database.url", default: "localhost") +let databasePort = config.int(forKey: "database.port", default: 5432) + +The matching JSON for this configuration might look like: + +{ +"database": { +"url": "localhost", +"port": 5432 +} +} + +### Reading from a directory of secret files + +Use the `DirectoryFilesProvider` to read multiple values collected together in a directory on the fileystem, each in a separate file. The default directory key encoder uses a hyphen in the filename to separate key components. The following example uses the directory `/run/secrets` as a base, and reads the file `database-password` as the key `database.password`: + +// Common pattern for secrets downloaded by an init container. +let config = ConfigReader( +provider: try await DirectoryFilesProvider( +directoryPath: "/run/secrets" +) +) + +// Reads the file `/run/secrets/database-password` +let dbPassword = config.string(forKey: "database.password") + +This pattern is useful for reading secrets that your infrastructure makes available on the file system, such as Kubernetes secrets mounted into a container’s filesystem. + +### Handling optional configuration files + +File-based providers support an `allowMissing` parameter to control whether missing files should throw an error or be treated as empty configuration. This is useful when configuration files are optional. + +When `allowMissing` is `false` (the default), missing files throw an error: + +// This will throw an error if config.json doesn't exist +let config = ConfigReader( + +filePath: "/etc/config.json", +allowMissing: false // This is the default +) +) + +When `allowMissing` is `true`, missing files are treated as empty configuration: + +// This won't throw if config.json is missing - treats it as empty +let config = ConfigReader( + +filePath: "/etc/config.json", +allowMissing: true +) +) + +// Returns the default value if the file is missing +let port = config.int(forKey: "server.port", default: 8080) + +The same applies to other file-based providers: + +// Optional secrets directory +let secretsConfig = ConfigReader( +provider: try await DirectoryFilesProvider( +directoryPath: "/run/secrets", +allowMissing: true +) +) + +// Optional environment file +let envConfig = ConfigReader( +provider: try await EnvironmentVariablesProvider( +environmentFilePath: "/etc/app.env", +allowMissing: true +) +) + +// Optional reloading configuration +let reloadingConfig = ConfigReader( + +filePath: "/etc/dynamic-config.yaml", +allowMissing: true +) +) + +### Setting up a fallback hierarchy + +Use multiple providers together to provide a configuration hierarchy that can override values at different levels. The following example uses both an environment variable provider and a JSON provider together, with values from environment variables overriding values from the JSON file. In this example, the defaults are provided using an `InMemoryProvider`, which are only read if the environment variable or the JSON key don’t exist: + +let config = ConfigReader(providers: [\ +// First check environment variables.\ +EnvironmentVariablesProvider(),\ +// Then check the config file.\ + +// Finally, use hardcoded defaults.\ +InMemoryProvider(values: [\ +"app.name": "MyApp",\ +"server.port": 8080,\ +"logging.level": "info"\ +])\ +]) + +### Fetching a value from a remote source + +You can host dynamic configuration that your app can retrieve remotely and use either the “fetch” or “watch” access pattern. The following example uses the “fetch” access pattern to asynchronously retrieve a configuration from the remote provider: + +let myRemoteProvider = MyRemoteProvider(...) +let config = ConfigReader(provider: myRemoteProvider) + +// Makes a network call to retrieve the up-to-date value. +let samplingRatio = try await config.fetchDouble(forKey: "sampling.ratio") + +### Watching for configuration changes + +You can periodically update configuration values using a reloading provider. The following example reloads a YAML file from the filesystem every 30 seconds, and illustrates using `watchInt(forKey:isSecret:fileID:line:updatesHandler:)` to provide an async sequence of updates that you can apply. + +import Configuration +import ServiceLifecycle + +// Create a reloading YAML provider + +filePath: "/etc/app-config.yaml", +pollInterval: .seconds(30) +) +// Omitted: add `provider` to the ServiceGroup. + +let config = ConfigReader(provider: provider) + +// Watch for timeout changes and update HTTP client configuration. +// Needs to run in a separate task from the provider. +try await config.watchInt(forKey: "http.requestTimeout", default: 30) { updates in +for await timeout in updates { +print("HTTP request timeout updated: \(timeout)s") +// Update HTTP client timeout configuration in real-time +} +} + +For details on reloading providers and ServiceLifecycle integration, see Using reloading providers. + +### Prefixing configuration keys + +In most cases, the configuration key provided by the reader can be directly used by the provided, for example `http.timeout` used as the environment variable name `HTTP_TIMEOUT`. + +Sometimes you might need to transform the incoming keys in some way, before they get delivered to the provider. A common example is prefixing each key with a constant prefix, for example `myapp`, turning the key `http.timeout` to `myapp.http.timeout`. + +You can use `KeyMappingProvider` and related extensions on `ConfigProvider` to achieve that. + +The following example uses the key mapping provider to adjust an environment variable provider to look for keys with the prefix `myapp`: + +// Create a base provider for environment variables +let envProvider = EnvironmentVariablesProvider() + +// Wrap it with a key mapping provider to automatically prepend "myapp." to all keys +let prefixedProvider = envProvider.prefixKeys(with: "myapp") + +let config = ConfigReader(provider: prefixedProvider) + +// This reads from the "MYAPP_DATABASE_URL" environment variable. +let databaseURL = config.string(forKey: "database.url", default: "localhost") + +For more configuration guidance, see Adopting best practices. To understand different reader method variants, check out Choosing reader methods. + +## See Also + +### Essentials + +Configuring applications + +Provide flexible and consistent configuration for your application. + +Configuring libraries + +Provide a consistent and flexible way to configure your library. + +Adopting best practices + +Follow these principles to make your code easily configurable and composable with other libraries. + +- Example use cases +- Overview +- Reading from environment variables +- Reading from a JSON configuration file +- Reading from a directory of secret files +- Handling optional configuration files +- Setting up a fallback hierarchy +- Fetching a value from a remote source +- Watching for configuration changes +- Prefixing configuration keys +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/scoped(to:) + +#app-main) + +- Configuration +- ConfigReader +- scoped(to:) + +Instance Method + +# scoped(to:) + +Returns a scoped config reader with the specified key appended to the current prefix. + +ConfigReader.swift + +## Parameters + +`configKey` + +The key components to append to the current key prefix. + +## Return Value + +A config reader for accessing values within the specified scope. + +## Discussion + +let httpConfig = config.scoped(to: ConfigKey(["http", "client"])) +let timeout = httpConfig.int(forKey: "timeout", default: 30) // Reads "http.client.timeout" + +- scoped(to:) +- Parameters +- Return Value +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider + +- Configuration +- EnvironmentVariablesProvider + +Structure + +# EnvironmentVariablesProvider + +A configuration provider that sources values from environment variables. + +struct EnvironmentVariablesProvider + +EnvironmentVariablesProvider.swift + +## Mentioned in + +Troubleshooting and access reporting + +Configuring applications + +Example use cases + +## Overview + +This provider reads configuration values from environment variables, supporting both the current process environment and `.env` files. It automatically converts hierarchical configuration keys into standard environment variable naming conventions and handles type conversion for all supported configuration value types. + +## Key transformation + +Configuration keys are transformed into environment variable names using these rules: + +- Components are joined with underscores + +- All characters are converted to uppercase + +- CamelCase is detected and word boundaries are marked with underscores + +- Non-alphanumeric characters are replaced with underscores + +For example: `http.serverTimeout` becomes `HTTP_SERVER_TIMEOUT` + +## Supported data types + +The provider supports all standard configuration types: + +- Strings, integers, doubles, and booleans + +- Arrays of strings, integers, doubles, and booleans (comma-separated by default) + +- Byte arrays (base64-encoded by default) + +- Arrays of byte chunks + +## Secret handling + +Environment variables can be marked as secrets using a `SecretsSpecifier`. Secret values are automatically redacted in debug output and logging. + +## Usage + +### Reading environment variables in the current process + +// Assuming the environment contains the following variables: +// HTTP_CLIENT_USER_AGENT=Config/1.0 (Test) +// HTTP_CLIENT_TIMEOUT=15.0 +// HTTP_SECRET=s3cret +// HTTP_VERSION=2 +// ENABLED=true + +let provider = EnvironmentVariablesProvider( +secretsSpecifier: .specific(["HTTP_SECRET"]) +) +// Prints all values, redacts "HTTP_SECRET" automatically. +print(provider) +let config = ConfigReader(provider: provider) +let isEnabled = config.bool(forKey: "enabled", default: false) +let userAgent = config.string(forKey: "http.client.user-agent", default: "unspecified") +// ... + +### Reading environment variables from a \`.env\`-style file + +// Assuming the local file system has a file called `.env` in the current working directory +// with the following contents: +// +// HTTP_CLIENT_USER_AGENT=Config/1.0 (Test) +// HTTP_CLIENT_TIMEOUT=15.0 +// HTTP_SECRET=s3cret +// HTTP_VERSION=2 +// ENABLED=true + +let provider = try await EnvironmentVariablesProvider( +environmentFilePath: ".env", +secretsSpecifier: .specific(["HTTP_SECRET"]) +) +// Prints all values, redacts "HTTP_SECRET" automatically. +print(provider) +let config = ConfigReader(provider: provider) +let isEnabled = config.bool(forKey: "enabled", default: false) +let userAgent = config.string(forKey: "http.client.user-agent", default: "unspecified") +// ... + +### Config context + +The environment variables provider ignores the context passed in `context`. + +## Topics + +### Creating an environment variable provider + +Creates a new provider that reads from the current process environment. + +Creates a new provider from a custom dictionary of environment variables. + +Creates a new provider that reads from an environment file. + +### Inspecting an environment variable provider + +Returns the raw string value for a specific environment variable name. + +## Relationships + +### Conforms To + +- `ConfigProvider` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- EnvironmentVariablesProvider +- Mentioned in +- Overview +- Key transformation +- Supported data types +- Secret handling +- Usage +- Reading environment variables in the current process +- Reading environment variables from a \`.env\`-style file +- Config context +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey + +- Configuration +- ConfigKey + +Structure + +# ConfigKey + +A configuration key representing a relative path to a configuration value. + +struct ConfigKey + +ConfigKey.swift + +## Overview + +Configuration keys consist of hierarchical string components forming paths similar to file system paths or JSON object keys. For example, `["http", "timeout"]` represents the `timeout` value nested under `http`. + +Keys support additional context information that providers can use to refine lookups or provide specialized behavior. + +## Usage + +Create keys using string literals, arrays, or the initializers: + +let key1: ConfigKey = "database.connection.timeout" +let key2 = ConfigKey(["api", "endpoints", "primary"]) +let key3 = ConfigKey("server.port", context: ["environment": .string("production")]) + +## Topics + +### Creating a configuration key + +[`init(String, context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-6vten) + +Creates a new configuration key. + +[`init([String], context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-9ifez) + +### Inspecting a configuration key + +[`var components: [String]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/components) + +The hierarchical components that make up this configuration key. + +[`var context: [String : ConfigContextValue]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/context) + +Additional context information for this configuration key. + +## Relationships + +### Conforms To + +- `Swift.Comparable` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.ExpressibleByExtendedGraphemeClusterLiteral` +- `Swift.ExpressibleByStringLiteral` +- `Swift.ExpressibleByUnicodeScalarLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Configuration keys + +`struct AbsoluteConfigKey` + +A configuration key that represents an absolute path to a configuration value. + +`enum ConfigContextValue` + +A value that can be stored in a configuration context. + +- ConfigKey +- Overview +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/commandlineargumentsprovider + +- Configuration +- CommandLineArgumentsProvider + +Structure + +# CommandLineArgumentsProvider + +A configuration provider that sources values from command-line arguments. + +struct CommandLineArgumentsProvider + +CommandLineArgumentsProvider.swift + +## Overview + +Reads configuration values from CLI arguments with type conversion and secrets handling. Keys are encoded to CLI flags at lookup time. + +## Package traits + +This type is guarded by the `CommandLineArgumentsSupport` package trait. + +## Key formats + +- `--key value` \- A key-value pair with separate arguments. + +- `--key=value` \- A key-value pair with an equals sign. + +- `--flag` \- A Boolean flag, treated as `true`. + +- `--key val1 val2` \- Multiple values (arrays). + +Configuration keys are transformed to CLI flags: `["http", "serverTimeout"]` → `--http-server-timeout`. + +## Array handling + +Arrays can be specified in multiple ways: + +- **Space-separated**: `--tags swift configuration cli` + +- **Repeated flags**: `--tags swift --tags configuration --tags cli` + +- **Comma-separated**: `--tags swift,configuration,cli` + +- **Mixed**: `--tags swift,configuration --tags cli` + +All formats produce the same result when accessed as an array type. + +## Usage + +// CLI: program --debug --host localhost --ports 8080 8443 +let provider = CommandLineArgumentsProvider() +let config = ConfigReader(provider: provider) + +let isDebug = config.bool(forKey: "debug", default: false) // true +let host = config.string(forKey: "host", default: "0.0.0.0") // "localhost" +let ports = config.intArray(forKey: "ports", default: []) // [8080, 8443] + +### With secrets + +let provider = CommandLineArgumentsProvider( +secretsSpecifier: .specific(["--api-key"]) +) + +### Custom arguments + +let provider = CommandLineArgumentsProvider( +arguments: ["program", "--verbose", "--timeout", "30"], +secretsSpecifier: .dynamic { key, _ in key.contains("--secret") } +) + +## Topics + +### Creating a command line arguments provider + +Creates a new CLI provider with the provided arguments. + +## Relationships + +### Conforms To + +- `ConfigProvider` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- CommandLineArgumentsProvider +- Overview +- Package traits +- Key formats +- Array handling +- Usage +- With secrets +- Custom arguments +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/choosing-reader-methods + +- Configuration +- Choosing reader methods + +Article + +# Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +## Overview + +For every configuration access pattern (get, fetch, watch) and data type, Swift Configuration provides three method variants that handle missing or invalid values differently: + +- **Optional variant**: Returns `nil` when a value is missing or cannot be converted. + +- **Default variant**: Returns a fallback value when a value is missing or cannot be converted. + +- **Required variant**: Throws an error when a value is missing or cannot be converted. + +Understanding these variants helps you write robust configuration code that handles missing values appropriately for your use case. + +### Optional variants + +Optional variants return `nil` when a configuration value is missing or cannot be converted to the expected type. These methods have the simplest signatures and are ideal when configuration values are truly optional. + +let config = ConfigReader(provider: EnvironmentVariablesProvider()) + +// Optional get +let timeout: Int? = config.int(forKey: "http.timeout") +let apiUrl: String? = config.string(forKey: "api.url") + +// Optional fetch +let latestTimeout: Int? = try await config.fetchInt(forKey: "http.timeout") + +// Optional watch +try await config.watchInt(forKey: "http.timeout") { updates in +for await timeout in updates { +if let timeout = timeout { +print("Timeout is set to: \(timeout)") +} else { +print("No timeout configured") +} +} +} + +#### When to use + +Use optional variants when: + +- **Truly optional features**: The configuration controls optional functionality. + +- **Gradual rollouts**: New configuration that might not be present everywhere. + +- **Conditional behavior**: Your code can operate differently based on presence or absence. + +- **Debugging and diagnostics**: You want to detect missing configuration explicitly. + +#### Error handling behavior + +Optional variants handle errors gracefully by returning `nil`: + +- Missing values return `nil`. + +- Type conversion errors return `nil`. + +- Provider errors return `nil` (except for fetch variants, which always propagate provider errors). + +// These all return nil instead of throwing +let missingPort = config.int(forKey: "nonexistent.port") // nil +let invalidPort = config.int(forKey: "invalid.port.value") // nil (if value can't convert to Int) +let failingPort = config.int(forKey: "provider.error.key") // nil (if provider fails) + +// Fetch variants still throw provider errors +do { +let port = try await config.fetchInt(forKey: "network.error") // Throws provider error +} catch { +// Handle network or provider errors +} + +### Default variants + +Default variants return a specified fallback value when a configuration value is missing or cannot be converted. These provide guaranteed non-optional results while handling missing configuration gracefully. + +// Default get +let timeout = config.int(forKey: "http.timeout", default: 30) +let retryCount = config.int(forKey: "network.retries", default: 3) + +// Default fetch +let latestTimeout = try await config.fetchInt(forKey: "http.timeout", default: 30) + +// Default watch +try await config.watchInt(forKey: "http.timeout", default: 30) { updates in +for await timeout in updates { +print("Using timeout: \(timeout)") // Always has a value +connectionManager.setTimeout(timeout) +} +} + +#### When to use + +Use default variants when: + +- **Sensible defaults exist**: You have reasonable fallback values for missing configuration. + +- **Simplified code flow**: You want to avoid optional handling in business logic. + +- **Required functionality**: The feature needs a value to operate, but can use defaults. + +- **Configuration evolution**: New settings that should work with older deployments. + +#### Choosing good defaults + +Consider these principles when choosing default values: + +// Safe defaults that won't cause issues +let timeout = config.int(forKey: "http.timeout", default: 30) // Reasonable timeout +let maxRetries = config.int(forKey: "retries.max", default: 3) // Conservative retry count +let cacheSize = config.int(forKey: "cache.size", default: 1000) // Modest cache size + +// Environment-specific defaults +let logLevel = config.string(forKey: "log.level", default: "info") // Safe default level +let enableDebug = config.bool(forKey: "debug.enabled", default: false) // Secure default + +// Performance defaults that err on the side of caution +let batchSize = config.int(forKey: "batch.size", default: 100) // Small safe batch +let maxConnections = config.int(forKey: "pool.max", default: 10) // Conservative pool + +#### Error handling behavior + +Default variants handle errors by returning the default value: + +- Missing values return the default. + +- Type conversion errors return the default. + +- Provider errors return the default (except for fetch variants). + +### Required variants + +Required variants throw errors when configuration values are missing or cannot be converted. These enforce that critical configuration must be present and valid. + +do { +// Required get +let serverPort = try config.requiredInt(forKey: "server.port") +let databaseHost = try config.requiredString(forKey: "database.host") + +// Required fetch +let latestPort = try await config.fetchRequiredInt(forKey: "server.port") + +// Required watch +try await config.watchRequiredInt(forKey: "server.port") { updates in +for try await port in updates { +print("Server port updated to: \(port)") +server.updatePort(port) +} +} +} catch { +fatalError("Configuration error: \(error)") +} + +#### When to use + +Use required variants when: + +- **Essential service configuration**: Server ports, database hosts, service endpoints. + +- **Application startup**: Values needed before the application can function properly. + +- **Critical functionality**: Configuration that must be present for core features to work. + +- **Fail-fast behavior**: You want immediate errors for missing critical configuration. + +### Choosing the right variant + +Use this decision tree to select the appropriate variant: + +#### Is the configuration value critical for application operation? + +**Yes** → Use **required variants** + +// Critical values that must be present +let serverPort = try config.requiredInt(forKey: "server.port") +let databaseHost = try config.requiredString(forKey: "database.host") + +**No** → Continue to next question + +#### Do you have a reasonable default value? + +**Yes** → Use **default variants** + +// Optional features with sensible defaults +let timeout = config.int(forKey: "http.timeout", default: 30) +let retryCount = config.int(forKey: "retries", default: 3) + +**No** → Use **optional variants** + +// Truly optional features where absence is meaningful +let debugEndpoint = config.string(forKey: "debug.endpoint") +let customTheme = config.string(forKey: "ui.theme") + +### Context and type conversion + +All variants support the same additional features: + +#### Configuration context + +// Optional with context +let timeout = config.int( +forKey: ConfigKey( +"service.timeout", +context: ["environment": "production", "region": "us-east-1"] +) +) + +// Default with context +let timeout = config.int( +forKey: ConfigKey( +"service.timeout", +context: ["environment": "production"] +), +default: 30 +) + +// Required with context +let timeout = try config.requiredInt( +forKey: ConfigKey( +"service.timeout", +context: ["environment": "production"] +) +) + +#### Type conversion + +String configuration values can be automatically converted to other types using the `as:` parameter. This works with: + +**Built-in convertible types:** + +- `SystemPackage.FilePath`: Converts from file paths. + +- `Foundation.URL`: Converts from URL strings. + +- `Foundation.UUID`: Converts from UUID strings. + +- `Foundation.Date`: Converts from ISO8601 date strings. + +**String-backed enums:** + +**Custom types:** + +- Types that you explicitly conform to `ExpressibleByConfigString`. + +// Built-in type conversion +let apiUrl = config.string(forKey: "api.url", as: URL.self) +let requestId = config.string(forKey: "request.id", as: UUID.self) +let configPath = config.string(forKey: "config.path", as: FilePath.self) +let startDate = config.string(forKey: "launch.date", as: Date.self) + +enum LogLevel: String { +case debug, info, warning, error +} + +// Optional conversion +let level: LogLevel? = config.string(forKey: "log.level", as: LogLevel.self) + +// Default conversion +let level = config.string(forKey: "log.level", as: LogLevel.self, default: .info) + +// Required conversion +let level = try config.requiredString(forKey: "log.level", as: LogLevel.self) + +// Custom type conversion (ExpressibleByConfigString) +struct DatabaseURL: ExpressibleByConfigString { +let url: URL + +init?(configString: String) { +guard let url = URL(string: configString) else { return nil } +self.url = url +} + +var description: String { url.absoluteString } +} +let dbUrl = config.string(forKey: "database.url", as: DatabaseURL.self) + +#### Secret handling + +// Mark sensitive values as secrets in all variants +let optionalKey = config.string(forKey: "api.key", isSecret: true) +let defaultKey = config.string(forKey: "api.key", isSecret: true, default: "development-key") +let requiredKey = try config.requiredString(forKey: "api.key", isSecret: true) + +Also check out Handling secrets correctly. + +### Best practices + +1. **Use required variants** only for truly critical configuration. + +2. **Use default variants** for user experience settings where missing configuration shouldn’t break functionality. + +3. **Use optional variants** for feature flags and debugging where the absence of configuration is meaningful. + +4. **Choose safe defaults** that won’t cause security issues or performance problems if used in production. + +For guidance on selecting between get, fetch, and watch access patterns, see Choosing the access pattern. For more configuration guidance, check out Adopting best practices. + +## See Also + +### Readers and providers + +`struct ConfigReader` + +A type that provides read-only access to configuration values from underlying providers. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigSnapshotReader` + +A container type for reading config values from snapshots. + +Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +- Choosing reader methods +- Overview +- Optional variants +- Default variants +- Required variants +- Choosing the right variant +- Context and type conversion +- Best practices +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/keymappingprovider + +- Configuration +- KeyMappingProvider + +Structure + +# KeyMappingProvider + +A configuration provider that maps all keys before delegating to an upstream provider. + +KeyMappingProvider.swift + +## Mentioned in + +Example use cases + +## Overview + +Use `KeyMappingProvider` to automatically apply a mapping function to every configuration key before passing it to an underlying provider. This is particularly useful when the upstream source of configuration keys differs from your own. Another example is namespacing configuration values from specific sources, such as prefixing environment variables with an application name while leaving other configuration sources unchanged. + +### Common use cases + +Use `KeyMappingProvider` for: + +- Rewriting configuration keys to match upstream configuration sources. + +- Legacy system integration that adapts existing sources with different naming conventions. + +## Example + +Use `KeyMappingProvider` when you want to map keys for specific providers in a multi-provider setup: + +// Create providers +let envProvider = EnvironmentVariablesProvider() + +// Only remap the environment variables, not the JSON config +let keyMappedEnvProvider = KeyMappingProvider(upstream: envProvider) { key in +key.prepending(["myapp", "prod"]) +} + +let config = ConfigReader(providers: [\ +keyMappedEnvProvider, // Reads from "MYAPP_PROD_*" environment variables\ +jsonProvider // Reads from JSON without prefix\ +]) + +// This reads from "MYAPP_PROD_DATABASE_HOST" env var or "database.host" in JSON +let host = config.string(forKey: "database.host", default: "localhost") + +## Convenience method + +You can also use the `prefixKeys(with:)` convenience method on configuration provider types to wrap one in a `KeyMappingProvider`: + +let envProvider = EnvironmentVariablesProvider() +let keyMappedEnvProvider = envProvider.mapKeys { key in +key.prepending(["myapp", "prod"]) +} + +## Topics + +### Creating a key-mapping provider + +Creates a new provider. + +## Relationships + +### Conforms To + +- `ConfigProvider` +Conforms when `Upstream` conforms to `ConfigProvider`. + +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +- KeyMappingProvider +- Mentioned in +- Overview +- Common use cases +- Example +- Convenience method +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/choosing-access-patterns + +- Configuration +- Choosing the access pattern + +Article + +# Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +## Overview + +Swift Configuration provides three access patterns for retrieving configuration values, each optimized for different use cases and performance requirements. + +The three access patterns are: + +- **Get**: Synchronous access to current values available locally, in-memory. + +- **Fetch**: Asynchronous access to retrieve fresh values from authoritative sources, optionally with extra context. + +- **Watch**: Reactive access that provides real-time updates when values change. + +### Get: Synchronous local access + +The “get” pattern provides immediate, synchronous access to configuration values that are already available in memory. This is the fastest and most commonly used access pattern. + +let config = ConfigReader(provider: EnvironmentVariablesProvider()) + +// Get the current timeout value synchronously +let timeout = config.int(forKey: "http.timeout", default: 30) + +// Get a required value that must be present +let apiKey = try config.requiredString(forKey: "api.key", isSecret: true) + +#### When to use + +Use the “get” pattern when: + +- **Performance is critical**: You need immediate access without async overhead. + +- **Values are stable**: Configuration doesn’t change frequently during runtime. + +- **Simple providers**: Using environment variables, command-line arguments, or files. + +- **Startup configuration**: Reading values during application initialization. + +- **Request handling**: Accessing configuration in hot code paths where async calls would add latency. + +#### Behavior characteristics + +- Returns the currently cached value from the provider. + +- No network or I/O operations occur during the call. + +- Values may become stale if the underlying data source changes and the provider is either non-reloading, or has a long reload interval. + +### Fetch: Asynchronous fresh access + +The “fetch” pattern asynchronously retrieves the most current value from the authoritative data source, ensuring you always get up-to-date configuration. + +let config = ConfigReader(provider: remoteConfigProvider) + +// Fetch the latest timeout from a remote configuration service +let timeout = try await config.fetchInt(forKey: "http.timeout", default: 30) + +// Fetch with context for environment-specific configuration +let dbConnectionString = try await config.fetchRequiredString( +forKey: ConfigKey( +"database.url", +context: [\ +"environment": "production",\ +"region": "us-west-2",\ +"service": "user-service"\ +] +), +isSecret: true +) + +#### When to use + +Use the “fetch” pattern when: + +- **Freshness is critical**: You need the latest configuration values. + +- **Remote providers**: Using configuration services, databases, or external APIs that perform evaluation remotely. + +- **Infrequent access**: Reading configuration occasionally, not in hot paths. + +- **Setup operations**: Configuring long-lived resources like database connections where one-time overhead isn’t a concern, and the improved freshness is important. + +- **Administrative operations**: Fetching current settings for management interfaces. + +#### Behavior characteristics + +- Always contacts the authoritative data source. + +- May involve network calls, file system access, or database queries. + +- Providers may (but are not required to) cache the fetched value for subsequent “get” calls. + +- Throws an error if the provider fails to reach the source. + +### Watch: Reactive continuous updates + +The “watch” pattern provides an async sequence of configuration updates, allowing you to react to changes in real-time. This is ideal for long-running services that need to adapt to configuration changes without restarting. + +The async sequence is required to receive the current value as the first element as quickly as possible - this is part of the API contract with configuration providers (for details, check out `ConfigProvider`.) + +let config = ConfigReader(provider: reloadingProvider) + +// Watch for timeout changes and update connection pools +try await config.watchInt(forKey: "http.timeout", default: 30) { updates in +for await newTimeout in updates { +print("HTTP timeout updated to: \(newTimeout)") +connectionPool.updateTimeout(newTimeout) +} +} + +#### When to use + +Use the “watch” pattern when: + +- **Dynamic configuration**: Values change during application runtime. + +- **Hot reloading**: You need to update behavior without restarting the service. + +- **Feature toggles**: Enabling or disabling features based on configuration changes. + +- **Resource management**: Adjusting timeouts, limits, or thresholds dynamically. + +- **A/B testing**: Updating experimental parameters in real-time. + +#### Behavior characteristics + +- Immediately emits the initial value, then subsequent updates. + +- Continues monitoring until the task is cancelled. + +- Works with providers like `ReloadingFileProvider`. + +For details on reloading providers, check out Using reloading providers. + +### Using configuration context + +All access patterns support configuration context, which provides additional metadata to help providers return more specific values. Context is particularly useful with the “fetch” and “watch” patterns when working with dynamic or environment-aware providers. + +#### Filtering watch updates using context + +let context: [String: ConfigContextValue] = [\ +"environment": "production",\ +"region": "us-east-1",\ +"service_version": "2.1.0",\ +"feature_tier": "premium",\ +"load_factor": 0.85\ +] + +// Get environment-specific database configuration +let dbConfig = try await config.fetchRequiredString( +forKey: ConfigKey( +"database.connection_string", +context: context +), +isSecret: true +) + +// Watch for region-specific timeout adjustments +try await config.watchInt( +forKey: ConfigKey( +"api.timeout", +context: ["region": "us-west-2"] +), +default: 5000 +) { updates in +for await timeout in updates { +apiClient.updateTimeout(milliseconds: timeout) +} +} + +#### Get pattern performance + +- **Fastest**: No async overhead, immediate return. + +- **Memory usage**: Minimal, uses cached values. + +- **Best for**: Request handling, hot code paths, startup configuration. + +#### Fetch pattern performance + +- **Moderate**: Async overhead plus data source access time. + +- **Network dependent**: Performance varies with provider implementation. + +- **Best for**: Infrequent access, setup operations, administrative tasks. + +#### Watch pattern performance + +- **Background monitoring**: Continuous resource usage for monitoring. + +- **Event-driven**: Efficient updates only when values change. + +- **Best for**: Long-running services, dynamic configuration, feature toggles. + +### Error handling strategies + +Each access pattern handles errors differently: + +#### Get pattern errors + +// Returns nil or default value for missing/invalid config +let timeout = config.int(forKey: "http.timeout", default: 30) + +// Required variants throw errors for missing values +do { +let apiKey = try config.requiredString(forKey: "api.key") +} catch { +// Handle missing required configuration +} + +#### Fetch pattern errors + +// All fetch methods propagate provider and conversion errors +do { +let config = try await config.fetchRequiredString(forKey: "database.url") +} catch { +// Handle network errors, missing values, or conversion failures +} + +#### Watch pattern errors + +// Errors appear in the async sequence +try await config.watchRequiredInt(forKey: "port") { updates in +do { +for try await port in updates { +server.updatePort(port) +} +} catch { +// Handle provider errors or missing required values +} +} + +### Best practices + +1. **Choose based on use case**: Use “get” for performance-critical paths, “fetch” for freshness, and “watch” for hot reloading. + +2. **Handle errors appropriately**: Design error handling strategies that match your application’s resilience requirements. + +3. **Use context judiciously**: Provide context when you need environment-specific or conditional configuration values. + +4. **Monitor configuration access**: Use `AccessReporter` to understand your application’s configuration dependencies. + +5. **Cache wisely**: For frequently accessed values, prefer “get” over repeated “fetch” calls. + +For more guidance on selecting the right reader methods for your needs, see Choosing reader methods. To learn about handling sensitive configuration values securely, check out Handling secrets correctly. If you encounter issues with configuration access, refer to Troubleshooting and access reporting for debugging techniques. + +## See Also + +### Readers and providers + +`struct ConfigReader` + +A type that provides read-only access to configuration values from underlying providers. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigSnapshotReader` + +A container type for reading config values from snapshots. + +Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +- Choosing the access pattern +- Overview +- Get: Synchronous local access +- Fetch: Asynchronous fresh access +- Watch: Reactive continuous updates +- Using configuration context +- Summary of performance considerations +- Error handling strategies +- Best practices +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessreporter + +- Configuration +- AccessReporter + +Protocol + +# AccessReporter + +A type that receives and processes configuration access events. + +protocol AccessReporter : Sendable + +AccessReporter.swift + +## Mentioned in + +Troubleshooting and access reporting + +Choosing the access pattern + +Configuring libraries + +## Overview + +Access reporters track when configuration values are read, fetched, or watched, to provide visibility into configuration usage patterns. This is useful for debugging, auditing, and understanding configuration dependencies. + +## Topics + +### Required methods + +`func report(AccessEvent)` + +Processes a configuration access event. + +**Required** + +## Relationships + +### Inherits From + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +### Conforming Types + +- `AccessLogger` +- `BroadcastingAccessReporter` +- `FileAccessLogger` + +## See Also + +### Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +`class AccessLogger` + +An access reporter that logs configuration access events using the Swift Log API. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct AccessEvent` + +An event that captures information about accessing a configuration value. + +`struct BroadcastingAccessReporter` + +An access reporter that forwards events to multiple other reporters. + +- AccessReporter +- Mentioned in +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/using-reloading-providers + +- Configuration +- Using reloading providers + +Article + +# Using reloading providers + +Automatically reload configuration from files when they change. + +## Overview + +A reloading provider monitors configuration files for changes and automatically updates your application’s configuration without requiring restarts. Swift Configuration provides: + +- `ReloadingFileProvider` with `JSONSnapshot` for JSON configuration files. + +- `ReloadingFileProvider` with `YAMLSnapshot` for YAML configuration files. + +#### Creating and running providers + +Reloading providers run in a `ServiceGroup`: + +import ServiceLifecycle + +filePath: "/etc/config.json", +allowMissing: true, // Optional: treat missing file as empty config +pollInterval: .seconds(15) +) + +let serviceGroup = ServiceGroup( +services: [provider], +logger: logger +) + +try await serviceGroup.run() + +#### Reading configuration + +Use a reloading provider in the same fashion as a static provider, pass it to a `ConfigReader`: + +let config = ConfigReader(provider: provider) +let host = config.string( +forKey: "database.host", +default: "localhost" +) + +#### Poll interval considerations + +Choose poll intervals based on how quickly you need to detect changes: + +// Development: Quick feedback +pollInterval: .seconds(1) + +// Production: Balanced performance (default) +pollInterval: .seconds(15) + +// Batch processing: Resource efficient +pollInterval: .seconds(300) + +### Watching for changes + +The following sections provide examples of watching for changes in configuration from a reloading provider. + +#### Individual values + +The example below watches for updates in a single key, `database.host`: + +try await config.watchString( +forKey: "database.host" +) { updates in +for await host in updates { +print("Database host updated: \(host)") +} +} + +#### Configuration snapshots + +The following example reads the `database.host` and `database.password` key with the guarantee that they are read from the same update of the reloading file: + +try await config.watchSnapshot { updates in +for await snapshot in updates { +let host = snapshot.string(forKey: "database.host") +let password = snapshot.string(forKey: "database.password", isSecret: true) +print("Configuration updated - Database: \(host)") +} +} + +### Comparison with static providers + +| Feature | Static providers | Reloading providers | +| --- | --- | --- | +| **File reading** | Load once at startup | Reloading on change | +| **Service lifecycle** | Not required | Conforms to `Service` and must run in a `ServiceGroup` | +| **Configuration updates** | Require restart | Automatic reload | + +### Handling missing files during reloading + +Reloading providers support the `allowMissing` parameter to handle cases where configuration files might be temporarily missing or optional. This is useful for: + +- Optional configuration files that might not exist in all environments. + +- Configuration files that are created or removed dynamically. + +- Graceful handling of file system issues during service startup. + +#### Missing file behavior + +When `allowMissing` is `false` (the default), missing files cause errors: + +filePath: "/etc/config.json", +allowMissing: false // Default: throw error if file is missing +) +// Will throw an error if config.json doesn't exist + +When `allowMissing` is `true`, missing files are treated as empty configuration: + +filePath: "/etc/config.json", +allowMissing: true // Treat missing file as empty config +) +// Won't throw if config.json is missing - uses empty config instead + +#### Behavior during reloading + +If a file becomes missing after the provider starts, the behavior depends on the `allowMissing` setting: + +- **`allowMissing: false`**: The provider keeps the last known configuration and logs an error. + +- **`allowMissing: true`**: The provider switches to empty configuration. + +In both cases, when a valid file comes back, the provider will load it and recover. + +// Example: File gets deleted during runtime +try await config.watchString(forKey: "database.host", default: "localhost") { updates in +for await host in updates { +// With allowMissing: true, this will receive "localhost" when file is removed +// With allowMissing: false, this keeps the last known value +print("Database host: \(host)") +} +} + +#### Configuration-driven setup + +The following example sets up an environment variable provider to select the path and interval to watch for a JSON file that contains the configuration for your app: + +let envProvider = EnvironmentVariablesProvider() +let envConfig = ConfigReader(provider: envProvider) + +config: envConfig.scoped(to: "json") +// Reads JSON_FILE_PATH and JSON_POLL_INTERVAL_SECONDS +) + +### Migration from static providers + +1. **Replace initialization**: + +// Before + +// After + +2. **Add the provider to a ServiceGroup**: + +let serviceGroup = ServiceGroup(services: [provider], logger: logger) +try await serviceGroup.run() + +3. **Use ConfigReader**: + +let config = ConfigReader(provider: provider) + +// Live updates. +try await config.watchDouble(forKey: "timeout") { updates in +// Handle changes +} + +// On-demand reads - returns the current value, so might change over time. +let timeout = config.double(forKey: "timeout", default: 60.0) + +For guidance on choosing between get, fetch, and watch access patterns with reloading providers, see Choosing the access pattern. For troubleshooting reloading provider issues, check out Troubleshooting and access reporting. To learn about in-memory providers as an alternative, see Using in-memory providers. + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- Using reloading providers +- Overview +- Basic usage +- Watching for changes +- Comparison with static providers +- Handling missing files during reloading +- Advanced features +- Migration from static providers +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider + +- Configuration +- MutableInMemoryProvider + +Class + +# MutableInMemoryProvider + +A configuration provider that stores mutable values in memory. + +final class MutableInMemoryProvider + +MutableInMemoryProvider.swift + +## Mentioned in + +Using in-memory providers + +## Overview + +Unlike `InMemoryProvider`, this provider allows configuration values to be modified after initialization. It maintains thread-safe access to values and supports real-time notifications when values change, making it ideal for dynamic configuration scenarios. + +## Change notifications + +The provider supports watching for configuration changes through the standard `ConfigProvider` watching methods. When a value changes, all active watchers are automatically notified with the new value. + +## Use cases + +The mutable in-memory provider is particularly useful for: + +- **Dynamic configuration**: Values that change during application runtime + +- **Configuration bridges**: Adapting external configuration systems that push updates + +- **Testing scenarios**: Simulating configuration changes in unit tests + +- **Feature flags**: Runtime toggles that can be modified programmatically + +## Performance characteristics + +This provider offers O(1) lookup time with minimal synchronization overhead. Value updates are atomic and efficiently notify only the relevant watchers. + +## Usage + +// Create provider with initial values +let provider = MutableInMemoryProvider(initialValues: [\ +"feature.enabled": true,\ +"api.timeout": 30.0,\ +"database.host": "localhost"\ +]) + +let config = ConfigReader(provider: provider) + +// Read initial values +let isEnabled = config.bool(forKey: "feature.enabled") // true + +// Update values dynamically +provider.setValue(false, forKey: "feature.enabled") + +// Read updated values +let stillEnabled = config.bool(forKey: "feature.enabled") // false + +To learn more about the in-memory providers, check out Using in-memory providers. + +## Topics + +### Creating a mutable in-memory provider + +[`init(name: String?, initialValues: [AbsoluteConfigKey : ConfigValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/init(name:initialvalues:)) + +Creates a new mutable in-memory provider with the specified initial values. + +### Updating values in a mutable in-memory provider + +`func setValue(ConfigValue?, forKey: AbsoluteConfigKey)` + +Updates the stored value for the specified configuration key. + +## Relationships + +### Conforms To + +- `ConfigProvider` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- MutableInMemoryProvider +- Mentioned in +- Overview +- Change notifications +- Use cases +- Performance characteristics +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/development + +- Configuration +- Developing Swift Configuration + +Article + +# Developing Swift Configuration + +Learn about tools and conventions used to develop the Swift Configuration package. + +## Overview + +The Swift Configuration package is developed using modern Swift development practices and tools. This guide covers the development workflow, code organization, and tooling used to maintain the package. + +### Process + +We follow an open process and discuss development on GitHub issues, pull requests, and on the Swift Forums. Details on how to submit an issue or a pull requests can be found in CONTRIBUTING.md. + +Large features and changes go through a lightweight proposals process - to learn more, check out Proposals. + +#### Package organization + +The package contains several Swift targets organized by functionality: + +- **Configuration** \- Core configuration reading APIs and built-in providers. + +- **ConfigurationTesting** \- Testing utilities for external configuration providers. + +- **ConfigurationTestingInternal** \- Internal testing utilities and helpers. + +#### Running CI checks locally + +You can run the Github Actions workflows locally using act. To run all the jobs that run on a pull request, use the following command: + +% act pull_request +% act workflow_call -j soundness --input shell_check_enabled=true + +To bind-mount the working directory to the container, rather than a copy, use `--bind`. For example, to run just the formatting, and have the results reflected in your working directory: + +% act --bind workflow_call -j soundness --input format_check_enabled=true + +If you’d like `act` to always run with certain flags, these can be be placed in an `.actrc` file either in the current working directory or your home directory, for example: + +--container-architecture=linux/amd64 +--remote-name upstream +--action-offline-mode + +#### Code generation with gyb + +This package uses the “generate your boilerplate” (gyb) script from the Swift repository to stamp out repetitive code for each supported primitive type. + +The files that include gyb syntax end with `.gyb`, and after making changes to any of those files, run: + +./Scripts/generate_boilerplate_files_with_gyb.sh + +If you’re adding a new `.gyb` file, also make sure to add it to the exclude list in `Package.swift`. + +After running this script, also run the formatter before opening a PR. + +#### Code formatting + +The project uses swift-format for consistent code style. You can run CI checks locally using `act`. + +To run formatting checks: + +act --bind workflow_call -j soundness --input format_check_enabled=true + +#### Testing + +The package includes comprehensive test suites for all components: + +- Unit tests for individual providers and utilities. + +- Compatibility tests using `ProviderCompatTest` for built-in providers. + +Run tests using Swift Package Manager: + +swift test --enable-all-traits + +#### Documentation + +Documentation is written using DocC and includes: + +- API reference documentation in source code. + +- Conceptual guides in `.docc` catalogs. + +- Usage examples and best practices. + +- Troubleshooting guides. + +Preview documentation locally: + +SWIFT_PREVIEW_DOCS=1 swift package --disable-sandbox preview-documentation --target Configuration + +#### Code style + +- Follow Swift API Design Guidelines. + +- Use meaningful names for types, methods, and variables. + +- Include comprehensive documentation for all APIs, not only public types. + +- Write unit tests for new functionality. + +#### Provider development + +When developing new configuration providers: + +1. Implement the `ConfigProvider` protocol. + +2. Add comprehensive unit tests. + +3. Run compatibility tests using `ProviderCompatTest`. + +4. Add documentation to all symbols, not just `public`. + +#### Documentation requirements + +All APIs must include: + +- Clear, concise documentation comments. + +- Usage examples where appropriate. + +- Parameter and return value descriptions. + +- Error conditions and handling. + +## See Also + +### Contributing + +Collaborate on API changes to Swift Configuration by writing a proposal. + +- Developing Swift Configuration +- Overview +- Process +- Repository structure +- Development tools +- Contributing guidelines +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/troubleshooting + +- Configuration +- Troubleshooting and access reporting + +Article + +# Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +## Overview + +### Debugging configuration issues + +If your configuration values aren’t being read correctly, check: + +1. **Environment variable naming**: When using `EnvironmentVariablesProvider`, keys are automatically converted to uppercase with dots replaced by underscores. For example, `database.url` becomes `DATABASE_URL`. + +2. **Provider ordering**: When using multiple providers, they’re checked in order and the first one that returns a value wins. + +3. **Debug with an access reporter**: Use access reporting to see which keys are being queried and what values (if any) are being returned. See the next section for details. + +For guidance on selecting the right configuration access patterns and reader methods, check out Choosing the access pattern and Choosing reader methods. + +### Access reporting + +Configuration access reporting can help you debug issues and understand which configuration values your application is using. Swift Configuration provides two built-in ways to log access ( `AccessLogger` and `FileAccessLogger`), and you can also implement your own `AccessReporter`. + +#### Using AccessLogger + +`AccessLogger` integrates with Swift Log and records all configuration accesses: + +let logger = Logger(label: "...") +let accessLogger = AccessLogger(logger: logger) +let config = ConfigReader(provider: provider, accessReporter: accessLogger) + +// Each access will now be logged. +let timeout = config.double(forKey: "http.timeout", default: 30.0) + +This produces log entries showing: + +- Which configuration keys were accessed. + +- What values were returned (with secret values redacted). + +- Which provider supplied the value. + +- Whether default values were used. + +- The location of the code reading the config value. + +- The timestamp of the access. + +#### Using FileAccessLogger + +For writing access events to a file, especially useful during ad-hoc debugging, use `FileAccessLogger`: + +let fileLogger = try FileAccessLogger(filePath: "/var/log/myapp/config-access.log") +let config = ConfigReader(provider: provider, accessReporter: fileLogger) + +You can also enable file access logging for the whole application, without recompiling your code, by setting an environment variable: + +export CONFIG_ACCESS_LOG_FILE=/var/log/myapp/config-access.log + +And then read from the file to see one line per config access: + +tail -f /var/log/myapp/config-access.log + +#### Provider errors + +If any provider throws an error during lookup: + +- **Required methods** (`requiredString`, etc.): Error is immediately thrown to the caller. + +- **Optional methods** (with or without defaults): Error is handled gracefully; `nil` or the default value is returned. + +#### Missing values + +When no provider has the requested value: + +- **Methods with defaults**: Return the provided default value. + +- **Methods without defaults**: Return `nil`. + +- **Required methods**: Throw an error. + +#### File not found errors + +File-based providers ( `FileProvider`, `ReloadingFileProvider`, `DirectoryFilesProvider`, `EnvironmentVariablesProvider` with file path) can throw “file not found” errors when expected configuration files don’t exist. + +Common scenarios and solutions: + +**Optional configuration files:** + +// Problem: App crashes when optional config file is missing + +// Solution: Use allowMissing parameter + +filePath: "/etc/optional-config.json", +allowMissing: true +) + +**Environment-specific files:** + +// Different environments may have different config files +let configPath = "/etc/\(environment)/config.json" + +filePath: configPath, +allowMissing: true // Gracefully handle missing env-specific configs +) + +**Container startup issues:** + +// Config files might not be ready when container starts + +filePath: "/mnt/config/app.json", +allowMissing: true // Allow startup with empty config, load when available +) + +#### Configuration not updating + +If your reloading provider isn’t detecting file changes: + +1. **Check ServiceGroup**: Ensure the provider is running in a `ServiceGroup`. + +2. **Enable verbose logging**: The built-in providers use Swift Log for detailed logging, which can help spot issues. + +3. **Verify file path**: Confirm the file path is correct, the file exists, and file permissions are correct. + +4. **Check poll interval**: Consider if your poll interval is appropriate for your use case. + +#### ServiceGroup integration issues + +Common ServiceGroup problems: + +// Incorrect: Provider not included in ServiceGroup + +let config = ConfigReader(provider: provider) +// File monitoring won't work + +// Correct: Provider runs in ServiceGroup + +let serviceGroup = ServiceGroup(services: [provider], logger: logger) +try await serviceGroup.run() + +For more details about reloading providers and ServiceLifecycle integration, see Using reloading providers. To learn about proper configuration practices that can prevent common issues, check out Adopting best practices. + +## See Also + +### Troubleshooting and access reporting + +`protocol AccessReporter` + +A type that receives and processes configuration access events. + +`class AccessLogger` + +An access reporter that logs configuration access events using the Swift Log API. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct AccessEvent` + +An event that captures information about accessing a configuration value. + +`struct BroadcastingAccessReporter` + +An access reporter that forwards events to multiple other reporters. + +- Troubleshooting and access reporting +- Overview +- Debugging configuration issues +- Access reporting +- Error handling +- Reloading provider troubleshooting +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileparsingoptions + +- Configuration +- FileParsingOptions + +Protocol + +# FileParsingOptions + +A type that provides parsing options for file configuration snapshots. + +protocol FileParsingOptions : Sendable + +FileProviderSnapshot.swift + +## Overview + +This protocol defines the requirements for parsing options types used with `FileConfigSnapshot` implementations. Types conforming to this protocol provide configuration parameters that control how file data is interpreted and parsed during snapshot creation. + +The parsing options are passed to the `init(data:providerName:parsingOptions:)` initializer, allowing custom file format implementations to access format-specific parsing settings such as character encoding, date formats, or validation rules. + +## Usage + +Implement this protocol to provide parsing options for your custom `FileConfigSnapshot`: + +struct MyParsingOptions: FileParsingOptions { +let encoding: String.Encoding +let dateFormat: String? +let strictValidation: Bool + +static let `default` = MyParsingOptions( +encoding: .utf8, +dateFormat: nil, +strictValidation: false +) +} + +struct MyFormatSnapshot: FileConfigSnapshot { +typealias ParsingOptions = MyParsingOptions + +init(data: RawSpan, providerName: String, parsingOptions: ParsingOptions) throws { +// Implementation that inspects `parsingOptions` properties like `encoding`, +// `dateFormat`, and `strictValidation`. +} +} + +## Topics + +### Required properties + +``static var `default`: Self`` + +The default instance of this options type. + +**Required** + +### Parsing options + +`protocol FileConfigSnapshot` + +A protocol for configuration snapshots created from file data. + +## Relationships + +### Inherits From + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +### Conforming Types + +- `JSONSnapshot.ParsingOptions` +- `YAMLSnapshot.ParsingOptions` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- FileParsingOptions +- Overview +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshot + +- Configuration +- ConfigSnapshot + +Protocol + +# ConfigSnapshot + +An immutable snapshot of a configuration provider’s state. + +protocol ConfigSnapshot : Sendable + +ConfigProvider.swift + +## Overview + +Snapshots enable consistent reads of multiple related configuration keys by capturing the provider’s state at a specific moment. This prevents the underlying data from changing between individual key lookups. + +## Topics + +### Required methods + +`var providerName: String` + +The human-readable name of the configuration provider that created this snapshot. + +**Required** + +Returns a value for the specified key from this immutable snapshot. + +## Relationships + +### Inherits From + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +### Inherited By + +- `FileConfigSnapshot` + +### Conforming Types + +- `JSONSnapshot` +- `YAMLSnapshot` + +## See Also + +### Creating a custom provider + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- ConfigSnapshot +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configuring-applications + +- Configuration +- Configuring applications + +Article + +# Configuring applications + +Provide flexible and consistent configuration for your application. + +## Overview + +Swift Configuration provides consistent configuration for your tools and applications. This guide shows how to: + +1. Set up a configuration hierarchy with multiple providers. + +2. Configure your application’s components. + +3. Access configuration values in your application and libraries. + +4. Monitor configuration access with access reporting. + +This pattern works well for server applications where configuration comes from environment variables, configuration files, and remote services. + +### Setting up a configuration hierarchy + +Start by creating a configuration hierarchy in your application’s entry point. This defines the order in which configuration sources are consulted when looking for values: + +import Configuration +import Logging + +// Create a logger. +let logger: Logger = ... + +// Set up the configuration hierarchy: +// - environment variables first, +// - then JSON file, +// - then in-memory defaults. +// Also emit log accesses into the provider logger, +// with secrets automatically redacted. + +let config = ConfigReader( +providers: [\ +EnvironmentVariablesProvider(),\ + +filePath: "/etc/myapp/config.json",\ +allowMissing: true // Optional: treat missing file as empty config\ +),\ +InMemoryProvider(values: [\ +"http.server.port": 8080,\ +"http.server.host": "127.0.0.1",\ +"http.client.timeout": 30.0\ +])\ +], +accessReporter: AccessLogger(logger: logger) +) + +// Start your application with the config. +try await runApplication(config: config, logger: logger) + +This configuration hierarchy gives priority to environment variables, then falls + +Next, configure your application using the configuration reader: + +func runApplication( +config: ConfigReader, +logger: Logger +) async throws { +// Get server configuration. +let serverHost = config.string( +forKey: "http.server.host", +default: "localhost" +) +let serverPort = config.int( +forKey: "http.server.port", +default: 8080 +) + +// Read library configuration with a scoped reader +// with the prefix `http.client`. +let httpClientConfig = HTTPClientConfiguration( +config: config.scoped(to: "http.client") +) +let httpClient = HTTPClient(configuration: httpClientConfig) + +// Run your server with the configured components +try await startHTTPServer( +host: serverHost, +port: serverPort, +httpClient: httpClient, +logger: logger +) +} + +Finally, you configure your application across the three sources. A fully configured set of environment variables could look like the following: + +export HTTP_SERVER_HOST=localhost +export HTTP_SERVER_PORT=8080 +export HTTP_CLIENT_TIMEOUT=30.0 +export HTTP_CLIENT_MAX_CONCURRENT_CONNECTIONS=20 +export HTTP_CLIENT_BASE_URL="https://example.com" +export HTTP_CLIENT_DEBUG_LOGGING=true + +In JSON: + +{ +"http": { +"server": { +"host": "localhost", +"port": 8080 +}, +"client": { +"timeout": 30.0, +"maxConcurrentConnections": 20, +"baseURL": "https://example.com", +"debugLogging": true +} +} +} + +And using `InMemoryProvider`: + +[\ +"http.server.port": 8080,\ +"http.server.host": "127.0.0.1",\ +"http.client.timeout": 30.0,\ +"http.client.maxConcurrentConnections": 20,\ +"http.client.baseURL": "https://example.com",\ +"http.client.debugLogging": true,\ +] + +In practice, you’d only specify a subset of the config keys in each location, to match the needs of your service’s operators. + +### Using scoped configuration + +For services with multiple instances of the same component, but with different settings, use scoped configuration: + +// For our server example, we might have different API clients +// that need different settings: + +let adminConfig = config.scoped(to: "services.admin") +let customerConfig = config.scoped(to: "services.customer") + +// Using the admin API configuration +let adminBaseURL = adminConfig.string( +forKey: "baseURL", +default: "https://admin-api.example.com" +) +let adminTimeout = adminConfig.double( +forKey: "timeout", +default: 60.0 +) + +// Using the customer API configuration +let customerBaseURL = customerConfig.string( +forKey: "baseURL", +default: "https://customer-api.example.com" +) +let customerTimeout = customerConfig.double( +forKey: "timeout", +default: 30.0 +) + +This can be configured via environment variables as follows: + +# Admin API configuration +export SERVICES_ADMIN_BASE_URL="https://admin.internal-api.example.com" +export SERVICES_ADMIN_TIMEOUT=120.0 +export SERVICES_ADMIN_DEBUG_LOGGING=true + +# Customer API configuration +export SERVICES_CUSTOMER_BASE_URL="https://api.example.com" +export SERVICES_CUSTOMER_MAX_CONCURRENT_CONNECTIONS=20 +export SERVICES_CUSTOMER_TIMEOUT=15.0 + +For details about the key conversion logic, check out `EnvironmentVariablesProvider`. + +For more configuration guidance, see Adopting best practices. To understand different access patterns and reader methods, refer to Choosing the access pattern and Choosing reader methods. For handling secrets securely, check out Handling secrets correctly. + +## See Also + +### Essentials + +Configuring libraries + +Provide a consistent and flexible way to configure your library. + +Example use cases + +Review common use cases with ready-to-copy code samples. + +Adopting best practices + +Follow these principles to make your code easily configurable and composable with other libraries. + +- Configuring applications +- Overview +- Setting up a configuration hierarchy +- Configure your application +- Using scoped configuration +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/systempackage + +- Configuration +- SystemPackage + +Extended Module + +# SystemPackage + +## Topics + +### Extended Structures + +`extension FilePath` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence + +- Configuration +- ConfigUpdatesAsyncSequence + +Structure + +# ConfigUpdatesAsyncSequence + +A concrete async sequence for delivering updated configuration values. + +AsyncSequences.swift + +## Topics + +### Creating an asynchronous update sequence + +Creates a new concrete async sequence wrapping the provided existential sequence. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.Sendable` +- `Swift.SendableMetatype` +- `_Concurrency.AsyncSequence` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +- ConfigUpdatesAsyncSequence +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/expressiblebyconfigstring + +- Configuration +- ExpressibleByConfigString + +Protocol + +# ExpressibleByConfigString + +A protocol for types that can be initialized from configuration string values. + +protocol ExpressibleByConfigString : CustomStringConvertible + +ExpressibleByConfigString.swift + +## Mentioned in + +Choosing reader methods + +## Overview + +Conform your custom types to this protocol to enable automatic conversion when using the `as:` parameter with configuration reader methods such as `string(forKey:as:isSecret:fileID:line:)`. + +## Custom types + +For other custom types, conform to the protocol `ExpressibleByConfigString` by providing a failable initializer and the `description` property: + +struct DatabaseURL: ExpressibleByConfigString { +let url: URL + +init?(configString: String) { +guard let url = URL(string: configString) else { return nil } +self.url = url +} + +var description: String { url.absoluteString } +} + +// Now you can use it with automatic conversion +let config = ConfigReader(provider: EnvironmentVariablesProvider()) +let dbUrl = config.string(forKey: "database.url", as: DatabaseURL.self) + +## Built-in conformances + +The following Foundation types already conform to `ExpressibleByConfigString`: + +- `SystemPackage.FilePath` \- Converts from file paths. + +- `Foundation.URL` \- Converts from URL strings. + +- `Foundation.UUID` \- Converts from UUID strings. + +- `Foundation.Date` \- Converts from ISO8601 date strings. + +## Topics + +### Required methods + +`init?(configString: String)` + +Creates an instance from a configuration string value. + +**Required** + +## Relationships + +### Inherits From + +- `Swift.CustomStringConvertible` + +### Conforming Types + +- `Date` +- `FilePath` +- `URL` +- `UUID` + +## See Also + +### Value conversion + +`protocol ConfigBytesFromStringDecoder` + +A protocol for decoding string configuration values into byte arrays. + +`struct ConfigBytesFromBase64StringDecoder` + +A decoder that converts base64-encoded strings into byte arrays. + +`struct ConfigBytesFromHexStringDecoder` + +A decoder that converts hexadecimal-encoded strings into byte arrays. + +- ExpressibleByConfigString +- Mentioned in +- Overview +- Custom types +- Built-in conformances +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/using-in-memory-providers + +- Configuration +- Using in-memory providers + +Article + +# Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +## Overview + +Swift Configuration provides two in-memory providers, which are directly instantiated with the desired keys and values, rather than being parsed from another representation. These providers are particularly useful for testing, providing fallback values, and bridging with other configuration systems. + +- `InMemoryProvider` is an immutable value type, and can be useful for defining overrides and fallbacks in a provider hierarchy. + +- `MutableInMemoryProvider` is a mutable reference type, allowing you to update values and get any watchers notified automatically. It can be used to bridge from other stateful, callback-based configuration sources. + +### InMemoryProvider + +The `InMemoryProvider` is ideal for static configuration values that don’t change during application runtime. + +#### Basic usage + +Create an `InMemoryProvider` with a dictionary of configuration values: + +let provider = InMemoryProvider(values: [\ +"database.host": "localhost",\ +"database.port": 5432,\ +"api.timeout": 30.0,\ +"debug.enabled": true\ +]) + +let config = ConfigReader(provider: provider) +let host = config.string(forKey: "database.host") // "localhost" +let port = config.int(forKey: "database.port") // 5432 + +#### Using with hierarchical keys + +You can use `AbsoluteConfigKey` for more complex key structures: + +let provider = InMemoryProvider(values: [\ +AbsoluteConfigKey(["http", "client", "timeout"]): 30.0,\ +AbsoluteConfigKey(["http", "server", "port"]): 8080,\ +AbsoluteConfigKey(["logging", "level"]): "info"\ +]) + +#### Configuration context + +The in-memory provider performs exact matching of config keys, including the context. This allows you to provide different values for the same key path based on contextual information. + +The following example shows using two keys with the same key path, but different context, and giving them two different values: + +let provider = InMemoryProvider( +values: [\ +AbsoluteConfigKey(\ +["http", "client", "timeout"],\ +context: ["upstream": "example1.org"]\ +): 15.0,\ +AbsoluteConfigKey(\ +["http", "client", "timeout"],\ +context: ["upstream": "example2.org"]\ +): 30.0,\ +] +) + +With a provider configured this way, a config reader will return the following results: + +let config = ConfigReader(provider: provider) +config.double(forKey: "http.client.timeout") // nil +config.double( +forKey: ConfigKey( +"http.client.timeout", +context: ["upstream": "example1.org"] +) +) // 15.0 +config.double( +forKey: ConfigKey( +"http.client.timeout", +context: ["upstream": "example2.org"] +) +) // 30.0 + +### MutableInMemoryProvider + +The `MutableInMemoryProvider` allows you to modify configuration values at runtime and notify watchers of changes. + +#### Basic usage + +let provider = MutableInMemoryProvider() +provider.setValue("localhost", forKey: "database.host") +provider.setValue(5432, forKey: "database.port") + +let config = ConfigReader(provider: provider) +let host = config.string(forKey: "database.host") // "localhost" + +#### Updating values + +You can update values after creation, and any watchers will be notified: + +// Initial setup +provider.setValue("debug", forKey: "logging.level") + +// Later in your application, watchers are notified +provider.setValue("info", forKey: "logging.level") + +#### Watching for changes + +Use the provider’s async sequence to watch for configuration changes: + +let config = ConfigReader(provider: provider) +try await config.watchString( +forKey: "logging.level", +as: Logger.Level.self, +default: .debug +) { updates in +for try await level in updates { +print("Logging level changed to: \(level)") +} +} + +#### Testing + +In-memory providers are excellent for unit testing: + +func testDatabaseConnection() { +let testProvider = InMemoryProvider(values: [\ +"database.host": "test-db.example.com",\ +"database.port": 5433,\ +"database.name": "test_db"\ +]) + +let config = ConfigReader(provider: testProvider) +let connection = DatabaseConnection(config: config) +// Test your database connection logic +} + +#### Fallback values + +Use `InMemoryProvider` as a fallback in a provider hierarchy: + +let fallbackProvider = InMemoryProvider(values: [\ +"api.timeout": 30.0,\ +"retry.maxAttempts": 3,\ +"cache.enabled": true\ +]) + +let config = ConfigReader(providers: [\ +EnvironmentVariablesProvider(),\ +fallbackProvider\ +// Used when environment variables are not set\ +]) + +#### Bridging other systems + +Use `MutableInMemoryProvider` to bridge configuration from other systems: + +class ConfigurationBridge { +private let provider = MutableInMemoryProvider() + +func updateFromExternalSystem(_ values: [String: ConfigValue]) { +for (key, value) in values { +provider.setValue(value, forKey: key) +} +} +} + +For comparison with reloading providers, see Using reloading providers. To understand different access patterns and when to use each provider type, check out Choosing the access pattern. For more configuration guidance, refer to Adopting best practices. + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- Using in-memory providers +- Overview +- InMemoryProvider +- MutableInMemoryProvider +- Common Use Cases +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/snapshot() + +#app-main) + +- Configuration +- ConfigReader +- snapshot() + +Instance Method + +# snapshot() + +Returns a snapshot of the current configuration state. + +ConfigSnapshotReader.swift + +## Return Value + +The snapshot. + +## Discussion + +The snapshot reader provides read-only access to the configuration’s state at the time the method was called. + +let snapshot = config.snapshot() +// Use snapshot to read config values +let cert = snapshot.string(forKey: "cert") +let privateKey = snapshot.string(forKey: "privateKey") +// Ensures that both values are coming from the same underlying snapshot and that a provider +// didn't change its internal state between the two `string(...)` calls. +let identity = MyIdentity(cert: cert, privateKey: privateKey) + +## See Also + +### Reading from a snapshot + +Watches the configuration for changes. + +- snapshot() +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/best-practices + +- Configuration +- Adopting best practices + +Article + +# Adopting best practices + +Follow these principles to make your code easily configurable and composable with other libraries. + +## Overview + +When designing configuration for Swift libraries and applications, follow these patterns to create consistent, maintainable code that integrates well with the Swift ecosystem. + +### Document configuration keys + +Include thorough documentation about what configuration keys your library reads. For each key, document: + +- The key name and its hierarchical structure. + +- The expected data type. + +- Whether the key is required or optional. + +- Default values when applicable. + +- Valid value ranges or constraints. + +- Usage examples. + +public struct HTTPClientConfiguration { +/// ... +/// +/// ## Configuration keys: +/// - `timeout` (double, optional, default: 30.0): Request timeout in seconds. +/// - `maxRetries` (int, optional, default: 3, range: 0-10): Maximum retry attempts. +/// - `baseURL` (string, required): Base URL for requests. +/// - `apiKey` (string, required, secret): API authentication key. +/// +/// ... +public init(config: ConfigReader) { +// Implementation... +} +} + +### Use sensible defaults + +Provide reasonable default values to make your library work without extensive configuration. + +// Good: Provides sensible defaults +let timeout = config.double(forKey: "http.timeout", default: 30.0) +let maxConnections = config.int(forKey: "http.maxConnections", default: 10) + +// Avoid: Requiring configuration for common scenarios +let timeout = try config.requiredDouble(forKey: "http.timeout") // Forces users to configure + +### Use scoped configuration + +Organize your configuration keys logically using namespaces to keep related keys together. + +// Good: +let httpConfig = config.scoped(to: "http") +let timeout = httpConfig.double(forKey: "timeout", default: 30.0) +let retries = httpConfig.int(forKey: "retries", default: 3) + +// Better (in libraries): Offer a convenience method that reads your library's configuration. +// Tip: Read the configuration values from the provided reader directly, do not scope it +// to a "myLibrary" namespace. Instead, let the caller of MyLibraryConfiguration.init(config:) +// perform any scoping for your library's configuration. +public struct MyLibraryConfiguration { +public init(config: ConfigReader) { +self.timeout = config.double(forKey: "timeout", default: 30.0) +self.retries = config.int(forKey: "retries", default: 3) +} +} + +// Called from an app - the caller is responsible for adding a namespace and naming it, if desired. +let libraryConfig = MyLibraryConfiguration(config: config.scoped(to: "myLib")) + +### Mark secrets appropriately + +Mark sensitive configuration values like API keys, passwords, or tokens as secrets using the `isSecret: true` parameter. This tells access reporters to redact those values in logs. + +// Mark sensitive values as secrets +let apiKey = try config.requiredString(forKey: "api.key", isSecret: true) +let password = config.string(forKey: "database.password", default: nil, isSecret: true) + +// Regular values don't need the isSecret parameter +let timeout = config.double(forKey: "api.timeout", default: 30.0) + +Some providers also support the `SecretsSpecifier`, allowing you to mark which values are secret during application bootstrapping. + +For comprehensive guidance on handling secrets securely, see Handling secrets correctly. + +### Prefer optional over required + +Only mark configuration as required if your library absolutely cannot function without it. For most cases, provide sensible defaults and make configuration optional. + +// Good: Optional with sensible defaults +let timeout = config.double(forKey: "timeout", default: 30.0) +let debug = config.bool(forKey: "debug", default: false) + +// Use required only when absolutely necessary +let apiEndpoint = try config.requiredString(forKey: "api.endpoint") + +For more details, check out Choosing reader methods. + +### Validate configuration values + +Validate configuration values and throw meaningful errors for invalid input to catch configuration issues early. + +public init(config: ConfigReader) throws { +let timeout = config.double(forKey: "timeout", default: 30.0) + +throw MyConfigurationError.invalidTimeout("Timeout must be positive, got: \(timeout)") +} + +let maxRetries = config.int(forKey: "maxRetries", default: 3) + +throw MyConfigurationError.invalidRetryCount("Max retries must be 0-10, got: \(maxRetries)") +} + +self.timeout = timeout +self.maxRetries = maxRetries +} + +#### When to use reloading providers + +Use reloading providers when you need configuration changes to take effect without restarting your application: + +- Long-running services that can’t be restarted frequently. + +- Development environments where you iterate on configuration. + +- Applications that receive configuration updates through file deployments. + +Check out Using reloading providers to learn more. + +#### When to use static providers + +Use static providers when configuration doesn’t change during runtime: + +- Containerized applications with immutable configuration. + +- Applications where configuration is set once at startup. + +For help choosing between different access patterns and reader method variants, see Choosing the access pattern and Choosing reader methods. For troubleshooting configuration issues, refer to Troubleshooting and access reporting. + +## See Also + +### Essentials + +Configuring applications + +Provide flexible and consistent configuration for your application. + +Configuring libraries + +Provide a consistent and flexible way to configure your library. + +Example use cases + +Review common use cases with ready-to-copy code samples. + +- Adopting best practices +- Overview +- Document configuration keys +- Use sensible defaults +- Use scoped configuration +- Mark secrets appropriately +- Prefer optional over required +- Validate configuration values +- Choosing provider types +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier + +- Configuration +- SecretsSpecifier + +Enumeration + +# SecretsSpecifier + +A specification for identifying which configuration values contain sensitive information. + +SecretsSpecifier.swift + +## Mentioned in + +Adopting best practices + +Handling secrets correctly + +## Overview + +Configuration providers use secrets specifiers to determine which values should be marked as sensitive and protected from accidental disclosure in logs, debug output, or access reports. Secret values are handled specially by `AccessReporter` instances and other components that process configuration data. + +## Usage patterns + +### Mark all values as secret + +Use this for providers that exclusively handle sensitive data: + +let provider = InMemoryProvider( +values: ["api.key": "secret123", "db.password": "pass456"], +secretsSpecifier: .all +) + +### Mark specific keys as secret + +Use this when you know which specific keys contain sensitive information: + +let provider = EnvironmentVariablesProvider( +secretsSpecifier: .specific( +["API_KEY", "DATABASE_PASSWORD", "JWT_SECRET"] +) +) + +### Dynamic secret detection + +Use this for complex logic that determines secrecy based on key patterns or values: + +filePath: "/etc/config.json", +secretsSpecifier: .dynamic { key, value in +// Mark keys containing "password", +// "secret", or "token" as secret +key.lowercased().contains("password") || +key.lowercased().contains("secret") || +key.lowercased().contains("token") +} +) + +### No secret values + +Use this for providers that handle only non-sensitive configuration: + +let provider = InMemoryProvider( +values: ["app.name": "MyApp", "log.level": "info"], +secretsSpecifier: .none +) + +## Topics + +### Types of specifiers + +`case all` + +The library treats all configuration values as secrets. + +The library treats the specified keys as secrets. + +The library determines the secret status dynamically by evaluating each key-value pair. + +`case none` + +The library treats no configuration values as secrets. + +### Inspecting a secrets specifier + +Determines whether a configuration value should be treated as secret. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- SecretsSpecifier +- Mentioned in +- Overview +- Usage patterns +- Mark all values as secret +- Mark specific keys as secret +- Dynamic secret detection +- No secret values +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/directoryfilesprovider + +- Configuration +- DirectoryFilesProvider + +Structure + +# DirectoryFilesProvider + +A configuration provider that reads values from individual files in a directory. + +struct DirectoryFilesProvider + +DirectoryFilesProvider.swift + +## Mentioned in + +Example use cases + +Handling secrets correctly + +Troubleshooting and access reporting + +## Overview + +This provider reads configuration values from a directory where each file represents a single configuration key-value pair. The file name becomes the configuration key, and the file contents become the value. This approach is commonly used by secret management systems that mount secrets as individual files. + +## Key mapping + +Configuration keys are transformed into file names using these rules: + +- Components are joined with dashes. + +- Non-alphanumeric characters (except dashes) are replaced with underscores. + +For example: + +## Value handling + +The provider reads file contents as UTF-8 strings and converts them to the requested type. For binary data (bytes type), it reads raw file contents directly without string conversion. Leading and trailing whitespace is always trimmed from string values. + +## Supported data types + +The provider supports all standard configuration types: + +- Strings (UTF-8 text files) + +- Integers, doubles, and booleans (parsed from string contents) + +- Arrays (using configurable separator, comma by default) + +- Byte arrays (raw file contents) + +## Secret handling + +By default, all values are marked as secrets for security. This is appropriate since this provider is typically used for sensitive data mounted by secret management systems. + +## Usage + +### Reading from a secrets directory + +// Assuming /run/secrets contains files: +// - database-password (contains: "secretpass123") +// - max-connections (contains: "100") +// - enable-cache (contains: "true") + +let provider = try await DirectoryFilesProvider( +directoryPath: "/run/secrets" +) + +let config = ConfigReader(provider: provider) +let dbPassword = config.string(forKey: "database.password") // "secretpass123" +let maxConn = config.int(forKey: "max.connections", default: 50) // 100 +let cacheEnabled = config.bool(forKey: "enable.cache", default: false) // true + +### Reading binary data + +// For binary files like certificates or keys +let provider = try await DirectoryFilesProvider( +directoryPath: "/run/secrets" +) + +let config = ConfigReader(provider: provider) +let certData = try config.requiredBytes(forKey: "tls.cert") // Raw file bytes + +### Custom array handling + +// If files contain comma-separated lists +let provider = try await DirectoryFilesProvider( +directoryPath: "/etc/config" +) + +// File "allowed-hosts" contains: "host1.example.com,host2.example.com,host3.example.com" +let hosts = config.stringArray(forKey: "allowed.hosts", default: []) +// ["host1.example.com", "host2.example.com", "host3.example.com"] + +## Configuration context + +This provider ignores the context passed in `context`. All keys are resolved using only their component path. + +## Topics + +### Creating a directory files provider + +Creates a new provider that reads files from a directory. + +## Relationships + +### Conforms To + +- `ConfigProvider` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +Using in-memory providers + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`struct InMemoryProvider` + +A configuration provider that stores values in memory. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- DirectoryFilesProvider +- Mentioned in +- Overview +- Key mapping +- Value handling +- Supported data types +- Secret handling +- Usage +- Reading from a secrets directory +- Reading binary data +- Custom array handling +- Configuration context +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey + +- Configuration +- AbsoluteConfigKey + +Structure + +# AbsoluteConfigKey + +A configuration key that represents an absolute path to a configuration value. + +struct AbsoluteConfigKey + +ConfigKey.swift + +## Mentioned in + +Using in-memory providers + +## Overview + +Absolute configuration keys are similar to relative keys but represent complete paths from the root of the configuration hierarchy. They are used internally by the configuration system after resolving any key prefixes or scoping. + +Like relative keys, absolute keys consist of hierarchical components and optional context information. + +## Topics + +### Creating an absolute configuration key + +`init(ConfigKey)` + +Creates a new absolute configuration key from a relative key. + +[`init([String], context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/init(_:context:)) + +Creates a new absolute configuration key. + +### Inspecting an absolute configuration key + +[`var components: [String]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/components) + +The hierarchical components that make up this absolute configuration key. + +[`var context: [String : ConfigContextValue]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/context) + +Additional context information for this configuration key. + +### Instance Methods + +Returns a new absolute configuration key by appending the given relative key. + +Returns a new absolute configuration key by prepending the given relative key. + +## Relationships + +### Conforms To + +- `Swift.Comparable` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByArrayLiteral` +- `Swift.ExpressibleByExtendedGraphemeClusterLiteral` +- `Swift.ExpressibleByStringLiteral` +- `Swift.ExpressibleByUnicodeScalarLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Configuration keys + +`struct ConfigKey` + +A configuration key representing a relative path to a configuration value. + +`enum ConfigContextValue` + +A value that can be stored in a configuration context. + +- AbsoluteConfigKey +- Mentioned in +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfromhexstringdecoder + +- Configuration +- ConfigBytesFromHexStringDecoder + +Structure + +# ConfigBytesFromHexStringDecoder + +A decoder that converts hexadecimal-encoded strings into byte arrays. + +struct ConfigBytesFromHexStringDecoder + +ConfigBytesFromStringDecoder.swift + +## Overview + +This decoder interprets string configuration values as hexadecimal-encoded data and converts them to their binary representation. It expects strings to contain only valid hexadecimal characters (0-9, A-F, a-f). + +## Hexadecimal format + +The decoder expects strings with an even number of characters, where each pair of characters represents one byte. For example, “48656C6C6F” represents the bytes for “Hello”. + +## Topics + +### Creating bytes from a hex string decoder + +`init()` + +Creates a new hexadecimal decoder. + +## Relationships + +### Conforms To + +- `ConfigBytesFromStringDecoder` +- `Swift.Copyable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Value conversion + +`protocol ExpressibleByConfigString` + +A protocol for types that can be initialized from configuration string values. + +`protocol ConfigBytesFromStringDecoder` + +A protocol for decoding string configuration values into byte arrays. + +`struct ConfigBytesFromBase64StringDecoder` + +A decoder that converts base64-encoded strings into byte arrays. + +- ConfigBytesFromHexStringDecoder +- Overview +- Hexadecimal format +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent + +- Configuration +- ConfigContent + +Enumeration + +# ConfigContent + +The raw content of a configuration value. + +@frozen +enum ConfigContent + +ConfigProvider.swift + +## Topics + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.Equatable` +- `Swift.ExpressibleByBooleanLiteral` +- `Swift.ExpressibleByExtendedGraphemeClusterLiteral` +- `Swift.ExpressibleByFloatLiteral` +- `Swift.ExpressibleByIntegerLiteral` +- `Swift.ExpressibleByStringLiteral` +- `Swift.ExpressibleByUnicodeScalarLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- ConfigContent +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue + +- Configuration +- ConfigValue + +Structure + +# ConfigValue + +A configuration value that wraps content with metadata. + +struct ConfigValue + +ConfigProvider.swift + +## Mentioned in + +Handling secrets correctly + +## Overview + +Configuration values pair raw content with a flag indicating whether the value contains sensitive information. Secret values are protected from accidental disclosure in logs and debug output: + +let apiKey = ConfigValue(.string("sk-abc123"), isSecret: true) + +## Topics + +### Creating a config value + +`init(ConfigContent, isSecret: Bool)` + +Creates a new configuration value. + +### Inspecting a config value + +`var content: ConfigContent` + +The configuration content. + +`var isSecret: Bool` + +Whether this value contains sensitive information that should not be logged. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByBooleanLiteral` +- `Swift.ExpressibleByExtendedGraphemeClusterLiteral` +- `Swift.ExpressibleByFloatLiteral` +- `Swift.ExpressibleByIntegerLiteral` +- `Swift.ExpressibleByStringLiteral` +- `Swift.ExpressibleByUnicodeScalarLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`enum ConfigType` + +The supported configuration value types. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- ConfigValue +- Mentioned in +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/foundation + +- Configuration +- Foundation + +Extended Module + +# Foundation + +## Topics + +### Extended Structures + +`extension Date` + +`extension URL` + +`extension UUID` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader + +- Configuration +- ConfigSnapshotReader + +Structure + +# ConfigSnapshotReader + +A container type for reading config values from snapshots. + +struct ConfigSnapshotReader + +ConfigSnapshotReader.swift + +## Overview + +A config snapshot reader provides read-only access to config values stored in an underlying `ConfigSnapshot`. Unlike a config reader, which can access live, changing config values from providers, a snapshot reader works with a fixed, immutable snapshot of the configuration data. + +## Usage + +Get a snapshot reader from a config reader by using the `snapshot()` method. All values in the snapshot are guaranteed to be from the same point in time: + +// Get a snapshot from a ConfigReader +let config = ConfigReader(provider: EnvironmentVariablesProvider()) +let snapshot = config.snapshot() +// Use snapshot to read config values +let cert = snapshot.string(forKey: "cert") +let privateKey = snapshot.string(forKey: "privateKey") +// Ensures that both values are coming from the same +// underlying snapshot and that a provider didn't change +// its internal state between the two `string(...)` calls. +let identity = MyIdentity(cert: cert, privateKey: privateKey) + +Or you can watch for snapshot updates using the `watchSnapshot(fileID:line:updatesHandler:)` method: + +try await config.watchSnapshot { snapshots in +for await snapshot in snapshots { +// Process each new configuration snapshot +let cert = snapshot.string(forKey: "cert") +let privateKey = snapshot.string(forKey: "privateKey") +// Ensures that both values are coming from the same +// underlying snapshot and that a provider didn't change +// its internal state between the two `string(...)` calls. +let newCert = MyCert(cert: cert, privateKey: privateKey) +print("Certificate was updated: \(newCert.redactedDescription)") +} +} + +### Scoping + +Like `ConfigReader`, you can set a key prefix on the config snapshot reader, allowing all config lookups to prepend a prefix to the keys, which lets you pass a scoped snapshot reader to nested components. + +let httpConfig = snapshotReader.scoped(to: "http") +let timeout = httpConfig.int(forKey: "timeout") +// Reads from "http.timeout" in the snapshot + +### Config keys and context + +The library requests config values using a canonical “config key”, that represents a key path. You can provide additional context that was used by some providers when the snapshot was created. + +let httpTimeout = snapshotReader.int( +forKey: ConfigKey("http.timeout", context: ["upstream": "example.com"]), +default: 60 +) + +### Automatic type conversion + +String configuration values can be automatically converted to other types using the `as:` parameter. This works with: + +- Types that you explicitly conform to `ExpressibleByConfigString`. + +- Built-in types that already conform to `ExpressibleByConfigString`: + +- `SystemPackage.FilePath` \- Converts from file paths. + +- `Foundation.URL` \- Converts from URL strings. + +- `Foundation.UUID` \- Converts from UUID strings. + +- `Foundation.Date` \- Converts from ISO8601 date strings. + +// Built-in type conversion +let apiUrl = snapshot.string( +forKey: "api.url", +as: URL.self +) +let requestId = snapshot.string( +forKey: "request.id", +as: UUID.self +) + +enum LogLevel: String { +case debug, info, warning, error +} +let logLevel = snapshot.string( +forKey: "logging.level", +as: LogLevel.self, +default: .info +) + +// Custom type conversion (ExpressibleByConfigString) +struct DatabaseURL: ExpressibleByConfigString { +let url: URL + +init?(configString: String) { +guard let url = URL(string: configString) else { return nil } +self.url = url +} + +var description: String { url.absoluteString } +} +let dbUrl = snapshot.string( +forKey: "database.url", +as: DatabaseURL.self +) + +### Access reporting + +When reading from a snapshot, access events are reported to the access reporter from the original config reader. This helps debug which config values are accessed, even when reading from snapshots. + +## Topics + +### Creating a snapshot + +Returns a snapshot of the current configuration state. + +Watches the configuration for changes. + +### Namespacing + +Returns a scoped snapshot reader by appending the provided key to the current key prefix. + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key, converting from string. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +### Synchronously reading lists of string values + +Synchronously gets an array of config values for the given config key, converting from strings. + +Synchronously gets an array of config values for the given config key with default fallback, converting from strings. + +### Synchronously reading required string values + +Synchronously gets a required config value for the given config key, throwing an error if it’s missing. + +Synchronously gets a required config value for the given config key, converting from string. + +### Synchronously reading required lists of string values + +Synchronously gets a required array of config values for the given config key, converting from strings. + +### Synchronously reading Boolean values + +### Synchronously reading required Boolean values + +### Synchronously reading lists of Boolean values + +### Synchronously reading required lists of Boolean values + +### Synchronously reading integer values + +### Synchronously reading required integer values + +### Synchronously reading lists of integer values + +### Synchronously reading required lists of integer values + +### Synchronously reading double values + +### Synchronously reading required double values + +### Synchronously reading lists of double values + +### Synchronously reading required lists of double values + +### Synchronously reading bytes + +### Synchronously reading required bytes + +### Synchronously reading collections of byte chunks + +### Synchronously reading required collections of byte chunks + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Readers and providers + +`struct ConfigReader` + +A type that provides read-only access to configuration values from underlying providers. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +- ConfigSnapshotReader +- Overview +- Usage +- Scoping +- Config keys and context +- Automatic type conversion +- Access reporting +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue + +- Configuration +- ConfigContextValue + +Enumeration + +# ConfigContextValue + +A value that can be stored in a configuration context. + +enum ConfigContextValue + +ConfigContext.swift + +## Overview + +Context values support common data types used for configuration metadata. + +## Topics + +### Configuration context values + +`case string(String)` + +A string value. + +`case bool(Bool)` + +A Boolean value. + +`case int(Int)` + +An integer value. + +`case double(Double)` + +A floating point value. + +## Relationships + +### Conforms To + +- `Swift.Copyable` +- `Swift.CustomStringConvertible` +- `Swift.Equatable` +- `Swift.ExpressibleByBooleanLiteral` +- `Swift.ExpressibleByExtendedGraphemeClusterLiteral` +- `Swift.ExpressibleByFloatLiteral` +- `Swift.ExpressibleByIntegerLiteral` +- `Swift.ExpressibleByStringLiteral` +- `Swift.ExpressibleByUnicodeScalarLiteral` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Configuration keys + +`struct ConfigKey` + +A configuration key representing a relative path to a configuration value. + +`struct AbsoluteConfigKey` + +A configuration key that represents an absolute path to a configuration value. + +- ConfigContextValue +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader + +- Configuration +- ConfigReader + +Structure + +# ConfigReader + +A type that provides read-only access to configuration values from underlying providers. + +struct ConfigReader + +ConfigReader.swift + +## Mentioned in + +Configuring libraries + +Example use cases + +Using reloading providers + +## Overview + +Use `ConfigReader` to access configuration values from various sources like environment variables, JSON files, or in-memory stores. The reader supports provider hierarchies, key scoping, and access reporting for debugging configuration usage. + +## Usage + +To read configuration values, create a config reader with one or more providers: + +let config = ConfigReader(provider: EnvironmentVariablesProvider()) +let httpTimeout = config.int(forKey: "http.timeout", default: 60) + +### Using multiple providers + +Create a hierarchy of providers by passing an array to the initializer. The reader queries providers in order, using the first non-nil value it finds: + +do { +let config = ConfigReader(providers: [\ +// First, check environment variables\ +EnvironmentVariablesProvider(),\ +// Then, check a JSON config file\ + +// Finally, fall \ +]) + +// Uses the first provider that has a value for "http.timeout" +let timeout = config.int(forKey: "http.timeout", default: 15) +} catch { +print("Failed to create JSON provider: \(error)") +} + +The `get` and `fetch` methods query providers sequentially, while the `watch` method monitors all providers in parallel and returns the first non-nil value from the latest results. + +### Creating scoped readers + +Create a scoped reader to access nested configuration sections without repeating key prefixes. This is useful for passing configuration to specific components. + +Given this JSON configuration: + +{ +"http": { +"timeout": 60 +} +} + +Create a scoped reader for the HTTP section: + +let httpConfig = config.scoped(to: "http") +let timeout = httpConfig.int(forKey: "timeout") // Reads "http.timeout" + +### Understanding config keys + +The library accesses configuration values using config keys that represent a hierarchical path to the value. Internally, the library represents a key as a list of string components, such as `["http", "timeout"]`. + +### Using configuration context + +Provide additional context to help providers return more specific values. In the following example with a configuration that includes repeated configurations per “upstream”, the value returned is potentially constrained to the configuration with the matching context: + +let httpTimeout = config.int( +forKey: ConfigKey("http.timeout", context: ["upstream": "example.com"]), +default: 60 +) + +Providers can use this context to return specialized values or fall + +The library can automatically convert string configuration values to other types using the `as:` parameter. This works with: + +- Types that you explicitly conform to `ExpressibleByConfigString`. + +- Built-in types that already conform to `ExpressibleByConfigString`: + +- `SystemPackage.FilePath` \- Converts from file paths. + +- `Foundation.URL` \- Converts from URL strings. + +- `Foundation.UUID` \- Converts from UUID strings. + +- `Foundation.Date` \- Converts from ISO8601 date strings. + +// Built-in type conversion +let apiUrl = config.string(forKey: "api.url", as: URL.self) +let requestId = config.string( +forKey: "request.id", +as: UUID.self +) + +enum LogLevel: String { +case debug, info, warning, error +} +let logLevel = config.string( +forKey: "logging.level", +as: LogLevel.self, +default: .info +) + +// Custom type conversion (ExpressibleByConfigString) +struct DatabaseURL: ExpressibleByConfigString { +let url: URL + +init?(configString: String) { +guard let url = URL(string: configString) else { return nil } +self.url = url +} + +var description: String { url.absoluteString } +} +let dbUrl = config.string( +forKey: "database.url", +as: DatabaseURL.self +) + +### How providers encode keys + +Each `ConfigProvider` interprets config keys according to its data source format. For example, `EnvironmentVariablesProvider` converts `["http", "timeout"]` to the environment variable name `HTTP_TIMEOUT` by uppercasing components and joining with underscores. + +### Monitoring configuration access + +Use an access reporter to track which configuration values your application reads. The reporter receives `AccessEvent` instances containing the requested key, calling code location, returned value, and source provider. + +This helps debug configuration issues and to discover the config dependencies in your codebase. + +### Protecting sensitive values + +Mark sensitive configuration values as secrets to prevent logging by access loggers. Both config readers and providers can set the `isSecret` property. When either marks a value as sensitive, `AccessReporter` instances should not log the raw value. + +### Configuration context + +Configuration context supplements the configuration key components with extra metadata that providers can use to refine value lookups or return more specific results. Context is particularly useful for scenarios where the same configuration key might need different values based on runtime conditions. + +Create context using dictionary literal syntax with automatic type inference: + +let context: [String: ConfigContextValue] = [\ +"environment": "production",\ +"region": "us-west-2",\ +"timeout": 30,\ +"retryEnabled": true\ +] + +#### Provider behavior + +Not all providers use context information. Providers that support context can: + +- Return specialized values based on context keys. + +- Fall , +default: "localhost:5432" +) + +### Error handling behavior + +The config reader handles provider errors differently based on the method type: + +- **Get and watch methods**: Gracefully handle errors by returning `nil` or default values, except for “required” variants which rethrow errors. + +- **Fetch methods**: Always rethrow both provider and conversion errors. + +- **Required methods**: Rethrow all errors without fallback behavior. + +The library reports all provider errors to the access reporter through the `providerResults` array, even when handled gracefully. + +## Topics + +### Creating config readers + +`init(provider: some ConfigProvider, accessReporter: (any AccessReporter)?)` + +Creates a config reader with a single provider. + +[`init(providers: [any ConfigProvider], accessReporter: (any AccessReporter)?)`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/init(providers:accessreporter:)) + +Creates a config reader with multiple providers. + +### Retrieving a scoped config reader + +Returns a scoped config reader with the specified key appended to the current prefix. + +### Reading from a snapshot + +Returns a snapshot of the current configuration state. + +Watches the configuration for changes. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Readers and providers + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`struct ConfigSnapshotReader` + +A container type for reading config values from snapshots. + +Choosing the access pattern + +Learn how to select the right method for reading configuration values based on your needs. + +Choosing reader methods + +Choose between optional, default, and required variants of configuration methods. + +Handling secrets correctly + +Protect sensitive configuration values from accidental disclosure in logs and debug output. + +- ConfigReader +- Mentioned in +- Overview +- Usage +- Using multiple providers +- Creating scoped readers +- Understanding config keys +- Using configuration context +- Automatic type conversion +- How providers encode keys +- Monitoring configuration access +- Protecting sensitive values +- Configuration context +- Error handling behavior +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfromstringdecoder + +- Configuration +- ConfigBytesFromStringDecoder + +Protocol + +# ConfigBytesFromStringDecoder + +A protocol for decoding string configuration values into byte arrays. + +protocol ConfigBytesFromStringDecoder : Sendable + +ConfigBytesFromStringDecoder.swift + +## Overview + +This protocol defines the interface for converting string-based configuration values into binary data. Different implementations can support various encoding formats such as base64, hexadecimal, or other custom encodings. + +## Usage + +Implementations of this protocol are used by configuration providers that need to convert string values to binary data, such as cryptographic keys, certificates, or other binary configuration data. + +let decoder: ConfigBytesFromStringDecoder = .base64 +let bytes = decoder.decode("SGVsbG8gV29ybGQ=") // "Hello World" in base64 + +## Topics + +### Required methods + +Decodes a string value into an array of bytes. + +**Required** + +### Built-in decoders + +`static var base64: ConfigBytesFromBase64StringDecoder` + +A decoder that interprets string values as base64-encoded data. + +`static var hex: ConfigBytesFromHexStringDecoder` + +A decoder that interprets string values as hexadecimal-encoded data. + +## Relationships + +### Inherits From + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +### Conforming Types + +- `ConfigBytesFromBase64StringDecoder` +- `ConfigBytesFromHexStringDecoder` + +## See Also + +### Value conversion + +`protocol ExpressibleByConfigString` + +A protocol for types that can be initialized from configuration string values. + +`struct ConfigBytesFromBase64StringDecoder` + +A decoder that converts base64-encoded strings into byte arrays. + +`struct ConfigBytesFromHexStringDecoder` + +A decoder that converts hexadecimal-encoded strings into byte arrays. + +- ConfigBytesFromStringDecoder +- Overview +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfrombase64stringdecoder + +- Configuration +- ConfigBytesFromBase64StringDecoder + +Structure + +# ConfigBytesFromBase64StringDecoder + +A decoder that converts base64-encoded strings into byte arrays. + +struct ConfigBytesFromBase64StringDecoder + +ConfigBytesFromStringDecoder.swift + +## Overview + +This decoder interprets string configuration values as base64-encoded data and converts them to their binary representation. + +## Topics + +### Creating bytes from a base64 string + +`init()` + +Creates a new base64 decoder. + +## Relationships + +### Conforms To + +- `ConfigBytesFromStringDecoder` +- `Swift.Copyable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Value conversion + +`protocol ExpressibleByConfigString` + +A protocol for types that can be initialized from configuration string values. + +`protocol ConfigBytesFromStringDecoder` + +A protocol for decoding string configuration values into byte arrays. + +`struct ConfigBytesFromHexStringDecoder` + +A decoder that converts hexadecimal-encoded strings into byte arrays. + +- ConfigBytesFromBase64StringDecoder +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype + +- Configuration +- ConfigType + +Enumeration + +# ConfigType + +The supported configuration value types. + +@frozen +enum ConfigType + +ConfigProvider.swift + +## Topics + +### Types of configuration content + +`case string` + +A string value. + +`case stringArray` + +An array of string values. + +`case bool` + +A Boolean value. + +`case boolArray` + +An array of Boolean values. + +`case int` + +An integer value. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +### Initializers + +`init?(rawValue: String)` + +## Relationships + +### Conforms To + +- `Swift.BitwiseCopyable` +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.RawRepresentable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`struct LookupResult` + +The result of looking up a configuration value in a provider. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- ConfigType +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent + +- Configuration +- AccessEvent + +Structure + +# AccessEvent + +An event that captures information about accessing a configuration value. + +struct AccessEvent + +AccessReporter.swift + +## Overview + +Access events are generated whenever configuration values are accessed through `ConfigReader` and `ConfigSnapshotReader` methods. They contain metadata about the access, results from individual providers, and the final outcome of the operation. + +## Topics + +### Creating an access event + +Creates a configuration access event. + +`struct Metadata` + +Metadata describing the configuration access operation. + +`struct ProviderResult` + +The result of a configuration lookup from a specific provider. + +### Inspecting an access event + +The final outcome of the configuration access operation. + +`var conversionError: (any Error)?` + +An error that occurred when converting the raw config value into another type, for example `RawRepresentable`. + +`var metadata: AccessEvent.Metadata` + +Metadata that describes the configuration access operation. + +[`var providerResults: [AccessEvent.ProviderResult]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/providerresults) + +The results from each configuration provider that was queried. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Troubleshooting and access reporting + +Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +`protocol AccessReporter` + +A type that receives and processes configuration access events. + +`class AccessLogger` + +An access reporter that logs configuration access events using the Swift Log API. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct BroadcastingAccessReporter` + +An access reporter that forwards events to multiple other reporters. + +- AccessEvent +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/broadcastingaccessreporter + +- Configuration +- BroadcastingAccessReporter + +Structure + +# BroadcastingAccessReporter + +An access reporter that forwards events to multiple other reporters. + +struct BroadcastingAccessReporter + +AccessReporter.swift + +## Overview + +Use this reporter to send configuration access events to multiple destinations simultaneously. Each upstream reporter receives a copy of every event in the order they were provided during initialization. + +let fileLogger = try FileAccessLogger(filePath: "/tmp/config.log") +let accessLogger = AccessLogger(logger: logger) +let broadcaster = BroadcastingAccessReporter(upstreams: [fileLogger, accessLogger]) + +let config = ConfigReader( +provider: EnvironmentVariablesProvider(), +accessReporter: broadcaster +) + +## Topics + +### Creating a broadcasting access reporter + +[`init(upstreams: [any AccessReporter])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/broadcastingaccessreporter/init(upstreams:)) + +Creates a new broadcasting access reporter. + +## Relationships + +### Conforms To + +- `AccessReporter` +- `Swift.Copyable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Troubleshooting and access reporting + +Troubleshooting and access reporting + +Check out some techniques to debug unexpected issues and to increase visibility into accessed config values. + +`protocol AccessReporter` + +A type that receives and processes configuration access events. + +`class AccessLogger` + +An access reporter that logs configuration access events using the Swift Log API. + +`class FileAccessLogger` + +An access reporter that writes configuration access events to a file. + +`struct AccessEvent` + +An event that captures information about accessing a configuration value. + +- BroadcastingAccessReporter +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/lookupresult + +- Configuration +- LookupResult + +Structure + +# LookupResult + +The result of looking up a configuration value in a provider. + +struct LookupResult + +ConfigProvider.swift + +## Overview + +Providers return this result from value lookup methods, containing both the encoded key used for the lookup and the value found: + +let result = try provider.value(forKey: key, type: .string) +if let value = result.value { +print("Found: \(value)") +} + +## Topics + +### Creating a lookup result + +`init(encodedKey: String, value: ConfigValue?)` + +Creates a lookup result. + +### Inspecting a lookup result + +`var encodedKey: String` + +The provider-specific encoding of the configuration key. + +`var value: ConfigValue?` + +The configuration value found for the key, or nil if not found. + +## Relationships + +### Conforms To + +- `Swift.Equatable` +- `Swift.Hashable` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a custom provider + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +`protocol FileParsingOptions` + +A type that provides parsing options for file configuration snapshots. + +`protocol ConfigProvider` + +A type that provides configuration values from a data source. + +`enum ConfigContent` + +The raw content of a configuration value. + +`struct ConfigValue` + +A configuration value that wraps content with metadata. + +`enum ConfigType` + +The supported configuration value types. + +`enum SecretsSpecifier` + +A specification for identifying which configuration values contain sensitive information. + +`struct ConfigUpdatesAsyncSequence` + +A concrete async sequence for delivering updated configuration values. + +- LookupResult +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/proposals + +- Configuration +- Proposals + +# Proposals + +Collaborate on API changes to Swift Configuration by writing a proposal. + +## Overview + +For non-trivial changes that affect the public API, the Swift Configuration project adopts a lightweight version of the Swift Evolution process. + +Writing a proposal first helps discuss multiple possible solutions early, apply useful feedback from other contributors, and avoid reimplementing the same feature multiple times. + +While it’s encouraged to get feedback by opening a pull request with a proposal early in the process, it’s also important to consider the complexity of the implementation when evaluating different solutions. For example, this might mean including a link to a branch containing a prototype implementation of the feature in the pull request description. + +### Steps + +1. Make sure there’s a GitHub issue for the feature or change you would like to propose. + +2. Duplicate the `SCO-NNNN.md` document and replace `NNNN` with the next available proposal number. + +3. Link the GitHub issue from your proposal, and fill in the proposal. + +4. Open a pull request with your proposal and solicit feedback from other contributors. + +5. Once a maintainer confirms that the proposal is ready for review, the state is updated accordingly. The review period is 7 days, and ends when one of the maintainers marks the proposal as Ready for Implementation, or Deferred. + +6. Before the pull request is merged, there should be an implementation ready, either in the same pull request, or a separate one, linked from the proposal. + +7. The proposal is considered Approved once the implementation, proposal PRs have been merged, and, if originally disabled by a feature flag, feature flag enabled unconditionally. + +If you have any questions, ask in an issue on GitHub. + +### Possible review states + +- Awaiting Review + +- In Review + +- Ready for Implementation + +- In Preview + +- Approved + +- Deferred + +## Topics + +SCO-NNNN: Feature name + +Feature abstract – a one sentence summary. + +SCO-0001: Generic file providers + +Introduce format-agnostic providers to simplify implementing additional file formats beyond JSON and YAML. + +SCO-0002: Remove custom key decoders + +Remove the custom key decoder feature to fix a flaw and simplify the project + +SCO-0003: Allow missing files in file providers + +Add an `allowMissing` parameter to file-based providers to handle missing configuration files gracefully. + +## See Also + +### Contributing + +Developing Swift Configuration + +Learn about tools and conventions used to develop the Swift Configuration package. + +- Proposals +- Overview +- Steps +- Possible review states +- Topics +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/inmemoryprovider + +- Configuration +- InMemoryProvider + +Structure + +# InMemoryProvider + +A configuration provider that stores values in memory. + +struct InMemoryProvider + +InMemoryProvider.swift + +## Mentioned in + +Using in-memory providers + +Configuring applications + +Example use cases + +## Overview + +This provider maintains a static dictionary of configuration values in memory, making it ideal for providing default values, overrides, or test configurations. Values are immutable once the provider is created and never change over time. + +## Use cases + +The in-memory provider is particularly useful for: + +- **Default configurations**: Providing fallback values when other providers don’t have a value + +- **Configuration overrides**: Taking precedence over other providers + +- **Testing**: Creating predictable configuration states for unit tests + +- **Static configurations**: Embedding compile-time configuration values + +## Value types + +The provider supports all standard configuration value types and automatically handles type validation. Values must match the requested type exactly - no automatic conversion is performed - for example, requesting a `String` value for a key that stores an `Int` value will throw an error. + +## Performance characteristics + +This provider offers O(1) lookup time and performs no I/O operations. All values are stored in memory. + +## Usage + +let provider = InMemoryProvider(values: [\ +"http.client.user-agent": "Config/1.0 (Test)",\ +"http.client.timeout": 15.0,\ +"http.secret": ConfigValue("s3cret", isSecret: true),\ +"http.version": 2,\ +"enabled": true\ +]) +// Prints all values, redacts "http.secret" automatically. +print(provider) +let config = ConfigReader(provider: provider) +let isEnabled = config.bool(forKey: "enabled", default: false) + +To learn more about the in-memory providers, check out Using in-memory providers. + +## Topics + +### Creating an in-memory provider + +[`init(name: String?, values: [AbsoluteConfigKey : ConfigValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/inmemoryprovider/init(name:values:)) + +Creates a new in-memory provider with the specified configuration values. + +## Relationships + +### Conforms To + +- `ConfigProvider` +- `Swift.Copyable` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Built-in providers + +`struct EnvironmentVariablesProvider` + +A configuration provider that sources values from environment variables. + +`struct CommandLineArgumentsProvider` + +A configuration provider that sources values from command-line arguments. + +`struct FileProvider` + +A configuration provider that reads from a file on disk using a configurable snapshot type. + +`class ReloadingFileProvider` + +A configuration provider that reads configuration from a file on disk with automatic reloading capability. + +`struct JSONSnapshot` + +A snapshot of configuration values parsed from JSON data. + +`class YAMLSnapshot` + +A snapshot of configuration values parsed from YAML data. + +Using reloading providers + +Automatically reload configuration from files when they change. + +`struct DirectoryFilesProvider` + +A configuration provider that reads values from individual files in a directory. + +Learn about the `InMemoryProvider` and `MutableInMemoryProvider` built-in types. + +`class MutableInMemoryProvider` + +A configuration provider that stores mutable values in memory. + +`struct KeyMappingProvider` + +A configuration provider that maps all keys before delegating to an upstream provider. + +- InMemoryProvider +- Mentioned in +- Overview +- Use cases +- Value types +- Performance characteristics +- Usage +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configuring-libraries + +- Configuration +- Configuring libraries + +Article + +# Configuring libraries + +Provide a consistent and flexible way to configure your library. + +## Overview + +Swift Configuration provides a pattern for configuring libraries that works across various configuration sources: environment variables, JSON files, and remote configuration services. + +This guide shows how to adopt this pattern in your library to make it easier to compose in larger applications. + +Adopt this pattern in three steps: + +1. Define your library’s configuration as a dedicated type (you might already have such a type in your library). + +2. Add a convenience method that accepts a `ConfigReader` \- can be an initializer, or a method that updates your configuration. + +3. Extract the individual configuration values using the provided reader. + +This approach makes your library configurable regardless of the user’s chosen configuration source and composes well with other libraries. + +### Define your configuration type + +Start by defining a type that encapsulates all the configuration options for your library. + +/// Configuration options for a hypothetical HTTPClient. +public struct HTTPClientConfiguration { +/// The timeout for network requests in seconds. +public var timeout: Double + +/// The maximum number of concurrent connections. +public var maxConcurrentConnections: Int + +/// Base URL for API requests. +public var baseURL: String + +/// Whether to enable debug logging. +public var debugLogging: Bool + +/// Create a configuration with explicit values. +public init( +timeout: Double = 30.0, +maxConcurrentConnections: Int = 5, +baseURL: String = "https://api.example.com", +debugLogging: Bool = false +) { +self.timeout = timeout +self.maxConcurrentConnections = maxConcurrentConnections +self.baseURL = baseURL +self.debugLogging = debugLogging +} +} + +### Add a convenience method + +Next, extend your configuration type to provide a method that accepts a `ConfigReader` as a parameter. In the example below, we use an initializer. + +extension HTTPClientConfiguration { +/// Creates a new HTTP client configuration using values from the provided reader. +/// +/// ## Configuration keys +/// - `timeout` (double, optional, default: `30.0`): The timeout for network requests in seconds. +/// - `maxConcurrentConnections` (int, optional, default: `5`): The maximum number of concurrent connections. +/// - `baseURL` (string, optional, default: `"https://api.example.com"`): Base URL for API requests. +/// - `debugLogging` (bool, optional, default: `false`): Whether to enable debug logging. +/// +/// - Parameter config: The config reader to read configuration values from. +public init(config: ConfigReader) { +self.timeout = config.double(forKey: "timeout", default: 30.0) +self.maxConcurrentConnections = config.int(forKey: "maxConcurrentConnections", default: 5) +self.baseURL = config.string(forKey: "baseURL", default: "https://api.example.com") +self.debugLogging = config.bool(forKey: "debugLogging", default: false) +} +} + +### Example: Adopting your library + +Once you’ve made your library configurable, users can easily configure it from various sources. Here’s how someone might configure your library using environment variables: + +import Configuration +import YourHTTPLibrary + +// Create a config reader from environment variables. +let config = ConfigReader(provider: EnvironmentVariablesProvider()) + +// Initialize your library's configuration from a config reader. +let httpConfig = HTTPClientConfiguration(config: config) + +// Create your library instance with the configuration. +let httpClient = HTTPClient(configuration: httpConfig) + +// Start using your library. +httpClient.get("/users") { response in +// Handle the response. +} + +With this approach, users can configure your library by setting environment variables that match your config keys: + +# Set configuration for your library through environment variables. +export TIMEOUT=60.0 +export MAX_CONCURRENT_CONNECTIONS=10 +export BASE_URL="https://api.production.com" +export DEBUG_LOGGING=true + +Your library now adapts to the user’s environment without any code changes. + +### Working with secrets + +Mark configuration values that contain sensitive information as secret to prevent them from being logged: + +extension HTTPClientConfiguration { +public init(config: ConfigReader) throws { +self.apiKey = try config.requiredString(forKey: "apiKey", isSecret: true) +// Other configuration... +} +} + +Built-in `AccessReporter` types such as `AccessLogger` and `FileAccessLogger` automatically redact secret values to avoid leaking sensitive information. + +For more guidance on secrets handling, see Handling secrets correctly. For more configuration guidance, check out Adopting best practices. To understand different access patterns and reader methods, refer to Choosing the access pattern and Choosing reader methods. + +## See Also + +### Essentials + +Configuring applications + +Provide flexible and consistent configuration for your application. + +Example use cases + +Review common use cases with ready-to-copy code samples. + +Adopting best practices + +Follow these principles to make your code easily configurable and composable with other libraries. + +- Configuring libraries +- Overview +- Define your configuration type +- Add a convenience method +- Example: Adopting your library +- Working with secrets +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/configsnapshot-implementations + +- Configuration +- YAMLSnapshot +- ConfigSnapshot Implementations + +API Collection + +# ConfigSnapshot Implementations + +## Topics + +### Instance Methods + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/init(data:providername:parsingoptions:) + +#app-main) + +- Configuration +- YAMLSnapshot +- init(data:providerName:parsingOptions:) + +Initializer + +# init(data:providerName:parsingOptions:) + +Inherited from `FileConfigSnapshot.init(data:providerName:parsingOptions:)`. + +convenience init( +data: RawSpan, +providerName: String, +parsingOptions: YAMLSnapshot.ParsingOptions +) throws + +YAMLSnapshot.swift + +## See Also + +### Creating a YAML snapshot + +`struct ParsingOptions` + +Custom input configuration for YAML snapshot creation. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/parsingoptions + +- Configuration +- YAMLSnapshot +- YAMLSnapshot.ParsingOptions + +Structure + +# YAMLSnapshot.ParsingOptions + +Custom input configuration for YAML snapshot creation. + +struct ParsingOptions + +YAMLSnapshot.swift + +## Overview + +This struct provides configuration options for parsing YAML data into configuration snapshots, including byte decoding and secrets specification. + +## Topics + +### Initializers + +Creates custom input configuration for YAML snapshots. + +### Instance Properties + +`var bytesDecoder: any ConfigBytesFromStringDecoder` + +A decoder of bytes from a string. + +A specifier for determining which configuration values should be treated as secrets. + +### Type Properties + +``static var `default`: YAMLSnapshot.ParsingOptions`` + +The default custom input configuration. + +## Relationships + +### Conforms To + +- `FileParsingOptions` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a YAML snapshot + +`convenience init(data: RawSpan, providerName: String, parsingOptions: YAMLSnapshot.ParsingOptions) throws` + +- YAMLSnapshot.ParsingOptions +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configurationtesting/providercompattest + +- ConfigurationTesting +- ProviderCompatTest + +Structure + +# ProviderCompatTest + +A comprehensive test suite for validating `ConfigProvider` implementations. + +struct ProviderCompatTest + +ProviderCompatTest.swift + +## Overview + +This test suite verifies that configuration providers correctly implement all required functionality including synchronous and asynchronous value retrieval, snapshot operations, and value watching capabilities. + +## Usage + +Create a test instance with your provider and run the compatibility tests: + +let provider = MyCustomProvider() +let test = ProviderCompatTest(provider: provider) +try await test.runTest() + +## Required Test Data + +The provider under test must be populated with specific test values to ensure comprehensive validation. The required configuration data includes: + +\ +"string": String("Hello"),\ +"other.string": String("Other Hello"),\ +"int": Int(42),\ +"other.int": Int(24),\ +"double": Double(3.14),\ +"other.double": Double(2.72),\ +"bool": Bool(true),\ +"other.bool": Bool(false),\ +"bytes": [UInt8,\ +"other.bytes": UInt8,\ +"stringy.array": String,\ +"other.stringy.array": String,\ +"inty.array": Int,\ +"other.inty.array": Int,\ +"doubly.array": Double,\ +"other.doubly.array": Double,\ +"booly.array": Bool,\ +"other.booly.array": Bool,\ +"byteChunky.array": [[UInt8]]([.magic, .magic2]),\ +"other.byteChunky.array": [[UInt8]]([.magic, .magic2, .magic]),\ +] + +## Topics + +### Structures + +`struct TestConfiguration` + +Configuration options for customizing test behavior. + +### Initializers + +`init(provider: any ConfigProvider, configuration: ProviderCompatTest.TestConfiguration)` + +Creates a new compatibility test suite. + +### Instance Methods + +`func runTest() async throws` + +Executes the complete compatibility test suite. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +- ProviderCompatTest +- Overview +- Usage +- Required Test Data +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileconfigsnapshot + +- Configuration +- FileConfigSnapshot + +Protocol + +# FileConfigSnapshot + +A protocol for configuration snapshots created from file data. + +protocol FileConfigSnapshot : ConfigSnapshot, CustomDebugStringConvertible, CustomStringConvertible + +FileProviderSnapshot.swift + +## Overview + +This protocol extends `ConfigSnapshot` to provide file-specific functionality for creating configuration snapshots from raw file data. Types conforming to this protocol can parse various file formats (such as JSON and YAML) and convert them into configuration values. + +Commonly used with `FileProvider` and `ReloadingFileProvider`. + +## Implementation + +To create a custom file configuration snapshot: + +struct MyFormatSnapshot: FileConfigSnapshot { +typealias ParsingOptions = MyParsingOptions + +let values: [String: ConfigValue] +let providerName: String + +init(data: RawSpan, providerName: String, parsingOptions: MyParsingOptions) throws { +self.providerName = providerName +// Parse the data according to your format +self.values = try parseMyFormat(data, using: parsingOptions) +} +} + +The snapshot is responsible for parsing the file data and converting it into a representation of configuration values that can be queried by the configuration system. + +## Topics + +### Required methods + +`init(data: RawSpan, providerName: String, parsingOptions: Self.ParsingOptions) throws` + +Creates a new snapshot from file data. + +**Required** + +`associatedtype ParsingOptions : FileParsingOptions` + +The parsing options type used for parsing this snapshot. + +### Protocol requirements + +`protocol ConfigSnapshot` + +An immutable snapshot of a configuration provider’s state. + +## Relationships + +### Inherits From + +- `ConfigSnapshot` +- `Swift.CustomDebugStringConvertible` +- `Swift.CustomStringConvertible` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +### Conforming Types + +- `JSONSnapshot` +- `YAMLSnapshot` + +- FileConfigSnapshot +- Overview +- Implementation +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/providername + +- Configuration +- YAMLSnapshot +- providerName + +Instance Property + +# providerName + +The name of the provider that created this snapshot. + +let providerName: String + +YAMLSnapshot.swift + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/customdebugstringconvertible-implementations + +- Configuration +- YAMLSnapshot +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/customstringconvertible-implementations + +- Configuration +- YAMLSnapshot +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/fileconfigsnapshot-implementations + +- Configuration +- YAMLSnapshot +- FileConfigSnapshot Implementations + +API Collection + +# FileConfigSnapshot Implementations + +## Topics + +### Initializers + +`convenience init(data: RawSpan, providerName: String, parsingOptions: YAMLSnapshot.ParsingOptions) throws` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accesslogger/accessreporter-implementations + +- Configuration +- AccessLogger +- AccessReporter Implementations + +API Collection + +# AccessReporter Implementations + +## Topics + +### Instance Methods + +`func report(AccessEvent)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/init(data:providername:parsingoptions:) + +#app-main) + +- Configuration +- JSONSnapshot +- init(data:providerName:parsingOptions:) + +Initializer + +# init(data:providerName:parsingOptions:) + +Inherited from `FileConfigSnapshot.init(data:providerName:parsingOptions:)`. + +init( +data: RawSpan, +providerName: String, +parsingOptions: JSONSnapshot.ParsingOptions +) throws + +JSONSnapshot.swift + +## See Also + +### Creating a JSON snapshot + +`struct ParsingOptions` + +Parsing options for JSON snapshot creation. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/customstringconvertible-implementations + +- Configuration +- JSONSnapshot +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/parsingoptions + +- Configuration +- JSONSnapshot +- JSONSnapshot.ParsingOptions + +Structure + +# JSONSnapshot.ParsingOptions + +Parsing options for JSON snapshot creation. + +struct ParsingOptions + +JSONSnapshot.swift + +## Overview + +This struct provides configuration options for parsing JSON data into configuration snapshots, including byte decoding and secrets specification. + +## Topics + +### Initializers + +Creates parsing options for JSON snapshots. + +### Instance Properties + +`var bytesDecoder: any ConfigBytesFromStringDecoder` + +A decoder of bytes from a string. + +A specifier for determining which configuration values should be treated as secrets. + +### Type Properties + +``static var `default`: JSONSnapshot.ParsingOptions`` + +The default parsing options. + +## Relationships + +### Conforms To + +- `FileParsingOptions` +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating a JSON snapshot + +`init(data: RawSpan, providerName: String, parsingOptions: JSONSnapshot.ParsingOptions) throws` + +- JSONSnapshot.ParsingOptions +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/customdebugstringconvertible-implementations + +- Configuration +- JSONSnapshot +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/run() + +#app-main) + +- Configuration +- ReloadingFileProvider +- run() + +Instance Method + +# run() + +Inherited from `Service.run()`. + +func run() async throws + +ReloadingFileProvider.swift + +Available when `Snapshot` conforms to `FileConfigSnapshot`. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/providername + +- Configuration +- JSONSnapshot +- providerName + +Instance Property + +# providerName + +The name of the provider that created this snapshot. + +let providerName: String + +JSONSnapshot.swift + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/fileconfigsnapshot-implementations + +- Configuration +- JSONSnapshot +- FileConfigSnapshot Implementations + +API Collection + +# FileConfigSnapshot Implementations + +## Topics + +### Initializers + +`init(data: RawSpan, providerName: String, parsingOptions: JSONSnapshot.ParsingOptions) throws` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accesslogger/init(logger:level:message:) + +#app-main) + +- Configuration +- AccessLogger +- init(logger:level:message:) + +Initializer + +# init(logger:level:message:) + +Creates a new access logger that reports configuration access events. + +init( +logger: Logger, +level: Logger.Level = .debug, +message: Logger.Message = "Config value accessed" +) + +AccessLogger.swift + +## Parameters + +`logger` + +The logger to emit access events to. + +`level` + +The log level for access events. Defaults to `.debug`. + +`message` + +The static message text for log entries. Defaults to “Config value accessed”. + +## Discussion + +let logger = Logger(label: "my.app.config") + +// Log at debug level by default +let accessLogger = AccessLogger(logger: logger) + +// Customize the log level +let accessLogger = AccessLogger(logger: logger, level: .info) + +- init(logger:level:message:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/providername + +- Configuration +- ReloadingFileProvider +- providerName + +Instance Property + +# providerName + +The human-readable name of the provider. + +let providerName: String + +ReloadingFileProvider.swift + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/jsonsnapshot/configsnapshot-implementations + +- Configuration +- JSONSnapshot +- ConfigSnapshot Implementations + +API Collection + +# ConfigSnapshot Implementations + +## Topics + +### Instance Methods + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/init(snapshottype:parsingoptions:filepath:allowmissing:pollinterval:logger:metrics:) + +#app-main) + +- Configuration +- ReloadingFileProvider +- init(snapshotType:parsingOptions:filePath:allowMissing:pollInterval:logger:metrics:) + +Initializer + +# init(snapshotType:parsingOptions:filePath:allowMissing:pollInterval:logger:metrics:) + +Creates a reloading file provider that monitors the specified file path. + +convenience init( +snapshotType: Snapshot.Type = Snapshot.self, +parsingOptions: Snapshot.ParsingOptions = .default, +filePath: FilePath, +allowMissing: Bool = false, +pollInterval: Duration = .seconds(15), +logger: Logger = Logger(label: "ReloadingFileProvider"), +metrics: any MetricsFactory = MetricsSystem.factory +) async throws + +ReloadingFileProvider.swift + +## Parameters + +`snapshotType` + +The type of snapshot to create from the file contents. + +`parsingOptions` + +Options used by the snapshot to parse the file data. + +`filePath` + +The path to the configuration file to monitor. + +`allowMissing` + +A flag controlling how the provider handles a missing file. + +- When `false` (the default), if the file is missing or malformed, throws an error. + +- When `true`, if the file is missing, treats it as empty. Malformed files still throw an error. + +`pollInterval` + +How often to check for file changes. + +`logger` + +The logger instance to use for this provider. + +`metrics` + +The metrics factory to use for monitoring provider performance. + +## Discussion + +## See Also + +### Creating a reloading file provider + +`convenience init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, config: ConfigReader, logger: Logger, metrics: any MetricsFactory) async throws` + +Creates a reloading file provider using configuration from a reader. + +- init(snapshotType:parsingOptions:filePath:allowMissing:pollInterval:logger:metrics:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/customdebugstringconvertible-implementations + +- Configuration +- ReloadingFileProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/customstringconvertible-implementations + +- Configuration +- ReloadingFileProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider/init(snapshottype:parsingoptions:config:) + +#app-main) + +- Configuration +- FileProvider +- init(snapshotType:parsingOptions:config:) + +Initializer + +# init(snapshotType:parsingOptions:config:) + +Creates a file provider using a file path from a configuration reader. + +init( +snapshotType: Snapshot.Type = Snapshot.self, +parsingOptions: Snapshot.ParsingOptions = .default, +config: ConfigReader +) async throws + +FileProvider.swift + +## Parameters + +`snapshotType` + +The type of snapshot to create from the file contents. + +`parsingOptions` + +Options used by the snapshot to parse the file data. + +`config` + +A configuration reader that contains the required configuration keys. + +## Discussion + +This initializer reads the file path from the provided configuration reader and creates a snapshot from that file. + +## Configuration keys + +- `filePath` (string, required): The path to the configuration file to read. + +- `allowMissing` (bool, optional, default: false): A flag controlling how the provider handles a missing file. When `false` (the default), if the file is missing or malformed, throws an error. When `true`, if the file is missing, treats it as empty. Malformed files still throw an error. + +## See Also + +### Creating a file provider + +`init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, filePath: FilePath, allowMissing: Bool) async throws` + +Creates a file provider that reads from the specified file path. + +- init(snapshotType:parsingOptions:config:) +- Parameters +- Discussion +- Configuration keys +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider/customstringconvertible-implementations + +- Configuration +- FileProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider/customdebugstringconvertible-implementations + +- Configuration +- FileProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider/init(snapshottype:parsingoptions:filepath:allowmissing:) + +#app-main) + +- Configuration +- FileProvider +- init(snapshotType:parsingOptions:filePath:allowMissing:) + +Initializer + +# init(snapshotType:parsingOptions:filePath:allowMissing:) + +Creates a file provider that reads from the specified file path. + +init( +snapshotType: Snapshot.Type = Snapshot.self, +parsingOptions: Snapshot.ParsingOptions = .default, +filePath: FilePath, +allowMissing: Bool = false +) async throws + +FileProvider.swift + +## Parameters + +`snapshotType` + +The type of snapshot to create from the file contents. + +`parsingOptions` + +Options used by the snapshot to parse the file data. + +`filePath` + +The path to the configuration file to read. + +`allowMissing` + +A flag controlling how the provider handles a missing file. + +- When `false` (the default), if the file is missing or malformed, throws an error. + +- When `true`, if the file is missing, treats it as empty. Malformed files still throw an error. + +## Discussion + +This initializer reads the file at the given path and creates a snapshot using the specified snapshot type. The file is read once during initialization. + +## See Also + +### Creating a file provider + +`init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, config: ConfigReader) async throws` + +Creates a file provider using a file path from a configuration reader. + +- init(snapshotType:parsingOptions:filePath:allowMissing:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/configprovider-implementations + +- Configuration +- ReloadingFileProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/init(environmentvariables:secretsspecifier:bytesdecoder:arrayseparator:) + +#app-main) + +- Configuration +- EnvironmentVariablesProvider +- init(environmentVariables:secretsSpecifier:bytesDecoder:arraySeparator:) + +Initializer + +# init(environmentVariables:secretsSpecifier:bytesDecoder:arraySeparator:) + +Creates a new provider from a custom dictionary of environment variables. + +init( +environmentVariables: [String : String], + +bytesDecoder: some ConfigBytesFromStringDecoder = .base64, +arraySeparator: Character = "," +) + +EnvironmentVariablesProvider.swift + +## Parameters + +`environmentVariables` + +A dictionary of environment variable names and values. + +`secretsSpecifier` + +Specifies which environment variables should be treated as secrets. + +`bytesDecoder` + +The decoder used for converting string values to byte arrays. + +`arraySeparator` + +The character used to separate elements in array values. + +## Discussion + +This initializer allows you to provide a custom set of environment variables, which is useful for testing or when you want to override specific values. + +let customEnvironment = [\ +"DATABASE_HOST": "localhost",\ +"DATABASE_PORT": "5432",\ +"API_KEY": "secret-key"\ +] +let provider = EnvironmentVariablesProvider( +environmentVariables: customEnvironment, +secretsSpecifier: .specific(["API_KEY"]) +) + +## See Also + +### Creating an environment variable provider + +Creates a new provider that reads from the current process environment. + +Creates a new provider that reads from an environment file. + +- init(environmentVariables:secretsSpecifier:bytesDecoder:arraySeparator:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/context + +- Configuration +- AbsoluteConfigKey +- context + +Instance Property + +# context + +Additional context information for this configuration key. + +var context: [String : ConfigContextValue] + +ConfigKey.swift + +## Discussion + +Context provides extra information that providers can use to refine lookups or return more specific values. Not all providers use context information. + +## See Also + +### Inspecting an absolute configuration key + +[`var components: [String]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/components) + +The hierarchical components that make up this absolute configuration key. + +- context +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/commandlineargumentsprovider/customstringconvertible-implementations + +- Configuration +- CommandLineArgumentsProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/watchint(forkey:issecret:fileid:line:updateshandler:) + +#app-main) + +- Configuration +- ConfigReader +- watchInt(forKey:isSecret:fileID:line:updatesHandler:) + +Instance Method + +# watchInt(forKey:isSecret:fileID:line:updatesHandler:) + +Watches for updates to a config value for the given config key. + +forKey key: ConfigKey, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line, + +ConfigReader+methods.swift + +## Parameters + +`key` + +The config key to watch. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +`updatesHandler` + +A closure that handles an async sequence of updates to the value. The sequence produces `nil` if the value is missing or can’t be converted. + +## Return Value + +The result produced by the handler. + +## Mentioned in + +Example use cases + +## Discussion + +Use this method to observe changes to optional configuration values over time. The handler receives an async sequence that produces the current value whenever it changes, or `nil` if the value is missing or can’t be converted. + +try await config.watchInt(forKey: ["server", "port"]) { updates in +for await port in updates { +if let port = port { +print("Server port is: \(port)") +} else { +print("No server port configured") +} +} +} + +## See Also + +### Watching integer values + +Watches for updates to a config value for the given config key with default fallback. + +- watchInt(forKey:isSecret:fileID:line:updatesHandler:) +- Parameters +- Return Value +- Mentioned in +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/service-implementations + +- Configuration +- ReloadingFileProvider +- Service Implementations + +API Collection + +# Service Implementations + +## Topics + +### Instance Methods + +`func run() async throws` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/customstringconvertible-implementations + +- Configuration +- ConfigKey +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-6vten + +-6vten#app-main) + +- Configuration +- ConfigKey +- init(\_:context:) + +Initializer + +# init(\_:context:) + +Creates a new configuration key. + +init( +_ string: String, +context: [String : ConfigContextValue] = [:] +) + +ConfigKey.swift + +## Parameters + +`string` + +The string representation of the key path, for example `"http.timeout"`. + +`context` + +Additional context information for the key. + +## See Also + +### Creating a configuration key + +[`init([String], context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-9ifez) + +- init(\_:context:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/environmentvalue(forname:) + +#app-main) + +- Configuration +- EnvironmentVariablesProvider +- environmentValue(forName:) + +Instance Method + +# environmentValue(forName:) + +Returns the raw string value for a specific environment variable name. + +EnvironmentVariablesProvider.swift + +## Parameters + +`name` + +The exact name of the environment variable to retrieve. + +## Return Value + +The string value of the environment variable, or nil if not found. + +## Discussion + +This method provides direct access to environment variable values by name, without any key transformation or type conversion. It’s useful when you need to access environment variables that don’t follow the standard configuration key naming conventions. + +let provider = EnvironmentVariablesProvider() +let path = try provider.environmentValue(forName: "PATH") +let home = try provider.environmentValue(forName: "HOME") + +- environmentValue(forName:) +- Parameters +- Return Value +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/init(environmentfilepath:allowmissing:secretsspecifier:bytesdecoder:arrayseparator:) + +#app-main) + +- Configuration +- EnvironmentVariablesProvider +- init(environmentFilePath:allowMissing:secretsSpecifier:bytesDecoder:arraySeparator:) + +Initializer + +# init(environmentFilePath:allowMissing:secretsSpecifier:bytesDecoder:arraySeparator:) + +Creates a new provider that reads from an environment file. + +init( +environmentFilePath: FilePath, +allowMissing: Bool = false, + +bytesDecoder: some ConfigBytesFromStringDecoder = .base64, +arraySeparator: Character = "," +) async throws + +EnvironmentVariablesProvider.swift + +## Parameters + +`environmentFilePath` + +The file system path to the environment file to load. + +`allowMissing` + +A flag controlling how the provider handles a missing file. + +- When `false` (the default), if the file is missing or malformed, throws an error. + +- When `true`, if the file is missing, treats it as empty. Malformed files still throw an error. + +`secretsSpecifier` + +Specifies which environment variables should be treated as secrets. + +`bytesDecoder` + +The decoder used for converting string values to byte arrays. + +`arraySeparator` + +The character used to separate elements in array values. + +## Discussion + +This initializer loads environment variables from an `.env` file at the specified path. The file should contain key-value pairs in the format `KEY=value`, one per line. Comments (lines starting with `#`) and empty lines are ignored. + +// Load from a .env file +let provider = try await EnvironmentVariablesProvider( +environmentFilePath: ".env", +allowMissing: true, +secretsSpecifier: .specific(["API_KEY"]) +) + +## See Also + +### Creating an environment variable provider + +Creates a new provider that reads from the current process environment. + +Creates a new provider from a custom dictionary of environment variables. + +- init(environmentFilePath:allowMissing:secretsSpecifier:bytesDecoder:arraySeparator:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/customstringconvertible-implementations + +- Configuration +- EnvironmentVariablesProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/keymappingprovider/init(upstream:keymapper:) + +#app-main) + +- Configuration +- KeyMappingProvider +- init(upstream:keyMapper:) + +Initializer + +# init(upstream:keyMapper:) + +Creates a new provider. + +init( +upstream: Upstream, + +) + +KeyMappingProvider.swift + +## Parameters + +`upstream` + +The upstream provider to delegate to after mapping. + +`mapKey` + +A closure to remap configuration keys. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configprovider/prefixkeys(with:) + +#app-main) + +- Configuration +- ConfigProvider +- prefixKeys(with:) + +Instance Method + +# prefixKeys(with:) + +Creates a new prefixed configuration provider. + +ConfigProvider+Operators.swift + +## Return Value + +A provider which prefixes keys with the given prefix. + +## Discussion + +- Parameter: prefix: The configuration key to prepend to all configuration keys. + +## See Also + +### Conveniences + +Implements `watchValue` by getting the current value and emitting it immediately. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Creates a new configuration provider where each key is rewritten by the given closure. + +- prefixKeys(with:) +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/customdebugstringconvertible-implementations + +- Configuration +- EnvironmentVariablesProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileprovider/configprovider-implementations + +- Configuration +- FileProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/reloadingfileprovider/init(snapshottype:parsingoptions:config:logger:metrics:) + +#app-main) + +- Configuration +- ReloadingFileProvider +- init(snapshotType:parsingOptions:config:logger:metrics:) + +Initializer + +# init(snapshotType:parsingOptions:config:logger:metrics:) + +Creates a reloading file provider using configuration from a reader. + +convenience init( +snapshotType: Snapshot.Type = Snapshot.self, +parsingOptions: Snapshot.ParsingOptions = .default, +config: ConfigReader, +logger: Logger = Logger(label: "ReloadingFileProvider"), +metrics: any MetricsFactory = MetricsSystem.factory +) async throws + +ReloadingFileProvider.swift + +## Parameters + +`snapshotType` + +The type of snapshot to create from the file contents. + +`parsingOptions` + +Options used by the snapshot to parse the file data. + +`config` + +A configuration reader that contains the required configuration keys. + +`logger` + +The logger instance to use for this provider. + +`metrics` + +The metrics factory to use for monitoring provider performance. + +## Configuration keys + +- `filePath` (string, required): The path to the configuration file to monitor. + +- `allowMissing` (bool, optional, default: false): A flag controlling how the provider handles a missing file. When `false` (the default), if the file is missing or malformed, throws an error. When `true`, if the file is missing, treats it as empty. Malformed files still throw an error. + +- `pollIntervalSeconds` (int, optional, default: 15): How often to check for file changes in seconds. + +## See Also + +### Creating a reloading file provider + +`convenience init(snapshotType: Snapshot.Type, parsingOptions: Snapshot.ParsingOptions, filePath: FilePath, allowMissing: Bool, pollInterval: Duration, logger: Logger, metrics: any MetricsFactory) async throws` + +Creates a reloading file provider that monitors the specified file path. + +- init(snapshotType:parsingOptions:config:logger:metrics:) +- Parameters +- Configuration keys +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/equatable-implementations + +- Configuration +- ConfigKey +- Equatable Implementations + +API Collection + +# Equatable Implementations + +## Topics + +### Operators + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/expressiblebyextendedgraphemeclusterliteral-implementations + +- Configuration +- ConfigKey +- ExpressibleByExtendedGraphemeClusterLiteral Implementations + +API Collection + +# ExpressibleByExtendedGraphemeClusterLiteral Implementations + +## Topics + +### Initializers + +`init(unicodeScalarLiteral: Self.ExtendedGraphemeClusterLiteralType)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/comparable-implementations + +- Configuration +- ConfigKey +- Comparable Implementations + +API Collection + +# Comparable Implementations + +## Topics + +### Operators + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-9ifez + +-9ifez#app-main) + +- Configuration +- ConfigKey +- init(\_:context:) + +Initializer + +# init(\_:context:) + +Creates a new configuration key. + +init( +_ components: [String], +context: [String : ConfigContextValue] = [:] +) + +ConfigKey.swift + +## Parameters + +`components` + +The hierarchical components that make up the key path. + +`context` + +Additional context information for the key. + +## See Also + +### Creating a configuration key + +[`init(String, context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/init(_:context:)-6vten) + +- init(\_:context:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/keymappingprovider/customdebugstringconvertible-implementations + +- Configuration +- KeyMappingProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/commandlineargumentsprovider/init(arguments:secretsspecifier:bytesdecoder:) + +#app-main) + +- Configuration +- CommandLineArgumentsProvider +- init(arguments:secretsSpecifier:bytesDecoder:) + +Initializer + +# init(arguments:secretsSpecifier:bytesDecoder:) + +Creates a new CLI provider with the provided arguments. + +init( +arguments: [String] = CommandLine.arguments, + +bytesDecoder: some ConfigBytesFromStringDecoder = .base64 +) + +CommandLineArgumentsProvider.swift + +## Parameters + +`arguments` + +The command-line arguments to parse. + +`secretsSpecifier` + +Specifies which CLI arguments should be treated as secret. + +`bytesDecoder` + +The decoder used for converting string values into bytes. + +## Discussion + +// Uses the current process's arguments. +let provider = CommandLineArgumentsProvider() +// Uses custom arguments. +let provider = CommandLineArgumentsProvider(arguments: ["program", "--test", "--port", "8089"]) + +- init(arguments:secretsSpecifier:bytesDecoder:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfromhexstringdecoder/configbytesfromstringdecoder-implementations + +- Configuration +- ConfigBytesFromHexStringDecoder +- ConfigBytesFromStringDecoder Implementations + +API Collection + +# ConfigBytesFromStringDecoder Implementations + +## Topics + +### Type Properties + +`static var hex: ConfigBytesFromHexStringDecoder` + +A decoder that interprets string values as hexadecimal-encoded data. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/init(name:initialvalues:) + +#app-main) + +- Configuration +- MutableInMemoryProvider +- init(name:initialValues:) + +Initializer + +# init(name:initialValues:) + +Creates a new mutable in-memory provider with the specified initial values. + +init( +name: String? = nil, +initialValues: [AbsoluteConfigKey : ConfigValue] +) + +MutableInMemoryProvider.swift + +## Parameters + +`name` + +An optional name for the provider, used in debugging and logging. + +`initialValues` + +A dictionary mapping absolute configuration keys to their initial values. + +## Discussion + +This initializer takes a dictionary of absolute configuration keys mapped to their initial values. The provider can be modified after creation using the `setValue(_:forKey:)` methods. + +let key1 = AbsoluteConfigKey(components: ["database", "host"], context: [:]) +let key2 = AbsoluteConfigKey(components: ["database", "port"], context: [:]) + +let provider = MutableInMemoryProvider( +name: "dynamic-config", +initialValues: [\ +key1: "localhost",\ +key2: 5432\ +] +) + +// Later, update values dynamically +provider.setValue("production-db", forKey: key1) + +- init(name:initialValues:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/expressiblebyarrayliteral-implementations + +- Configuration +- ConfigKey +- ExpressibleByArrayLiteral Implementations + +API Collection + +# ExpressibleByArrayLiteral Implementations + +## Topics + +### Initializers + +`init(arrayLiteral: String...)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/configprovider-implementations + +- Configuration +- EnvironmentVariablesProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/context + +- Configuration +- ConfigKey +- context + +Instance Property + +# context + +Additional context information for this configuration key. + +var context: [String : ConfigContextValue] + +ConfigKey.swift + +## Discussion + +Context provides extra information that providers can use to refine lookups or return more specific values. Not all providers use context information. + +## See Also + +### Inspecting a configuration key + +[`var components: [String]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/components) + +The hierarchical components that make up this configuration key. + +- context +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessreporter/report(_:) + +#app-main) + +- Configuration +- AccessReporter +- report(\_:) + +Instance Method + +# report(\_:) + +Processes a configuration access event. + +func report(_ event: AccessEvent) + +AccessReporter.swift + +**Required** + +## Parameters + +`event` + +The configuration access event to process. + +## Discussion + +This method is called whenever a configuration value is accessed through a `ConfigReader` or a `ConfigSnapshotReader`. Implementations should handle events efficiently as they may be called frequently. + +- report(\_:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/commandlineargumentsprovider/customdebugstringconvertible-implementations + +- Configuration +- CommandLineArgumentsProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.doubleArray(\_:) + +Case + +# ConfigContent.doubleArray(\_:) + +An array of double values. + +case doubleArray([Double]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/expressiblebyextendedgraphemeclusterliteral-implementations + +- Configuration +- ConfigContextValue +- ExpressibleByExtendedGraphemeClusterLiteral Implementations + +API Collection + +# ExpressibleByExtendedGraphemeClusterLiteral Implementations + +## Topics + +### Initializers + +`init(unicodeScalarLiteral: Self.ExtendedGraphemeClusterLiteralType)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier/specific(_:) + +#app-main) + +- Configuration +- SecretsSpecifier +- SecretsSpecifier.specific(\_:) + +Case + +# SecretsSpecifier.specific(\_:) + +The library treats the specified keys as secrets. + +SecretsSpecifier.swift + +## Parameters + +`keys` + +The set of keys that should be treated as secrets. + +## Discussion + +Use this case when you have a known set of keys that contain sensitive information. All other keys will be treated as non-secret. + +## See Also + +### Types of specifiers + +`case all` + +The library treats all configuration values as secrets. + +The library determines the secret status dynamically by evaluating each key-value pair. + +`case none` + +The library treats no configuration values as secrets. + +- SecretsSpecifier.specific(\_:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileconfigsnapshot/init(data:providername:parsingoptions:) + +# An unknown error occurred. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/directoryfilesprovider/init(directorypath:allowmissing:secretsspecifier:arrayseparator:) + +#app-main) + +- Configuration +- DirectoryFilesProvider +- init(directoryPath:allowMissing:secretsSpecifier:arraySeparator:) + +Initializer + +# init(directoryPath:allowMissing:secretsSpecifier:arraySeparator:) + +Creates a new provider that reads files from a directory. + +init( +directoryPath: FilePath, +allowMissing: Bool = false, + +arraySeparator: Character = "," +) async throws + +DirectoryFilesProvider.swift + +## Parameters + +`directoryPath` + +The file system path to the directory containing configuration files. + +`allowMissing` + +A flag controlling how the provider handles a missing directory. + +- When `false`, if the directory is missing, throws an error. + +- When `true`, if the directory is missing, treats it as empty. + +`secretsSpecifier` + +Specifies which values should be treated as secrets. + +`arraySeparator` + +The character used to separate elements in array values. + +## Discussion + +This initializer scans the specified directory and loads all regular files as configuration values. Subdirectories are not traversed. Hidden files (starting with a dot) are skipped. + +// Load configuration from a directory +let provider = try await DirectoryFilesProvider( +directoryPath: "/run/secrets" +) + +- init(directoryPath:allowMissing:secretsSpecifier:arraySeparator:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/string + +- Configuration +- ConfigType +- ConfigType.string + +Case + +# ConfigType.string + +A string value. + +case string + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case stringArray` + +An array of string values. + +`case bool` + +A Boolean value. + +`case boolArray` + +An array of Boolean values. + +`case int` + +An integer value. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/string(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.string(\_:) + +Case + +# ConfigContent.string(\_:) + +A string value. + +case string(String) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/keymappingprovider/configprovider-implementations + +- Configuration +- KeyMappingProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.boolArray(\_:) + +Case + +# ConfigContent.boolArray(\_:) + +An array of Boolean value. + +case boolArray([Bool]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/init(metadata:providerresults:conversionerror:result:) + +#app-main) + +- Configuration +- AccessEvent +- init(metadata:providerResults:conversionError:result:) + +Initializer + +# init(metadata:providerResults:conversionError:result:) + +Creates a configuration access event. + +init( +metadata: AccessEvent.Metadata, +providerResults: [AccessEvent.ProviderResult], +conversionError: (any Error)? = nil, + +AccessReporter.swift + +## Parameters + +`metadata` + +Metadata describing the access operation. + +`providerResults` + +The results from each provider queried. + +`conversionError` + +An error that occurred when converting the raw config value into another type, for example `RawRepresentable`. + +`result` + +The final outcome of the access operation. + +## See Also + +### Creating an access event + +`struct Metadata` + +Metadata describing the configuration access operation. + +`struct ProviderResult` + +The result of a configuration lookup from a specific provider. + +- init(metadata:providerResults:conversionError:result:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/setvalue(_:forkey:) + +#app-main) + +- Configuration +- MutableInMemoryProvider +- setValue(\_:forKey:) + +Instance Method + +# setValue(\_:forKey:) + +Updates the stored value for the specified configuration key. + +func setValue( +_ value: ConfigValue?, +forKey key: AbsoluteConfigKey +) + +MutableInMemoryProvider.swift + +## Parameters + +`value` + +The new configuration value, or `nil` to remove the value entirely. + +`key` + +The absolute configuration key to update. + +## Discussion + +This method atomically updates the value and notifies all active watchers of the change. If the new value is the same as the existing value, no notification is sent. + +let provider = MutableInMemoryProvider(initialValues: [:]) +let key = AbsoluteConfigKey(components: ["api", "enabled"], context: [:]) + +// Set a new value +provider.setValue(true, forKey: key) + +// Remove a value +provider.setValue(nil, forKey: key) + +- setValue(\_:forKey:) +- Parameters +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/fileparsingoptions/default + +- Configuration +- FileParsingOptions +- default + +Type Property + +# default + +The default instance of this options type. + +static var `default`: Self { get } + +FileProviderSnapshot.swift + +**Required** + +## Discussion + +This property provides a default configuration that can be used when no parsing options are specified. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/environmentvariablesprovider/init(secretsspecifier:bytesdecoder:arrayseparator:) + +#app-main) + +- Configuration +- EnvironmentVariablesProvider +- init(secretsSpecifier:bytesDecoder:arraySeparator:) + +Initializer + +# init(secretsSpecifier:bytesDecoder:arraySeparator:) + +Creates a new provider that reads from the current process environment. + +init( + +bytesDecoder: some ConfigBytesFromStringDecoder = .base64, +arraySeparator: Character = "," +) + +EnvironmentVariablesProvider.swift + +## Parameters + +`secretsSpecifier` + +Specifies which environment variables should be treated as secrets. + +`bytesDecoder` + +The decoder used for converting string values to byte arrays. + +`arraySeparator` + +The character used to separate elements in array values. + +## Discussion + +This initializer creates a provider that sources configuration values from the environment variables of the current process. + +// Basic usage +let provider = EnvironmentVariablesProvider() + +// With secret handling +let provider = EnvironmentVariablesProvider( +secretsSpecifier: .specific(["API_KEY", "DATABASE_PASSWORD"]) +) + +## See Also + +### Creating an environment variable provider + +Creates a new provider from a custom dictionary of environment variables. + +Creates a new provider that reads from an environment file. + +- init(secretsSpecifier:bytesDecoder:arraySeparator:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/expressiblebystringliteral-implementations + +- Configuration +- ConfigKey +- ExpressibleByStringLiteral Implementations + +API Collection + +# ExpressibleByStringLiteral Implementations + +## Topics + +### Initializers + +`init(extendedGraphemeClusterLiteral: Self.StringLiteralType)` + +`init(stringLiteral: String)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/components + +- Configuration +- ConfigKey +- components + +Instance Property + +# components + +The hierarchical components that make up this configuration key. + +var components: [String] + +ConfigKey.swift + +## Discussion + +Each component represents a level in the configuration hierarchy. For example, `["database", "connection", "timeout"]` represents a three-level nested key. + +## See Also + +### Inspecting a configuration key + +[`var context: [String : ConfigContextValue]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configkey/context) + +Additional context information for this configuration key. + +- components +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/init(_:) + +#app-main) + +- Configuration +- ConfigUpdatesAsyncSequence +- init(\_:) + +Initializer + +# init(\_:) + +Creates a new concrete async sequence wrapping the provided existential sequence. + +AsyncSequences.swift + +## Parameters + +`upstream` + +The async sequence to wrap. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/foundation/uuid + +- Configuration +- Foundation +- UUID + +Extended Structure + +# UUID + +ConfigurationFoundation + +extension UUID + +## Topics + +## Relationships + +### Conforms To + +- `ExpressibleByConfigString` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` + +- UUID +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/customstringconvertible-implementations + +- Configuration +- MutableInMemoryProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfrombase64stringdecoder/init() + +#app-main) + +- Configuration +- ConfigBytesFromBase64StringDecoder +- init() + +Initializer + +# init() + +Creates a new base64 decoder. + +init() + +ConfigBytesFromStringDecoder.swift + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/commandlineargumentsprovider/configprovider-implementations + +- Configuration +- CommandLineArgumentsProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/customstringconvertible-implementations + +- Configuration +- ConfigValue +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/string(forkey:as:issecret:fileid:line:)-4oust + +-4oust#app-main) + +- Configuration +- ConfigReader +- string(forKey:as:isSecret:fileID:line:) + +Instance Method + +# string(forKey:as:isSecret:fileID:line:) + +Synchronously gets a config value for the given config key, converting from string. + +forKey key: ConfigKey, +as type: Value.Type = Value.self, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line + +ConfigReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`type` + +The type to convert the string value to. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The value converted to the expected type if found and convertible, otherwise `nil`. + +## Discussion + +Use this method to retrieve configuration values that can be converted from strings, such as custom types conforming to string conversion protocols. If the value doesn’t exist or can’t be converted to the expected type, the method returns `nil`. + +let serverMode = config.string(forKey: ["server", "mode"], as: ServerMode.self) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +- string(forKey:as:isSecret:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.bytes(\_:) + +Case + +# ConfigContent.bytes(\_:) + +An array of bytes. + +case bytes([UInt8]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/content + +- Configuration +- ConfigValue +- content + +Instance Property + +# content + +The configuration content. + +var content: ConfigContent + +ConfigProvider.swift + +## See Also + +### Inspecting a config value + +`var isSecret: Bool` + +Whether this value contains sensitive information that should not be logged. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/watchsnapshot(fileid:line:updateshandler:) + +#app-main) + +- Configuration +- ConfigReader +- watchSnapshot(fileID:line:updatesHandler:) + +Instance Method + +# watchSnapshot(fileID:line:updatesHandler:) + +Watches the configuration for changes. + +fileID: String = #fileID, +line: UInt = #line, + +ConfigSnapshotReader.swift + +## Parameters + +`fileID` + +The file where this method is called from. + +`line` + +The line where this method is called from. + +`updatesHandler` + +A closure that receives an async sequence of `ConfigSnapshotReader` instances. + +## Return Value + +The value returned by the handler. + +## Discussion + +This method watches the configuration for changes and provides a stream of snapshots to the handler closure. Each snapshot represents the configuration state at a specific point in time. + +try await config.watchSnapshot { snapshots in +for await snapshot in snapshots { +// Process each new configuration snapshot +let cert = snapshot.string(forKey: "cert") +let privateKey = snapshot.string(forKey: "privateKey") +// Ensures that both values are coming from the same underlying snapshot and that a provider +// didn't change its internal state between the two `string(...)` calls. +let newCert = MyCert(cert: cert, privateKey: privateKey) +print("Certificate was updated: \(newCert.redactedDescription)") +} +} + +## See Also + +### Reading from a snapshot + +Returns a snapshot of the current configuration state. + +- watchSnapshot(fileID:line:updatesHandler:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/configprovider-implementations + +- Configuration +- MutableInMemoryProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/expressiblebybooleanliteral-implementations + +- Configuration +- ConfigValue +- ExpressibleByBooleanLiteral Implementations + +API Collection + +# ExpressibleByBooleanLiteral Implementations + +## Topics + +### Initializers + +`init(booleanLiteral: Bool)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/directoryfilesprovider/configprovider-implementations + +- Configuration +- DirectoryFilesProvider +- ConfigProvider Implementations + +API Collection + +# ConfigProvider Implementations + +## Topics + +### Instance Properties + +`var providerName: String` + +### Instance Methods + +Creates a new configuration provider where each key is rewritten by the given closure. + +Creates a new prefixed configuration provider. + +Implements `watchSnapshot` by getting the current snapshot and emitting it immediately. + +Implements `watchValue` by getting the current value and emitting it immediately. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/int(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.int(\_:) + +Case + +# ConfigContent.int(\_:) + +An integer value. + +case int(Int) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier/none + +- Configuration +- SecretsSpecifier +- SecretsSpecifier.none + +Case + +# SecretsSpecifier.none + +The library treats no configuration values as secrets. + +case none + +SecretsSpecifier.swift + +## Discussion + +Use this case when the provider handles only non-sensitive configuration data that can be safely logged or displayed. + +## See Also + +### Types of specifiers + +`case all` + +The library treats all configuration values as secrets. + +The library treats the specified keys as secrets. + +The library determines the secret status dynamically by evaluating each key-value pair. + +- SecretsSpecifier.none +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.byteChunkArray(\_:) + +Case + +# ConfigContent.byteChunkArray(\_:) + +An array of byte arrays. + +case byteChunkArray([[UInt8]]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/issecret + +- Configuration +- ConfigValue +- isSecret + +Instance Property + +# isSecret + +Whether this value contains sensitive information that should not be logged. + +var isSecret: Bool + +ConfigProvider.swift + +## See Also + +### Inspecting a config value + +`var content: ConfigContent` + +The configuration content. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfromhexstringdecoder/init() + +#app-main) + +- Configuration +- ConfigBytesFromHexStringDecoder +- init() + +Initializer + +# init() + +Creates a new hexadecimal decoder. + +init() + +ConfigBytesFromStringDecoder.swift + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/expressiblebybooleanliteral-implementations + +- Configuration +- ConfigContextValue +- ExpressibleByBooleanLiteral Implementations + +API Collection + +# ExpressibleByBooleanLiteral Implementations + +## Topics + +### Initializers + +`init(booleanLiteral: Bool)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/result + +- Configuration +- AccessEvent +- result + +Instance Property + +# result + +The final outcome of the configuration access operation. + +AccessReporter.swift + +## Discussion + +## See Also + +### Inspecting an access event + +`var conversionError: (any Error)?` + +An error that occurred when converting the raw config value into another type, for example `RawRepresentable`. + +`var metadata: AccessEvent.Metadata` + +Metadata that describes the configuration access operation. + +[`var providerResults: [AccessEvent.ProviderResult]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/providerresults) + +The results from each configuration provider that was queried. + +- result +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/scoped(to:) + +#app-main) + +- Configuration +- ConfigSnapshotReader +- scoped(to:) + +Instance Method + +# scoped(to:) + +Returns a scoped snapshot reader by appending the provided key to the current key prefix. + +ConfigSnapshotReader.swift + +## Parameters + +`configKey` + +The key to append to the current key prefix. + +## Return Value + +A reader for accessing scoped values. + +## Discussion + +Use this method to create a reader that accesses a subset of the configuration. + +let httpConfig = snapshotReader.scoped(to: ["client", "http"]) +let timeout = httpConfig.int(forKey: "timeout") // Reads from "client.http.timeout" in the snapshot + +- scoped(to:) +- Parameters +- Return Value +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/broadcastingaccessreporter/accessreporter-implementations + +- Configuration +- BroadcastingAccessReporter +- AccessReporter Implementations + +API Collection + +# AccessReporter Implementations + +## Topics + +### Instance Methods + +`func report(AccessEvent)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:as:issecret:fileid:line:)-7bpif + +-7bpif#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:as:isSecret:fileID:line:) + +Instance Method + +# string(forKey:as:isSecret:fileID:line:) + +Synchronously gets a config value for the given config key, converting from string. + +forKey key: ConfigKey, +as type: Value.Type = Value.self, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`type` + +The type to convert the string value to. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The value converted to the expected type if found and convertible, otherwise `nil`. + +## Discussion + +Use this method to retrieve configuration values that can be converted from strings, such as custom types conforming to string conversion protocols. If the value doesn’t exist or can’t be converted to the expected type, the method returns `nil`. + +let serverMode = snapshot.string(forKey: ["server", "mode"], as: ServerMode.self) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +- string(forKey:as:isSecret:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/customstringconvertible-implementations + +- Configuration +- AbsoluteConfigKey +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/keymappingprovider/customstringconvertible-implementations + +- Configuration +- KeyMappingProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/bool(_:) + +#app-main) + +- Configuration +- ConfigContextValue +- ConfigContextValue.bool(\_:) + +Case + +# ConfigContextValue.bool(\_:) + +A Boolean value. + +case bool(Bool) + +ConfigContext.swift + +## See Also + +### Configuration context values + +`case string(String)` + +A string value. + +`case int(Int)` + +An integer value. + +`case double(Double)` + +A floating point value. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader-fetch + +- Configuration +- ConfigReader +- Asynchronously fetching values + +API Collection + +# Asynchronously fetching values + +## Topics + +### Asynchronously fetching string values + +Asynchronously fetches a config value for the given config key. + +Asynchronously fetches a config value for the given config key, with a default fallback. + +Asynchronously fetches a config value for the given config key, converting from string. + +Asynchronously fetches a config value for the given config key with default fallback, converting from string. + +### Asynchronously fetching lists of string values + +Asynchronously fetches an array of config values for the given config key, converting from strings. + +Asynchronously fetches an array of config values for the given config key with default fallback, converting from strings. + +### Asynchronously fetching required string values + +Asynchronously fetches a required config value for the given config key, throwing an error if it’s missing. + +Asynchronously fetches a required config value for the given config key, converting from string. + +### Asynchronously fetching required lists of string values + +Asynchronously fetches a required array of config values for the given config key, converting from strings. + +### Asynchronously fetching Boolean values + +### Asynchronously fetching required Boolean values + +### Asynchronously fetching lists of Boolean values + +### Asynchronously fetching required lists of Boolean values + +### Asynchronously fetching integer values + +### Asynchronously fetching required integer values + +### Asynchronously fetching lists of integer values + +### Asynchronously fetching required lists of integer values + +### Asynchronously fetching double values + +### Asynchronously fetching required double values + +### Asynchronously fetching lists of double values + +### Asynchronously fetching required lists of double values + +### Asynchronously fetching bytes + +### Asynchronously fetching required bytes + +### Asynchronously fetching lists of byte chunks + +### Asynchronously fetching required lists of byte chunks + +## See Also + +### Reading from a snapshot + +Returns a snapshot of the current configuration state. + +Watches the configuration for changes. + +- Asynchronously fetching values +- Topics +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader-watch + +- Configuration +- ConfigReader +- Watching values + +API Collection + +# Watching values + +## Topics + +### Watching string values + +Watches for updates to a config value for the given config key. + +Watches for updates to a config value for the given config key, converting from string. + +Watches for updates to a config value for the given config key with default fallback. + +Watches for updates to a config value for the given config key with default fallback, converting from string. + +### Watching required string values + +Watches for updates to a required config value for the given config key. + +Watches for updates to a required config value for the given config key, converting from string. + +### Watching lists of string values + +Watches for updates to an array of config values for the given config key, converting from strings. + +Watches for updates to an array of config values for the given config key with default fallback, converting from strings. + +### Watching required lists of string values + +Watches for updates to a required array of config values for the given config key, converting from strings. + +### Watching Boolean values + +### Watching required Boolean values + +### Watching lists of Boolean values + +### Watching required lists of Boolean values + +### Watching integer values + +### Watching required integer values + +### Watching lists of integer values + +### Watching required lists of integer values + +### Watching double values + +### Watching required double values + +### Watching lists of double values + +### Watching required lists of double values + +### Watching bytes + +### Watching required bytes + +### Watching lists of byte chunks + +### Watching required lists of byte chunks + +## See Also + +### Reading from a snapshot + +Returns a snapshot of the current configuration state. + +Watches the configuration for changes. + +- Watching values +- Topics +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/yamlsnapshot/parsingoptions/init(bytesdecoder:secretsspecifier:) + +#app-main) + +- Configuration +- YAMLSnapshot +- YAMLSnapshot.ParsingOptions +- init(bytesDecoder:secretsSpecifier:) + +Initializer + +# init(bytesDecoder:secretsSpecifier:) + +Creates custom input configuration for YAML snapshots. + +init( +bytesDecoder: some ConfigBytesFromStringDecoder = .base64, + +) + +YAMLSnapshot.swift + +## Parameters + +`bytesDecoder` + +The decoder to use for converting string values to byte arrays. + +`secretsSpecifier` + +The specifier for identifying secret values. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:as:issecret:default:fileid:line:)-2mphx + +-2mphx#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:as:isSecret:default:fileID:line:) + +Instance Method + +# string(forKey:as:isSecret:default:fileID:line:) + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +forKey key: ConfigKey, +as type: Value.Type = Value.self, +isSecret: Bool = false, +default defaultValue: Value, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`type` + +The type to convert the string value to. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`defaultValue` + +The fallback value returned when the config value is missing or invalid. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The config value if found and convertible, otherwise the default value. + +## Discussion + +Use this method when you need a guaranteed non-nil result for string-convertible types. If the configuration value is missing or can’t be converted to the expected type, the default value is returned instead. + +let serverMode = snapshot.string(forKey: ["server", "mode"], as: ServerMode.self, default: .production) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key, converting from string. + +- string(forKey:as:isSecret:default:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/conversionerror + +- Configuration +- AccessEvent +- conversionError + +Instance Property + +# conversionError + +An error that occurred when converting the raw config value into another type, for example `RawRepresentable`. + +var conversionError: (any Error)? + +AccessReporter.swift + +## See Also + +### Inspecting an access event + +The final outcome of the configuration access operation. + +`var metadata: AccessEvent.Metadata` + +Metadata that describes the configuration access operation. + +[`var providerResults: [AccessEvent.ProviderResult]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/providerresults) + +The results from each configuration provider that was queried. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configbytesfromstringdecoder/decode(_:) + +#app-main) + +- Configuration +- ConfigBytesFromStringDecoder +- decode(\_:) + +Instance Method + +# decode(\_:) + +Decodes a string value into an array of bytes. + +ConfigBytesFromStringDecoder.swift + +**Required** + +## Parameters + +`value` + +The string representation to decode. + +## Return Value + +An array of bytes if decoding succeeds, or `nil` if it fails. + +## Discussion + +This method attempts to parse the provided string according to the decoder’s specific format and returns the corresponding byte array. If the string cannot be decoded (due to invalid format or encoding), the method returns `nil`. + +- decode(\_:) +- Parameters +- Return Value +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader-get + +- Configuration +- ConfigReader +- Synchronously reading values + +API Collection + +# Synchronously reading values + +## Topics + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key, converting from string. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +### Synchronously reading lists of string values + +Synchronously gets an array of config values for the given config key, converting from strings. + +Synchronously gets an array of config values for the given config key with default fallback, converting from strings. + +### Synchronously reading required string values + +Synchronously gets a required config value for the given config key, throwing an error if it’s missing. + +Synchronously gets a required config value for the given config key, converting from string. + +### Synchronously reading required lists of string values + +Synchronously gets a required array of config values for the given config key, converting from strings. + +### Synchronously reading Boolean values + +### Synchronously reading required Boolean values + +### Synchronously reading lists of Boolean values + +### Synchronously reading required lists of Boolean values + +### Synchronously reading integer values + +### Synchronously reading required integer values + +### Synchronously reading lists of integer values + +### Synchronously reading required lists of integer values + +### Synchronously reading double values + +### Synchronously reading required double values + +### Synchronously reading lists of double values + +### Synchronously reading required lists of double values + +### Synchronously reading bytes + +### Synchronously reading required bytes + +### Synchronously reading collections of byte chunks + +### Synchronously reading required collections of byte chunks + +## See Also + +### Reading from a snapshot + +Returns a snapshot of the current configuration state. + +Watches the configuration for changes. + +- Synchronously reading values +- Topics +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.intArray(\_:) + +Case + +# ConfigContent.intArray(\_:) + +An array of integer values. + +case intArray([Int]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/foundation/url + +- Configuration +- Foundation +- URL + +Extended Structure + +# URL + +ConfigurationFoundation + +extension URL + +## Topics + +## Relationships + +### Conforms To + +- `ExpressibleByConfigString` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` + +- URL +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/appending(_:) + +#app-main) + +- Configuration +- AbsoluteConfigKey +- appending(\_:) + +Instance Method + +# appending(\_:) + +Returns a new absolute configuration key by appending the given relative key. + +ConfigKey.swift + +## Parameters + +`relative` + +The relative configuration key to append to this key. + +## Return Value + +A new absolute configuration key with the relative key appended. + +- appending(\_:) +- Parameters +- Return Value + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/init(_:issecret:) + +#app-main) + +- Configuration +- ConfigValue +- init(\_:isSecret:) + +Initializer + +# init(\_:isSecret:) + +Creates a new configuration value. + +init( +_ content: ConfigContent, +isSecret: Bool +) + +ConfigProvider.swift + +## Parameters + +`content` + +The configuration content. + +`isSecret` + +Whether the value contains sensitive information. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:issecret:default:fileid:line:) + +#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:isSecret:default:fileID:line:) + +Instance Method + +# string(forKey:isSecret:default:fileID:line:) + +Synchronously gets a config value for the given config key, with a default fallback. + +func string( +forKey key: ConfigKey, +isSecret: Bool = false, +default defaultValue: String, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`defaultValue` + +The fallback value returned when the config value is missing or invalid. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The config value if found and convertible, otherwise the default value. + +## Discussion + +Use this method when you need a guaranteed non-nil result. If the configuration value is missing or can’t be converted to the expected type, the default value is returned instead. + +let maxRetries = snapshot.int(forKey: ["network", "maxRetries"], default: 3) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, converting from string. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +- string(forKey:isSecret:default:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/systempackage/filepath + +- Configuration +- SystemPackage +- FilePath + +Extended Structure + +# FilePath + +ConfigurationSystemPackage + +extension FilePath + +## Topics + +## Relationships + +### Conforms To + +- `ExpressibleByConfigString` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` + +- FilePath +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/expressiblebyconfigstring/init(configstring:) + +#app-main) + +- Configuration +- ExpressibleByConfigString +- init(configString:) + +Initializer + +# init(configString:) + +Creates an instance from a configuration string value. + +init?(configString: String) + +ExpressibleByConfigString.swift + +**Required** + +## Parameters + +`configString` + +The string value from the configuration provider. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/metadata-swift.struct + +- Configuration +- AccessEvent +- AccessEvent.Metadata + +Structure + +# AccessEvent.Metadata + +Metadata describing the configuration access operation. + +struct Metadata + +AccessReporter.swift + +## Overview + +Contains information about the type of access, the key accessed, value type, source location, and timestamp. + +## Topics + +### Creating access event metadata + +`init(accessKind: AccessEvent.Metadata.AccessKind, key: AbsoluteConfigKey, valueType: ConfigType, sourceLocation: AccessEvent.Metadata.SourceLocation, accessTimestamp: Date)` + +Creates access event metadata. + +`enum AccessKind` + +The type of configuration access operation. + +### Inspecting access event metadata + +`var accessKind: AccessEvent.Metadata.AccessKind` + +The type of configuration access operation for this event. + +`var accessTimestamp: Date` + +The timestamp when the configuration access occurred. + +`var key: AbsoluteConfigKey` + +The configuration key accessed. + +`var sourceLocation: AccessEvent.Metadata.SourceLocation` + +The source code location where the access occurred. + +`var valueType: ConfigType` + +The expected type of the configuration value. + +### Structures + +`struct SourceLocation` + +The source code location where a configuration access occurred. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating an access event + +Creates a configuration access event. + +`struct ProviderResult` + +The result of a configuration lookup from a specific provider. + +- AccessEvent.Metadata +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/broadcastingaccessreporter/init(upstreams:) + +#app-main) + +- Configuration +- BroadcastingAccessReporter +- init(upstreams:) + +Initializer + +# init(upstreams:) + +Creates a new broadcasting access reporter. + +init(upstreams: [any AccessReporter]) + +AccessReporter.swift + +## Parameters + +`upstreams` + +The reporters that will receive forwarded events. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/expressiblebyextendedgraphemeclusterliteral-implementations + +- Configuration +- ConfigValue +- ExpressibleByExtendedGraphemeClusterLiteral Implementations + +API Collection + +# ExpressibleByExtendedGraphemeClusterLiteral Implementations + +## Topics + +### Initializers + +`init(unicodeScalarLiteral: Self.ExtendedGraphemeClusterLiteralType)` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/customstringconvertible-implementations + +- Configuration +- ConfigContextValue +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/init(provider:accessreporter:) + +#app-main) + +- Configuration +- ConfigReader +- init(provider:accessReporter:) + +Initializer + +# init(provider:accessReporter:) + +Creates a config reader with a single provider. + +init( +provider: some ConfigProvider, +accessReporter: (any AccessReporter)? = nil +) + +ConfigReader.swift + +## Parameters + +`provider` + +The configuration provider. + +`accessReporter` + +The reporter for configuration access events. + +## See Also + +### Creating config readers + +[`init(providers: [any ConfigProvider], accessReporter: (any AccessReporter)?)`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/init(providers:accessreporter:)) + +Creates a config reader with multiple providers. + +- init(provider:accessReporter:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/prepending(_:) + +# An unknown error occurred. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/int + +- Configuration +- ConfigType +- ConfigType.int + +Case + +# ConfigType.int + +An integer value. + +case int + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string` + +A string value. + +`case stringArray` + +An array of string values. + +`case bool` + +A Boolean value. + +`case boolArray` + +An array of Boolean values. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configvalue/equatable-implementations + +- Configuration +- ConfigValue +- Equatable Implementations + +API Collection + +# Equatable Implementations + +## Topics + +### Operators + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/string(_:) + +#app-main) + +- Configuration +- ConfigContextValue +- ConfigContextValue.string(\_:) + +Case + +# ConfigContextValue.string(\_:) + +A string value. + +case string(String) + +ConfigContext.swift + +## See Also + +### Configuration context values + +`case bool(Bool)` + +A Boolean value. + +`case int(Int)` + +An integer value. + +`case double(Double)` + +A floating point value. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/stringarray + +- Configuration +- ConfigType +- ConfigType.stringArray + +Case + +# ConfigType.stringArray + +An array of string values. + +case stringArray + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string` + +A string value. + +`case bool` + +A Boolean value. + +`case boolArray` + +An array of Boolean values. + +`case int` + +An integer value. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/stringarray(forkey:issecret:fileid:line:) + +#app-main) + +- Configuration +- ConfigSnapshotReader +- stringArray(forKey:isSecret:fileID:line:) + +Instance Method + +# stringArray(forKey:isSecret:fileID:line:) + +Synchronously gets a config value for the given config key. + +func stringArray( +forKey key: ConfigKey, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The value converted to the expected type if found and convertible, otherwise `nil`. + +## Discussion + +Use this method to retrieve optional configuration values from a snapshot. If the value doesn’t exist or can’t be converted to the expected type, the method returns `nil`. + +let port = snapshot.int(forKey: ["server", "port"]) + +## See Also + +### Synchronously reading lists of string values + +Synchronously gets an array of config values for the given config key, converting from strings. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets an array of config values for the given config key with default fallback, converting from strings. + +- stringArray(forKey:isSecret:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/components + +- Configuration +- AbsoluteConfigKey +- components + +Instance Property + +# components + +The hierarchical components that make up this absolute configuration key. + +var components: [String] + +ConfigKey.swift + +## Discussion + +Each component represents a level in the configuration hierarchy, forming a complete path from the root of the configuration structure. + +## See Also + +### Inspecting an absolute configuration key + +[`var context: [String : ConfigContextValue]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/context) + +Additional context information for this configuration key. + +- components +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/bool + +- Configuration +- ConfigType +- ConfigType.bool + +Case + +# ConfigType.bool + +A Boolean value. + +case bool + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string` + +A string value. + +`case stringArray` + +An array of string values. + +`case boolArray` + +An array of Boolean values. + +`case int` + +An integer value. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier/dynamic(_:) + +#app-main) + +- Configuration +- SecretsSpecifier +- SecretsSpecifier.dynamic(\_:) + +Case + +# SecretsSpecifier.dynamic(\_:) + +The library determines the secret status dynamically by evaluating each key-value pair. + +SecretsSpecifier.swift + +## Parameters + +`closure` + +A closure that takes a key and value and returns whether the value should be treated as secret. + +## Discussion + +Use this case when you need complex logic to determine whether a value is secret based on the key name, value content, or other criteria. + +## See Also + +### Types of specifiers + +`case all` + +The library treats all configuration values as secrets. + +The library treats the specified keys as secrets. + +`case none` + +The library treats no configuration values as secrets. + +- SecretsSpecifier.dynamic(\_:) +- Parameters +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier/all + +- Configuration +- SecretsSpecifier +- SecretsSpecifier.all + +Case + +# SecretsSpecifier.all + +The library treats all configuration values as secrets. + +case all + +SecretsSpecifier.swift + +## Discussion + +Use this case when the provider exclusively handles sensitive information and all values should be protected from disclosure. + +## See Also + +### Types of specifiers + +The library treats the specified keys as secrets. + +The library determines the secret status dynamically by evaluating each key-value pair. + +`case none` + +The library treats no configuration values as secrets. + +- SecretsSpecifier.all +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configurationtesting/providercompattest/testconfiguration + +- ConfigurationTesting +- ProviderCompatTest +- ProviderCompatTest.TestConfiguration + +Structure + +# ProviderCompatTest.TestConfiguration + +Configuration options for customizing test behavior. + +struct TestConfiguration + +ProviderCompatTest.swift + +## Topics + +### Initializers + +[`init(overrides: [String : ConfigContent])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configurationtesting/providercompattest/testconfiguration/init(overrides:)) + +Creates a new test configuration. + +### Instance Properties + +[`var overrides: [String : ConfigContent]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configurationtesting/providercompattest/testconfiguration/overrides) + +Value overrides for testing custom scenarios. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +- ProviderCompatTest.TestConfiguration +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/foundation/date + +- Configuration +- Foundation +- Date + +Extended Structure + +# Date + +ConfigurationFoundation + +extension Date + +## Topics + +## Relationships + +### Conforms To + +- `ExpressibleByConfigString` +- `Swift.Copyable` +- `Swift.CustomStringConvertible` + +- Date +- Topics +- Relationships + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/boolarray + +- Configuration +- ConfigType +- ConfigType.boolArray + +Case + +# ConfigType.boolArray + +An array of Boolean values. + +case boolArray + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string` + +A string value. + +`case stringArray` + +An array of string values. + +`case bool` + +A Boolean value. + +`case int` + +An integer value. + +`case intArray` + +An array of integer values. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/equatable-implementations + +- Configuration +- ConfigContextValue +- Equatable Implementations + +API Collection + +# Equatable Implementations + +## Topics + +### Operators + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/init(_:) + +#app-main) + +- Configuration +- AbsoluteConfigKey +- init(\_:) + +Initializer + +# init(\_:) + +Creates a new absolute configuration key from a relative key. + +init(_ relative: ConfigKey) + +ConfigKey.swift + +## Parameters + +`relative` + +The relative configuration key to convert. + +## See Also + +### Creating an absolute configuration key + +[`init([String], context: [String : ConfigContextValue])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/init(_:context:)) + +Creates a new absolute configuration key. + +- init(\_:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/asyncsequence-implementations + +- Configuration +- ConfigUpdatesAsyncSequence +- AsyncSequence Implementations + +API Collection + +# AsyncSequence Implementations + +## Topics + +### Instance Methods + +[`func chunked(by: AsyncTimerSequence) -> AsyncChunksOfCountOrSignalSequence>`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/chunked(by:)-trjw) + +`func chunked(by: AsyncTimerSequence, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence>` + +[`func chunks(ofCount: Int, or: AsyncTimerSequence) -> AsyncChunksOfCountOrSignalSequence>`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/chunks(ofcount:or:)-8u4c4) + +`func chunks(ofCount: Int, or: AsyncTimerSequence, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence>` + +`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/makeasynciterator()) + +`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configupdatesasyncsequence/share(bufferingpolicy:)) + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshot/value(forkey:type:) + +#app-main) + +- Configuration +- ConfigSnapshot +- value(forKey:type:) + +Instance Method + +# value(forKey:type:) + +Returns a value for the specified key from this immutable snapshot. + +func value( +forKey key: AbsoluteConfigKey, +type: ConfigType + +ConfigProvider.swift + +**Required** + +## Parameters + +`key` + +The configuration key to look up. + +`type` + +The expected configuration value type. + +## Return Value + +The lookup result containing the value and encoded key, or nil if not found. + +## Discussion + +Unlike `value(forKey:type:)`, this method always returns the same value for identical parameters because the snapshot represents a fixed point in time. Values can be accessed synchronously and efficiently. + +## See Also + +### Required methods + +`var providerName: String` + +The human-readable name of the configuration provider that created this snapshot. + +- value(forKey:type:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configtype/intarray + +- Configuration +- ConfigType +- ConfigType.intArray + +Case + +# ConfigType.intArray + +An array of integer values. + +case intArray + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string` + +A string value. + +`case stringArray` + +An array of string values. + +`case bool` + +A Boolean value. + +`case boolArray` + +An array of Boolean values. + +`case int` + +An integer value. + +`case double` + +A double value. + +`case doubleArray` + +An array of double values. + +`case bytes` + +An array of bytes. + +`case byteChunkArray` + +An array of byte chunks. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/double(_:) + +#app-main) + +- Configuration +- ConfigContextValue +- ConfigContextValue.double(\_:) + +Case + +# ConfigContextValue.double(\_:) + +A floating point value. + +case double(Double) + +ConfigContext.swift + +## See Also + +### Configuration context values + +`case string(String)` + +A string value. + +`case bool(Bool)` + +A Boolean value. + +`case int(Int)` + +An integer value. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/directoryfilesprovider/customstringconvertible-implementations + +- Configuration +- DirectoryFilesProvider +- CustomStringConvertible Implementations + +API Collection + +# CustomStringConvertible Implementations + +## Topics + +### Instance Properties + +`var description: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontextvalue/int(_:) + +#app-main) + +- Configuration +- ConfigContextValue +- ConfigContextValue.int(\_:) + +Case + +# ConfigContextValue.int(\_:) + +An integer value. + +case int(Int) + +ConfigContext.swift + +## See Also + +### Configuration context values + +`case string(String)` + +A string value. + +`case bool(Bool)` + +A Boolean value. + +`case double(Double)` + +A floating point value. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/comparable-implementations + +- Configuration +- AbsoluteConfigKey +- Comparable Implementations + +API Collection + +# Comparable Implementations + +## Topics + +### Operators + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configreader/init(providers:accessreporter:) + +#app-main) + +- Configuration +- ConfigReader +- init(providers:accessReporter:) + +Initializer + +# init(providers:accessReporter:) + +Creates a config reader with multiple providers. + +init( +providers: [any ConfigProvider], +accessReporter: (any AccessReporter)? = nil +) + +ConfigReader.swift + +## Parameters + +`providers` + +The configuration providers, queried in order until a value is found. + +`accessReporter` + +The reporter for configuration access events. + +## See Also + +### Creating config readers + +`init(provider: some ConfigProvider, accessReporter: (any AccessReporter)?)` + +Creates a config reader with a single provider. + +- init(providers:accessReporter:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:as:issecret:default:fileid:line:)-fzpe + +-fzpe#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:as:isSecret:default:fileID:line:) + +Instance Method + +# string(forKey:as:isSecret:default:fileID:line:) + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +forKey key: ConfigKey, +as type: Value.Type = Value.self, +isSecret: Bool = false, +default defaultValue: Value, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`type` + +The type to convert the string value to. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`defaultValue` + +The fallback value returned when the config value is missing or invalid. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The config value if found and convertible, otherwise the default value. + +## Discussion + +Use this method when you need a guaranteed non-nil result for string-convertible types. If the configuration value is missing or can’t be converted to the expected type, the default value is returned instead. + +let serverMode = snapshot.string(forKey: ["server", "mode"], as: ServerMode.self, default: .production) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key, converting from string. + +- string(forKey:as:isSecret:default:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/absoluteconfigkey/init(_:context:) + +#app-main) + +- Configuration +- AbsoluteConfigKey +- init(\_:context:) + +Initializer + +# init(\_:context:) + +Creates a new absolute configuration key. + +init( +_ components: [String], +context: [String : ConfigContextValue] = [:] +) + +ConfigKey.swift + +## Parameters + +`components` + +The hierarchical components that make up the complete key path. + +`context` + +Additional context information for the key. + +## See Also + +### Creating an absolute configuration key + +`init(ConfigKey)` + +Creates a new absolute configuration key from a relative key. + +- init(\_:context:) +- Parameters +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/mutableinmemoryprovider/customdebugstringconvertible-implementations + +- Configuration +- MutableInMemoryProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/providerresult + +- Configuration +- AccessEvent +- AccessEvent.ProviderResult + +Structure + +# AccessEvent.ProviderResult + +The result of a configuration lookup from a specific provider. + +struct ProviderResult + +AccessReporter.swift + +## Overview + +Contains the provider’s name and the outcome of querying that provider, which can be either a successful lookup result or an error. + +## Topics + +### Creating provider results + +Creates a provider result. + +### Inspecting provider results + +The outcome of the configuration lookup operation. + +`var providerName: String` + +The name of the configuration provider that processed the lookup. + +## Relationships + +### Conforms To + +- `Swift.Sendable` +- `Swift.SendableMetatype` + +## See Also + +### Creating an access event + +Creates a configuration access event. + +`struct Metadata` + +Metadata describing the configuration access operation. + +- AccessEvent.ProviderResult +- Overview +- Topics +- Relationships +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:issecret:fileid:line:) + +#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:isSecret:fileID:line:) + +Instance Method + +# string(forKey:isSecret:fileID:line:) + +Synchronously gets a config value for the given config key. + +func string( +forKey key: ConfigKey, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The value converted to the expected type if found and convertible, otherwise `nil`. + +## Discussion + +Use this method to retrieve optional configuration values from a snapshot. If the value doesn’t exist or can’t be converted to the expected type, the method returns `nil`. + +let port = snapshot.int(forKey: ["server", "port"]) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key, converting from string. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +- string(forKey:isSecret:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/double(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.double(\_:) + +Case + +# ConfigContent.double(\_:) + +A double value. + +case double(Double) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +[`case stringArray([String])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:)) + +An array of string values. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/stringarray(_:) + +#app-main) + +- Configuration +- ConfigContent +- ConfigContent.stringArray(\_:) + +Case + +# ConfigContent.stringArray(\_:) + +An array of string values. + +case stringArray([String]) + +ConfigProvider.swift + +## See Also + +### Types of configuration content + +`case string(String)` + +A string value. + +`case bool(Bool)` + +A Boolean value. + +[`case boolArray([Bool])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/boolarray(_:)) + +An array of Boolean value. + +`case int(Int)` + +An integer value. + +[`case intArray([Int])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/intarray(_:)) + +An array of integer values. + +`case double(Double)` + +A double value. + +[`case doubleArray([Double])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/doublearray(_:)) + +An array of double values. + +[`case bytes([UInt8])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytes(_:)) + +An array of bytes. + +[`case byteChunkArray([[UInt8]])`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configcontent/bytechunkarray(_:)) + +An array of byte arrays. + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshotreader/string(forkey:as:issecret:fileid:line:)-8hlcf + +-8hlcf#app-main) + +- Configuration +- ConfigSnapshotReader +- string(forKey:as:isSecret:fileID:line:) + +Instance Method + +# string(forKey:as:isSecret:fileID:line:) + +Synchronously gets a config value for the given config key, converting from string. + +forKey key: ConfigKey, +as type: Value.Type = Value.self, +isSecret: Bool = false, +fileID: String = #fileID, +line: UInt = #line + +ConfigSnapshotReader+methods.swift + +## Parameters + +`key` + +The config key to look up. + +`type` + +The type to convert the string value to. + +`isSecret` + +Whether the value should be treated as secret for logging and debugging purposes. + +`fileID` + +The file ID where this call originates. Used for access reporting. + +`line` + +The line number where this call originates. Used for access reporting. + +## Return Value + +The value converted to the expected type if found and convertible, otherwise `nil`. + +## Discussion + +Use this method to retrieve configuration values that can be converted from strings, such as custom types conforming to string conversion protocols. If the value doesn’t exist or can’t be converted to the expected type, the method returns `nil`. + +let serverMode = snapshot.string(forKey: ["server", "mode"], as: ServerMode.self) + +## See Also + +### Synchronously reading string values + +Synchronously gets a config value for the given config key. + +Synchronously gets a config value for the given config key, with a default fallback. + +Synchronously gets a config value for the given config key with default fallback, converting from string. + +- string(forKey:as:isSecret:fileID:line:) +- Parameters +- Return Value +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/directoryfilesprovider/customdebugstringconvertible-implementations + +- Configuration +- DirectoryFilesProvider +- CustomDebugStringConvertible Implementations + +API Collection + +# CustomDebugStringConvertible Implementations + +## Topics + +### Instance Properties + +`var debugDescription: String` + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/configsnapshot/providername + +- Configuration +- ConfigSnapshot +- providerName + +Instance Property + +# providerName + +The human-readable name of the configuration provider that created this snapshot. + +var providerName: String { get } + +ConfigProvider.swift + +**Required** + +## Discussion + +Used by `AccessReporter` and when diagnostic logging the config reader types. + +## See Also + +### Required methods + +Returns a value for the specified key from this immutable snapshot. + +- providerName +- Discussion +- See Also + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/secretsspecifier/issecret(key:value:) + +#app-main) + +- Configuration +- SecretsSpecifier +- isSecret(key:value:) + +Instance Method + +# isSecret(key:value:) + +Determines whether a configuration value should be treated as secret. + +func isSecret( +key: KeyType, +value: ValueType + +SecretsSpecifier.swift + +Available when `KeyType` conforms to `Hashable`, `KeyType` conforms to `Sendable`, and `ValueType` conforms to `Sendable`. + +## Parameters + +`key` + +The provider-specific configuration key. + +`value` + +The configuration value to evaluate. + +## Return Value + +`true` if the value should be treated as secret; otherwise, `false`. + +## Discussion + +This method evaluates the secrets specifier against the provided key-value pair to determine if the value contains sensitive information that should be protected from disclosure. + +let isSecret = specifier.isSecret(key: "API_KEY", value: "secret123") +// Returns: true + +- isSecret(key:value:) +- Parameters +- Return Value +- Discussion + +| +| + +--- + +# https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/metadata-swift.property + +- Configuration +- AccessEvent +- metadata + +Instance Property + +# metadata + +Metadata that describes the configuration access operation. + +var metadata: AccessEvent.Metadata + +AccessReporter.swift + +## See Also + +### Inspecting an access event + +The final outcome of the configuration access operation. + +`var conversionError: (any Error)?` + +An error that occurred when converting the raw config value into another type, for example `RawRepresentable`. + +[`var providerResults: [AccessEvent.ProviderResult]`](https://swiftpackageindex.com/apple/swift-configuration/1.0.0/documentation/configuration/accessevent/providerresults) + +The results from each configuration provider that was queried. + +| +| + +--- + diff --git a/Docs/skit-analyze-plan.md b/Docs/skit-analyze-plan.md new file mode 100644 index 0000000..5348f54 --- /dev/null +++ b/Docs/skit-analyze-plan.md @@ -0,0 +1,954 @@ +# Plan: SyntaxKit Analyzer CLI Tool + +## Context + +We need to create a CLI tool that uses the Claude API to automatically update the SyntaxKit library with missing features. The tool will: + +1. Take an **input folder** containing: + - `dsl.swift` - Swift DSL code (desired API) + - `expected.swift` - Expected Swift code output +2. Take a **SyntaxKit library path** (existing sources) +3. **Auto-generate AST** from `expected.swift` using existing SyntaxParser +4. Analyze what's missing using Claude API +5. **Generate updated SyntaxKit library** with the missing features implemented +6. Write updated library to an **output folder** + +This addresses the problem of implementing missing SyntaxKit features. Instead of manual implementation after identifying gaps, this tool automates the entire process: analysis → code generation → updated library output. Developers provide examples of what they want to generate, and the tool implements the necessary SyntaxKit features. + +## Implementation Approach + +### 1. Create New Executable Target: `skit-analyze` + +**Location**: `Sources/skit-analyze/` + +**Dependencies**: +- `SyntaxParser` (existing) - for parsing Swift code to AST +- `ConfigKeyKit` (existing in project) - for configuration key management +- `swift-configuration` - for CLI argument and environment variable handling +- Foundation (URLSession) - for HTTP requests to Claude API + +### 2. Core Components + +#### A. Configuration Structure (`AnalyzerConfiguration.swift`) + +Configuration using ConfigKeyKit pattern: + +```swift +import Configuration +import ConfigKeyKit + +struct AnalyzerConfiguration: ConfigurationParseable { + typealias ConfigReader = Configuration.ConfigReader + typealias BaseConfig = Never + + // Configuration keys + static let syntaxKitPathKey = ConfigKey( + "syntaxkit.path", + default: "Sources/SyntaxKit" + ) + + static let apiKeyKey = OptionalConfigKey( + cli: "api-key", + env: "ANTHROPIC_API_KEY" + ) + + static let modelKey = ConfigKey( + "model", + default: "claude-opus-4-6" + ) + + static let verboseKey = ConfigKey("verbose", default: false) + + // Properties + let inputFolderPath: String // Folder containing dsl.swift, expected.swift + let syntaxKitPath: String // Path to existing SyntaxKit sources + let outputFolderPath: String // Where to write updated library + let apiKey: String + let model: String + let verbose: Bool + + init(configuration: ConfigReader, base: Never?) async throws { + // Read positional arguments from command line + let args = CommandLine.arguments.dropFirst() // Skip executable name + let positionalArgs = args.filter { !$0.hasPrefix("--") } + + guard positionalArgs.count >= 3 else { + throw AnalyzerError.missingRequiredArguments( + "Usage: skit-analyze [options]" + ) + } + + self.inputFolderPath = positionalArgs[0] + self.syntaxKitPath = positionalArgs[1] + self.outputFolderPath = positionalArgs[2] + + // Read from configuration (CLI flags and env vars) + self.model = configuration.string(forKey: Self.modelKey) + self.verbose = configuration.bool(forKey: Self.verboseKey) + + // API key is required - check CLI flag, then env var + guard let key = configuration.string(forKey: Self.apiKeyKey) else { + throw AnalyzerError.missingAPIKey( + "API key required. Provide via --api-key flag or ANTHROPIC_API_KEY environment variable" + ) + } + self.apiKey = key + + // Validate paths exist + try validatePaths() + } + + private func validatePaths() throws { + let fm = FileManager.default + + guard fm.fileExists(atPath: inputFolderPath) else { + throw AnalyzerError.invalidPath("Input folder does not exist: \(inputFolderPath)") + } + + guard fm.fileExists(atPath: syntaxKitPath) else { + throw AnalyzerError.invalidPath("SyntaxKit path does not exist: \(syntaxKitPath)") + } + } +} + +enum AnalyzerError: Error { + case missingRequiredArguments(String) + case missingAPIKey(String) + case invalidPath(String) + case missingInputFile(String) + case astGenerationError(String) + case apiError(String) + case codeGenerationError(String) +} +``` + +#### B. Command Implementation (`AnalyzeCommand.swift`) + +Command using ConfigKeyKit Command protocol: + +```swift +import ConfigKeyKit +import Configuration + +struct AnalyzeCommand: Command { + typealias Config = AnalyzerConfiguration + + static let commandName = "analyze" + static let abstract = "Generate updated SyntaxKit library with missing features" + static let helpText = """ + OVERVIEW: Automatically implement missing SyntaxKit features using Claude API + + USAGE: skit-analyze [options] + + ARGUMENTS: + Folder containing: + - dsl.swift: Swift DSL code (desired API) + - expected.swift: Expected Swift code output + Note: AST is auto-generated from expected.swift + + Path to existing SyntaxKit library sources + + Where to write the updated SyntaxKit library + + OPTIONS: + --api-key Claude API key (or set ANTHROPIC_API_KEY) + --model Claude model to use (default: claude-opus-4-6) + --verbose Enable verbose output + -h, --help Show help information + + EXAMPLE: + mkdir examples/subscript-feature + echo 'Subscript("Item") { ... }' > examples/subscript-feature/dsl.swift + echo 'subscript(index: Int) -> Item { ... }' > examples/subscript-feature/expected.swift + + export ANTHROPIC_API_KEY="sk-ant-..." + skit-analyze examples/subscript-feature Sources/SyntaxKit output/SyntaxKit + """ + + let config: Config + + init(config: Config) { + self.config = config + } + + static func createInstance() async throws -> Self { + // Create providers + let envProvider = EnvironmentVariablesProvider() + let cliProvider = CommandLineArgumentsProvider() + + // Provider hierarchy: CLI args override environment variables + let reader = ConfigReader(providers: [cliProvider, envProvider]) + + // Parse configuration + let configuration = try await Config(configuration: reader) + + return Self(config: configuration) + } + + func execute() async throws { + // Delegate to analyzer + let analyzer = SyntaxKitAnalyzer(config: config) + try await analyzer.run() + } +} +``` + +#### C. Main Entry Point (`main.swift`) + +```swift +@main +enum SkitAnalyze { + static func main() async { + do { + let command = try await AnalyzeCommand.createInstance() + try await command.execute() + } catch { + print("Error: \(error)") + exit(1) + } + } +} +``` + +#### D. Main Analyzer (`SyntaxKitAnalyzer.swift`) + +Core analyzer that orchestrates the entire workflow: + +```swift +struct SyntaxKitAnalyzer { + let config: AnalyzerConfiguration + + func run() async throws { + if config.verbose { + print("Generating updated SyntaxKit library...") + print("Input Folder: \(config.inputFolderPath)") + print("SyntaxKit Path: \(config.syntaxKitPath)") + print("Output Folder: \(config.outputFolderPath)") + } + + // 1. Read input files from folder + let inputReader = InputFolderReader(folderPath: config.inputFolderPath) + let inputs = try inputReader.readInputs() + + if config.verbose { + print("Found: DSL (\(inputs.dslCode.count) chars), " + + "Expected Swift (\(inputs.expectedSwift.count) chars)") + } + + // 2. Generate AST from expected.swift using SyntaxParser + if config.verbose { print("Generating AST from expected.swift...") } + let astGenerator = ASTGenerator() + let swiftAST = try astGenerator.generateAST(from: inputs.expectedSwift) + + // 3. Collect library code + if config.verbose { print("Collecting SyntaxKit library code...") } + let collector = LibraryCollector() + let libraryCode = try collector.collectLibraryCode(from: config.syntaxKitPath) + + if config.verbose { + print("Library: \(libraryCode.split(separator: "\n").count) lines from " + + "\(collector.fileCount) files") + } + + // 4. Call Claude API for analysis AND code generation + if config.verbose { print("Calling Claude API (\(config.model))...") } + let client = ClaudeAPIClient(apiKey: config.apiKey, model: config.model) + let result = try await client.generateUpdatedLibrary( + syntaxKitLibrary: libraryCode, + expectedSwift: inputs.expectedSwift, + swiftAST: swiftAST, + swiftDSL: inputs.dslCode + ) + + if config.verbose { + print("Received \(result.updatedFiles.count) updated files") + } + + // 5. Write updated library to output folder + try writeUpdatedLibrary(result) + + print("✓ Updated SyntaxKit library written to: \(config.outputFolderPath)") + } + + private func writeUpdatedLibrary(_ result: LibraryUpdateResult) throws { + let writer = LibraryWriter(outputPath: config.outputFolderPath) + try writer.writeUpdatedLibrary(result) + + if config.verbose { + print("\nUpdated files:") + for file in result.updatedFiles { + print(" - \(file.path)") + } + if !result.newFiles.isEmpty { + print("\nNew files:") + for file in result.newFiles { + print(" + \(file.path)") + } + } + } + } +} +``` + +#### E. Input Folder Reader (`InputFolderReader.swift`) + +Reads and validates files from the input folder: + +```swift +struct InputFolderReader { + let folderPath: String + + struct Inputs { + let dslCode: String + let expectedSwift: String + } + + func readInputs() throws -> Inputs { + let fm = FileManager.default + + // Required: dsl.swift + let dslPath = "\(folderPath)/dsl.swift" + guard fm.fileExists(atPath: dslPath) else { + throw AnalyzerError.missingInputFile("Missing required file: dsl.swift") + } + let dslCode = try String(contentsOfFile: dslPath) + + // Required: expected.swift + let expectedPath = "\(folderPath)/expected.swift" + guard fm.fileExists(atPath: expectedPath) else { + throw AnalyzerError.missingInputFile("Missing required file: expected.swift") + } + let expectedSwift = try String(contentsOfFile: expectedPath) + + return Inputs( + dslCode: dslCode, + expectedSwift: expectedSwift + ) + } +} +``` + +#### F. Library Code Collector (`LibraryCollector.swift`) + +Responsible for gathering all SyntaxKit source files: + +```swift +struct LibraryCollector { + private(set) var fileCount: Int = 0 // Track number of files collected + + /// Recursively collects all .swift files from SyntaxKit directory + mutating func collectLibraryCode(from path: String) throws -> String + + /// Formats collected code with file markers for clarity + private func formatWithFileMarkers(_ files: [(path: String, content: String)]) -> String +} +``` + +Implementation will: +- Recursively scan the SyntaxKit directory +- Read all `.swift` files +- Concatenate with clear file path markers for each file +- Track file count for verbose output +- Skip test files and build artifacts +- Preserve relative paths for later reference + +#### G. Library Writer (`LibraryWriter.swift`) + +Writes the updated library files to the output folder: + +```swift +struct LibraryWriter { + let outputPath: String + + func writeUpdatedLibrary(_ result: LibraryUpdateResult) throws { + let fm = FileManager.default + + // Create output directory if it doesn't exist + try fm.createDirectory(atPath: outputPath, withIntermediateDirectories: true) + + // Write updated files + for file in result.updatedFiles { + let fullPath = "\(outputPath)/\(file.relativePath)" + let directory = (fullPath as NSString).deletingLastPathComponent + try fm.createDirectory(atPath: directory, withIntermediateDirectories: true) + try file.content.write(toFile: fullPath, atomically: true, encoding: .utf8) + } + + // Write new files + for file in result.newFiles { + let fullPath = "\(outputPath)/\(file.relativePath)" + let directory = (fullPath as NSString).deletingLastPathComponent + try fm.createDirectory(atPath: directory, withIntermediateDirectories: true) + try file.content.write(toFile: fullPath, atomically: true, encoding: .utf8) + } + + // Copy unchanged files (optional - could skip and only write changes) + if result.includeUnchangedFiles { + for file in result.unchangedFiles { + let fullPath = "\(outputPath)/\(file.relativePath)" + let directory = (fullPath as NSString).deletingLastPathComponent + try fm.createDirectory(atPath: directory, withIntermediateDirectories: true) + try fm.copyItem(atPath: file.sourcePath, toPath: fullPath) + } + } + } +} +``` + +#### H. AST Generator (`ASTGenerator.swift`) + +Wraps existing SyntaxParser to produce formatted AST: + +```swift +import SyntaxParser + +struct ASTGenerator { + /// Generates formatted AST from Swift code using SyntaxParser + func generateAST(from swiftCode: String) throws -> String { + // Use existing SyntaxParser to parse Swift code + let treeNodes = SyntaxParser.parse(code: swiftCode) + + // Format TreeNode array as readable hierarchical text or JSON + return formatAST(treeNodes) + } + + /// Formats TreeNode array as readable hierarchical text or JSON + private func formatAST(_ nodes: [TreeNode]) -> String { + // Could output as JSON or formatted text + // JSON is probably better for Claude to parse + let encoder = JSONEncoder() + encoder.outputFormatting = [.prettyPrinted, .sortedKeys] + + guard let data = try? encoder.encode(nodes), + let json = String(data: data, encoding: .utf8) else { + return "[]" + } + + return json + } +} +``` + +**Key Points**: +- Reuses existing `SyntaxParser.parse(code:)` from `Sources/SyntaxParser/` +- Returns JSON representation of the AST (TreeNode array) +- This is the same code path used by the `skit` executable +- No need for external AST generation - it's built-in! + +#### I. Claude API Client (`ClaudeAPIClient.swift`) + +Handles communication with Claude API for code generation: + +```swift +struct ClaudeAPIClient { + let apiKey: String + let model: String + + /// Sends request to generate updated library code + func generateUpdatedLibrary( + syntaxKitLibrary: String, + expectedSwift: String, + swiftAST: String, + swiftDSL: String + ) async throws -> LibraryUpdateResult + + /// Formats the API request payload with code generation instructions + private func createRequestPayload(...) -> [String: Any] + + /// Parses API response containing generated code + private func parseCodeGenerationResponse(_ data: Data) throws -> LibraryUpdateResult +} + +struct LibraryUpdateResult: Codable { + struct UpdatedFile: Codable { + let relativePath: String // e.g., "Declarations/Subscript.swift" + let content: String + let changeDescription: String + } + + struct NewFile: Codable { + let relativePath: String + let content: String + let purpose: String + } + + let updatedFiles: [UpdatedFile] + let newFiles: [NewFile] + let unchangedFiles: [FileReference] + let includeUnchangedFiles: Bool + let summary: String // Claude's explanation of changes +} + +struct FileReference: Codable { + let relativePath: String + let sourcePath: String +} +``` + +API request structure: +- Endpoint: `https://api.anthropic.com/v1/messages` +- Headers: `x-api-key`, `anthropic-version: 2023-06-01`, `content-type: application/json` +- Body: Enhanced prompt asking Claude to generate actual Swift code, not just describe changes + +Modified Prompt Strategy: +- Still uses the Workbench prompt for analysis +- **Additionally** asks Claude to generate the actual implementation code +- Requests output in structured format using XML-style markers +- Each code file marked with: `...code...` + +**Response Parsing**: +The API client will parse Claude's response by: +1. Extract all `` blocks using regex or XML parsing +2. For each file block: + - Extract `path` attribute (relative path like "Declarations/Subscript.swift") + - Extract content between tags (complete Swift code) + - Determine if it's a new file or modification (check against library file list) +3. Build `LibraryUpdateResult` with categorized files +4. Include Claude's analysis summary from the response + +**Code Generation Reliability**: +- Claude Opus 4.6 is excellent at generating complete, valid Swift code +- The prompt emphasizes: "provide COMPLETE file content, not diffs" +- Each file should be self-contained and compilable +- The tool can optionally run `swift build` on output to verify validity + +#### J. Prompt Template (`PromptTemplate.swift`) + +Contains enhanced version of Workbench prompt with code generation instructions: + +```swift +struct PromptTemplate { + static func createAnalysisAndCodeGeneration( + syntaxKitLibrary: String, + expectedSwift: String, + swiftAST: String, + swiftDSL: String + ) -> String { + // Original Workbench prompt for analysis + // PLUS additional instructions for code generation + } +} +``` + +**Prompt Structure**: +1. **Analysis Phase** (from Workbench): Analyze what needs to be added/modified +2. **Code Generation Phase** (added): Generate actual Swift implementation +3. **Output Format**: Structured response with: + - Analysis summary + - List of files to modify with complete new content + - List of new files to create with complete content + - Each file marked with: `...` + +**Example Enhanced Prompt**: +``` +[Original Workbench prompt...] + +After your analysis, generate the actual Swift code needed to implement these changes: + + +For each required change you identified, provide the COMPLETE updated file content. +Mark each file with its path relative to the SyntaxKit root. + +Format: + +// Complete file content here + + +Include: +- Modified existing files (full content, not diffs) +- New files that need to be created +- Updated Package.swift if new targets/dependencies needed + +``` + +### 3. Workflow + +``` +User runs: skit-analyze examples/subscript-feature Sources/SyntaxKit output/SyntaxKit + +1. main.swift: Entry point +2. AnalyzeCommand.createInstance(): + - Create EnvironmentVariablesProvider and CommandLineArgumentsProvider + - Create ConfigReader with provider hierarchy (CLI > ENV) + - Parse AnalyzerConfiguration from ConfigReader + - Validate required arguments (input folder, syntaxkit path, output folder, API key) + - Validate paths exist +3. AnalyzeCommand.execute(): + - Create SyntaxKitAnalyzer instance with config + - Call analyzer.run() +4. SyntaxKitAnalyzer.run(): + a. Read input folder: + - InputFolderReader reads dsl.swift and expected.swift + b. Generate AST: + - ASTGenerator.generateAST(from: expected.swift) using SyntaxParser + - Returns JSON representation of TreeNode array + c. Collect library code: LibraryCollector.collectLibraryCode() → syntaxKitLibrary + d. Create Claude API client with API key and model + e. Call API: client.generateUpdatedLibrary() → LibraryUpdateResult + - Claude analyzes what's missing + - Claude generates complete Swift implementation + - Returns structured result with file contents + f. Write updated library: LibraryWriter.writeUpdatedLibrary() + - Create output directory structure + - Write updated files with new content + - Write new files + - Optionally copy unchanged files + g. Print success message with output path +``` + +### 4. Package.swift Changes + +Add ConfigKeyKit as a local target and integrate swift-configuration: + +```swift +// In dependencies (add swift-configuration): +.package( + url: "https://github.com/apple/swift-configuration", + from: "1.0.0", + traits: ["CommandLineArguments"] // Enable CLI args trait +), + +// Add ConfigKeyKit as a target: +.target( + name: "ConfigKeyKit", + dependencies: [ + .product(name: "Configuration", package: "swift-configuration") + ], + swiftSettings: swiftSettings +), + +// Add new executable target: +.executableTarget( + name: "skit-analyze", + dependencies: [ + "SyntaxParser", + "ConfigKeyKit", + .product(name: "Configuration", package: "swift-configuration") + ], + swiftSettings: swiftSettings +), + +// In products: +.executable( + name: "skit-analyze", + targets: ["skit-analyze"] +), +``` + +**Note**: ConfigKeyKit already exists in the project directory, so we just need to add it as a target in Package.swift. + +### 5. Configuration & Environment + +**How swift-configuration + ConfigKeyKit Works Together**: + +1. **ConfigKeyKit** provides the abstraction layer: + - `ConfigKey` for required values with defaults + - `OptionalConfigKey` for optional values + - Automatic key naming transformations (e.g., `api.key` → `--api-key` or `API_KEY`) + - Source-specific key generation (CLI vs ENV have different naming conventions) + +2. **swift-configuration** provides the runtime: + - `ConfigReader` reads from multiple providers + - `CommandLineArgumentsProvider` parses `--flag value` style arguments + - `EnvironmentVariablesProvider` reads from environment + - Provider hierarchy: CLI arguments override environment variables + +3. **Integration**: + ```swift + // Define key with both sources + let apiKeyKey = OptionalConfigKey( + cli: "api-key", // Becomes --api-key + env: "ANTHROPIC_API_KEY" // Reads from $ANTHROPIC_API_KEY + ) + + // Read with ConfigReader + let apiKey = configuration.string(forKey: apiKeyKey) // Checks CLI first, then ENV + ``` + +**API Key Management**: +- `--api-key` flag takes precedence (via CommandLineArgumentsProvider) +- Falls back to `ANTHROPIC_API_KEY` environment variable (via EnvironmentVariablesProvider) +- Error if neither is provided + +**Positional Arguments**: +- Three required positional arguments (not flags): + 1. Input folder path (containing dsl.swift, expected.swift, optional ast files) + 2. SyntaxKit library path (existing sources to read) + 3. Output folder path (where to write updated library) +- Parsed manually from `CommandLine.arguments` in configuration initializer +- More intuitive than using flags for required paths +- Example: `skit-analyze examples/feature Sources/SyntaxKit output/updated` + +**Default Values**: +- SyntaxKit library path: `Sources/SyntaxKit` (via `ConfigKey` default) +- Model: `claude-opus-4-6` (via `ConfigKey` default) +- Verbose: `false` (via `ConfigKey` default) +- Can all be overridden via CLI flags or environment variables + +**Model Configuration**: +- Model: Default `claude-opus-4-6`, override with `--model` +- Max tokens: 20000 (hardcoded in API client) +- Temperature: 1 (hardcoded as specified in Workbench) + +### 6. Error Handling + +Comprehensive error handling for: +- Missing files (Swift code, DSL code) +- Invalid paths (SyntaxKit library not found) +- API errors (authentication, rate limits, network issues) +- Parsing errors (invalid Swift code) +- JSON encoding/decoding errors + +Use Swift's error handling with descriptive error messages. + +### 7. Output Format + +**Standard Output** (default): +``` +Analyzing SyntaxKit requirements... + +Swift Code: target.swift (245 lines) +DSL Code: dsl.swift (89 lines) +Generated AST: 1,234 nodes +Library Code: 15,678 lines from 142 files + +Calling Claude API (model: claude-opus-4-6)... +Response received (3,456 tokens) + +REQUIRED CHANGES: +================ + +[Claude's analysis output here] +``` + +**File Output** (with `--output changes.md`): +Save just the required changes section to the specified file. + +**Verbose Mode** (with `--verbose`): +Include full API request/response, intermediate parsing steps, file collection details. + +## Critical Files to Create + +1. **Sources/skit-analyze/main.swift** - Main entry point +2. **Sources/skit-analyze/AnalyzeCommand.swift** - Command implementation using ConfigKeyKit +3. **Sources/skit-analyze/AnalyzerConfiguration.swift** - Configuration structure using ConfigKeyKit +4. **Sources/skit-analyze/SyntaxKitAnalyzer.swift** - Core analyzer orchestration +5. **Sources/skit-analyze/InputFolderReader.swift** - Reads dsl.swift, expected.swift, ast files +6. **Sources/skit-analyze/LibraryCollector.swift** - Collects SyntaxKit source files +7. **Sources/skit-analyze/LibraryWriter.swift** - Writes updated library to output folder +8. **Sources/skit-analyze/ASTGenerator.swift** - Wraps SyntaxParser for AST generation +9. **Sources/skit-analyze/ClaudeAPIClient.swift** - Claude API communication for code generation +10. **Sources/skit-analyze/PromptTemplate.swift** - Enhanced Workbench prompt with code generation +11. **Sources/skit-analyze/Models.swift** - Data models (LibraryUpdateResult, UpdatedFile, NewFile, AnalyzerError) +12. **Package.swift** (modify) - Add ConfigKeyKit target, swift-configuration dependency, and executable target + +## Verification Steps + +1. **Build Test**: + ```bash + swift build -c release + ``` + +2. **Create Test Input**: + ```bash + # Create input folder with test case + mkdir -p examples/simple-property + + cat > examples/simple-property/dsl.swift << 'EOF' + Struct("Person") { + Variable("age", type: "Int") + } + EOF + + cat > examples/simple-property/expected.swift << 'EOF' + struct Person { + let age: Int + } + EOF + ``` + +3. **Run Tool**: + ```bash + export ANTHROPIC_API_KEY="sk-ant-..." + .build/release/skit-analyze \ + examples/simple-property \ + Sources/SyntaxKit \ + output/SyntaxKit-updated + ``` + +4. **Verify Output**: + ```bash + # Check that output directory was created + ls -la output/SyntaxKit-updated + + # Verify updated files exist + # Should see modified/new files for the feature + + # Check that generated code is valid Swift + cd output/SyntaxKit-updated && swift build + ``` + +5. **Test Generated Code**: + ```bash + # Create a test that uses the new feature + # Verify it compiles and produces expected output + ``` + +6. **Error Handling Tests**: + ```bash + # Test missing API key + skit-analyze examples/test Sources/SyntaxKit output # Should error + + # Test invalid input folder + skit-analyze nonexistent Sources/SyntaxKit output # Should error + + # Test missing required files + mkdir -p examples/incomplete + echo "test" > examples/incomplete/dsl.swift + # Missing expected.swift - should error + skit-analyze examples/incomplete Sources/SyntaxKit output + ``` + +7. **Integration Test**: Use a real missing feature (e.g., subscript syntax) and verify: + - Tool generates valid Swift code + - Generated code follows SyntaxKit patterns + - Generated code compiles + - Feature actually works as expected + +## Future Enhancements (Not in Scope) + +- **Validation Mode**: Run `swift build` on generated code and retry if compilation fails +- **Interactive Review**: Show diff before writing, allow user to approve/reject changes +- **Batch Processing**: Process multiple feature folders in one run +- **Incremental Updates**: Only update changed files, preserve git history +- **Test Generation**: Also generate unit tests for new features +- **Template Library**: Save/reuse common patterns across feature generations +- **Local Caching**: Cache library code and API responses to reduce API calls +- **Multi-Provider**: Support OpenAI, Google Gemini as alternative to Claude +- **Diff Output**: Optionally output unified diffs instead of complete files + +## Dependencies Summary + +**New Dependencies**: +- `swift-configuration` (1.0.0+) with `CommandLineArguments` trait - Configuration management + +**Existing Dependencies** (reused): +- `ConfigKeyKit` (in project) - Configuration key abstraction +- `SwiftSyntax` (601.0.1+) - via SyntaxParser +- `SyntaxParser` (existing module) - AST generation +- Foundation - HTTP requests, file I/O + +**Advantages of swift-configuration + ConfigKeyKit**: +- Unified handling of CLI args and environment variables +- Type-safe configuration keys with automatic naming transformations +- Composable provider hierarchy (CLI overrides ENV) +- Consistent with project's existing ConfigKeyKit architecture +- More flexible than ArgumentParser for complex configuration scenarios + +## Build & Install + +```bash +# Build +swift build -c release + +# Install to system (optional) +cp .build/release/skit-analyze /usr/local/bin/ + +# Or run from build directory +.build/release/skit-analyze +``` + +## Example Usage + +### Basic Example: Add Subscript Support + +```bash +# 1. Create input folder with feature specification +mkdir -p examples/subscript-feature + +# 2. Define the desired DSL syntax +cat > examples/subscript-feature/dsl.swift << 'EOF' +Struct("Collection") { + Subscript(parameters: [Parameter("index", type: "Int")], returnType: "Element") { + Return(PropertyAccessExp("items", "index")) + } +} +EOF + +# 3. Define expected Swift output +cat > examples/subscript-feature/expected.swift << 'EOF' +struct Collection { + subscript(index: Int) -> Element { + return items[index] + } +} +EOF + +# 4. Run the tool +# Note: AST is automatically generated from expected.swift using SyntaxParser +export ANTHROPIC_API_KEY="sk-ant-..." +skit-analyze \ + examples/subscript-feature \ + Sources/SyntaxKit \ + output/SyntaxKit-with-subscripts +``` + +### Advanced Examples + +```bash +# With custom model +skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ + --model claude-sonnet-4-5 + +# With verbose output to see what's happening +skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ + --verbose + +# Using CLI flag for API key instead of environment +skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ + --api-key sk-ant-... + +# Show help +skit-analyze --help +``` + +### Full Workflow Example + +```bash +# Step 1: Identify a missing feature (e.g., defer statements) +mkdir -p examples/defer-statement + +# Step 2: Write the DSL you wish existed +cat > examples/defer-statement/dsl.swift << 'EOF' +Function("cleanup") { + Defer { + Call("closeFile") + } +} +EOF + +# Step 3: Write what Swift code it should generate +cat > examples/defer-statement/expected.swift << 'EOF' +func cleanup() { + defer { + closeFile() + } +} +EOF + +# Step 4: Generate updated SyntaxKit with defer support +export ANTHROPIC_API_KEY="sk-ant-..." +skit-analyze \ + examples/defer-statement \ + Sources/SyntaxKit \ + output/SyntaxKit-with-defer \ + --verbose + +# Step 5: Verify it works +cd output/SyntaxKit-with-defer +swift build + +# Step 6: Test the new feature +# Create a test file that uses Defer { ... } +# Run it and verify output matches expected +``` diff --git a/Sources/ConfigKeyKit/Command.swift b/Sources/ConfigKeyKit/Command.swift new file mode 100644 index 0000000..693b23c --- /dev/null +++ b/Sources/ConfigKeyKit/Command.swift @@ -0,0 +1,61 @@ +// +// Command.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Generic protocol for CLI commands using Swift Configuration +public protocol Command: Sendable { + /// Associated configuration type for this command + associatedtype Config: ConfigurationParseable + + /// Command name for CLI parsing + static var commandName: String { get } + + /// Abstract description of the command + static var abstract: String { get } + + /// Detailed help text for the command + static var helpText: String { get } + + /// Initialize command with configuration + init(config: Config) + + /// Execute the command asynchronously + func execute() async throws + + /// Create a command instance with configuration + static func createInstance() async throws -> Self +} + +public extension Command { + /// Print help information for this command + static func printHelp() { + print(helpText) + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/CommandConfiguration.swift b/Sources/ConfigKeyKit/CommandConfiguration.swift new file mode 100644 index 0000000..03ffdcd --- /dev/null +++ b/Sources/ConfigKeyKit/CommandConfiguration.swift @@ -0,0 +1,39 @@ +// +// CommandConfiguration.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +/// Command configuration for identifying and routing commands +public struct CommandConfiguration { + public let commandName: String + public let abstract: String + + public init(commandName: String, abstract: String) { + self.commandName = commandName + self.abstract = abstract + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/CommandLineParser.swift b/Sources/ConfigKeyKit/CommandLineParser.swift new file mode 100644 index 0000000..a7c2f8a --- /dev/null +++ b/Sources/ConfigKeyKit/CommandLineParser.swift @@ -0,0 +1,74 @@ +// +// CommandLineParser.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Command line argument parser for Swift Configuration integration +public struct CommandLineParser { + private let arguments: [String] + + public init(arguments: [String] = CommandLine.arguments) { + self.arguments = arguments + } + + /// Parse the command name from command line arguments + public func parseCommandName() -> String? { + // Skip the executable name (first argument) + guard arguments.count > 1 else { return nil } + let commandCandidate = arguments[1] + + // If it starts with '--', it's not a command but a global option + if commandCandidate.hasPrefix("--") { + return nil + } + + return commandCandidate + } + + /// Get all arguments after the command name for command-specific parsing + public func commandArguments() -> [String] { + guard arguments.count > 1 else { return [] } + let commandName = arguments[1] + + // If first argument is an option, return all arguments for global parsing + if commandName.hasPrefix("--") { + return Array(arguments.dropFirst()) + } + + // Return arguments after command name + return Array(arguments.dropFirst(2)) + } + + /// Check if help was requested + public func isHelpRequested() -> Bool { + arguments.contains { arg in + arg == "--help" || arg == "-h" || arg == "help" + } + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/CommandRegistry.swift b/Sources/ConfigKeyKit/CommandRegistry.swift new file mode 100644 index 0000000..39f9e8e --- /dev/null +++ b/Sources/ConfigKeyKit/CommandRegistry.swift @@ -0,0 +1,88 @@ +// +// CommandRegistry.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Actor-based registry for managing available commands +public actor CommandRegistry { + private var registeredCommands: [String: any Command.Type] = [:] + private var commandMetadata: [String: CommandMetadata] = [:] + + /// Metadata about a command + public struct CommandMetadata: Sendable { + public let commandName: String + public let abstract: String + public let helpText: String + } + + /// Shared instance + public static let shared = CommandRegistry() + + // Internal initializer for testability - allows tests to create isolated instances + internal init() {} + + /// Register a command type with the registry + public func register(_ commandType: T.Type) { + registeredCommands[T.commandName] = commandType + commandMetadata[T.commandName] = CommandMetadata( + commandName: T.commandName, + abstract: T.abstract, + helpText: T.helpText + ) + } + + /// Get all registered command names + public var availableCommands: [String] { + Array(registeredCommands.keys).sorted() + } + + /// Get command metadata + public func metadata(for name: String) -> CommandMetadata? { + commandMetadata[name] + } + + /// Get command type for the given name + public func commandType(named name: String) -> (any Command.Type)? { + return registeredCommands[name] + } + + /// Create a command instance dynamically with automatic config parsing + public func createCommand(named name: String) async throws -> any Command { + guard let commandType = registeredCommands[name] else { + throw CommandRegistryError.unknownCommand(name) + } + + return try await commandType.createInstance() + } + + /// Check if a command is registered + public func isRegistered(_ name: String) -> Bool { + return registeredCommands[name] != nil + } +} diff --git a/Sources/ConfigKeyKit/CommandRegistryError.swift b/Sources/ConfigKeyKit/CommandRegistryError.swift new file mode 100644 index 0000000..84e7848 --- /dev/null +++ b/Sources/ConfigKeyKit/CommandRegistryError.swift @@ -0,0 +1,42 @@ +// +// CommandRegistryError.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +public import Foundation + +/// Errors that can occur in command registry operations +public enum CommandRegistryError: Error, LocalizedError { + case unknownCommand(String) + + public var errorDescription: String? { + switch self { + case .unknownCommand(let name): + return "Unknown command: \(name)" + } + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/ConfigKey+Bool.swift b/Sources/ConfigKeyKit/ConfigKey+Bool.swift new file mode 100644 index 0000000..afb6819 --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigKey+Bool.swift @@ -0,0 +1,72 @@ +// +// ConfigKey+Bool.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +// MARK: - Specialized Initializers for Booleans + +extension ConfigKey where Value == Bool { + /// Non-optional default value accessor for booleans + @available(*, deprecated, message: "Use defaultValue directly instead") + public var boolDefault: Bool { + defaultValue // Already non-optional! + } + + /// Initialize a boolean configuration key with non-optional default + /// - Parameters: + /// - cli: Command-line argument name + /// - env: Environment variable name + /// - defaultVal: Default value (defaults to false) + public init(cli: String, env: String, default defaultVal: Bool = false) { + self.baseKey = nil + self.styles = [:] + var keys: [ConfigKeySource: String] = [:] + keys[.commandLine] = cli + keys[.environment] = env + self.explicitKeys = keys + self.defaultValue = defaultVal + } + + /// Initialize a boolean configuration key from base string + /// - Parameters: + /// - base: Base key string (e.g., "sync.verbose") + /// - envPrefix: Prefix for environment variable (defaults to nil) + /// - defaultVal: Default value (defaults to false) + public init(_ base: String, envPrefix: String? = nil, default defaultVal: Bool = false) { + self.baseKey = base + self.styles = [ + .commandLine: StandardNamingStyle.dotSeparated, + .environment: StandardNamingStyle.screamingSnakeCase(prefix: envPrefix), + ] + self.explicitKeys = [:] + self.defaultValue = defaultVal + } +} + +// Application-specific boolean key helpers should be added in application code \ No newline at end of file diff --git a/Sources/ConfigKeyKit/ConfigKey+Debug.swift b/Sources/ConfigKeyKit/ConfigKey+Debug.swift new file mode 100644 index 0000000..3e101ab --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigKey+Debug.swift @@ -0,0 +1,36 @@ +// +// ConfigKey+Debug.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +extension ConfigKey: CustomDebugStringConvertible { + public var debugDescription: String { + let cliKey = key(for: .commandLine) ?? "nil" + let envKey = key(for: .environment) ?? "nil" + return "ConfigKey(cli: \(cliKey), env: \(envKey), default: \(defaultValue))" + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/ConfigKey.swift b/Sources/ConfigKeyKit/ConfigKey.swift new file mode 100644 index 0000000..8d43e7c --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigKey.swift @@ -0,0 +1,113 @@ +// +// ConfigKey.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +// MARK: - Generic Configuration Key + +/// Configuration key for values with default fallbacks +/// +/// Use `ConfigKey` when a configuration value has a sensible default +/// that should be used when not provided by the user. The `read()` method +/// will always return a non-optional value. +/// +/// Example: +/// ```swift +/// let containerID = ConfigKey( +/// base: "cloudkit.container_id", +/// default: "iCloud.com.example.MyApp" +/// ) +/// // read(containerID) returns String (non-optional) +/// ``` +public struct ConfigKey: ConfigurationKey, Sendable { + internal let baseKey: String? + internal let styles: [ConfigKeySource: any NamingStyle] + internal let explicitKeys: [ConfigKeySource: String] + public let defaultValue: Value // Non-optional! + + /// The base key string used for this configuration key + public var base: String? { baseKey } + + /// Initialize with explicit CLI and ENV keys and required default + public init(cli: String? = nil, env: String? = nil, default defaultVal: Value) { + self.baseKey = nil + self.styles = [:] + var keys: [ConfigKeySource: String] = [:] + if let cli = cli { keys[.commandLine] = cli } + if let env = env { keys[.environment] = env } + self.explicitKeys = keys + self.defaultValue = defaultVal + } + + /// Initialize from a base key string with naming styles and required default + /// - Parameters: + /// - base: Base key string (e.g., "cloudkit.container_id") + /// - styles: Dictionary mapping sources to naming styles + /// - defaultVal: Required default value + public init( + base: String, + styles: [ConfigKeySource: any NamingStyle], + default defaultVal: Value + ) { + self.baseKey = base + self.styles = styles + self.explicitKeys = [:] + self.defaultValue = defaultVal + } + + /// Convenience initializer with standard naming conventions and required default + /// - Parameters: + /// - base: Base key string (e.g., "cloudkit.container_id") + /// - envPrefix: Prefix for environment variable (defaults to nil) + /// - defaultVal: Required default value + public init(_ base: String, envPrefix: String? = nil, default defaultVal: Value) { + self.baseKey = base + self.styles = [ + .commandLine: StandardNamingStyle.dotSeparated, + .environment: StandardNamingStyle.screamingSnakeCase(prefix: envPrefix), + ] + self.explicitKeys = [:] + self.defaultValue = defaultVal + } + + public func key(for source: ConfigKeySource) -> String? { + // Check for explicit key first + if let explicit = explicitKeys[source] { + return explicit + } + + // Generate from base key and style + guard let base = baseKey, let style = styles[source] else { + return nil + } + + return style.transform(base) + } +} + diff --git a/Sources/ConfigKeyKit/ConfigKeySource.swift b/Sources/ConfigKeyKit/ConfigKeySource.swift new file mode 100644 index 0000000..96a928b --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigKeySource.swift @@ -0,0 +1,39 @@ +// +// ConfigKeySource.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +// MARK: - Configuration Key Source + +/// Source for configuration keys (CLI arguments or environment variables) +public enum ConfigKeySource: CaseIterable, Sendable { + /// Command-line arguments (e.g., --cloudkit-container-id) + case commandLine + + /// Environment variables (e.g., CLOUDKIT_CONTAINER_ID) + case environment +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/ConfigurationKey.swift b/Sources/ConfigKeyKit/ConfigurationKey.swift new file mode 100644 index 0000000..a2f015d --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigurationKey.swift @@ -0,0 +1,40 @@ +// +// ConfigurationKey.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +// MARK: - Configuration Key Protocol + +/// Protocol for configuration keys that support multiple sources +public protocol ConfigurationKey: Sendable { + /// Get the key string for a specific source + /// - Parameter source: The configuration source (CLI or ENV) + /// - Returns: The key string for that source, or nil if the key doesn't support that source + func key(for source: ConfigKeySource) -> String? +} diff --git a/Sources/ConfigKeyKit/ConfigurationParseable.swift b/Sources/ConfigKeyKit/ConfigurationParseable.swift new file mode 100644 index 0000000..0ed4d0a --- /dev/null +++ b/Sources/ConfigKeyKit/ConfigurationParseable.swift @@ -0,0 +1,54 @@ +// +// ConfigurationParseable.swift +// ConfigKeyKit +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Protocol for configuration types that can parse themselves from command line arguments and environment variables +public protocol ConfigurationParseable: Sendable { + /// Associated type for the configuration reader + associatedtype ConfigReader: Sendable + + /// Associated type for the parent configuration + /// Use `Never` for root configurations that have no parent + associatedtype BaseConfig: Sendable + + /// Initialize the configuration by parsing from available sources (CLI args, environment variables, defaults) + /// - Parameters: + /// - configuration: The configuration reader to parse values from + /// - base: Optional parent configuration (nil for root configs) + init(configuration: ConfigReader, base: BaseConfig?) async throws +} + +/// Extension for root configurations (where BaseConfig == Never) +public extension ConfigurationParseable where BaseConfig == Never { + /// Convenience initializer for root configs that don't need a parent + init(configuration: ConfigReader) async throws { + try await self.init(configuration: configuration, base: nil) + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/NamingStyle.swift b/Sources/ConfigKeyKit/NamingStyle.swift new file mode 100644 index 0000000..f9982f4 --- /dev/null +++ b/Sources/ConfigKeyKit/NamingStyle.swift @@ -0,0 +1,38 @@ +// +// NamingStyle.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +// MARK: - Naming Style + +/// Protocol for transforming base key strings into different naming conventions +public protocol NamingStyle: Sendable { + /// Transform a base key string according to this naming style + /// - Parameter base: Base key string (e.g., "cloudkit.container_id") + /// - Returns: Transformed key string + func transform(_ base: String) -> String +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/OptionalConfigKey+Debug.swift b/Sources/ConfigKeyKit/OptionalConfigKey+Debug.swift new file mode 100644 index 0000000..e9e0dab --- /dev/null +++ b/Sources/ConfigKeyKit/OptionalConfigKey+Debug.swift @@ -0,0 +1,36 @@ +// +// OptionalConfigKey+Debug.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +extension OptionalConfigKey: CustomDebugStringConvertible { + public var debugDescription: String { + let cliKey = key(for: .commandLine) ?? "nil" + let envKey = key(for: .environment) ?? "nil" + return "OptionalConfigKey(cli: \(cliKey), env: \(envKey))" + } +} \ No newline at end of file diff --git a/Sources/ConfigKeyKit/OptionalConfigKey.swift b/Sources/ConfigKeyKit/OptionalConfigKey.swift new file mode 100644 index 0000000..24cfada --- /dev/null +++ b/Sources/ConfigKeyKit/OptionalConfigKey.swift @@ -0,0 +1,103 @@ +// +// OptionalConfigKey.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +// MARK: - Optional Configuration Key + +/// Configuration key for optional values without defaults +/// +/// Use `OptionalConfigKey` when a configuration value has no sensible default +/// and should be `nil` when not provided by the user. The `read()` method +/// will return an optional value. +/// +/// Example: +/// ```swift +/// let apiKey = OptionalConfigKey(base: "api.key") +/// // read(apiKey) returns String? +/// ``` +public struct OptionalConfigKey: ConfigurationKey, Sendable { + internal let baseKey: String? + internal let styles: [ConfigKeySource: any NamingStyle] + internal let explicitKeys: [ConfigKeySource: String] + + /// The base key string used for this configuration key + public var base: String? { baseKey } + + /// Initialize with explicit CLI and ENV keys (no default) + public init(cli: String? = nil, env: String? = nil) { + self.baseKey = nil + self.styles = [:] + var keys: [ConfigKeySource: String] = [:] + if let cli = cli { keys[.commandLine] = cli } + if let env = env { keys[.environment] = env } + self.explicitKeys = keys + } + + /// Initialize from a base key string with naming styles (no default) + /// - Parameters: + /// - base: Base key string (e.g., "cloudkit.key_id") + /// - styles: Dictionary mapping sources to naming styles + public init( + base: String, + styles: [ConfigKeySource: any NamingStyle] + ) { + self.baseKey = base + self.styles = styles + self.explicitKeys = [:] + } + + /// Convenience initializer with standard naming conventions (no default) + /// - Parameters: + /// - base: Base key string (e.g., "cloudkit.key_id") + /// - envPrefix: Prefix for environment variable (defaults to nil) + public init(_ base: String, envPrefix: String? = nil) { + self.baseKey = base + self.styles = [ + .commandLine: StandardNamingStyle.dotSeparated, + .environment: StandardNamingStyle.screamingSnakeCase(prefix: envPrefix), + ] + self.explicitKeys = [:] + } + + public func key(for source: ConfigKeySource) -> String? { + // Check for explicit key first + if let explicit = explicitKeys[source] { + return explicit + } + + // Generate from base key and style + guard let base = baseKey, let style = styles[source] else { + return nil + } + + return style.transform(base) + } +} + diff --git a/Sources/ConfigKeyKit/StandardNamingStyle.swift b/Sources/ConfigKeyKit/StandardNamingStyle.swift new file mode 100644 index 0000000..82cb32b --- /dev/null +++ b/Sources/ConfigKeyKit/StandardNamingStyle.swift @@ -0,0 +1,53 @@ +// +// StandardNamingStyle.swift +// MistDemo +// +// Created by Leo Dion. +// Copyright © 2026 BrightDigit. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// + +import Foundation + +/// Common naming styles for configuration keys +public enum StandardNamingStyle: NamingStyle, Sendable { + /// Dot-separated lowercase (e.g., "cloudkit.container_id") + case dotSeparated + + /// Screaming snake case with prefix (e.g., "APP_CLOUDKIT_CONTAINER_ID") + case screamingSnakeCase(prefix: String?) + + public func transform(_ base: String) -> String { + switch self { + case .dotSeparated: + return base + + case .screamingSnakeCase(let prefix): + let snakeCase = base.uppercased().replacingOccurrences(of: ".", with: "_") + if let prefix = prefix { + return "\(prefix)_\(snakeCase)" + } + return snakeCase + } + } +} \ No newline at end of file From 3395cf6feb0e91956896c429d19dfc1a0c9653ac Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Sun, 8 Feb 2026 22:12:25 -0500 Subject: [PATCH 05/10] Add test/validation mode section to skit-analyze plan Adds comprehensive test mode specifications including: - Test case structure and organization - Test configuration formats (manifest.json, test-config.json) - Four validation strategies (structural, content, build, functional) - Implementation components overview - Usage examples and CLI flags - Benefits of automated testing for prompt validation This enables validation of Claude's code generation against known-good outputs, preventing regressions and ensuring quality. Co-Authored-By: Claude Sonnet 4.5 --- Docs/skit-analyze-plan.md | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/Docs/skit-analyze-plan.md b/Docs/skit-analyze-plan.md index 5348f54..338571b 100644 --- a/Docs/skit-analyze-plan.md +++ b/Docs/skit-analyze-plan.md @@ -815,6 +815,124 @@ Include full API request/response, intermediate parsing steps, file collection d - Generated code compiles - Feature actually works as expected +## 8. Test/Validation Mode + +To ensure the prompt generates correct code changes reliably, we need a test mode that validates Claude's responses against known-good outputs. + +### Overview + +Test mode (`--test` flag) runs the tool against a suite of test cases with predefined inputs and expected outputs, then validates that Claude's generated code matches expectations. + +### Test Case Structure + +``` +test-cases/ +├── subscript-basic/ +│ ├── input/ +│ │ ├── dsl.swift # Input DSL code +│ │ └── expected.swift # Expected Swift output +│ ├── expected-changes/ +│ │ ├── manifest.json # List of expected file changes +│ │ └── Declarations/ +│ │ └── Subscript.swift # Expected new/updated file content +│ └── test-config.json # Test metadata (optional) +├── defer-statement/ +│ └── ... +└── generic-function/ + └── ... +``` + +### Test Configuration Format + +**manifest.json** - Describes expected changes: +```json +{ + "description": "Add subscript support to SyntaxKit", + "expectedNewFiles": [ + "Declarations/Subscript.swift", + "Declarations/SubscriptParameter.swift" + ], + "expectedUpdatedFiles": [ + "Core/CodeBlock.swift" + ], + "minimumNewFiles": 1, + "minimumUpdatedFiles": 0, + "validationStrategy": "structural", + "buildRequired": true +} +``` + +**test-config.json** - Test metadata (optional): +```json +{ + "name": "Subscript Basic Support", + "description": "Tests basic subscript declaration generation", + "tags": ["declaration", "subscript", "basic"], + "priority": "high", + "model": "claude-opus-4-6", + "timeout": 120 +} +``` + +### Validation Strategies + +1. **Structural Validation** (`structural`): + - Verifies expected files were created/modified + - Checks file paths match expectations + - Does not validate exact content + +2. **Content Validation** (`content`): + - Compares generated file content against expected content + - Allows for minor whitespace/formatting differences + - Validates key code structures are present + +3. **Build Validation** (`build`): + - Runs `swift build` on generated library + - Verifies no compilation errors + - Does not compare against expected content + +4. **Functional Validation** (`functional`): + - Runs test suite against generated library + - Verifies generated code produces correct output + - Requires test files in test case + +### Implementation Components + +See the full implementation plan in the main plan file for detailed component specifications including: +- Updated AnalyzerConfiguration with test mode flags +- TestRunner for orchestrating test execution +- TestCaseDiscoverer for finding and loading test cases +- TestValidator for validating results against expectations +- TestModels for test data structures + +### Usage + +```bash +# Run all test cases +skit-analyze --test + +# Run with verbose output +skit-analyze --test --verbose + +# Stop on first failure +skit-analyze --test --test-stop-on-fail + +# Run only tests matching "subscript" +skit-analyze --test --test-filter=subscript + +# Run tests from custom path +skit-analyze --test --test-cases=custom-tests/ +``` + +### Benefits + +1. **Prompt Validation**: Ensures the Claude prompt generates correct code +2. **Regression Prevention**: Catches when prompt changes break existing features +3. **Quality Assurance**: Validates generated code quality before deployment +4. **Documentation**: Test cases serve as examples of expected behavior +5. **Confidence**: Developers can iterate on prompts with confidence +6. **Debugging**: Failed tests pinpoint exactly what's wrong with generated code + ## Future Enhancements (Not in Scope) - **Validation Mode**: Run `swift build` on generated code and retry if compilation fails From 672293d4eb4cb8d81e0be40a939fe6393131c9be Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Mon, 9 Feb 2026 16:22:56 -0500 Subject: [PATCH 06/10] Update skit-analyze plan to use Swift OpenAPI Generator Replace manual ClaudeAPIClient implementation with Swift OpenAPI Generator approach: - Add swift-openapi-generator, runtime, and urlsession dependencies - Use unofficial OpenAPI spec from laszukdawid/anthropic-openapi-spec - Generate type-safe client code at build time - Include setup instructions for OpenAPI spec and config files - Add AuthenticationMiddleware for API key injection Benefits: type safety, maintainability, automatic updates when official spec is released. Co-Authored-By: Claude Sonnet 4.5 --- Docs/skit-analyze-plan.md | 245 +++++++++++++++++++++++++++++++++----- 1 file changed, 218 insertions(+), 27 deletions(-) diff --git a/Docs/skit-analyze-plan.md b/Docs/skit-analyze-plan.md index 338571b..90cacd3 100644 --- a/Docs/skit-analyze-plan.md +++ b/Docs/skit-analyze-plan.md @@ -25,7 +25,9 @@ This addresses the problem of implementing missing SyntaxKit features. Instead o - `SyntaxParser` (existing) - for parsing Swift code to AST - `ConfigKeyKit` (existing in project) - for configuration key management - `swift-configuration` - for CLI argument and environment variable handling -- Foundation (URLSession) - for HTTP requests to Claude API +- `swift-openapi-generator` - for generating type-safe Claude API client from OpenAPI spec +- `swift-openapi-runtime` - runtime support for generated OpenAPI client +- `swift-openapi-urlsession` - URLSession transport for OpenAPI client ### 2. Core Components @@ -437,12 +439,30 @@ struct ASTGenerator { #### I. Claude API Client (`ClaudeAPIClient.swift`) -Handles communication with Claude API for code generation: +Wraps the OpenAPI-generated client for code generation: ```swift +import OpenAPIRuntime +import OpenAPIURLSession + struct ClaudeAPIClient { let apiKey: String let model: String + private let client: Client // Generated from OpenAPI spec + + init(apiKey: String, model: String) { + self.apiKey = apiKey + self.model = model + + // Create OpenAPI client with URLSession transport + self.client = Client( + serverURL: try! Servers.server1(), // https://api.anthropic.com + transport: URLSessionTransport(), + middlewares: [ + AuthenticationMiddleware(apiKey: apiKey) + ] + ) + } /// Sends request to generate updated library code func generateUpdatedLibrary( @@ -450,13 +470,112 @@ struct ClaudeAPIClient { expectedSwift: String, swiftAST: String, swiftDSL: String - ) async throws -> LibraryUpdateResult + ) async throws -> LibraryUpdateResult { + // Create prompt using template + let prompt = PromptTemplate.createAnalysisAndCodeGeneration( + syntaxKitLibrary: syntaxKitLibrary, + expectedSwift: expectedSwift, + swiftAST: swiftAST, + swiftDSL: swiftDSL + ) - /// Formats the API request payload with code generation instructions - private func createRequestPayload(...) -> [String: Any] + // Call Claude API using generated client + let response = try await client.postV1Messages( + body: .json( + Components.Schemas.MessageRequest( + model: model, + max_tokens: 20000, + temperature: 1.0, + messages: [ + Components.Schemas.Message( + role: .user, + content: prompt + ) + ] + ) + ) + ) + + // Extract response content + let messageResponse = try response.ok.body.json + let responseText = messageResponse.content + .compactMap { content -> String? in + if case .text(let text) = content { + return text.text + } + return nil + } + .joined() + + // Parse code generation response + return try parseCodeGenerationResponse(responseText) + } /// Parses API response containing generated code - private func parseCodeGenerationResponse(_ data: Data) throws -> LibraryUpdateResult + private func parseCodeGenerationResponse(_ text: String) throws -> LibraryUpdateResult { + // Extract blocks using regex + let filePattern = #"(.+?)"# + let regex = try NSRegularExpression(pattern: filePattern, options: [.dotMatchesLineSeparators]) + let nsText = text as NSString + let matches = regex.matches(in: text, range: NSRange(location: 0, length: nsText.length)) + + var updatedFiles: [LibraryUpdateResult.UpdatedFile] = [] + var newFiles: [LibraryUpdateResult.NewFile] = [] + + for match in matches { + let pathRange = match.range(at: 1) + let contentRange = match.range(at: 2) + + let relativePath = nsText.substring(with: pathRange) + let content = nsText.substring(with: contentRange) + .trimmingCharacters(in: .whitespacesAndNewlines) + + // Determine if new or updated file based on library scan + // For now, treat all as new files (can enhance later) + newFiles.append( + LibraryUpdateResult.NewFile( + relativePath: relativePath, + content: content, + purpose: "Generated implementation" + ) + ) + } + + // Extract summary (text before first tag) + let summaryPattern = #"^(.+?)(?= HTTPResponse + ) async throws -> HTTPResponse { + var modifiedRequest = request + modifiedRequest.headerFields.append( + .init(name: "x-api-key", value: apiKey) + ) + modifiedRequest.headerFields.append( + .init(name: "anthropic-version", value: "2023-06-01") + ) + return try await next(modifiedRequest, baseURL) + } } struct LibraryUpdateResult: Codable { @@ -485,20 +604,31 @@ struct FileReference: Codable { } ``` -API request structure: -- Endpoint: `https://api.anthropic.com/v1/messages` -- Headers: `x-api-key`, `anthropic-version: 2023-06-01`, `content-type: application/json` -- Body: Enhanced prompt asking Claude to generate actual Swift code, not just describe changes +**OpenAPI Specification Source**: +- Uses unofficial OpenAPI spec from [laszukdawid/anthropic-openapi-spec](https://github.com/laszukdawid/anthropic-openapi-spec) +- Specifically the `hosted_spec.json` file (derived from Anthropic's TypeScript SDK) +- Download to `Sources/skit-analyze/openapi.json` or `openapi.yaml` +- Swift OpenAPI Generator will create type-safe client code at build time + +**Setup Steps**: +1. Download OpenAPI spec: `curl -o Sources/skit-analyze/openapi.json https://raw.githubusercontent.com/laszukdawid/anthropic-openapi-spec/main/hosted_spec.json` +2. Create `Sources/skit-analyze/openapi-generator-config.yaml`: + ```yaml + generate: + - types + - client + ``` +3. Swift OpenAPI Generator plugin will generate client code automatically during build -Modified Prompt Strategy: -- Still uses the Workbench prompt for analysis +**Modified Prompt Strategy**: +- Uses the Workbench prompt for analysis - **Additionally** asks Claude to generate the actual implementation code - Requests output in structured format using XML-style markers - Each code file marked with: `...code...` **Response Parsing**: -The API client will parse Claude's response by: -1. Extract all `` blocks using regex or XML parsing +The API client parses Claude's response by: +1. Extract all `` blocks using regex 2. For each file block: - Extract `path` attribute (relative path like "Declarations/Subscript.swift") - Extract content between tags (complete Swift code) @@ -598,15 +728,27 @@ User runs: skit-analyze examples/subscript-feature Sources/SyntaxKit output/Synt ### 4. Package.swift Changes -Add ConfigKeyKit as a local target and integrate swift-configuration: +Add ConfigKeyKit as a local target, integrate swift-configuration, and add OpenAPI Generator: ```swift -// In dependencies (add swift-configuration): +// In dependencies: .package( url: "https://github.com/apple/swift-configuration", from: "1.0.0", traits: ["CommandLineArguments"] // Enable CLI args trait ), +.package( + url: "https://github.com/apple/swift-openapi-generator", + from: "1.0.0" +), +.package( + url: "https://github.com/apple/swift-openapi-runtime", + from: "1.0.0" +), +.package( + url: "https://github.com/apple/swift-openapi-urlsession", + from: "1.0.0" +), // Add ConfigKeyKit as a target: .target( @@ -617,13 +759,18 @@ Add ConfigKeyKit as a local target and integrate swift-configuration: swiftSettings: swiftSettings ), -// Add new executable target: +// Add new executable target with OpenAPI Generator plugin: .executableTarget( name: "skit-analyze", dependencies: [ "SyntaxParser", "ConfigKeyKit", - .product(name: "Configuration", package: "swift-configuration") + .product(name: "Configuration", package: "swift-configuration"), + .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"), + .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession") + ], + plugins: [ + .plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator") ], swiftSettings: swiftSettings ), @@ -635,7 +782,27 @@ Add ConfigKeyKit as a local target and integrate swift-configuration: ), ``` -**Note**: ConfigKeyKit already exists in the project directory, so we just need to add it as a target in Package.swift. +**Setup Requirements**: +1. Download OpenAPI spec to `Sources/skit-analyze/`: + ```bash + curl -o Sources/skit-analyze/openapi.json \ + https://raw.githubusercontent.com/laszukdawid/anthropic-openapi-spec/main/hosted_spec.json + ``` + +2. Create `Sources/skit-analyze/openapi-generator-config.yaml`: + ```yaml + generate: + - types + - client + accessModifier: internal + ``` + +3. The OpenAPI Generator plugin will automatically generate type-safe client code during build + +**Notes**: +- ConfigKeyKit already exists in the project directory, so we just need to add it as a target in Package.swift +- OpenAPI Generator runs as a build plugin and generates Swift code from the OpenAPI spec at build time +- Generated code includes type-safe request/response models and client methods ### 5. Configuration & Environment @@ -729,6 +896,7 @@ Include full API request/response, intermediate parsing steps, file collection d ## Critical Files to Create +### Source Files 1. **Sources/skit-analyze/main.swift** - Main entry point 2. **Sources/skit-analyze/AnalyzeCommand.swift** - Command implementation using ConfigKeyKit 3. **Sources/skit-analyze/AnalyzerConfiguration.swift** - Configuration structure using ConfigKeyKit @@ -737,10 +905,20 @@ Include full API request/response, intermediate parsing steps, file collection d 6. **Sources/skit-analyze/LibraryCollector.swift** - Collects SyntaxKit source files 7. **Sources/skit-analyze/LibraryWriter.swift** - Writes updated library to output folder 8. **Sources/skit-analyze/ASTGenerator.swift** - Wraps SyntaxParser for AST generation -9. **Sources/skit-analyze/ClaudeAPIClient.swift** - Claude API communication for code generation +9. **Sources/skit-analyze/ClaudeAPIClient.swift** - Wraps OpenAPI-generated client for code generation 10. **Sources/skit-analyze/PromptTemplate.swift** - Enhanced Workbench prompt with code generation 11. **Sources/skit-analyze/Models.swift** - Data models (LibraryUpdateResult, UpdatedFile, NewFile, AnalyzerError) -12. **Package.swift** (modify) - Add ConfigKeyKit target, swift-configuration dependency, and executable target + +### Configuration Files +12. **Sources/skit-analyze/openapi.json** - Anthropic OpenAPI specification (downloaded) +13. **Sources/skit-analyze/openapi-generator-config.yaml** - OpenAPI Generator configuration +14. **Package.swift** (modify) - Add ConfigKeyKit target, dependencies, and OpenAPI plugin + +### Test Mode Files (Section 8) +15. **Sources/skit-analyze/Testing/TestRunner.swift** - Orchestrates test execution +16. **Sources/skit-analyze/Testing/TestCaseDiscoverer.swift** - Discovers and loads test cases +17. **Sources/skit-analyze/Testing/TestValidator.swift** - Validates results against expectations +18. **Sources/skit-analyze/Testing/TestModels.swift** - Test data structures ## Verification Steps @@ -949,6 +1127,9 @@ skit-analyze --test --test-cases=custom-tests/ **New Dependencies**: - `swift-configuration` (1.0.0+) with `CommandLineArguments` trait - Configuration management +- `swift-openapi-generator` (1.0.0+) - Generates type-safe API client from OpenAPI spec +- `swift-openapi-runtime` (1.0.0+) - Runtime support for generated OpenAPI client +- `swift-openapi-urlsession` (1.0.0+) - URLSession transport for OpenAPI client **Existing Dependencies** (reused): - `ConfigKeyKit` (in project) - Configuration key abstraction @@ -956,12 +1137,22 @@ skit-analyze --test --test-cases=custom-tests/ - `SyntaxParser` (existing module) - AST generation - Foundation - HTTP requests, file I/O -**Advantages of swift-configuration + ConfigKeyKit**: -- Unified handling of CLI args and environment variables -- Type-safe configuration keys with automatic naming transformations -- Composable provider hierarchy (CLI overrides ENV) -- Consistent with project's existing ConfigKeyKit architecture -- More flexible than ArgumentParser for complex configuration scenarios +**External Resources**: +- [Unofficial Anthropic OpenAPI Spec](https://github.com/laszukdawid/anthropic-openapi-spec) - `hosted_spec.json` derived from Anthropic's TypeScript SDK + +**Advantages of This Approach**: +- **swift-configuration + ConfigKeyKit**: + - Unified handling of CLI args and environment variables + - Type-safe configuration keys with automatic naming transformations + - Composable provider hierarchy (CLI overrides ENV) + - Consistent with project's existing ConfigKeyKit architecture + +- **Swift OpenAPI Generator**: + - Type-safe API client generated at build time from OpenAPI spec + - Automatic request/response serialization + - Built-in error handling and validation + - No manual JSON parsing or HTTP request construction + - Easy to update when Anthropic publishes official OpenAPI spec (just replace the spec file) ## Build & Install From 29e962f0cb8688357e9854941a58af97e858f1f5 Mon Sep 17 00:00:00 2001 From: Leo Dion Date: Mon, 9 Feb 2026 16:56:11 -0500 Subject: [PATCH 07/10] Rename targets to AiSTKit, ClaudeKit, and skit-aist Update plan with clever naming scheme: - ClaudeKit: OpenAPI-generated Claude API client (was ClaudeAPIClient) - AiSTKit: SDK/bridge layer combining AI+AST+Kit (was AnalyzerSDK) - skit-aist: Command-line executable (was skit-aist) AiSTKit cleverly combines: - AI: Claude's artificial intelligence - AST: Abstract Syntax Tree - Kit: Follows SyntaxKit naming convention Can be read as "AI-ST-Kit" or "Assist-Kit" (AI assistance). Co-Authored-By: Claude Sonnet 4.5 --- Docs/skit-analyze-plan.md | 162 ++++++++++++++++++++++++-------------- 1 file changed, 103 insertions(+), 59 deletions(-) diff --git a/Docs/skit-analyze-plan.md b/Docs/skit-analyze-plan.md index 90cacd3..95a8715 100644 --- a/Docs/skit-analyze-plan.md +++ b/Docs/skit-analyze-plan.md @@ -1,4 +1,4 @@ -# Plan: SyntaxKit Analyzer CLI Tool +# Plan: AiSTKit - AI-Powered AST Generation for SyntaxKit ## Context @@ -17,18 +17,62 @@ This addresses the problem of implementing missing SyntaxKit features. Instead o ## Implementation Approach -### 1. Create New Executable Target: `skit-analyze` +### 1. Create Three Targets with Clear Separation -**Location**: `Sources/skit-analyze/` +This implementation uses three separate targets for better modularity and testability: + +#### Target 1: `ClaudeKit` (OpenAPI Generated Code) +**Location**: `Sources/ClaudeKit/` + +**Purpose**: Contains the raw OpenAPI-generated client code for the Anthropic Claude API **Dependencies**: -- `SyntaxParser` (existing) - for parsing Swift code to AST -- `ConfigKeyKit` (existing in project) - for configuration key management -- `swift-configuration` - for CLI argument and environment variable handling -- `swift-openapi-generator` - for generating type-safe Claude API client from OpenAPI spec - `swift-openapi-runtime` - runtime support for generated OpenAPI client - `swift-openapi-urlsession` - URLSession transport for OpenAPI client +**Build Plugin**: `OpenAPIGenerator` (generates client from `openapi.json`) + +**Contents**: +- `openapi.json` - Anthropic OpenAPI specification +- `openapi-generator-config.yaml` - Generator configuration +- Generated code (types, client) created automatically at build time + +#### Target 2: `AiSTKit` (SDK/Bridge Layer) +**Location**: `Sources/AiSTKit/` + +**Purpose**: Provides a clean, domain-specific interface between the command executable and the raw OpenAPI client. Handles prompt formatting, response parsing, and code generation logic. + +**Dependencies**: +- `ClaudeKit` - the OpenAPI-generated client +- `SyntaxParser` - for AST generation +- Foundation + +**Key Responsibilities**: +- Wraps `ClaudeKit` with domain-specific methods +- Implements `SyntaxKitAnalyzer` orchestration logic +- Handles prompt template creation +- Parses Claude responses into `LibraryUpdateResult` +- Manages AST generation +- Collects and writes library files + +#### Target 3: `skit-aist` (Command Executable) +**Location**: `Sources/skit-aist/` + +**Purpose**: CLI executable that handles argument parsing, configuration, and user interaction + +**Dependencies**: +- `AiSTKit` - the SDK/bridge layer +- `ConfigKeyKit` (existing in project) - for configuration key management +- `swift-configuration` - for CLI argument and environment variable handling + +**Key Responsibilities**: +- Parse command-line arguments +- Load configuration from environment variables +- Display help text and usage information +- Handle test mode execution +- Provide verbose output and error messages +- Entry point (`main.swift`) + ### 2. Core Components #### A. Configuration Structure (`AnalyzerConfiguration.swift`) @@ -76,7 +120,7 @@ struct AnalyzerConfiguration: ConfigurationParseable { guard positionalArgs.count >= 3 else { throw AnalyzerError.missingRequiredArguments( - "Usage: skit-analyze [options]" + "Usage: skit-aist [options]" ) } @@ -136,11 +180,11 @@ struct AnalyzeCommand: Command { typealias Config = AnalyzerConfiguration static let commandName = "analyze" - static let abstract = "Generate updated SyntaxKit library with missing features" + static let abstract = "AI-powered AST generation for SyntaxKit" static let helpText = """ OVERVIEW: Automatically implement missing SyntaxKit features using Claude API - USAGE: skit-analyze [options] + USAGE: skit-aist [options] ARGUMENTS: Folder containing: @@ -164,7 +208,7 @@ struct AnalyzeCommand: Command { echo 'subscript(index: Int) -> Item { ... }' > examples/subscript-feature/expected.swift export ANTHROPIC_API_KEY="sk-ant-..." - skit-analyze examples/subscript-feature Sources/SyntaxKit output/SyntaxKit + skit-aist examples/subscript-feature Sources/SyntaxKit output/SyntaxKit """ let config: Config @@ -254,7 +298,7 @@ struct SyntaxKitAnalyzer { // 4. Call Claude API for analysis AND code generation if config.verbose { print("Calling Claude API (\(config.model))...") } - let client = ClaudeAPIClient(apiKey: config.apiKey, model: config.model) + let client = ClaudeKit(apiKey: config.apiKey, model: config.model) let result = try await client.generateUpdatedLibrary( syntaxKitLibrary: libraryCode, expectedSwift: inputs.expectedSwift, @@ -437,7 +481,7 @@ struct ASTGenerator { - This is the same code path used by the `skit` executable - No need for external AST generation - it's built-in! -#### I. Claude API Client (`ClaudeAPIClient.swift`) +#### I. Claude API Client (`ClaudeKit.swift`) Wraps the OpenAPI-generated client for code generation: @@ -445,7 +489,7 @@ Wraps the OpenAPI-generated client for code generation: import OpenAPIRuntime import OpenAPIURLSession -struct ClaudeAPIClient { +struct ClaudeKit { let apiKey: String let model: String private let client: Client // Generated from OpenAPI spec @@ -607,12 +651,12 @@ struct FileReference: Codable { **OpenAPI Specification Source**: - Uses unofficial OpenAPI spec from [laszukdawid/anthropic-openapi-spec](https://github.com/laszukdawid/anthropic-openapi-spec) - Specifically the `hosted_spec.json` file (derived from Anthropic's TypeScript SDK) -- Download to `Sources/skit-analyze/openapi.json` or `openapi.yaml` +- Download to `Sources/skit-aist/openapi.json` or `openapi.yaml` - Swift OpenAPI Generator will create type-safe client code at build time **Setup Steps**: -1. Download OpenAPI spec: `curl -o Sources/skit-analyze/openapi.json https://raw.githubusercontent.com/laszukdawid/anthropic-openapi-spec/main/hosted_spec.json` -2. Create `Sources/skit-analyze/openapi-generator-config.yaml`: +1. Download OpenAPI spec: `curl -o Sources/skit-aist/openapi.json https://raw.githubusercontent.com/laszukdawid/anthropic-openapi-spec/main/hosted_spec.json` +2. Create `Sources/skit-aist/openapi-generator-config.yaml`: ```yaml generate: - types @@ -694,7 +738,7 @@ Include: ### 3. Workflow ``` -User runs: skit-analyze examples/subscript-feature Sources/SyntaxKit output/SyntaxKit +User runs: skit-aist examples/subscript-feature Sources/SyntaxKit output/SyntaxKit 1. main.swift: Entry point 2. AnalyzeCommand.createInstance(): @@ -761,7 +805,7 @@ Add ConfigKeyKit as a local target, integrate swift-configuration, and add OpenA // Add new executable target with OpenAPI Generator plugin: .executableTarget( - name: "skit-analyze", + name: "skit-aist", dependencies: [ "SyntaxParser", "ConfigKeyKit", @@ -777,19 +821,19 @@ Add ConfigKeyKit as a local target, integrate swift-configuration, and add OpenA // In products: .executable( - name: "skit-analyze", - targets: ["skit-analyze"] + name: "skit-aist", + targets: ["skit-aist"] ), ``` **Setup Requirements**: -1. Download OpenAPI spec to `Sources/skit-analyze/`: +1. Download OpenAPI spec to `Sources/skit-aist/`: ```bash - curl -o Sources/skit-analyze/openapi.json \ + curl -o Sources/skit-aist/openapi.json \ https://raw.githubusercontent.com/laszukdawid/anthropic-openapi-spec/main/hosted_spec.json ``` -2. Create `Sources/skit-analyze/openapi-generator-config.yaml`: +2. Create `Sources/skit-aist/openapi-generator-config.yaml`: ```yaml generate: - types @@ -844,7 +888,7 @@ Add ConfigKeyKit as a local target, integrate swift-configuration, and add OpenA 3. Output folder path (where to write updated library) - Parsed manually from `CommandLine.arguments` in configuration initializer - More intuitive than using flags for required paths -- Example: `skit-analyze examples/feature Sources/SyntaxKit output/updated` +- Example: `skit-aist examples/feature Sources/SyntaxKit output/updated` **Default Values**: - SyntaxKit library path: `Sources/SyntaxKit` (via `ConfigKey` default) @@ -897,28 +941,28 @@ Include full API request/response, intermediate parsing steps, file collection d ## Critical Files to Create ### Source Files -1. **Sources/skit-analyze/main.swift** - Main entry point -2. **Sources/skit-analyze/AnalyzeCommand.swift** - Command implementation using ConfigKeyKit -3. **Sources/skit-analyze/AnalyzerConfiguration.swift** - Configuration structure using ConfigKeyKit -4. **Sources/skit-analyze/SyntaxKitAnalyzer.swift** - Core analyzer orchestration -5. **Sources/skit-analyze/InputFolderReader.swift** - Reads dsl.swift, expected.swift, ast files -6. **Sources/skit-analyze/LibraryCollector.swift** - Collects SyntaxKit source files -7. **Sources/skit-analyze/LibraryWriter.swift** - Writes updated library to output folder -8. **Sources/skit-analyze/ASTGenerator.swift** - Wraps SyntaxParser for AST generation -9. **Sources/skit-analyze/ClaudeAPIClient.swift** - Wraps OpenAPI-generated client for code generation -10. **Sources/skit-analyze/PromptTemplate.swift** - Enhanced Workbench prompt with code generation -11. **Sources/skit-analyze/Models.swift** - Data models (LibraryUpdateResult, UpdatedFile, NewFile, AnalyzerError) +1. **Sources/skit-aist/main.swift** - Main entry point +2. **Sources/skit-aist/AnalyzeCommand.swift** - Command implementation using ConfigKeyKit +3. **Sources/skit-aist/AnalyzerConfiguration.swift** - Configuration structure using ConfigKeyKit +4. **Sources/skit-aist/SyntaxKitAnalyzer.swift** - Core analyzer orchestration +5. **Sources/skit-aist/InputFolderReader.swift** - Reads dsl.swift, expected.swift, ast files +6. **Sources/skit-aist/LibraryCollector.swift** - Collects SyntaxKit source files +7. **Sources/skit-aist/LibraryWriter.swift** - Writes updated library to output folder +8. **Sources/skit-aist/ASTGenerator.swift** - Wraps SyntaxParser for AST generation +9. **Sources/skit-aist/ClaudeKit.swift** - Wraps OpenAPI-generated client for code generation +10. **Sources/skit-aist/PromptTemplate.swift** - Enhanced Workbench prompt with code generation +11. **Sources/skit-aist/Models.swift** - Data models (LibraryUpdateResult, UpdatedFile, NewFile, AnalyzerError) ### Configuration Files -12. **Sources/skit-analyze/openapi.json** - Anthropic OpenAPI specification (downloaded) -13. **Sources/skit-analyze/openapi-generator-config.yaml** - OpenAPI Generator configuration +12. **Sources/skit-aist/openapi.json** - Anthropic OpenAPI specification (downloaded) +13. **Sources/skit-aist/openapi-generator-config.yaml** - OpenAPI Generator configuration 14. **Package.swift** (modify) - Add ConfigKeyKit target, dependencies, and OpenAPI plugin ### Test Mode Files (Section 8) -15. **Sources/skit-analyze/Testing/TestRunner.swift** - Orchestrates test execution -16. **Sources/skit-analyze/Testing/TestCaseDiscoverer.swift** - Discovers and loads test cases -17. **Sources/skit-analyze/Testing/TestValidator.swift** - Validates results against expectations -18. **Sources/skit-analyze/Testing/TestModels.swift** - Test data structures +15. **Sources/skit-aist/Testing/TestRunner.swift** - Orchestrates test execution +16. **Sources/skit-aist/Testing/TestCaseDiscoverer.swift** - Discovers and loads test cases +17. **Sources/skit-aist/Testing/TestValidator.swift** - Validates results against expectations +18. **Sources/skit-aist/Testing/TestModels.swift** - Test data structures ## Verification Steps @@ -948,7 +992,7 @@ Include full API request/response, intermediate parsing steps, file collection d 3. **Run Tool**: ```bash export ANTHROPIC_API_KEY="sk-ant-..." - .build/release/skit-analyze \ + .build/release/skit-aist \ examples/simple-property \ Sources/SyntaxKit \ output/SyntaxKit-updated @@ -975,16 +1019,16 @@ Include full API request/response, intermediate parsing steps, file collection d 6. **Error Handling Tests**: ```bash # Test missing API key - skit-analyze examples/test Sources/SyntaxKit output # Should error + skit-aist examples/test Sources/SyntaxKit output # Should error # Test invalid input folder - skit-analyze nonexistent Sources/SyntaxKit output # Should error + skit-aist nonexistent Sources/SyntaxKit output # Should error # Test missing required files mkdir -p examples/incomplete echo "test" > examples/incomplete/dsl.swift # Missing expected.swift - should error - skit-analyze examples/incomplete Sources/SyntaxKit output + skit-aist examples/incomplete Sources/SyntaxKit output ``` 7. **Integration Test**: Use a real missing feature (e.g., subscript syntax) and verify: @@ -1087,19 +1131,19 @@ See the full implementation plan in the main plan file for detailed component sp ```bash # Run all test cases -skit-analyze --test +skit-aist --test # Run with verbose output -skit-analyze --test --verbose +skit-aist --test --verbose # Stop on first failure -skit-analyze --test --test-stop-on-fail +skit-aist --test --test-stop-on-fail # Run only tests matching "subscript" -skit-analyze --test --test-filter=subscript +skit-aist --test --test-filter=subscript # Run tests from custom path -skit-analyze --test --test-cases=custom-tests/ +skit-aist --test --test-cases=custom-tests/ ``` ### Benefits @@ -1161,10 +1205,10 @@ skit-analyze --test --test-cases=custom-tests/ swift build -c release # Install to system (optional) -cp .build/release/skit-analyze /usr/local/bin/ +cp .build/release/skit-aist /usr/local/bin/ # Or run from build directory -.build/release/skit-analyze +.build/release/skit-aist ``` ## Example Usage @@ -1196,7 +1240,7 @@ EOF # 4. Run the tool # Note: AST is automatically generated from expected.swift using SyntaxParser export ANTHROPIC_API_KEY="sk-ant-..." -skit-analyze \ +skit-aist \ examples/subscript-feature \ Sources/SyntaxKit \ output/SyntaxKit-with-subscripts @@ -1206,19 +1250,19 @@ skit-analyze \ ```bash # With custom model -skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ +skit-aist examples/my-feature Sources/SyntaxKit output/updated \ --model claude-sonnet-4-5 # With verbose output to see what's happening -skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ +skit-aist examples/my-feature Sources/SyntaxKit output/updated \ --verbose # Using CLI flag for API key instead of environment -skit-analyze examples/my-feature Sources/SyntaxKit output/updated \ +skit-aist examples/my-feature Sources/SyntaxKit output/updated \ --api-key sk-ant-... # Show help -skit-analyze --help +skit-aist --help ``` ### Full Workflow Example @@ -1247,7 +1291,7 @@ EOF # Step 4: Generate updated SyntaxKit with defer support export ANTHROPIC_API_KEY="sk-ant-..." -skit-analyze \ +skit-aist \ examples/defer-statement \ Sources/SyntaxKit \ output/SyntaxKit-with-defer \ From 447373e77caf594bfcdbfe389b1b980fbd39296f Mon Sep 17 00:00:00 2001 From: leogdion Date: Mon, 9 Feb 2026 17:58:39 -0500 Subject: [PATCH 08/10] Enforce one-type-per-file organization in skit-analyze plan - Add explicit Code Organization Principle section - Split AnalyzerConfiguration and AnalyzerError into separate files - Split ClaudeKit types into individual files (ClaudeKit, AuthenticationMiddleware, LibraryUpdateResult, FileReference) - Update Critical Files list to reflect 21 individual files - Add clear examples and exception rules for nested types Co-Authored-By: Claude Sonnet 4.5 --- Docs/skit-analyze-plan.md | 74 ++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/Docs/skit-analyze-plan.md b/Docs/skit-analyze-plan.md index 95a8715..7e2228b 100644 --- a/Docs/skit-analyze-plan.md +++ b/Docs/skit-analyze-plan.md @@ -17,6 +17,24 @@ This addresses the problem of implementing missing SyntaxKit features. Instead o ## Implementation Approach +### Code Organization Principle + +**IMPORTANT: Each type and extension must be in its own file.** + +All structs, enums, classes, protocols, and extensions should be defined in separate files named after the type. This ensures: +- Better code navigation and discoverability +- Clearer module boundaries and dependencies +- Easier maintenance and refactoring +- Simpler code reviews and version control + +**Examples:** +- `AnalyzerConfiguration` → `AnalyzerConfiguration.swift` +- `AnalyzerError` → `AnalyzerError.swift` +- `ClaudeKit` → `ClaudeKit.swift` +- `AuthenticationMiddleware` → `AuthenticationMiddleware.swift` + +**Exception:** Nested types that are tightly coupled to their parent (like `LibraryUpdateResult.UpdatedFile`) may remain in the same file as their parent type. + ### 1. Create Three Targets with Clear Separation This implementation uses three separate targets for better modularity and testability: @@ -156,7 +174,11 @@ struct AnalyzerConfiguration: ConfigurationParseable { } } } +``` +#### A2. Error Types (`AnalyzerError.swift`) + +```swift enum AnalyzerError: Error { case missingRequiredArguments(String) case missingAPIKey(String) @@ -600,8 +622,15 @@ struct ClaudeKit { ) } } +``` + +#### I2. Authentication Middleware (`AuthenticationMiddleware.swift`) + +Custom middleware for adding Anthropic API key header: + +```swift +import OpenAPIRuntime -/// Custom middleware for adding Anthropic API key header struct AuthenticationMiddleware: ClientMiddleware { let apiKey: String @@ -621,7 +650,13 @@ struct AuthenticationMiddleware: ClientMiddleware { return try await next(modifiedRequest, baseURL) } } +``` + +#### I3. Library Update Result (`LibraryUpdateResult.swift`) +Data structures for library update results: + +```swift struct LibraryUpdateResult: Codable { struct UpdatedFile: Codable { let relativePath: String // e.g., "Declarations/Subscript.swift" @@ -641,7 +676,11 @@ struct LibraryUpdateResult: Codable { let includeUnchangedFiles: Bool let summary: String // Claude's explanation of changes } +``` +#### I4. File Reference (`FileReference.swift`) + +```swift struct FileReference: Codable { let relativePath: String let sourcePath: String @@ -944,25 +983,28 @@ Include full API request/response, intermediate parsing steps, file collection d 1. **Sources/skit-aist/main.swift** - Main entry point 2. **Sources/skit-aist/AnalyzeCommand.swift** - Command implementation using ConfigKeyKit 3. **Sources/skit-aist/AnalyzerConfiguration.swift** - Configuration structure using ConfigKeyKit -4. **Sources/skit-aist/SyntaxKitAnalyzer.swift** - Core analyzer orchestration -5. **Sources/skit-aist/InputFolderReader.swift** - Reads dsl.swift, expected.swift, ast files -6. **Sources/skit-aist/LibraryCollector.swift** - Collects SyntaxKit source files -7. **Sources/skit-aist/LibraryWriter.swift** - Writes updated library to output folder -8. **Sources/skit-aist/ASTGenerator.swift** - Wraps SyntaxParser for AST generation -9. **Sources/skit-aist/ClaudeKit.swift** - Wraps OpenAPI-generated client for code generation -10. **Sources/skit-aist/PromptTemplate.swift** - Enhanced Workbench prompt with code generation -11. **Sources/skit-aist/Models.swift** - Data models (LibraryUpdateResult, UpdatedFile, NewFile, AnalyzerError) +4. **Sources/skit-aist/AnalyzerError.swift** - Error types for analyzer operations +5. **Sources/skit-aist/SyntaxKitAnalyzer.swift** - Core analyzer orchestration +6. **Sources/skit-aist/InputFolderReader.swift** - Reads dsl.swift, expected.swift, ast files +7. **Sources/skit-aist/LibraryCollector.swift** - Collects SyntaxKit source files +8. **Sources/skit-aist/LibraryWriter.swift** - Writes updated library to output folder +9. **Sources/skit-aist/ASTGenerator.swift** - Wraps SyntaxParser for AST generation +10. **Sources/skit-aist/ClaudeKit.swift** - Wraps OpenAPI-generated client for code generation +11. **Sources/skit-aist/AuthenticationMiddleware.swift** - OpenAPI middleware for API authentication +12. **Sources/skit-aist/LibraryUpdateResult.swift** - Data structures for library update results +13. **Sources/skit-aist/FileReference.swift** - File reference data structure +14. **Sources/skit-aist/PromptTemplate.swift** - Enhanced Workbench prompt with code generation ### Configuration Files -12. **Sources/skit-aist/openapi.json** - Anthropic OpenAPI specification (downloaded) -13. **Sources/skit-aist/openapi-generator-config.yaml** - OpenAPI Generator configuration -14. **Package.swift** (modify) - Add ConfigKeyKit target, dependencies, and OpenAPI plugin +15. **Sources/skit-aist/openapi.json** - Anthropic OpenAPI specification (downloaded) +16. **Sources/skit-aist/openapi-generator-config.yaml** - OpenAPI Generator configuration +17. **Package.swift** (modify) - Add ConfigKeyKit target, dependencies, and OpenAPI plugin ### Test Mode Files (Section 8) -15. **Sources/skit-aist/Testing/TestRunner.swift** - Orchestrates test execution -16. **Sources/skit-aist/Testing/TestCaseDiscoverer.swift** - Discovers and loads test cases -17. **Sources/skit-aist/Testing/TestValidator.swift** - Validates results against expectations -18. **Sources/skit-aist/Testing/TestModels.swift** - Test data structures +18. **Sources/skit-aist/Testing/TestRunner.swift** - Orchestrates test execution +19. **Sources/skit-aist/Testing/TestCaseDiscoverer.swift** - Discovers and loads test cases +20. **Sources/skit-aist/Testing/TestValidator.swift** - Validates results against expectations +21. **Sources/skit-aist/Testing/TestModels.swift** - Test data structures ## Verification Steps From 1b4212af9c35b91ca22f297631ae0bc44e5c41fa Mon Sep 17 00:00:00 2001 From: leogdion Date: Mon, 9 Feb 2026 18:18:45 -0500 Subject: [PATCH 09/10] Add GitHub issue creation automation for skit-aist implementation Created automated tooling to export the skit-analyze-plan.md into 18 structured GitHub issues organized across 7 implementation phases. New files: - scripts/create-issues.js: Automated issue creation script - scripts/issue-config.json: Issue metadata and specifications - scripts/package.json: Node.js package configuration - scripts/README.md: Script documentation and usage guide - scripts/ISSUE_CREATION_SUMMARY.md: Detailed issue breakdown - IMPLEMENTATION_STATUS.md: Project status tracking document Issues created (#107-#124): - Phase 1: Project Setup & Infrastructure (3 issues) - Phase 2: Core Configuration & Command (2 issues) - Phase 3: Input/Output Handlers (4 issues) - Phase 4: Claude API Integration (4 issues) - Phase 5: Main Orchestration (1 issue) - Phase 6: Testing Infrastructure (1 issue) - Phase 7: Verification & Documentation (3 issues) Labels created: infrastructure, setup, configuration, cli, io, api, models, prompts, orchestration, ast, testing, integration All issues properly cross-reference dependencies and include complete specifications, acceptance criteria, and file references. Co-Authored-By: Claude Sonnet 4.5 --- IMPLEMENTATION_STATUS.md | 257 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 IMPLEMENTATION_STATUS.md diff --git a/IMPLEMENTATION_STATUS.md b/IMPLEMENTATION_STATUS.md new file mode 100644 index 0000000..0b26128 --- /dev/null +++ b/IMPLEMENTATION_STATUS.md @@ -0,0 +1,257 @@ +# skit-aist Implementation Status + +## Overview + +This document tracks the implementation of the skit-aist tool, an AI-powered AST generation system for automatically implementing missing SyntaxKit features using the Claude API. + +**Plan Document**: [Docs/skit-analyze-plan.md](Docs/skit-analyze-plan.md) + +## GitHub Issues + +All implementation tasks have been broken down into 18 GitHub issues organized into 7 phases. + +**Issue Range**: #107 - #124 + +### Quick Links + +- [View All Issues](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Ainfrastructure%2Cconfiguration%2Ccli%2Cio%2Capi%2Corchestration%2Ctesting) +- [Phase 1: Infrastructure](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Ainfrastructure) +- [Phase 2: Configuration](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Aconfiguration) +- [Phase 3: I/O Handlers](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Aio) +- [Phase 4: API Integration](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Aapi) +- [Phase 5: Orchestration](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Aorchestration) +- [Phase 6-7: Testing & Documentation](https://github.com/brightdigit/SyntaxKit/issues?q=is%3Aissue+is%3Aopen+label%3Atesting%2Cdocumentation) + +## Implementation Phases + +### Phase 1: Project Setup & Infrastructure ✓ Planned + +**Issues**: #107, #108, #109 + +- [x] Issue #107: Setup OpenAPI Specification and Generator Configuration +- [x] Issue #108: Update Package.swift with Dependencies and Targets +- [x] Issue #109: Create ConfigKeyKit Target Structure + +**Status**: Ready to implement +**Estimated Effort**: 2-3 hours +**Critical Path**: Yes - blocks all other work + +### Phase 2: Core Configuration & Command Infrastructure ⏳ Waiting + +**Issues**: #110, #111 + +- [ ] Issue #110: Implement AnalyzerConfiguration and AnalyzerError +- [ ] Issue #111: Implement AnalyzeCommand and Main Entry Point + +**Status**: Blocked by Phase 1 +**Estimated Effort**: 3-4 hours +**Critical Path**: Yes + +### Phase 3: Input/Output Handlers ⏳ Waiting + +**Issues**: #112, #113, #114, #115 + +- [ ] Issue #112: Implement InputFolderReader +- [ ] Issue #113: Implement LibraryCollector +- [ ] Issue #114: Implement LibraryWriter +- [ ] Issue #115: Implement ASTGenerator + +**Status**: #112, #113, #115 can start after Phase 2; #114 needs #118 +**Estimated Effort**: 4-5 hours +**Parallelizable**: #112, #113, #115 can be done in parallel + +### Phase 4: Claude API Integration ⏳ Waiting + +**Issues**: #116, #117, #118, #119 + +- [ ] Issue #116: Implement ClaudeKit Wrapper +- [ ] Issue #117: Implement AuthenticationMiddleware +- [ ] Issue #118: Implement LibraryUpdateResult and FileReference Models +- [ ] Issue #119: Implement PromptTemplate + +**Status**: #117, #118, #119 can start after Phase 1; #116 needs #117, #119 +**Estimated Effort**: 5-6 hours +**Parallelizable**: #117, #118, #119 can be done in parallel + +### Phase 5: Main Orchestration ⏳ Waiting + +**Issues**: #120 + +- [ ] Issue #120: Implement SyntaxKitAnalyzer Orchestration + +**Status**: Blocked by #112, #113, #114, #115, #116 +**Estimated Effort**: 3-4 hours +**Critical Path**: Yes - integrates all components + +### Phase 6: Testing Infrastructure ⏳ Waiting + +**Issues**: #121 + +- [ ] Issue #121: Implement Test/Validation Mode Components + +**Status**: Blocked by #120 +**Estimated Effort**: 4-5 hours +**Optional**: Can skip for MVP + +### Phase 7: Verification & Documentation ⏳ Waiting + +**Issues**: #122, #123, #124 + +- [ ] Issue #122: Create Verification Test Cases +- [ ] Issue #123: Create Example Usage Documentation +- [ ] Issue #124: Create Integration Tests + +**Status**: #123 blocked by #120; #122, #124 blocked by #121 +**Estimated Effort**: 3-4 hours +**Parallelizable**: #122 and #123 can be done in parallel + +## Progress Tracking + +### Overall Progress + +- **Issues Created**: 18/18 ✓ +- **Issues Completed**: 0/18 +- **Phases Completed**: 0/7 +- **Estimated Total Effort**: 24-31 hours + +### Current Status + +**Current Phase**: Phase 1 (Project Setup) +**Next Actionable Issue**: #107 +**Blocked Issues**: 15 (waiting on dependencies) + +## Critical Path + +The minimum viable implementation follows this path: + +1. #107 → #108 → #109 (Infrastructure) +2. #110 (Configuration) +3. #111 (CLI Command) +4. #112, #113, #115 (I/O and AST - parallel) +5. #117, #118, #119 (API components - parallel) +6. #116 (ClaudeKit wrapper) +7. #114 (Library writer) +8. #120 (Orchestration) +9. #123 (Documentation) + +**Minimum Path Effort**: ~18-22 hours +**Can Skip for MVP**: Issues #121, #122, #124 (testing infrastructure) + +## Quick Start Guide + +### For Implementation + +```bash +# Start with Phase 1 +gh issue view 107 +gh issue view 108 +gh issue view 109 + +# Then move to Phase 2 +gh issue view 110 +gh issue view 111 + +# Continue following dependency order... +``` + +### For Project Management + +```bash +# View all open issues +gh issue list --label infrastructure,configuration,cli,io,api,orchestration + +# View issues ready to work on (no dependencies) +gh issue list --label infrastructure --state open + +# Track progress +gh issue list --state closed --label infrastructure,configuration,cli,io,api,orchestration +``` + +## Architecture Overview + +### Three-Target Design + +1. **ClaudeKit** - OpenAPI-generated Claude API client +2. **AiSTKit** - SDK/bridge layer for domain logic +3. **skit-aist** - CLI executable for user interaction + +### Key Dependencies + +- **Swift OpenAPI Generator** - Type-safe API client generation +- **swift-configuration** - CLI/ENV configuration management +- **ConfigKeyKit** - Configuration key abstraction +- **SyntaxParser** - Existing AST generation (reused) + +### Data Flow + +``` +Input Folder (dsl.swift, expected.swift) + → InputFolderReader + → ASTGenerator (via SyntaxParser) + → LibraryCollector (scan SyntaxKit sources) + → ClaudeKit (API call with prompt) + → LibraryUpdateResult (parsed response) + → LibraryWriter + → Output Folder (updated SyntaxKit) +``` + +## Testing Strategy + +### Unit Tests (Phase 6) + +- Configuration parsing +- Input/output file operations +- AST generation +- Response parsing + +### Integration Tests (Phase 7) + +- End-to-end with real missing feature +- Verify generated code compiles +- Verify generated code follows patterns + +### Validation Tests (Phase 7) + +- Structural validation +- Content validation +- Build validation +- Functional validation + +## Documentation + +- **Implementation Plan**: [Docs/skit-analyze-plan.md](Docs/skit-analyze-plan.md) +- **Issue Summary**: [scripts/ISSUE_CREATION_SUMMARY.md](scripts/ISSUE_CREATION_SUMMARY.md) +- **Script Documentation**: [scripts/README.md](scripts/README.md) +- **Usage Documentation**: To be created in #123 + +## Next Steps + +1. **Review Issues**: Ensure all issue specifications are complete +2. **Start Phase 1**: Begin with #107 (OpenAPI setup) +3. **Create Project Board** (optional): Visualize progress +4. **Assign Milestones** (optional): Group related work + +```bash +# Optional: Create project board +gh project create --title "skit-aist Implementation" \ + --body "Track implementation of AI-powered AST generation tool" +``` + +## Success Criteria + +- [ ] All 18 issues completed +- [ ] Tool builds successfully: `swift build -c release` +- [ ] Can process example input and generate valid SyntaxKit code +- [ ] Generated code compiles +- [ ] Integration test passes with real missing feature +- [ ] Documentation complete +- [ ] Test mode validates Claude responses + +## Contact + +For questions or issues, please comment on the relevant GitHub issue or create a new issue. + +--- + +**Last Updated**: 2026-02-09 +**Status**: Planning Complete, Implementation Ready From 4781ac8723e09fbf695b119def0d34932814e957 Mon Sep 17 00:00:00 2001 From: leogdion Date: Mon, 9 Feb 2026 18:18:58 -0500 Subject: [PATCH 10/10] Add issue creation scripts and documentation Scripts for automated GitHub issue generation: - Scripts/create-issues.js: Main automation script - Scripts/issue-config.json: Issue specifications for all 18 tasks - Scripts/package.json: Node.js configuration - Scripts/README.md: Script usage documentation - Scripts/ISSUE_CREATION_SUMMARY.md: Detailed breakdown of created issues These scripts successfully created issues #107-#124 for the skit-aist implementation, organized into 7 phases with proper dependency tracking. Co-Authored-By: Claude Sonnet 4.5 --- Scripts/ISSUE_CREATION_SUMMARY.md | 191 ++++++++++++++++ Scripts/README.md | 155 +++++++++++++ Scripts/create-issues.js | 152 +++++++++++++ Scripts/issue-config.json | 351 ++++++++++++++++++++++++++++++ Scripts/package.json | 10 + 5 files changed, 859 insertions(+) create mode 100644 Scripts/ISSUE_CREATION_SUMMARY.md create mode 100644 Scripts/README.md create mode 100755 Scripts/create-issues.js create mode 100644 Scripts/issue-config.json create mode 100644 Scripts/package.json diff --git a/Scripts/ISSUE_CREATION_SUMMARY.md b/Scripts/ISSUE_CREATION_SUMMARY.md new file mode 100644 index 0000000..ff0c8ae --- /dev/null +++ b/Scripts/ISSUE_CREATION_SUMMARY.md @@ -0,0 +1,191 @@ +# GitHub Issues Creation Summary + +## Overview + +Successfully created 18 GitHub issues from the skit-analyze-plan.md implementation plan. + +## Issue Breakdown by Phase + +### Phase 1: Project Setup & Infrastructure (Issues #107-#109) + +**Issue #107: Setup OpenAPI Specification and Generator Configuration** +- Labels: infrastructure, setup +- Dependencies: None +- Files: Sources/ClaudeKit/openapi.json, Sources/ClaudeKit/openapi-generator-config.yaml + +**Issue #108: Update Package.swift with Dependencies and Targets** +- Labels: infrastructure, setup +- Dependencies: #107 +- Files: Package.swift + +**Issue #109: Create ConfigKeyKit Target Structure** +- Labels: infrastructure, setup +- Dependencies: #108 +- Files: Package.swift + +### Phase 2: Core Configuration & Command Infrastructure (Issues #110-#111) + +**Issue #110: Implement AnalyzerConfiguration and AnalyzerError** +- Labels: enhancement, configuration +- Dependencies: #109 +- Files: Sources/AiSTKit/AnalyzerConfiguration.swift, Sources/AiSTKit/AnalyzerError.swift + +**Issue #111: Implement AnalyzeCommand and Main Entry Point** +- Labels: enhancement, cli +- Dependencies: #110 +- Files: Sources/skit-aist/AnalyzeCommand.swift, Sources/skit-aist/main.swift + +### Phase 3: Input/Output Handlers (Issues #112-#115) + +**Issue #112: Implement InputFolderReader** +- Labels: enhancement, io +- Dependencies: #110 +- Files: Sources/AiSTKit/InputFolderReader.swift + +**Issue #113: Implement LibraryCollector** +- Labels: enhancement, io +- Dependencies: #110 +- Files: Sources/AiSTKit/LibraryCollector.swift + +**Issue #114: Implement LibraryWriter** +- Labels: enhancement, io +- Dependencies: #118 (LibraryUpdateResult) +- Files: Sources/AiSTKit/LibraryWriter.swift + +**Issue #115: Implement ASTGenerator** +- Labels: enhancement, ast +- Dependencies: #110 +- Files: Sources/AiSTKit/ASTGenerator.swift + +### Phase 4: Claude API Integration (Issues #116-#119) + +**Issue #116: Implement ClaudeKit Wrapper** +- Labels: enhancement, api +- Dependencies: #108, #117, #119 +- Files: Sources/AiSTKit/ClaudeKit.swift + +**Issue #117: Implement AuthenticationMiddleware** +- Labels: enhancement, api +- Dependencies: #108 +- Files: Sources/AiSTKit/AuthenticationMiddleware.swift + +**Issue #118: Implement LibraryUpdateResult and FileReference Models** +- Labels: enhancement, models +- Dependencies: #110 +- Files: Sources/AiSTKit/LibraryUpdateResult.swift, Sources/AiSTKit/FileReference.swift + +**Issue #119: Implement PromptTemplate** +- Labels: enhancement, prompts +- Dependencies: None +- Files: Sources/AiSTKit/PromptTemplate.swift + +### Phase 5: Main Orchestration (Issue #120) + +**Issue #120: Implement SyntaxKitAnalyzer Orchestration** +- Labels: enhancement, orchestration +- Dependencies: #112, #113, #114, #115, #116 +- Files: Sources/AiSTKit/SyntaxKitAnalyzer.swift + +### Phase 6: Testing Infrastructure (Issue #121) + +**Issue #121: Implement Test/Validation Mode Components** +- Labels: enhancement, testing +- Dependencies: #120 +- Files: Sources/AiSTKit/Testing/*.swift (TestRunner, TestCaseDiscoverer, TestValidator, TestModels) + +### Phase 7: Verification & Documentation (Issues #122-#124) + +**Issue #122: Create Verification Test Cases** +- Labels: testing +- Dependencies: #121 +- Files: examples/*/dsl.swift, examples/*/expected.swift + +**Issue #123: Create Example Usage Documentation** +- Labels: documentation +- Dependencies: #120 +- Files: Docs/skit-aist-usage.md + +**Issue #124: Create Integration Tests** +- Labels: testing, integration +- Dependencies: #122 +- Files: Tests/AiSTKitTests/IntegrationTests.swift + +## Labels Created + +The following labels were created for this project: + +- **infrastructure** (#0052CC) - Infrastructure and setup tasks +- **setup** (#0052CC) - Setup and configuration +- **configuration** (#5319E7) - Configuration related +- **cli** (#1D76DB) - Command-line interface +- **io** (#006B75) - Input/Output operations +- **api** (#0E8A16) - API integration +- **models** (#FBCA04) - Data models +- **prompts** (#D93F0B) - Prompt templates +- **orchestration** (#C5DEF5) - Workflow orchestration +- **ast** (#BFD4F2) - AST generation +- **testing** (#d876e3) - Testing infrastructure +- **integration** (#5319E7) - Integration testing + +Existing labels used: +- **enhancement** - New features +- **documentation** - Documentation updates + +## Implementation Order + +Issues should be worked on in dependency order: + +1. **Phase 1**: #107 → #108 → #109 (Foundation) +2. **Phase 2**: #110 → #111 (Configuration) +3. **Phase 3**: #112, #113, #115 (can be parallel), then #118, then #114 +4. **Phase 4**: #119 (parallel), #117 (parallel with #118), then #116 +5. **Phase 5**: #120 (Main orchestration - requires most prior work) +6. **Phase 6**: #121 (Testing infrastructure) +7. **Phase 7**: #122 → #123 (parallel), #124 + +## Quick Reference Commands + +```bash +# View all skit-aist issues +gh issue list --label infrastructure,configuration,cli,io,api,orchestration + +# View issues by phase (using labels) +gh issue list --label infrastructure # Phase 1 +gh issue list --label configuration # Phase 2 +gh issue list --label io # Phase 3 +gh issue list --label api # Phase 4 +gh issue list --label orchestration # Phase 5 +gh issue list --label testing # Phase 6-7 + +# Start work on first issue +gh issue view 107 +``` + +## Files Created + +- `scripts/package.json` - Node.js package configuration +- `scripts/issue-config.json` - Issue metadata and configuration +- `scripts/create-issues.js` - Automated issue creation script +- `scripts/ISSUE_CREATION_SUMMARY.md` - This summary document + +## Success Metrics + +- ✅ All 18 issues created successfully +- ✅ All labels created with appropriate colors +- ✅ Dependencies correctly cross-referenced +- ✅ Issues numbered #107-#124 +- ✅ Each issue is self-contained and actionable +- ✅ All code snippets from plan included in relevant issues +- ✅ Acceptance criteria clearly defined for each issue + +## Next Steps + +1. Review all issues to ensure completeness +2. Consider creating a GitHub Project board to track progress +3. Assign issues to team members or milestones +4. Begin implementation starting with Phase 1 issues + +```bash +# Optional: Create a project board +gh project create --title "skit-aist Implementation" --body "Track skit-aist tool development" +``` diff --git a/Scripts/README.md b/Scripts/README.md new file mode 100644 index 0000000..5f3dfe4 --- /dev/null +++ b/Scripts/README.md @@ -0,0 +1,155 @@ +# GitHub Issue Creation Scripts + +This directory contains scripts for automating the creation of GitHub issues from implementation plans. + +## Files + +- **`create-issues.js`** - Main script that creates GitHub issues from configuration +- **`issue-config.json`** - Issue metadata, labels, and specifications +- **`package.json`** - Node.js package configuration +- **`ISSUE_CREATION_SUMMARY.md`** - Summary of created issues + +## Prerequisites + +1. **GitHub CLI** installed and authenticated: + ```bash + gh auth status + gh auth login # if needed + ``` + +2. **Node.js** (v18 or later recommended): + ```bash + node --version + ``` + +## Usage + +### Create Issues + +```bash +cd scripts +node create-issues.js +``` + +The script will: +1. Create all necessary labels if they don't exist +2. Create issues in dependency order +3. Cross-reference dependencies between issues +4. Output a summary with issue numbers + +### View Created Issues + +```bash +# List all issues +gh issue list --limit 20 + +# View specific issue +gh issue view 107 + +# List issues by label +gh issue list --label infrastructure +gh issue list --label testing +``` + +## Issue Configuration + +The `issue-config.json` file defines: + +- **labels** - Label names and colors +- **issues** - Array of issue specifications with: + - `id` - Local issue ID (for dependency tracking) + - `phase` - Implementation phase + - `title` - Issue title + - `labels` - Array of label names + - `dependencies` - Array of issue IDs this depends on + - `files` - Files to create/modify + - `spec` - Specification text + - `acceptance` - Array of acceptance criteria + +## Adding New Issues + +To add new issues: + +1. Edit `issue-config.json` +2. Add new issue object to the `issues` array +3. Ensure dependencies reference existing issue IDs +4. Run `node create-issues.js` + +## Script Features + +- **Dependency Handling** - Creates issues in order, cross-references dependencies +- **Label Management** - Creates missing labels automatically +- **Error Handling** - Continues on errors, reports failures +- **Rate Limiting** - Small delays between API calls +- **Summary Output** - Maps local IDs to GitHub issue numbers + +## Example Output + +``` +GitHub Issue Creator for skit-analyze-plan.md +================================================== + +Step 1: Creating labels... + Created label: infrastructure + Label "enhancement" already exists + ... + +Step 2: Creating issues... + +Creating issue 1: Setup OpenAPI Specification and Generator Configuration + Created issue #107: Setup OpenAPI Specification and Generator Configuration + +Creating issue 2: Update Package.swift with Dependencies and Targets + Created issue #108: Update Package.swift with Dependencies and Targets + ... + +================================================== +Summary: + Total issues created: 18 / 18 + +Issue mapping: + Issue 1 -> #107: Setup OpenAPI Specification and Generator Configuration + Issue 2 -> #108: Update Package.swift with Dependencies and Targets + ... +``` + +## Troubleshooting + +### GitHub CLI Not Authenticated + +```bash +gh auth login +``` + +### Label Already Exists Error + +This is expected - the script handles existing labels gracefully. + +### Issue Creation Failed + +Check the error message. Common issues: +- Network connectivity +- API rate limiting (add delays in script) +- Invalid characters in title/body (check escaping) + +## Customization + +### Changing Label Colors + +Edit the `labels` object in `issue-config.json`: + +```json +"labels": { + "infrastructure": "0052CC", + "custom-label": "FF0000" +} +``` + +### Modifying Issue Template + +Edit the `formatIssueBody()` function in `create-issues.js` to change the issue body format. + +## Related Documentation + +- [skit-analyze-plan.md](../Docs/skit-analyze-plan.md) - Full implementation plan +- [ISSUE_CREATION_SUMMARY.md](./ISSUE_CREATION_SUMMARY.md) - Summary of created issues diff --git a/Scripts/create-issues.js b/Scripts/create-issues.js new file mode 100755 index 0000000..eb333f3 --- /dev/null +++ b/Scripts/create-issues.js @@ -0,0 +1,152 @@ +#!/usr/bin/env node + +import { readFileSync } from 'fs'; +import { execSync } from 'child_process'; + +// Load configuration +const config = JSON.parse(readFileSync('./issue-config.json', 'utf8')); + +// Function to execute shell command and return output +function exec(command) { + try { + return execSync(command, { encoding: 'utf8' }).trim(); + } catch (error) { + console.error(`Error executing command: ${command}`); + console.error(error.message); + throw error; + } +} + +// Function to check if a label exists +function labelExists(label) { + try { + exec(`gh label list --limit 1000 --json name --jq '.[] | select(.name=="${label}") | .name'`); + return true; + } catch { + return false; + } +} + +// Function to create a label if it doesn't exist +function createLabel(name, color) { + if (labelExists(name)) { + console.log(` Label "${name}" already exists`); + return; + } + + try { + exec(`gh label create "${name}" --color "${color}" --description ""`); + console.log(` Created label: ${name}`); + } catch (error) { + console.error(` Failed to create label: ${name}`); + } +} + +// Function to format issue body +function formatIssueBody(issue, createdIssues) { + const phaseSection = `## Phase\n\n${issue.phase}\n`; + + const specSection = `## Specification\n\n${issue.spec}\n`; + + const acceptanceSection = `## Acceptance Criteria\n\n${issue.acceptance.map(c => `- [ ] ${c}`).join('\n')}\n`; + + const dependenciesSection = issue.dependencies.length > 0 + ? `## Dependencies\n\n${issue.dependencies.map(depId => { + const ghIssueNum = createdIssues.get(depId); + return ghIssueNum ? `- Depends on: #${ghIssueNum}` : `- Depends on: Issue ${depId} (to be created)`; + }).join('\n')}\n` + : ''; + + const filesSection = issue.files.length > 0 + ? `## Files to Create/Modify\n\n${issue.files.map(f => `- \`${f}\``).join('\n')}\n` + : ''; + + const relatedSection = `## Related Documentation\n\n- [skit-analyze-plan.md](../blob/main/Docs/skit-analyze-plan.md)\n`; + + return [phaseSection, specSection, acceptanceSection, dependenciesSection, filesSection, relatedSection] + .filter(s => s) + .join('\n'); +} + +// Function to create a GitHub issue +function createIssue(issue, createdIssues) { + const body = formatIssueBody(issue, createdIssues); + const labels = issue.labels.join(','); + + // Escape special characters in title and body for shell + const escapedTitle = issue.title.replace(/"/g, '\\"'); + const escapedBody = body.replace(/"/g, '\\"').replace(/`/g, '\\`'); + + try { + const result = exec(`gh issue create --title "${escapedTitle}" --body "${escapedBody}" --label "${labels}"`); + // Extract issue number from URL (format: https://github.com/owner/repo/issues/123) + const match = result.match(/issues\/(\d+)/); + if (match) { + const issueNumber = parseInt(match[1], 10); + console.log(` Created issue #${issueNumber}: ${issue.title}`); + return issueNumber; + } + } catch (error) { + console.error(` Failed to create issue: ${issue.title}`); + console.error(` Error: ${error.message}`); + } + + return null; +} + +// Main execution +async function main() { + console.log('GitHub Issue Creator for skit-analyze-plan.md'); + console.log('='.repeat(50)); + + // Step 1: Create labels + console.log('\nStep 1: Creating labels...'); + Object.entries(config.labels).forEach(([name, color]) => { + createLabel(name, color); + }); + + // Step 2: Create issues in dependency order + console.log('\nStep 2: Creating issues...'); + const createdIssues = new Map(); // Maps local issue ID to GitHub issue number + + // Sort issues by ID to ensure dependencies are created first + const sortedIssues = config.issues.sort((a, b) => a.id - b.id); + + for (const issue of sortedIssues) { + console.log(`\nCreating issue ${issue.id}: ${issue.title}`); + + // Check if all dependencies have been created + const missingDeps = issue.dependencies.filter(depId => !createdIssues.has(depId)); + if (missingDeps.length > 0) { + console.log(` Warning: Missing dependencies: ${missingDeps.join(', ')}`); + } + + const issueNumber = createIssue(issue, createdIssues); + if (issueNumber) { + createdIssues.set(issue.id, issueNumber); + } + + // Small delay to avoid rate limiting + await new Promise(resolve => setTimeout(resolve, 500)); + } + + // Step 3: Summary + console.log('\n' + '='.repeat(50)); + console.log('Summary:'); + console.log(` Total issues created: ${createdIssues.size} / ${config.issues.length}`); + console.log('\nIssue mapping:'); + Array.from(createdIssues.entries()) + .sort((a, b) => a[0] - b[0]) + .forEach(([localId, ghNumber]) => { + const issue = config.issues.find(i => i.id === localId); + console.log(` Issue ${localId} -> #${ghNumber}: ${issue.title}`); + }); + + console.log('\nDone! View all issues:'); + console.log(' gh issue list --limit 20'); +} + +main().catch(error => { + console.error('Fatal error:', error); + process.exit(1); +}); diff --git a/Scripts/issue-config.json b/Scripts/issue-config.json new file mode 100644 index 0000000..173e4f4 --- /dev/null +++ b/Scripts/issue-config.json @@ -0,0 +1,351 @@ +{ + "labels": { + "infrastructure": "0052CC", + "setup": "0052CC", + "configuration": "5319E7", + "cli": "1D76DB", + "io": "006B75", + "api": "0E8A16", + "models": "FBCA04", + "prompts": "D93F0B", + "orchestration": "C5DEF5", + "ast": "BFD4F2", + "enhancement": "a2eeef", + "documentation": "0075ca", + "testing": "d876e3" + }, + "milestone": null, + "issues": [ + { + "id": 1, + "phase": "Phase 1: Project Setup & Infrastructure", + "title": "Setup OpenAPI Specification and Generator Configuration", + "labels": ["infrastructure", "setup"], + "dependencies": [], + "files": [ + "Sources/ClaudeKit/openapi.json", + "Sources/ClaudeKit/openapi-generator-config.yaml" + ], + "spec": "Download Anthropic OpenAPI spec from laszukdawid/anthropic-openapi-spec repository and configure Swift OpenAPI Generator build plugin.", + "acceptance": [ + "OpenAPI spec downloaded to Sources/ClaudeKit/openapi.json", + "openapi-generator-config.yaml created with types and client generation enabled", + "Configuration specifies internal access modifier", + "Files are ready for Package.swift integration" + ] + }, + { + "id": 2, + "phase": "Phase 1: Project Setup & Infrastructure", + "title": "Update Package.swift with Dependencies and Targets", + "labels": ["infrastructure", "setup"], + "dependencies": [1], + "files": ["Package.swift"], + "spec": "Add all required dependencies (swift-configuration, OpenAPI packages) and create three new targets: ClaudeKit, AiSTKit, and skit-aist executable.", + "acceptance": [ + "swift-configuration dependency added with CommandLineArguments trait", + "swift-openapi-generator, swift-openapi-runtime, swift-openapi-urlsession dependencies added", + "ClaudeKit target created with OpenAPIGenerator plugin", + "AiSTKit target created with dependencies on ClaudeKit and SyntaxParser", + "skit-aist executable target created with all required dependencies", + "skit-aist product exported as executable", + "Package builds successfully: swift build" + ] + }, + { + "id": 3, + "phase": "Phase 1: Project Setup & Infrastructure", + "title": "Create ConfigKeyKit Target Structure", + "labels": ["infrastructure", "setup"], + "dependencies": [2], + "files": ["Package.swift"], + "spec": "Add ConfigKeyKit as a library target in Package.swift with swift-configuration dependency.", + "acceptance": [ + "ConfigKeyKit added as a library target in Package.swift", + "ConfigKeyKit has swift-configuration dependency", + "ConfigKeyKit pattern is compatible with existing code", + "Package builds successfully" + ] + }, + { + "id": 4, + "phase": "Phase 2: Core Configuration & Command Infrastructure", + "title": "Implement AnalyzerConfiguration and AnalyzerError", + "labels": ["enhancement", "configuration"], + "dependencies": [3], + "files": [ + "Sources/AiSTKit/AnalyzerConfiguration.swift", + "Sources/AiSTKit/AnalyzerError.swift" + ], + "spec": "Create configuration structure using ConfigKeyKit pattern with support for positional arguments and environment variables. Define comprehensive error types.", + "acceptance": [ + "AnalyzerConfiguration implements ConfigurationParseable protocol", + "Configuration keys defined: syntaxKitPathKey, apiKeyKey, modelKey, verboseKey", + "Positional argument parsing implemented for input folder, syntaxkit path, output folder", + "Path validation logic implemented", + "AnalyzerError enum defines all error cases", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 5, + "phase": "Phase 2: Core Configuration & Command Infrastructure", + "title": "Implement AnalyzeCommand and Main Entry Point", + "labels": ["enhancement", "cli"], + "dependencies": [4], + "files": [ + "Sources/skit-aist/AnalyzeCommand.swift", + "Sources/skit-aist/main.swift" + ], + "spec": "Create command implementation using ConfigKeyKit Command protocol and main entry point with error handling.", + "acceptance": [ + "AnalyzeCommand implements Command protocol", + "commandName, abstract, and helpText defined with complete usage information", + "createInstance() creates ConfigReader with CLI and ENV providers", + "execute() delegates to SyntaxKitAnalyzer", + "main.swift implements @main entry point with error handling", + "Help text documents all arguments and options", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 6, + "phase": "Phase 3: Input/Output Handlers", + "title": "Implement InputFolderReader", + "labels": ["enhancement", "io"], + "dependencies": [4], + "files": ["Sources/AiSTKit/InputFolderReader.swift"], + "spec": "Create input folder reader that validates and reads dsl.swift and expected.swift files.", + "acceptance": [ + "InputFolderReader struct created with folderPath property", + "Inputs nested struct defined with dslCode and expectedSwift properties", + "readInputs() validates presence of required files", + "readInputs() reads file contents with error handling", + "Appropriate errors thrown for missing files", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 7, + "phase": "Phase 3: Input/Output Handlers", + "title": "Implement LibraryCollector", + "labels": ["enhancement", "io"], + "dependencies": [4], + "files": ["Sources/AiSTKit/LibraryCollector.swift"], + "spec": "Create library collector that recursively scans SyntaxKit directory for Swift source files.", + "acceptance": [ + "LibraryCollector struct created", + "Recursive .swift file scanning implemented", + "Test files and build artifacts are skipped", + "Output formatted with file path markers", + "File count tracking for verbose output", + "Relative paths preserved", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 8, + "phase": "Phase 3: Input/Output Handlers", + "title": "Implement LibraryWriter", + "labels": ["enhancement", "io"], + "dependencies": [12], + "files": ["Sources/AiSTKit/LibraryWriter.swift"], + "spec": "Create library writer that writes LibraryUpdateResult to output directory with proper structure.", + "acceptance": [ + "LibraryWriter struct created with outputPath property", + "writeUpdatedLibrary() creates output directory with intermediate directories", + "Updated files written to correct paths", + "New files written to correct paths", + "Optional: unchanged files copied if needed", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 9, + "phase": "Phase 3: Input/Output Handlers", + "title": "Implement ASTGenerator", + "labels": ["enhancement", "ast"], + "dependencies": [4], + "files": ["Sources/AiSTKit/ASTGenerator.swift"], + "spec": "Create AST generator that wraps SyntaxParser to produce JSON AST from Swift code.", + "acceptance": [ + "ASTGenerator struct created", + "generateAST() uses SyntaxParser.parse()", + "TreeNode array formatted as JSON", + "JSONEncoder uses prettyPrinted and sortedKeys", + "Error handling for encoding failures", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 10, + "phase": "Phase 4: Claude API Integration", + "title": "Implement ClaudeKit Wrapper", + "labels": ["enhancement", "api"], + "dependencies": [2, 11, 13], + "files": ["Sources/AiSTKit/ClaudeKit.swift"], + "spec": "Create ClaudeKit wrapper around OpenAPI-generated client for code generation API calls.", + "acceptance": [ + "ClaudeKit struct created with apiKey, model, and client properties", + "init creates OpenAPI client with URLSession transport and AuthenticationMiddleware", + "generateUpdatedLibrary() calls OpenAPI client.postV1Messages()", + "Response content extracted from API response", + "parseCodeGenerationResponse() called to parse response", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 11, + "phase": "Phase 4: Claude API Integration", + "title": "Implement AuthenticationMiddleware", + "labels": ["enhancement", "api"], + "dependencies": [2], + "files": ["Sources/AiSTKit/AuthenticationMiddleware.swift"], + "spec": "Create OpenAPI middleware that adds Anthropic API authentication headers.", + "acceptance": [ + "AuthenticationMiddleware implements ClientMiddleware protocol", + "intercept() adds x-api-key header with API key", + "intercept() adds anthropic-version header", + "Middleware correctly forwards request to next handler", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 12, + "phase": "Phase 4: Claude API Integration", + "title": "Implement LibraryUpdateResult and FileReference Models", + "labels": ["enhancement", "models"], + "dependencies": [4], + "files": [ + "Sources/AiSTKit/LibraryUpdateResult.swift", + "Sources/AiSTKit/FileReference.swift" + ], + "spec": "Create data models for library update results including updated files, new files, and file references.", + "acceptance": [ + "LibraryUpdateResult struct created as Codable", + "UpdatedFile nested struct defined", + "NewFile nested struct defined", + "FileReference struct created as Codable", + "All necessary properties included (paths, content, descriptions)", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 13, + "phase": "Phase 4: Claude API Integration", + "title": "Implement PromptTemplate", + "labels": ["enhancement", "prompts"], + "dependencies": [], + "files": ["Sources/AiSTKit/PromptTemplate.swift"], + "spec": "Create prompt template that combines Workbench analysis prompt with code generation instructions.", + "acceptance": [ + "PromptTemplate struct created", + "createAnalysisAndCodeGeneration() static method implemented", + "Original Workbench prompt integrated", + "Code generation instructions added", + "Structured output format defined with XML-style markers", + "Prompt requests complete file content (not diffs)", + "Compilation validity emphasized", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 14, + "phase": "Phase 5: Main Orchestration", + "title": "Implement SyntaxKitAnalyzer Orchestration", + "labels": ["enhancement", "orchestration"], + "dependencies": [6, 7, 8, 9, 10], + "files": ["Sources/AiSTKit/SyntaxKitAnalyzer.swift"], + "spec": "Create main orchestrator that coordinates the entire workflow from input reading through library writing.", + "acceptance": [ + "SyntaxKitAnalyzer struct created with config property", + "run() method orchestrates: read inputs, generate AST, collect library, call API, write output", + "Verbose output at each step when enabled", + "writeUpdatedLibrary() helper implemented", + "Success message printed with output path", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 15, + "phase": "Phase 6: Testing Infrastructure", + "title": "Implement Test/Validation Mode Components", + "labels": ["enhancement", "testing"], + "dependencies": [14], + "files": [ + "Sources/AiSTKit/Testing/TestRunner.swift", + "Sources/AiSTKit/Testing/TestCaseDiscoverer.swift", + "Sources/AiSTKit/Testing/TestValidator.swift", + "Sources/AiSTKit/Testing/TestModels.swift" + ], + "spec": "Create comprehensive test mode infrastructure for validating Claude's generated code against expected outputs.", + "acceptance": [ + "TestRunner implements test case discovery and execution", + "TestCaseDiscoverer loads test cases from test-cases/ directory", + "TestValidator implements validation strategies (structural, content, build, functional)", + "TestModels defines TestCase, TestConfig, TestManifest, ValidationResult", + "AnalyzerConfiguration updated with test mode flags (--test, --test-stop-on-fail, --test-filter, --test-cases)", + "Test mode can run all tests or filtered subset", + "Code follows one-type-per-file organization" + ] + }, + { + "id": 16, + "phase": "Phase 7: Verification & Documentation", + "title": "Create Verification Test Cases", + "labels": ["testing"], + "dependencies": [15], + "files": [ + "examples/simple-property/dsl.swift", + "examples/simple-property/expected.swift", + "examples/subscript-feature/dsl.swift", + "examples/subscript-feature/expected.swift", + "examples/defer-statement/dsl.swift", + "examples/defer-statement/expected.swift" + ], + "spec": "Create comprehensive test inputs and verify the tool works end-to-end including error handling.", + "acceptance": [ + "simple-property test input created", + "subscript-feature test input created", + "defer-statement test input created", + "Build test verification works", + "Generated code compilation test passes", + "Error handling tests pass (missing API key, invalid paths, missing files)" + ] + }, + { + "id": 17, + "phase": "Phase 7: Verification & Documentation", + "title": "Create Example Usage Documentation", + "labels": ["documentation"], + "dependencies": [14], + "files": ["Docs/skit-aist-usage.md"], + "spec": "Create comprehensive usage documentation with examples for basic and advanced usage scenarios.", + "acceptance": [ + "Basic example workflow documented", + "Advanced usage examples documented (custom model, verbose, API key flag)", + "Custom model configuration documented", + "Verbose output usage documented", + "API key configuration documented", + "Help command documented", + "Full workflow example provided" + ] + }, + { + "id": 18, + "phase": "Phase 7: Verification & Documentation", + "title": "Create Integration Tests", + "labels": ["testing", "integration"], + "dependencies": [16], + "files": ["Tests/AiSTKitTests/IntegrationTests.swift"], + "spec": "Create end-to-end integration test using a real missing feature to verify the entire pipeline.", + "acceptance": [ + "Integration test using real missing feature (e.g., subscript syntax)", + "Test verifies generated code validity", + "Test verifies code follows SyntaxKit patterns", + "Test verifies code compiles", + "Test verifies feature works as expected" + ] + } + ] +} diff --git a/Scripts/package.json b/Scripts/package.json new file mode 100644 index 0000000..c7c273b --- /dev/null +++ b/Scripts/package.json @@ -0,0 +1,10 @@ +{ + "name": "skit-issue-creator", + "version": "1.0.0", + "description": "Creates GitHub issues from skit-analyze-plan.md", + "type": "module", + "scripts": { + "create-issues": "node create-issues.js" + }, + "dependencies": {} +}