Skip to content

Commit 8542e17

Browse files
committed
Lift isRoot extension as it's used in two places.
1 parent bf42ce7 commit 8542e17

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

Sources/SwiftFormat/API/Configuration.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,3 @@ public struct NoAssignmentInExpressionsConfiguration: Codable, Equatable {
472472

473473
public init() {}
474474
}
475-
476-
fileprivate extension URL {
477-
var isRoot: Bool {
478-
#if os(Windows)
479-
// 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.
480-
// https://github.com/swiftlang/swift-format/issues/844
481-
return self.pathComponents.count <= 1
482-
#else
483-
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
484-
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.
485-
return self.path == "/" || self.path == ""
486-
#endif
487-
}
488-
}

Sources/SwiftFormat/Utilities/FileIterator.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,3 @@ private func inputShouldBeProcessed(at url: URL) -> Bool {
199199
} while !containingDirectory.isRoot
200200
return true
201201
}
202-
203-
fileprivate extension URL {
204-
var isRoot: Bool {
205-
#if os(Windows)
206-
// 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.
207-
// https://github.com/swiftlang/swift-format/issues/844
208-
return self.pathComponents.count <= 1
209-
#else
210-
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
211-
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.
212-
return self.path == "/" || self.path == ""
213-
#endif
214-
}
215-
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Foundation
14+
15+
extension URL {
16+
var isRoot: Bool {
17+
#if os(Windows)
18+
// 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.
19+
// https://github.com/swiftlang/swift-format/issues/844
20+
return self.pathComponents.count <= 1
21+
#else
22+
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
23+
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.
24+
return self.path == "/" || self.path == ""
25+
#endif
26+
}
27+
}

0 commit comments

Comments
 (0)