Skip to content

Commit 57fc161

Browse files
authored
Merge pull request #942 from ahoppen/ahoppen/log-less-noisy
Make logs less noisy
2 parents 4ad1c83 + f879950 commit 57fc161

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Sources/SKCore/CompilationDatabaseBuildSystem.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ public actor CompilationDatabaseBuildSystem {
7373
return nil
7474
}
7575

76-
public init(projectRoot: AbsolutePath? = nil, searchPaths: [RelativePath], fileSystem: FileSystem = localFileSystem) {
76+
public init?(projectRoot: AbsolutePath? = nil, searchPaths: [RelativePath], fileSystem: FileSystem = localFileSystem) {
7777
self.fileSystem = fileSystem
7878
self.projectRoot = projectRoot
7979
self.searchPaths = searchPaths
80-
if let path = projectRoot {
81-
self.compdb = tryLoadCompilationDatabase(directory: path, additionalSearchPaths: searchPaths, fileSystem)
80+
if let path = projectRoot,
81+
let compdb = tryLoadCompilationDatabase(directory: path, additionalSearchPaths: searchPaths, fileSystem)
82+
{
83+
self.compdb = compdb
84+
} else {
85+
return nil
8286
}
8387
}
8488
}

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ private func findPackageDirectory(
554554
extension Basics.Diagnostic.Severity {
555555
var asLogLevel: LogLevel {
556556
switch self {
557-
case .error, .warning: return .error
557+
case .error, .warning: return .default
558558
case .info: return .info
559559
case .debug: return .debug
560560
}

Sources/SourceKitLSP/Workspace.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,16 @@ public final class Workspace {
118118
reloadPackageStatusCallback: reloadPackageStatusCallback
119119
) {
120120
buildSystem = swiftpm
121+
} else if let compdb = CompilationDatabaseBuildSystem(
122+
projectRoot: rootPath,
123+
searchPaths: compilationDatabaseSearchPaths
124+
) {
125+
buildSystem = compdb
121126
} else {
122-
buildSystem = CompilationDatabaseBuildSystem(projectRoot: rootPath, searchPaths: compilationDatabaseSearchPaths)
127+
logger.error(
128+
"Could not set up a build system for workspace at '\(rootUri.forLogging)'"
129+
)
130+
buildSystem = nil
123131
}
124132
} else {
125133
// We assume that workspaces are directories. This is only true for URLs not for URIs in general.

Tests/SKCoreTests/CompilationDatabaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,5 @@ private func checkCompilationDatabaseBuildSystem(
453453
searchPaths: try [RelativePath(validating: ".")],
454454
fileSystem: fs
455455
)
456-
try await block(buildSystem)
456+
try await block(XCTUnwrap(buildSystem))
457457
}

0 commit comments

Comments
 (0)