mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-06 18:24:36 +01:00
Set the build system to nil if no compilation database can be loaded
When we couldn’t start a build server or find a SwiftPM package, we currently always create a `CompilationDatabaseBuildSystem`, even if no `compile_commands.json` or `compile_flags.txt` exits. Every request for build settings would then log an error that the compilation database can’t be opened, which was very spammy. Instead, if the compilation database can’t be loaded, just set the build system to `nil` and log a single error message.
This commit is contained in:
@@ -73,12 +73,16 @@ public actor CompilationDatabaseBuildSystem {
|
||||
return nil
|
||||
}
|
||||
|
||||
public init(projectRoot: AbsolutePath? = nil, searchPaths: [RelativePath], fileSystem: FileSystem = localFileSystem) {
|
||||
public init?(projectRoot: AbsolutePath? = nil, searchPaths: [RelativePath], fileSystem: FileSystem = localFileSystem) {
|
||||
self.fileSystem = fileSystem
|
||||
self.projectRoot = projectRoot
|
||||
self.searchPaths = searchPaths
|
||||
if let path = projectRoot {
|
||||
self.compdb = tryLoadCompilationDatabase(directory: path, additionalSearchPaths: searchPaths, fileSystem)
|
||||
if let path = projectRoot,
|
||||
let compdb = tryLoadCompilationDatabase(directory: path, additionalSearchPaths: searchPaths, fileSystem)
|
||||
{
|
||||
self.compdb = compdb
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user