Skip to content

Commit cf18660

Browse files
authored
Fix use of deprecated AbsolutePath.init (#719)
Non-throwing `AbsolutePath.init(_:)` is deprecated, we should use `AbsolutePath.init(validating:) throws` instead.
1 parent 24ce1be commit cf18660

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Sources/sourcekit-lsp/SourceKitLSP.swift

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ import var TSCBasic.localFileSystem
2626

2727
extension AbsolutePath: ExpressibleByArgument {
2828
public init?(argument: String) {
29+
let path: AbsolutePath?
30+
2931
if let cwd = localFileSystem.currentWorkingDirectory {
30-
self.init(argument, relativeTo: cwd)
32+
path = try? AbsolutePath(validating: argument, relativeTo: cwd)
3133
} else {
32-
guard let path = try? AbsolutePath(validating: argument) else {
33-
return nil
34-
}
35-
self = path
34+
path = try? AbsolutePath(validating: argument)
35+
}
36+
37+
guard let path = path else {
38+
return nil
3639
}
40+
41+
self = path
3742
}
3843

3944
public static var defaultCompletionKind: CompletionKind {
@@ -192,7 +197,7 @@ struct SourceKitLSP: ParsableCommand {
192197
syncRequests: syncRequests
193198
)
194199

195-
let installPath = AbsolutePath(Bundle.main.bundlePath)
200+
let installPath = try AbsolutePath(validating: Bundle.main.bundlePath)
196201
ToolchainRegistry.shared = ToolchainRegistry(installPath: installPath, localFileSystem)
197202

198203
let server = SourceKitServer(client: clientConnection, options: mapOptions(), onExit: {

0 commit comments

Comments
 (0)