Skip to content

Commit 4174e18

Browse files
gibachanahoppen
andauthored
Refactor to use keyPathInParent
Co-authored-by: Alex Hoppen <[email protected]>
1 parent c819914 commit 4174e18

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Sources/SwiftBasicFormat/BasicFormat.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,9 @@ open class BasicFormat: SyntaxRewriter {
237237
(nil, _):
238238
return false
239239
case (_, .colon):
240-
let isTernaryExpr = second?.parent?.is(UnresolvedTernaryExprSyntax.self) == true
241-
|| second?.parent?.is(TernaryExprSyntax.self) == true
242-
243-
if !isTernaryExpr {
240+
if second?.keyPathInParent != \TernaryExprSyntax.colonMark
241+
&& second?.keyPathInParent != \UnresolvedTernaryExprSyntax.colonMark
242+
{
244243
return false
245244
}
246245
case (.leftAngle, _) where second?.tokenKind != .rightAngle: // `<` and `>` need to be separated by a space because otherwise they become an operator

0 commit comments

Comments
 (0)