Skip to content

Commit 8414a8b

Browse files
authored
Merge pull request #415 from owenv/package-cleanup
Migrate to TSC versions of some Absolute/RelativePath APIs
2 parents 7055a62 + 9e1e6a4 commit 8414a8b

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/SwiftDriver/Utilities/RelativePathAdditions.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
import TSCBasic
1313

1414
extension RelativePath {
15-
/// Retrieve the basename of the relative path without the extension.
16-
///
17-
/// FIXME: Probably belongs in TSC
18-
var basenameWithoutExt: String {
19-
if let ext = self.extension {
20-
return String(basename.dropLast(ext.count + 1))
21-
}
22-
23-
return basename
24-
}
25-
2615
/// Retrieve the basename of the relative path without any extensions,
2716
/// even if there are several, and without any leading dots. Roughly
2817
/// equivalent to the regex `/[^.]+/`.

Sources/SwiftDriver/Utilities/VirtualPath.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,21 @@ public enum VirtualPath: Hashable {
162162
}
163163

164164
public func appending(components: String...) -> VirtualPath {
165-
// FIXME: TSC should add non-variadic overloads of appending(components:)
166-
// so we can forward arguments here instead of appending components one-by-one.
167-
var result = self
168-
components.forEach {
169-
result = result.appending(component: $0)
165+
switch self {
166+
case .absolute(let path):
167+
return .absolute(path.appending(components: components))
168+
case .relative(let path):
169+
return .relative(path.appending(components: components))
170+
case .temporary(let path):
171+
return .temporary(path.appending(components: components))
172+
case let .temporaryWithKnownContents(path, contents):
173+
return .temporaryWithKnownContents(path.appending(components: components), contents)
174+
case .fileList(let path, let content):
175+
return .fileList(path.appending(components: components), content)
176+
case .standardInput, .standardOutput:
177+
assertionFailure("Can't append path component to standard in/out")
178+
return self
170179
}
171-
return result
172180
}
173181

174182
/// Returns the virtual path with an additional suffix appended to base name.

0 commit comments

Comments
 (0)