Skip to content

Commit c995ec3

Browse files
committed
Lift isRoot extension as it's used in two places.
1 parent 9ab91a5 commit c995ec3

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

Sources/SwiftFormat/Utilities/FileIterator.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,3 @@ private func inputShouldBeProcessed(at url: URL) -> Bool {
209209
} while !containingDirectory.isRoot
210210
return true
211211
}
212-
213-
fileprivate extension URL {
214-
var isRoot: Bool {
215-
#if os(Windows)
216-
// 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.
217-
// https://github.com/swiftlang/swift-format/issues/844
218-
return self.pathComponents.count <= 1
219-
#else
220-
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
221-
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.
222-
return self.path == "/" || self.path == ""
223-
#endif
224-
}
225-
}
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)