Skip to content

Commit e45efa7

Browse files
authored
Merge pull request #957 from ahoppen/ahoppen/always-prefix-for-orlog
Always require a prefix for `orLog` calls
2 parents 6cff70a + c37b4b8 commit e45efa7

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

Sources/LSPLogging/OrLog.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private func logError(prefix: String, error: Error, level: LogLevel) {
2323

2424
/// Like `try?`, but logs the error on failure.
2525
public func orLog<R>(
26-
_ prefix: String = "",
26+
_ prefix: String,
2727
level: LogLevel = .error,
2828
_ block: () throws -> R?
2929
) -> R? {
@@ -39,7 +39,7 @@ public func orLog<R>(
3939
///
4040
/// - SeeAlso: ``orLog(_:level:_:)-66i2z``
4141
public func orLog<R>(
42-
_ prefix: String = "",
42+
_ prefix: String,
4343
level: LogLevel = .error,
4444
_ block: () async throws -> R?
4545
) async -> R? {

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ extension SwiftPMWorkspace: SKCore.BuildSystem {
348348

349349
public func filesDidChange(_ events: [FileEvent]) async {
350350
if events.contains(where: { self.fileEventShouldTriggerPackageReload(event: $0) }) {
351-
await orLog {
351+
await orLog("Reloading package") {
352352
// TODO: It should not be necessary to reload the entire package just to get build settings for one file.
353353
try await self.reloadPackage()
354354
}

Sources/SourceKitLSP/Swift/SemanticTokens.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension SwiftLanguageServer {
5252
in range: Range<Position>? = nil
5353
) async -> [SyntaxHighlightingToken] {
5454
async let tree = syntaxTreeManager.syntaxTree(for: snapshot)
55-
async let semanticTokens = await orLog { try await semanticHighlightingTokens(for: snapshot) }
55+
async let semanticTokens = await orLog("Loading semantic tokens") { try await semanticHighlightingTokens(for: snapshot) }
5656

5757
let range =
5858
if let range = range.flatMap({ $0.byteSourceRange(in: snapshot) }) {

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,12 @@ extension SwiftLanguageServer {
528528
if let doc = cursorInfo.documentationXML {
529529
result += """
530530
531-
\(orLog { try xmlDocumentationToMarkdown(doc) } ?? doc)
531+
\(orLog("Convert XML to Markdown") { try xmlDocumentationToMarkdown(doc) } ?? doc)
532532
"""
533533
} else if let annotated: String = cursorInfo.annotatedDeclaration {
534534
result += """
535535
536-
\(orLog { try xmlDocumentationToMarkdown(annotated) } ?? annotated)
536+
\(orLog("Convert XML to Markdown") { try xmlDocumentationToMarkdown(annotated) } ?? annotated)
537537
"""
538538
}
539539

0 commit comments

Comments
 (0)