Skip to content

Commit fdc708f

Browse files
author
David Brunow
committed
Simplify the implementation
1 parent 4cad9a8 commit fdc708f

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,33 +3511,16 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
35113511
}
35123512

35133513
private func isNestedInPostfixIfConfig(node: MemberAccessExprSyntax) -> Bool {
3514-
func containsDescendent(ancestor: Syntax, node: MemberAccessExprSyntax) -> Bool {
3515-
if ancestor.children(viewMode: .sourceAccurate).contains(Syntax(node)) {
3516-
return true
3517-
}
3518-
3519-
for child in ancestor.children(viewMode: .sourceAccurate) {
3520-
if containsDescendent(ancestor: child, node: node) {
3521-
return true
3522-
}
3523-
}
3524-
3525-
return false
3526-
}
3527-
35283514
var this: Syntax? = Syntax(node)
35293515

35303516
while this?.parent != nil {
35313517
if this?.is(TupleExprElementSyntax.self) == true {
35323518
return false
35333519
}
35343520

3535-
if let postfixIfConfig = this?.as(PostfixIfConfigExprSyntax.self) {
3536-
if let ifConfigListSyntax = postfixIfConfig.config.children(viewMode: .sourceAccurate).first?.as(IfConfigClauseListSyntax.self) {
3537-
if containsDescendent(ancestor: Syntax(ifConfigListSyntax), node: node) {
3538-
return true
3539-
}
3540-
}
3521+
if this?.is(IfConfigDeclSyntax.self) == true &&
3522+
this?.parent?.is(PostfixIfConfigExprSyntax.self) == true {
3523+
return true
35413524
}
35423525

35433526
this = this?.parent

0 commit comments

Comments
 (0)