Skip to content

Commit bbffc84

Browse files
committed
Improve documentation comments of DeclReferenceExprSyntax
1 parent f2aff2e commit bbffc84

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesD.swift

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,35 @@ public struct DeclNameArgumentsSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynt
605605

606606
// MARK: - DeclReferenceExprSyntax
607607

608+
/// An expression that refers to a declaration by name, such as a reference to a function, type, or variable.
609+
///
610+
/// This type represents references to declarations in Swift code, commonly used when building syntax for:
611+
/// - Function and type references
612+
/// - Variable and property references
613+
/// - Special declarations like `self`, `Self`, and `init`
614+
///
615+
/// Example creating a simple reference to a type:
616+
/// ```swift
617+
/// let stringReference = DeclReferenceExprSyntax(baseName: "String")
618+
/// ```
619+
///
620+
/// Example using a declaration reference in a function call:
621+
/// ```swift
622+
/// let functionCall = FunctionCallExprSyntax(
623+
/// calledExpression: DeclReferenceExprSyntax(baseName: "print"),
624+
/// leftParen: .leftParenToken(),
625+
/// arguments: arguments,
626+
/// rightParen: .rightParenToken()
627+
/// )
628+
/// ```
629+
///
608630
/// ### Children
609-
///
631+
///
610632
/// - `baseName`: (`<identifier>` | `self` | `Self` | `init` | `deinit` | `subscript` | `<dollarIdentifier>` | `<binaryOperator>` | `<integerLiteral>`)
611633
/// - `argumentNames`: ``DeclNameArgumentsSyntax``?
612634
///
613635
/// ### Contained in
614-
///
636+
///
615637
/// - ``DynamicReplacementAttributeArgumentsSyntax``.``DynamicReplacementAttributeArgumentsSyntax/declName``
616638
/// - ``ImplementsAttributeArgumentsSyntax``.``ImplementsAttributeArgumentsSyntax/declName``
617639
/// - ``KeyPathPropertyComponentSyntax``.``KeyPathPropertyComponentSyntax/declName``
@@ -620,16 +642,37 @@ public struct DeclNameArgumentsSyntax: SyntaxProtocol, SyntaxHashable, _LeafSynt
620642
public struct DeclReferenceExprSyntax: ExprSyntaxProtocol, SyntaxHashable, _LeafExprSyntaxNodeProtocol {
621643
public let _syntaxNode: Syntax
622644

645+
/// Internal initializer used by swift-syntax to create declaration references from existing syntax nodes.
646+
///
647+
/// This initializer is not intended for direct use when creating declaration references programmatically.
648+
/// Instead, use the main initializer that accepts individual components.
649+
///
650+
/// - Parameters:
651+
/// - node: An existing syntax node to convert. Must be of kind `.declReferenceExpr`.
623652
public init?(_ node: __shared some SyntaxProtocol) {
624653
guard node.raw.kind == .declReferenceExpr else {
625654
return nil
626655
}
627656
self._syntaxNode = node._syntaxNode
628657
}
629658

659+
/// Creates a new declaration reference with the given base name and optional components.
660+
///
661+
/// Example creating a reference to a type:
662+
/// ```swift
663+
/// let reference = DeclReferenceExprSyntax(
664+
/// baseName: .identifier("String")
665+
/// )
666+
/// ```
667+
///
630668
/// - Parameters:
631-
/// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
632-
/// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
669+
/// - leadingTrivia: Trivia to be prepended to the leading trivia of the node's first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
670+
/// - unexpectedBeforeBaseName: Used internally by swift-syntax to handle malformed source code. When creating expressions programmatically, you should pass nil.
671+
/// - baseName: The name of the declaration being referenced.
672+
/// - unexpectedBetweenBaseNameAndArgumentNames: Used internally by swift-syntax to handle malformed source code. When creating expressions programmatically, you should pass nil.
673+
/// - argumentNames: Optional argument labels when referring to specific function overloads.
674+
/// - unexpectedAfterArgumentNames: Used internally by swift-syntax to handle malformed source code. When creating expressions programmatically, you should pass nil.
675+
/// - trailingTrivia: Trivia to be appended to the trailing trivia of the node's last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
633676
public init(
634677
leadingTrivia: Trivia? = nil,
635678
_ unexpectedBeforeBaseName: UnexpectedNodesSyntax? = nil,

0 commit comments

Comments
 (0)