We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa817f3 commit 136f6f2Copy full SHA for 136f6f2
lib/ASTGen/Sources/ASTGen/Macros.swift
@@ -422,13 +422,17 @@ private func findSyntaxNodeInSourceFile<Node: SyntaxProtocol>(
422
return nil
423
}
424
425
- // Dig out its parent.
426
- guard let parentSyntax = token.parent else {
427
- print("not on a macro expansion node: \(token.recursiveDescription)")
428
- return nil
+ var currentSyntax = Syntax(token)
+ while let parentSyntax = currentSyntax.parent {
+ if let typedParent = parentSyntax.as(type) {
+ return typedParent
429
+ }
430
+
431
+ currentSyntax = parentSyntax
432
433
- return parentSyntax.as(type)
434
+ print("unable to find node: \(token.recursiveDescription)")
435
+ return nil
436
437
438
@_cdecl("swift_ASTGen_expandAttachedMacro")
0 commit comments