Commit Graph

118 Commits

Author SHA1 Message Date
Alex Hoppen
79dde81bbf Merge pull request #2107 from kateinoigakukun/yt/remove-default-wasi-sysroot-test
Remove test for default Swift SDK selection for WASI
2025-04-09 08:34:39 -07:00
Yuta Saito
541cbcade8 Remove test for default Swift SDK selection for WASI
After https://github.com/swiftlang/swift-package-manager/pull/8468, we
no longer support wasi-sysroot embedded in the Swift toolchain, so the
test no longer makes sense.
2025-04-09 06:34:50 +00:00
Alex Hoppen
4883ee7088 Merge pull request #2088 from ahoppen/cancellation-issue
Wait for request to be sent to sourcekitd before cancelling it in `SwiftSourceKitPluginTests.testCancellation`
2025-03-26 14:39:25 -07:00
Alex Hoppen
0f5727f4f0 Introduce assertContains to check that a sequence/string contains an element/substring
This also prints the sequence and expected element on failure, which is useful for debugging.
2025-03-25 19:12:51 -07:00
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
Alex Hoppen
d5e254137c Make fulfillmentOfOrThrow take a variadic list of expectations
In almost all cases, we pass a single expectation and that looks a lot nicer with a variadic parameter.
2025-03-25 09:16:17 -07:00
Alex Hoppen
b49b40968b Fix issue that caused code completion to fail using compile_flags.txt
The compiler name shouldn’t be part of the build settings.
2025-03-13 20:19:26 -07:00
Alex Hoppen
64147963d0 Support cancellation in CustomBuildServer
I developed this for a test case that didn’t end up being useful. But supporting request cancellation here might come in useful in the future.
2025-03-10 15:25:50 -07:00
Alex Hoppen
5c60d1d39c Add a new test project type that uses a custom build server
This allows us to more easily test behavior for build servers that have different behavior than SwiftPM and compile commands without having to implement the build server in Python.
2025-03-05 23:54:32 -08:00
Alex Hoppen
28e3f99319 Allow a build system to use standardized paths while indexstore-db return realpaths
On Darwin platforms, this fixes the following problem: indexstore-db by itself returns realpaths but the build system might be using standardized Darwin paths (eg. realpath is `/private/tmp` but the standardized path is `/tmp`). Because of this, when inferring the main file for a file, we might get a URI that the build system doesn’t know about. To fix this, if the realpath that indexstore-db returns could not be found in the build system's source files but the standardized path is part of the source files, use the standardized path instead.
2025-03-03 21:16:14 -08:00
Alex Hoppen
0a54c25785 Merge pull request #1999 from ahoppen/schedule-initial-syntactic-test-population
Do not block initialization of the build server when build server is unresponsive in returning the list of test files
2025-02-28 15:36:17 -08:00
Alex Hoppen
112252632d Make response of workspace/_sourceKitOptions request non-optional
The response was not specified as being optional and shouldn’t be.
2025-02-27 19:03:50 -08:00
Alex Hoppen
bd6fb5d04c Do not block initialization of the build server when build server is unresponsive in returning the list of test files
We were blocking the initialization response on `self.buildSystemManager.testFiles`, which requires the list of test files to be determined. Make that operation asynchronous so that a slow build server can’t take down all of SourceKit-LSP.
2025-02-26 16:31:29 -08:00
Alex Hoppen
f4e015b3c0 Merge pull request #1988 from ahoppen/sourcekitoptions
Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
2025-02-26 16:06:20 -08:00
Alex Hoppen
9496b49c72 Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
This can be useful to IDEs that want to perform some additional semantic processing of source files, which requires knowledge of a file’s build settings.
2025-02-26 09:12:47 -08:00
Alex Hoppen
af62cbcfd3 Change the build server injection logic to inject a Connection instead of BuiltInBuildSystem
This gives the injected build system more flexibility by being able to respond to all BSP messages instead of only those methods defined in `BuiltInBuildSystem`.
2025-02-25 17:46:37 -08:00
Ben Barham
ab12429651 Update the compiler arguments used for background AST builds
This fixes two issues:
1. The SwiftPM build system was setup without passing through whether it
   should prepare or not. This meant that we lost eg. the argument to
   allow compiler errors when building the AST (even though it was set
   when building the modules)
2. The compiler argument adjustment to remove harmful and unnecessary
   flags only applied to indexing arguments, not those passed to the AST
   builds

Resolves rdar://141508656.
2025-02-07 11:57:30 -08:00
Alex Hoppen
825c17e50c Merge pull request #1970 from ahoppen/active-compilation-condition-no-swiftpm
Use an active compilation condition to build SourceKit-LSP without SwiftPM support
2025-02-05 22:31:16 -08:00
Alex Hoppen
6678fb0e40 Use an active compilation condition to build SourceKit-LSP without SwiftPM support
This is more explicit than using `#if canImport(PackageModel)`.
2025-02-05 17:56:20 -08:00
Alex Hoppen
b33a42f0ab When using SOURCEKIT_LSP_TEST_PLUGIN_PATHS=RELATIVE_TO_SOURCEKITD infer plugin paths from default testing toolchain
Otherwise, we infer the SourceKit plugin paths from the toolchain when creating a `SourceKitLSPServer` during testing because we don’t override the plugin paths in the SourceKitLSPOptions. But when running `SourceKitDTests`, we pass `pluginPaths: nil`, which would not load any plugins. If both of the tests run in the same process, this causes a fault to get logged because sourcekitd can only loaded once per process and we can’t modify which plugins are loaded after the fact.
2025-02-05 08:23:04 -08:00
Alex Hoppen
ed098f58cb Merge pull request #1934 from ahoppen/multi-toolchain-support
Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
2025-01-25 08:52:52 -08:00
Alex Hoppen
c67c06e7b1 Merge pull request #1950 from ahoppen/gardening
Gardening
2025-01-24 22:33:51 -08:00
Alex Hoppen
98b1294ad9 Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
rdar://142909783
2025-01-24 22:32:05 -08:00
Alex Hoppen
aee36fdf6c Remove SkipUnless checks that always evaluate to true
We don’t support testing SourceKit-LSP using toolchains that don’t contain these features anymore.
2025-01-23 21:11:08 -08:00
Alex Hoppen
15b9670888 Split build systems for JSON compilation database and fixed compilation database
I feel like the implementations are actually simpler if we split them. This will also allow us to add more advanced logic to the JSON compilation database build system in the future, such as inferring the toolchain from the compile command.
2025-01-17 14:38:37 -08: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
31b1909ce1 Allow injection of build systems into SourceKitLSP
This allows us to clean up the creation of `TestBuildSystem` a little bit because the tests can create `TestBuildSystem` instead of retrieving it from the `BuildSystemManager`.

rdar://142906050
2025-01-15 15:57:21 -08:00
Alex Hoppen
8617b8bbcc Do not realpath the project root of a SwiftPMBuildSystem
If you have a package located at `/pkg` and a symlink at `/symlink` and you open `/symlink` as a workspace, the SwiftPMBuildSystem’s project root would be `/pkg`. This would mean that it also only knew about build settings for files in `/pkg`, not in `/symlink`. Thus, whenever we were opening a file in `/symlink` we would create an implicit workspace to handle it (but which ended up having a project root at `/symlink` again) – or something close to this.

We shouldn’t need to realpath here. If you open `/symlink`, we should view `/symlink` as the project root of your workspace.
2025-01-15 09:54:20 -08:00
Alex Hoppen
5326852ea8 Support building SourceKit-LSP without a dependency on SwiftPM 2025-01-08 13:13:31 +01:00
Alex Hoppen
718c0ee809 Remove imports of SwiftPM modules that are not strictly necessary 2025-01-08 12:43:43 +01:00
Alex Hoppen
1cd010db98 Merge pull request #1888 from ahoppen/indexstore-relative-compdb
Interpret the `-index-store-path` relative to the command’s directory
2024-12-13 23:47:50 +01:00
Alex Hoppen
b07044d25d Interpret the -index-store-path relative to the command’s directory
Fixes #1856
rdar://141004197
2024-12-13 18:35:13 +01:00
Alex Hoppen
8afacd7d7e Check that we get correct package version even if package manifest is invalid
Addresses https://github.com/swiftlang/sourcekit-lsp/pull/1846/files#r1856529041

rdar://141311942
2024-12-12 16:09:23 -08:00
Alex Hoppen
a087692725 Return compiler arguments for invalid package manifests
Currently, when there‘s a syntax error in a package manifest, we don’t get any build settings from it in SourceKit-LSP and thus loose almost all semantic functionality. If we can’t parse the package manifest, fall back to providing build settings by assuming it has the current Swift tools version.

Currently, when there‘s a syntax error in a package manifest, we don’t get any build settings from it in SourceKit-LSP and thus loose almost all semantic functionality. If we can’t parse the package manifest, fall back to providing build settings by assuming it has the current Swift tools version.

Fixes #1704
rdar://136423767
2024-12-09 15:25:38 -08:00
Alex Hoppen
cddd810455 Provide build settings for version-specific package manifests
Fixes #1670
rdar://136014520
2024-11-22 22:04:20 +01:00
Alex Hoppen
76304db5e2 Fix merge conflict
https://github.com/swiftlang/sourcekit-lsp/pull/1824 and https://github.com/swiftlang/sourcekit-lsp/pull/1832 raced.
2024-11-19 15:47:52 -08:00
Alex Hoppen
8d13afa73d Merge pull request #1824 from kateinoigakukun/katei/interpret-relative-scratch-dir
Allow `scratchPath` to be a relative path
2024-11-19 11:14:40 -08:00
Yuta Saito
184fa12389 Allow scratchPath to be relative paths
Interpret it as relative to the project root directory if it's a
relative path.
2024-11-19 11:19:54 +09: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
bce09932ed Merge pull request #1714 from ahoppen/background-indexing-on 2024-11-16 21:58:12 -08:00
Alex Hoppen
84fc3fec1a Enable background indexing by default 2024-11-15 16:58:40 -08:00
Alex Hoppen
5627a4198c Enable testPluginArgs on Windows
This should be fixed by https://github.com/swiftlang/swift-package-manager/pull/8118
2024-11-15 15:10:43 -08:00
Alex Hoppen
9c84a344c8 Merge pull request #1817 from ahoppen/bsp-review 2024-11-14 08:10:02 -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
0fbb6466e7 Make BuildSystemKind a struct and rename to BuildSystemSpec 2024-11-13 10:23:43 -08:00
Alex Hoppen
5c7d495ebd Merge pull request #1808 from ahoppen/member-import-visibility
Adopt `MemberImportVisibility`
2024-11-07 15:38:05 -08:00
Alex Hoppen
06f58db5c8 Use build/taskStart, build/taskProgress and build/taskFinish to communicate progress from a BSP server to the client
Instead of defining BSP extensions for `window/workDoneProgress/create` and `$/progress`, we should be able to use the standard `build/taskStart`, `build/taskProgress` and `build/taskFinish` messages to the same effect, as suggested by https://forums.swift.org/t/extending-functionality-of-build-server-protocol-with-sourcekit-lsp/74400/9.

Fixes #1783
rdar://138653131
2024-11-06 09:39:09 -08:00
Alex Hoppen
1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08:00
Alex Hoppen
a22bf900ad Merge pull request #1781 from ahoppen/no-timer-target-change
Don’t rely on timers for BSP target / settings change tests
2024-10-29 13:02:30 -07:00