Commit Graph

38 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 a6c926fa34 Relax atomic memory orderings; switch semaphore to release/acquire
For ID counters and standalone flags (most sites), drop to .relaxed
since nothing reads other memory based on the atomic's value.

MultiEntrySemaphore.signaled is the exception: it is used as a
signal/wait primitive where waiters proceed to use state set up
before signal(). Use .releasing on store and .acquiring on load so
that pre-signal writes are visible to waiters that observe `true`.
.relaxed there would be incorrect on weakly-ordered architectures.
2026-05-21 11:16:17 -07:00
Rintaro Ishizaki 83de30d29f Migrate atomic call sites to Synchronization.Atomic and ThreadSafeBox
Replace AtomicBool/UInt8/UInt32/Int32 from
ToolsProtocolsSwiftExtensions with Synchronization.Atomic<T> where
the storage is a static, module-level let, or class stored property.
For local lets captured by @Sendable closures (where Atomic's
~Copyable nature prevents capture), use ThreadSafeBox<T> instead.
2026-05-21 10:58:34 -07:00
Rintaro Ishizaki f56a27b996 Fix build warnings 2026-05-18 18:04:44 -07:00
Alex Hoppen 0cacc26db3 Merge pull request #2591 from ahoppen/require-6.3
Require Swift 6.3
2026-05-18 15:27:18 +02: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 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
Gabe Braden 61eb1d6aad Added forceResolvedVersions option 2026-04-17 16:57:51 -04:00
Alex Hoppen b4fafb64b3 Fix build warnings
Fix all build warnings except those caused by using old DocC request/response types, which are a little harder to resolve.
2026-04-12 16:11:11 +10:00
Alex Hoppen 93872a0f08 Merge pull request #2574 from ahoppen/implicittargets
Fix build failure caused by `BuildTargetPrepareRequest` changing its return type
2026-04-09 06:55:07 +10: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
Alex Hoppen afac106704 Pass pluginConfiguration to SourceKitLSPAPI.BuildDescription initializer
To stage in https://github.com/swiftlang/swift-package-manager/pull/9583.
2026-04-07 06:57:40 +10:00
Rintaro Ishizaki 309e3969a3 Fix build failure with SOURCEKIT_LSP_NO_SWIFTPM_DEPENDENCY 2026-04-06 18:34:37 +09:00
Alex Hoppen 448164aae4 Require Swift 6.3
Swift 6.3 has been released and we no longer need to support building or testing SourceKit-LSP with Swift 6.2.
2026-04-03 08:14:13 +02:00
Alex Hoppen 16176fa854 Start passing pluginConfiguration to BuildDescription initializer in SwiftPMBuildServer
To stage in https://github.com/swiftlang/swift-package-manager/pull/9583 because SwiftPM doesn’t support cross-PR testing.
2026-04-02 13:46:33 +02:00
Owen Voorhees bab011f8ba Address review feedback from https://github.com/swiftlang/sourcekit-lsp/pull/2561 2026-03-30 19:44:13 -07:00
Alex Hoppen d803a4b757 Add SourceKit-LSP configuration option to pass --sdk to the SwiftPMBuildServer 2026-03-23 11:34:28 +01:00
Owen Voorhees 12c6a983c3 Merge pull request #2561 from owenv/owenv/buildsysteminference
When background indexing is disabled, attempt to infer the SwiftPM build system
2026-03-20 09:07:36 -07:00
Owen Voorhees 7e853de0ce When background indexing is disabled, attempt to infer the SwiftPM build system 2026-03-18 18:19:25 -07:00
Owen Voorhees 8cb9276cc6 Explicitly pass --build-system native when preparing using the builtin SwiftPMBuildServer 2026-03-15 19:19:13 -07:00
Alex Hoppen 4029dd5449 Use for loops to accumulate SourceItem elements in SwiftPMBuildServer
This seems cleaner than having multiple map calls that then get concatenated.
2026-01-03 19:59:53 +01:00
Ben Barham 9c145fd9a2 Merge pull request #2375 from bnbarham/pass-toolset-through
Pass toolsets through to preparation for the SwiftPM build server
2025-12-04 07:46:36 +10: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
Anthony Latsis d1b9c27b95 Merge pull request #2366 from AnthonyLatsis/jepa
Enable some Swift 7 mode features
2025-12-02 17:37:01 +00:00
Anthony Latsis 6b19657739 Enable ExistentialAny 2025-12-02 12:27:27 +00:00
Alex Hoppen 99f2bb3915 Merge pull request #2364 from ahoppen/no-optional-map
Don’t use `Optional.map` or `Optional.flatMap`
2025-12-02 00:01:23 +01:00
Alex Hoppen f9f13a4105 Don’t use Optional.map or Optional.flatMap
Replace usages of `Optional.map` and `Optional.flatMap` by if expressions or other expressions.

I personally find `Optional.map` to be hard to read because `map` implies mapping a collection to me. Usually the alternative constructs seem clearer to me.
2025-11-20 09:47:21 +01:00
Alex Hoppen 05b290ea9d Fix issue that caused the target preparation status to not be cleared when workspace root did not have trailing slash
If a workspace was opened as `/path/to/workspace` instead of `/path/to/workspace/` (notice the trailing slash), the check for `url.deletingLastPathComponent() == self.projectRoot` failed because deleting the last path component always produces a URL with a trailing slash and URL considers two path different if they mismatch in their trailing slash usage.

Use `DocumentURI` for equality checking, which is a little more lenient with declaring equality, including with regard to trailing slashes, and whose equality definition aligns better with what we want in SourceKit-LSP.

I searched for other usages of `==` between URLs and there doesn’t seem to be any similar issues.
2025-11-20 09:21:47 +01:00
Owen Voorhees f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07: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 a005021666 Support indexing of mulitple Swift files within the same compiler invocation
Fixes #1268
2025-09-20 16:26:26 +02:00
Alex Hoppen d73433128d Make the build/logMessage conform to the BSP spec
When I added the log structure to `build/logMessage` in #2022 I must have assumed that the entire BSP notifciation was an extension defined by SourceKit-LSP and didn’t realized that this was actually a change that made the notification non-compliant with BSP. Change it up a little bit to make it compliant again.
2025-09-02 20:41:40 +02:00
Alex Hoppen c31b62eeda Merge pull request #2259 from ahoppen/only-reload-current-package
Improve package reloading logic when manifest is changed
2025-08-25 23:26:25 +02:00
Alex Hoppen ac0eb22226 Improve package reloading logic when manifest is changed
Two improvements to the logic that determines if we need to reload the package on a file change:
1. Only reload a package if the modified package manifest or Package.resolved is in the root of the package folder. This is relevant if we have a multi-root workspace, in which currently a single change to a package manifest or Package.resolved causes all packages to get reloaded.
2. While I was at it, I noticed that we didn’t properly handle version-specific package manifests. Also trigger a package reload if a version-specific package manifest is modified, created or deleted.
2025-08-25 09:23:08 +02:00
Alex Hoppen 13007e7493 Catch output-file-map.json write error thrown from TSC
We already had logic to retry loading a package manifest if writing the output-file-map failed. This only covered errors thrown from Foundation but I was seeing similar errors from TSC. Cover those as well.
2025-08-25 07:48:46 +02:00
Alex Hoppen d811fcf855 Ensure that we end the Reloading package interval if a call in reloadPackageAssumingOnPackageLoadingQueue throws
If a call in `reloadPackageAssumingOnPackageLoadingQueue` throws, we weren’t getting to the end of it and would thus never end the signpost started within. Move the `endInterval` call up ensure it is always ended.

Found this while investigating https://ci-external.swift.org/job/swift-PR-windows/44247/console, which failed SourceKit-LSP testing because PackageA could not be loaded due to

```
Initial package loading: invalid access to C:\Users\swift-ci\jenkins\workspace\swift-PR-windows\build\tmp\lsp-test\924F7085\PackageA\.build\index-build\x86_64-unknown-windows-msvc\debug\MyLibrary.build\output-file-map.json
```
2025-08-13 13:37:37 +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 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