Skip to content

Commit

Permalink
fix: adding try & orLog where necesary
Browse files Browse the repository at this point in the history
  • Loading branch information
louisunlimited committed Jun 26, 2024
1 parent f080229 commit f0e8710
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/SourceKitLSP/Rename.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ extension SwiftLanguageService {
in uri: DocumentURI,
name: CompoundDeclName
) async throws -> String {
guard let snapshot = documentManager.latestSnapshotOrDisk(uri, language: .swift) else {
guard let snapshot = try? documentManager.latestSnapshotOrDisk(uri, language: .swift) else {
throw ResponseError.unknown("Failed to get contents of \(uri.forLogging) to translate Swift name to clang name")
}

Expand Down
10 changes: 6 additions & 4 deletions Sources/SourceKitLSP/Swift/SwiftLanguageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public actor SwiftLanguageService: LanguageService, Sendable {
self.diagnosticReportManager = DiagnosticReportManager(
sourcekitd: self.sourcekitd,
syntaxTreeManager: syntaxTreeManager,
documentManager: documentManager,
documentManager: try documentManager,
clientHasDiagnosticsCodeDescriptionSupport: await self.clientHasDiagnosticsCodeDescriptionSupport
)

Expand Down Expand Up @@ -437,7 +437,7 @@ extension SwiftLanguageService {
cancelInFlightPublishDiagnosticsTask(for: notification.textDocument.uri)
await diagnosticReportManager.removeItemsFromCache(with: notification.textDocument.uri)

guard let snapshot = self.documentManager.open(notification) else {
guard let snapshot = try? self.documentManager.open(notification) else {
// Already logged failure.
return
}
Expand All @@ -454,7 +454,9 @@ extension SwiftLanguageService {
inFlightPublishDiagnosticsTasks[notification.textDocument.uri] = nil
await diagnosticReportManager.removeItemsFromCache(with: notification.textDocument.uri)

self.documentManager.close(notification)
orLog("Connection to the editor closed") {
try? self.documentManager.close(notification)
}

let req = closeDocumentSourcekitdRequest(uri: notification.textDocument.uri)
_ = try? await self.sourcekitd.send(req, fileContents: nil)
Expand Down Expand Up @@ -548,7 +550,7 @@ extension SwiftLanguageService {
let replacement: String
}

guard let (preEditSnapshot, postEditSnapshot, edits) = self.documentManager.edit(notification) else {
guard let (preEditSnapshot, postEditSnapshot, edits) = try? self.documentManager.edit(notification) else {
return
}

Expand Down

0 comments on commit f0e8710

Please sign in to comment.