in Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift [1519:1541]
func findTryAwaitExprConnectingToken(inExpr expr: ExprSyntax) -> TokenSyntax? {
if let awaitExpr = expr.as(AwaitExprSyntax.self) {
// If we were called from the `try` of a `try await <expr>`, drill into the child expression.
return findTryAwaitExprConnectingToken(inExpr: awaitExpr.expression)
}
if let callingExpr = expr.asProtocol(CallingExprSyntaxProtocol.self) {
return findTryAwaitExprConnectingToken(inExpr: callingExpr.calledExpression)
}
if let memberAccessExpr = expr.as(MemberAccessExprSyntax.self), let base = memberAccessExpr.base
{
// When there's a simple base (i.e. identifier), group the entire `try/await <base>.<name>`
// sequence. This check has to happen here so that the `MemberAccessExprSyntax.name` is
// available.
if base.is(IdentifierExprSyntax.self) {
return memberAccessExpr.name.lastToken
}
return findTryAwaitExprConnectingToken(inExpr: base)
}
if expr.is(IdentifierExprSyntax.self) {
return expr.lastToken
}
return nil
}