Commit Graph

27 Commits

Author SHA1 Message Date
Bri Peticca da0c9a9ad9 Fix spm API usage for appropriate trait configuration
The `WorkspaceConfiguration.default` was being used to populate
the `Workspace`; there was an extra step here needed to assure that
we are propagating the trait configuration to the workspace.

The added test assures that non-default traits that are enabled are
indeed processed as enabled.
2026-05-27 12:57:16 -04:00
Rintaro Ishizaki f9cbba2c2c Migrate test-case atomic usages to ThreadSafeBox / Atomic
Migrate remaining AtomicBool / AtomicUInt32 usages in test cases to
ThreadSafeBox / Atomic.

- Closure-captured `AtomicBool` flags become `ThreadSafeBox<Bool>` for
  now. We will revisit this when eliminating ThreadSafeBox.
- One `AtomicUInt32` counter (SourceKitDRegistryTests.swift's
  `nextToken`) to `Atomic<UInt32>`.
2026-05-22 16:40:29 -07:00
Rintaro Ishizaki 829802891d [Test] Fix deployment target mismatch in SwiftPMBuildServerTests
testToolsets: sourcekit-lsp is built against a just-built SwiftPM,
which can use macOS 10.13 as the minimum for packages with no explicit
platforms requirement. The preparation step runs the toolchain's
'swift build', which can use a higher macOS minimum deployment target.
The resulting module embeds a higher deployment target, causing a
spurious mismatch diagnostic when the other target imports it.

testBasicSwiftArgs (swiftbuild variant): swift-build can clamp the
deployment target to the SDK's MinimumDeploymentTarget, which can be
above the 10.13 the BSP reports, so the expected triple no longer
matches.

Fix by explicitly setting the deployment target to 13.0 in both test
packages via 'platforms: [.macOS(.v13)]'.
2026-05-17 15:52:31 -07:00
25harsh 90ceac197d Use ExpressibleByLiteral conformances for LSPAny 2026-05-13 16:19:42 +05:30
Bassam Khouri 1f7be4b2ef Tests: Update tests based
There was feedback in #2621 to update how the `.buildSystem_{config}`
file was be created.  While looking as this change, I converted one test
to a parameterized and also ensure the `.buildSystem_{config}` file is
created in the `createFiles()` call.

Relates to #2621
2026-04-30 10:50:21 -04:00
Bassam Khouri d3b39dafa0 Improve build system inferrence
SwiftPM PR #9985 introduce files in the scratch path whose contents
indicate which build system was used to build artifact for a given build
configuration.  if this file exist, use it's contents to infer the build
system. Otherwise, fallback to the existing behaviour.

Fixes: #2576
2026-04-26 17:21:58 -04:00
Rintaro Ishizaki 709ff92adc Merge pull request #2617 from rintaro/fix-rdar175272642
[Test] Fix testCompilerArgumentsForFileThatContainsPlusCharacterURLEcoded
2026-04-23 06:39:22 -07:00
Rintaro Ishizaki 9e6b71dc07 [Test] Fix testCompilerArgumentsForFileThatContainsPlusCharacterURLEncoded
The test was constructing the percent-encoded file URL from `filePath`,
which uses native OS path separators. On Windows this produced a
backslash-separated path inside a `file://` URL, making the URL
malformed. Fix by replacing `+` with `%2B` in `absoluteString` instead,
which is already a well-formed URL string with forward slashes on all
platforms.

rdar://175272642
2026-04-22 13:03:57 -07:00
Rintaro Ishizaki 0a432b94d2 [SwiftPM] Ignore file events in scratch directory
Binary targets backed by remote `.artifactbundleindex` URLs cause
SwiftPM to re-extract the artifact bundle into the scratch directory
on every package load. The resulting file-change events (delete +
create) for the extracted files triggered another reload, causing an
infinite loop.

Add `isInScratchDirectory` to `fileEventShouldTriggerPackageReload`
to filter out events before the build-settings check. It covers
both the configured scratch directory and the default `.build/`
directory (which receives regular `swift build` output even when
a custom scratch path is configured).

Also add tests using local zip-based binary targets to cover both
the default and custom-scratch-path scenarios. Local zips are used
in the tests to avoid a network dependency; they exercise the same
`isInScratchDirectory` code path even though the infinite loop in
practice requires a remote `.artifactbundleindex` target (where
SwiftPM's checksum mismatch causes re-extraction on every load).

https://github.com/swiftlang/sourcekit-lsp/issues/2615
2026-04-22 10:55:45 -07:00
Rintaro Ishizaki dfa7df3f6f [Test] Disable a test case while investigating
rdar://175272642
2026-04-21 15:47:27 -07:00
Alex Hoppen d5691db255 Fix build failure caused by BuildTargetPrepareRequest changing its return type
API-break caused by swiftlang/swift-tools-protocols#34.
2026-04-07 10:26:45 +10:00
Rintaro Ishizaki c0e890e689 [Tests] Fix build failures when using 6.2 toolchains 2026-03-31 13:01:24 -07:00
Alex Hoppen 3f82222c05 Merge pull request #2565 from ahoppen/skip-swiftpm-bsp-server
Skip tests for the experimental SwiftPM build server if it is not installed in the user's toolchain
2026-03-23 17:30:07 +01:00
Owen Voorhees 7e853de0ce When background indexing is disabled, attempt to infer the SwiftPM build system 2026-03-18 18:19:25 -07:00
Alex Hoppen 2924d28866 Skip tests for the experimental SwiftPM build server if it is not installed in the user's toolchain
Currently, `testBasicSwiftArgs` fails if the user’s toolchain is not recent enough to have `swift package experimental-build-server`. Skip testing the SwiftPM BSP server integration in this case, similar to what we do in other tests using `SkipUnless`.
2026-03-18 12:29:52 +01:00
Owen Voorhees 260b4df07a Allow opting in to using the new SwiftPM BSP when opening a package 2025-12-10 13:17:25 -08:00
Ben Barham 9952a11f4b Pass toolsets through to preparation for the SwiftPM build server
Also adds some logging to the synchronize request so that it's obvious
when background indexing is being skipped.

Fixes #2373
Resolves rdar://165519940
2025-12-03 10:19:49 +10:00
Owen Voorhees f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07:00
Alex Hoppen c34d9e20fe Interpret the working directories in compile_commands.json relative to the directory that contains compile_commands.json
Fixes #1908
2025-10-30 08:38:08 +01:00
Alex Hoppen a6c291b84e Do not block SourceKit-LSP functionality when a build server takes long to initialize
We previously waited for the initialization response from the build server during the creation of a `Workspace` so that we could create a `SemanticIndexManager` with the index store path etc. that was returned by the `build/initialize` response. This caused all functionality (including syntactic) of SourceKit-LSP to be blocked until the build server was initialized.

Change the computation of the `SemanticIndexManager` and related types to happen in the background so that we can provide functionality that doesn’t rely on the build server immediately.

Fixes #2304
2025-09-29 13:02:08 +01:00
Alex Hoppen 95538e7de9 Migrate appendingPathComponent to appending(component:)
`appending(component:)` is the more modern API and can take multiple path components at the same time.
2025-09-23 16:57:56 +02:00
Alex Hoppen c142b601ff Add a timeout for workspace/buildTargets and buildTarget/sources requests
This allows us to provide functionality based on fallback settings for unresponsive BSP servers.

Fixes #2252
2025-09-01 16:12:41 +02:00
Alex Hoppen 3f9dedd663 If a BSP server fails to initialize, show the error message to the user
When the BSP server fails to initialize, it can’t give us any compiler arguments and we won’t be able to provide semantic functionality. Show the message to the user so they can do something about fixing it instead having to dig into SourceKit-LSP logs.
2025-08-28 16:42:38 +02:00
Alex Hoppen d887490990 Merge pull request #2231 from ahoppen/exhaustive-swift-format
Apply exhaustive swift-format configuration from swift-syntax
2025-08-11 21:02:32 +02:00
Alex Hoppen 98cd30bb1c Apply exhaustive swift-format configuration from swift-syntax
Apply the exhaustive swift-format configuration from https://github.com/swiftlang/swift-syntax/pull/3117 to sourcekit-lsp. Also apply all automatic formattings.
2025-08-11 09:23:39 +02:00
Alex Hoppen 0b3db5e49b Fix a couple build warnings 2025-08-04 12:32:39 +02:00
Alex Hoppen 7f4f92e5bd Rename build system to build server in most cases
The term *build system* predated our wide-spread adoption of BSP for communicating between SourceKit-LSP to the build system and was never really the correct term anyway – ie. a `JSONCompilationDatabaseBuildSystem` never really sounded right. We now have a correct term for the communication layer between SourceKit-LSP: A build server. Rename most occurrences of *build system* to *build server* to reflect this. There are unfortunately a couple lingering instances of *build system* that we can’t change, most notably: `fallbackBuildSystem` in the config file, the `workspace/waitForBuildSystemUpdates` BSP extension request and the `synchronize-for-build-system-updates` experimental feature.
2025-08-02 08:45:01 +02:00