-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #893 from ahoppen/merge-main-6.1-2024-12-10
Merge `main` into `release/6.1`
- Loading branch information
Showing
9 changed files
with
226 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2023 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
|
||
extension URL { | ||
@_spi(Testing) public var isRoot: Bool { | ||
#if os(Windows) | ||
// FIXME: We should call into Windows' native check to check if this path is a root once https://github.com/swiftlang/swift-foundation/issues/976 is fixed. | ||
// https://github.com/swiftlang/swift-format/issues/844 | ||
var pathComponents = self.pathComponents | ||
if pathComponents.first == "/" { | ||
// Canonicalize `/C:/` to `C:/`. | ||
pathComponents = Array(pathComponents.dropFirst()) | ||
} | ||
return pathComponents.count <= 1 | ||
#else | ||
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980 | ||
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed. | ||
return self.path == "/" || self.path == "" | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import SwiftFormat | ||
import _SwiftFormatTestSupport | ||
|
||
final class LineNumbersTests: PrettyPrintTestCase { | ||
func testLineNumbers() { | ||
let input = | ||
""" | ||
final class A { | ||
@Test func b() throws { | ||
doSomethingInAFunctionWithAVeryLongName() 1️⃣// Here we have a very long comment that should not be here because it is far too long | ||
} | ||
} | ||
""" | ||
|
||
let expected = | ||
""" | ||
final class A { | ||
@Test func b() throws { | ||
doSomethingInAFunctionWithAVeryLongName() // Here we have a very long comment that should not be here because it is far too long | ||
} | ||
} | ||
""" | ||
|
||
assertPrettyPrintEqual( | ||
input: input, | ||
expected: expected, | ||
linelength: 120, | ||
whitespaceOnly: true, | ||
findings: [ | ||
FindingSpec("1️⃣", message: "move end-of-line comment that exceeds the line length") | ||
] | ||
) | ||
} | ||
|
||
func testLineNumbersWithComments() { | ||
let input = | ||
""" | ||
// Copyright (C) 2024 My Coorp. All rights reserved. | ||
// | ||
// This document is the property of My Coorp. | ||
// It is considered confidential and proprietary. | ||
// | ||
// This document may not be reproduced or transmitted in any form, | ||
// in whole or in part, without the express written permission of | ||
// My Coorp. | ||
final class A { | ||
@Test func b() throws { | ||
doSomethingInAFunctionWithAVeryLongName() 1️⃣// Here we have a very long comment that should not be here because it is far too long | ||
} | ||
} | ||
""" | ||
|
||
let expected = | ||
""" | ||
// Copyright (C) 2024 My Coorp. All rights reserved. | ||
// | ||
// This document is the property of My Coorp. | ||
// It is considered confidential and proprietary. | ||
// | ||
// This document may not be reproduced or transmitted in any form, | ||
// in whole or in part, without the express written permission of | ||
// My Coorp. | ||
final class A { | ||
@Test func b() throws { | ||
doSomethingInAFunctionWithAVeryLongName() // Here we have a very long comment that should not be here because it is far too long | ||
} | ||
} | ||
""" | ||
|
||
assertPrettyPrintEqual( | ||
input: input, | ||
expected: expected, | ||
linelength: 120, | ||
whitespaceOnly: true, | ||
findings: [ | ||
FindingSpec("1️⃣", message: "move end-of-line comment that exceeds the line length") | ||
] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
6.2 | ||
--- | ||
|
||
API breakage: constructor FileIterator.init(urls:followSymlinks:) has been removed |