Skip to content

Commit 4073657

Browse files
Use AbsolutePath.asURL instead of creating a new URL from the path string (#8159)
Use `AbsolutePath.asURL` instead of creating a new URL from the path string. ### Motivation: The original PR that added `resources`, `ignored`, and `other` files to `BuildTarget` should have used `AbsolutePath.asURL` instead of creating a new URL from the path string. This PR fixes that in order to maintain a single location where absolute paths can be converted to URLs. ### Modifications: I've replaced the `AbsolutePath` to `URL` mappings in `SourceKitLSPAPI` with calls to `AbsolutePath.asURL`. ### Result: This PR does not have an affect on the functionality of Swift Package Manager.
1 parent bafa1ba commit 4073657

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Sources/SourceKitLSPAPI/BuildDescription.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ private struct WrappedClangTargetBuildDescription: BuildTarget {
8282
}
8383

8484
var resources: [URL] {
85-
return description.resources.map { URL(fileURLWithPath: $0.path.pathString) }
85+
return description.resources.map(\.path.asURL)
8686
}
8787

8888
var ignored: [URL] {
89-
return description.ignored.map { URL(fileURLWithPath: $0.pathString) }
89+
return description.ignored.map(\.asURL)
9090
}
9191

9292
var others: [URL] {
93-
return description.others.map { URL(fileURLWithPath: $0.pathString) }
93+
return description.others.map(\.asURL)
9494
}
9595

9696
public var name: String {
@@ -129,21 +129,21 @@ private struct WrappedSwiftTargetBuildDescription: BuildTarget {
129129
}
130130

131131
var sources: [URL] {
132-
return description.sources.map { URL(fileURLWithPath: $0.pathString) }
132+
return description.sources.map(\.asURL)
133133
}
134134

135135
var headers: [URL] { [] }
136136

137137
var resources: [URL] {
138-
return description.resources.map { URL(fileURLWithPath: $0.path.pathString) }
138+
return description.resources.map(\.path.asURL)
139139
}
140140

141141
var ignored: [URL] {
142-
return description.ignored.map { URL(fileURLWithPath: $0.pathString) }
142+
return description.ignored.map(\.asURL)
143143
}
144144

145145
var others: [URL] {
146-
return description.others.map { URL(fileURLWithPath: $0.pathString) }
146+
return description.others.map(\.asURL)
147147
}
148148

149149
func compileArguments(for fileURL: URL) throws -> [String] {

Sources/SourceKitLSPAPI/PluginTargetBuildDescription.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ struct PluginTargetBuildDescription: BuildTarget {
3636
}
3737

3838
var sources: [URL] {
39-
return target.sources.paths.map { URL(fileURLWithPath: $0.pathString) }
39+
return target.sources.paths.map(\.asURL)
4040
}
4141

4242
var headers: [URL] { [] }
4343

4444
var resources: [URL] {
45-
return target.underlying.resources.map { URL(fileURLWithPath: $0.path.pathString) }
45+
return target.underlying.resources.map(\.path.asURL)
4646
}
4747

4848
var ignored: [URL] {
49-
return target.underlying.ignored.map { URL(fileURLWithPath: $0.pathString) }
49+
return target.underlying.ignored.map(\.asURL)
5050
}
5151

5252
var others: [URL] {
53-
return target.underlying.others.map { URL(fileURLWithPath: $0.pathString) }
53+
return target.underlying.others.map(\.asURL)
5454
}
5555

5656
var name: String {

0 commit comments

Comments
 (0)