Skip to content

Commit d491eec

Browse files
authored
Improve SyntaxWriter.visitAny(_:) docs (#2738)
1 parent eb3ff35 commit d491eec

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxRewriterFile.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,14 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
109109
/// Override point to choose custom visitation dispatch instead of the
110110
/// specialized `visit(_:)` methods. Use this instead of those methods if
111111
/// you intend to dynamically dispatch rewriting behavior.
112-
/// - note: If this method returns a non-nil result, the specialized
113-
/// `visit(_:)` methods will not be called for this node and the
112+
/// - note: If this method returns a non-nil result, the subsequent
113+
/// `visitAny(_:)` methods and the specialized `visit(_:)`
114+
/// methods will not be called for this node and the
114115
/// visited node will be replaced by the returned node in the
115116
/// rewritten tree.
117+
/// You can call the ``SyntaxRewriter/rewrite(_:detach:)``
118+
/// method recursively when returning a non-nil result
119+
/// if you want to visit the node's children anyway.
116120
open func visitAny(_ node: Syntax) -> Syntax? {
117121
return nil
118122
}

Sources/SwiftSyntax/generated/SyntaxRewriter.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ open class SyntaxRewriter {
7373
/// Override point to choose custom visitation dispatch instead of the
7474
/// specialized `visit(_:)` methods. Use this instead of those methods if
7575
/// you intend to dynamically dispatch rewriting behavior.
76-
/// - note: If this method returns a non-nil result, the specialized
77-
/// `visit(_:)` methods will not be called for this node and the
76+
/// - note: If this method returns a non-nil result, the subsequent
77+
/// `visitAny(_:)` methods and the specialized `visit(_:)`
78+
/// methods will not be called for this node and the
7879
/// visited node will be replaced by the returned node in the
7980
/// rewritten tree.
81+
/// You can call the ``SyntaxRewriter/rewrite(_:detach:)``
82+
/// method recursively when returning a non-nil result
83+
/// if you want to visit the node's children anyway.
8084
open func visitAny(_ node: Syntax) -> Syntax? {
8185
return nil
8286
}

0 commit comments

Comments
 (0)