Skip to content

Commit 8ea381d

Browse files
committed
Only load BSP servers that support one of the language we are interested in
Instead of unconditionally loading any BSP server from one of the search locations, only load those that support, C, C++, Obj-C, Obj-C++ or Swift.
1 parent f900b4e commit 8ea381d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Sources/BuildSystemIntegration/ExternalBuildSystemAdapter.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ actor ExternalBuildSystemAdapter {
223223
for case let buildServerConfigLocation? in buildServerConfigLocations {
224224
let jsonFiles =
225225
try? FileManager.default.contentsOfDirectory(at: buildServerConfigLocation, includingPropertiesForKeys: nil)
226-
.filter { $0.pathExtension == "json" }
226+
.filter {
227+
guard let config = try? BuildServerConfig.load(from: $0) else {
228+
return false
229+
}
230+
return !Set([Language.c, .cpp, .objective_c, .objective_cpp, .swift].map(\.rawValue))
231+
.intersection(config.languages).isEmpty
232+
}
227233

228234
if let configFileURL = jsonFiles?.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }).first {
229235
return configFileURL

Sources/SKTestSupport/BuildServerTestProject.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ package class BuildServerTestProject: MultiFileTestProject {
6363
var files = files
6464
files[buildServerConfigLocation] = """
6565
{
66-
"name": "client name",
67-
"version": "10",
66+
"name": "Test BSP-server",
67+
"version": "1",
6868
"bspVersion": "2.0",
69-
"languages": ["a", "b"],
69+
"languages": ["swift"],
7070
"argv": ["server.py"]
7171
}
7272
"""

0 commit comments

Comments
 (0)