From b2466d9f477e06c6c7baa6b20319e6c8a4ecc72e Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 19 May 2025 16:01:34 -0700 Subject: [PATCH 1/3] Add extra code owners to help with reviews --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index a8142cf6..f5bc2420 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,7 +8,7 @@ # See https://swift.org/CONTRIBUTORS.txt for Swift project authors # -* @allevato @bnbarham @shawnhyam +* @allevato @bnbarham @hamishknight @rintaro .github/ @bnbarham @shahmishal .swiftci/ @bnbarham @shahmishal From 24c744665e4e0de6100ca7fd06f8862ab41e358b Mon Sep 17 00:00:00 2001 From: TTOzzi Date: Thu, 12 Jun 2025 00:27:30 +0900 Subject: [PATCH 2/3] Add support for BorrowExprSyntax (#1031) --- .../PrettyPrint/TokenStreamCreator.swift | 7 +++++ .../PrettyPrint/BorrowExprTests.swift | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Tests/SwiftFormatTests/PrettyPrint/BorrowExprTests.swift diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 966ccc39..2a08bb15 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -2737,6 +2737,13 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { return .visitChildren } + override func visit(_ node: BorrowExprSyntax) -> SyntaxVisitorContinueKind { + // The `borrow` keyword cannot be separated from the following token or it will be parsed as + // an identifier. + after(node.borrowKeyword, tokens: .space) + return .visitChildren + } + override func visit(_ node: ConsumeExprSyntax) -> SyntaxVisitorContinueKind { // The `consume` keyword cannot be separated from the following token or it will be parsed as // an identifier. diff --git a/Tests/SwiftFormatTests/PrettyPrint/BorrowExprTests.swift b/Tests/SwiftFormatTests/PrettyPrint/BorrowExprTests.swift new file mode 100644 index 00000000..1113a710 --- /dev/null +++ b/Tests/SwiftFormatTests/PrettyPrint/BorrowExprTests.swift @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +final class BorrowExprTests: PrettyPrintTestCase { + func testBorrow() { + assertPrettyPrintEqual( + input: """ + @lifetime(borrow self) + init() {} + """, + expected: """ + @lifetime( + borrow self) + init() {} + + """, + linelength: 21 + ) + } +} From acf0aa14ebaedaf10f2273949a6af52ccfd37c46 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Tue, 17 Jun 2025 17:50:40 -0700 Subject: [PATCH 3/3] Revert "Merge pull request #1023 from bnbarham/update-codeowners" This reverts commit 1af8fbc1ebfebbe80cfdaa2572d1b7250b2df6fe, reversing changes made to adcbed1267abe757624a05bf5d3d498f2d746233. --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index f5bc2420..a8142cf6 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,7 +8,7 @@ # See https://swift.org/CONTRIBUTORS.txt for Swift project authors # -* @allevato @bnbarham @hamishknight @rintaro +* @allevato @bnbarham @shawnhyam .github/ @bnbarham @shahmishal .swiftci/ @bnbarham @shahmishal