Commit Graph

13 Commits

Author SHA1 Message Date
Alex Hoppen
3bb4690db4 Terminate pending background indexing and preparation tasks when shutting down SourceKit-LSP
When SourceKit-LSP is shut down, we should make sure that we don’t leave behind child processes, which will become orphans after SourceKit-LSP has terminated. What’s worse, when SourceKit-LSP has exited, these processes might not have any process to read their stdout/stderr, which can lead to them running indefinitely.

This change does not cover the termination of subprocess trees. For example, if we launch `swift build` and need to kill it because it doesn’t honor SIGINT, its child processes will still live on. Similarly, if we kill a BSP server, its child processes might live on. Fixing this is a drastically bigger endeavor, likely requiring changes to Foundation and/or TSC. I filed https://github.com/swiftlang/sourcekit-lsp/issues/2080 for it.
2025-03-25 14:10:38 -07:00
Ben Barham
0c896696c9 Allow workspace options to affect build system search
There were a few places that options only took place *after* determining
a build system, even though we have multiple that impact the search (eg.
`defaultBuildSystem` and `searchPaths`).

Additionally track project root and configuration paths separately, so
that when searching for implicit workspaces we can make sure to skip
creating duplicates.
2025-01-17 08:36:36 -08:00
Alex Hoppen
8ea381d7be 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.
2024-12-05 16:59:07 -08:00
Alex Hoppen
be546308ca Use URL in many cases where we used AbsolutePath
We made quite a few fixes recently to make sure that path handling works correctly using `URL` on Windows. Use `URL` in most places to have a single type that represents file paths instead of sometimes using `AbsolutePath`.

While doing so, also remove usages of `TSCBasic.FileSystem` an `InMemoryFileSystem`. The pattern of using `InMemoryFileSystem` for tests was never consistently used and it was a little confusing that some types took a `FileSystem` parameter while other always assumed to work on the local file system.
2024-11-18 18:19:48 -08:00
Alex Hoppen
8c2def8ef9 Rename SKSupport to LanguageServerProtocolExtensions 2024-11-13 16:53:58 -08:00
Alex Hoppen
47f3cd506b Split TSCExtensions into a separate module 2024-11-13 13:58:36 -08:00
Alex Hoppen
1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08:00
Alex Hoppen
951e923245 Use withUnsafeFileSystemRepresentation to get the path of a URL on disk
`URL.path` returns forward slashes in the path on Windows (https://github.com/swiftlang/swift-foundation/issues/973) where we expect backslashes. Work around that by defining our own `filePath` property that is backed by `withUnsafeFileSystemRepresentation`, which produces backslashes.

rdar://137963660
2024-10-21 11:12:30 -07:00
Rajveer
7b1f59e4a3 Update BSP connection build server config lookup path
Resolves #1695

Adopt `<workspace_root>/.bsp` search locations in addition to
`<workspace_root>/`.
2024-10-14 13:22:22 -07:00
Alex Hoppen
d25b65c307 Explicitly shut down the build server when SourceKit-LSP is shut down
The build server is automatically shut down using a background task when `BuildSystemManager` is deallocated.

This, however, leads to possible race conditions where the shutdown task might not finish before the test is done, which could result in the connection being reported as a leak. To avoid this problem, we want to explicitly shut, down the build server when the `SourceKitLSPServer` gets shut down.
2024-09-30 11:57:39 -07:00
Alex Hoppen
bdf9615324 Specify explicit self in ExternalBuildSystemAdapter
I’m not entirely sure why but the file fails to compile with multiple arches without the `self`.
2024-09-26 13:29:59 -07:00
Alex Hoppen
2b3d733af6 Restart a BSP server after it has crashed
If a BSP server crashes, we should try to relaunch it. Use a similar relaunch logic as the one we use for `clangd`: Try restarting immediately unless the BSP server has crashed within the last 30 seconds, in which case we delay the restart by 10s.

rdar://136311009
Fixes #1686
2024-09-25 13:57:43 -07:00
Alex Hoppen
1fd700b810 Expose all BSP messages used by SourceKit-LSP to BSP servers
The interaction to an out-of-process BSP server still went through the `BuildServerBuildSystem`, which doesn’t forward all messages to the build system and uses the old push-based model for build settings.

If we discover that the BSP server supports the new pull-based build settings model, we now forward all methods to it directly, without going through `BuiltInBuildSystemAdapter`, which has been renamed to `LegacyBuildServerBuildSystem`.

rdar://136106323
rdar://127606323
rdar://126493405
Fixes #1226
Fixes #1173
2024-09-24 22:47:07 -07:00