Commit Graph

3893 Commits

Author SHA1 Message Date
Alex Hoppen
e519d46a93 Change instructions of how to run swift-format
Running swift-format from the toolchain does not require building swift-format and also runs swift-format in release mode, which is faster.
2025-06-11 13:36:19 +02:00
Saleem Abdulrasool
1bc5e9bdc1 build: update swift-argument-parser depedency
Update the dependency to match the version in update-checkout for
standalone builds.
swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a
2025-06-10 20:26:24 -07:00
Alex Hoppen
6abdf7bb68 Merge pull request #2171 from ahoppen/autoclosure-prefix
Compute the prefix of `orLog` only when the closure threw an error
swift-DEVELOPMENT-SNAPSHOT-2025-06-09-a swift-DEVELOPMENT-SNAPSHOT-2025-06-08-a
2025-06-06 08:36:22 +02:00
Alex Hoppen
5709b9ec14 Compute the prefix of orLog only when the closure threw an error
Probably not significant in practice but I noticed that we don’t need to compute the prefix of `orLog` unless the closure threw an error. Make `prefix` an autoclosure to avoid its eager computation.
2025-06-05 16:34:22 +02:00
Hamish Knight
ddba392f1c Merge pull request #2170 from hamishknight/place-mac
Update for new `ExpandEditorPlaceholdersToLiteralClosures` API
2025-06-05 13:00:19 +01:00
Hamish Knight
e6df9e7483 Update for new ExpandEditorPlaceholdersToLiteralClosures API
This refactoring now takes a `Syntax` parameter. We don't actually
need to change anything else to handle placeholder expansion for
macro expansion completions since they get parsed as function calls.
2025-06-04 12:32:36 +01:00
Alex Hoppen
98fe45edde Merge pull request #2167 from etcwilde/ewilde/freebsd-builds
FreeBSD: Fix build for FreeBSD
swift-DEVELOPMENT-SNAPSHOT-2025-06-03-a
2025-06-02 11:24:14 +02:00
Evan Wilde
696cb04f80 FreeBSD: Fix setpriority call
The setpriority function call is imported differently on FreeBSD than on
Linux or macOS. No type conversions are needed.
2025-05-30 17:54:14 -07:00
Evan Wilde
4fcb707eb3 build-script: find sqlite header
User-installed package headers are installed to `/usr/local/include` on
FreeBSD. The build system should tell the compiler where the additional
headers are located.
2025-05-30 15:32:31 -07:00
Ben Barham
12da8e5f54 Merge pull request #2165 from rockbruno/patch-1
Expose BuildServerProtocol as a product
swift-DEVELOPMENT-SNAPSHOT-2025-06-01-a swift-DEVELOPMENT-SNAPSHOT-2025-05-31-a
2025-05-29 09:25:01 -07:00
Bruno Rocha
79d8387bf5 Expose BuildServerProtocol as a product 2025-05-25 11:06:08 +02:00
Ben Barham
c6ed68aeac Merge pull request #2154 from Wilfred/fix_package_warnings
Fix Package.swift warnings
swift-DEVELOPMENT-SNAPSHOT-2025-05-20-a swift-DEVELOPMENT-SNAPSHOT-2025-05-21-a swift-DEVELOPMENT-SNAPSHOT-2025-05-23-a swift-DEVELOPMENT-SNAPSHOT-2025-05-24-a swift-DEVELOPMENT-SNAPSHOT-2025-05-25-a swift-DEVELOPMENT-SNAPSHOT-2025-05-26-a swift-DEVELOPMENT-SNAPSHOT-2025-05-27-a swift-DEVELOPMENT-SNAPSHOT-2025-05-29-a
2025-05-19 15:39:00 -07:00
Alex Hoppen
efe483636c Merge pull request #2158 from ahoppen/no-cancel-on-subsequent-request
Pass `cancelOnSubsequentRequest: 0` to all requests that support it
2025-05-19 13:44:39 +02:00
Max Desiatov
8a908f21b6 Pass hostToolchainBinDir to SwiftSDKBundleStore (#2157)
This became a required parameter in
https://github.com/swiftlang/swift-package-manager/pull/8668, which can
be easily computed, since the host toolchain in practice is always available when `SwiftSDKBundleStore` is initialized.
2025-05-15 11:25:23 +01:00
Alex Hoppen
66b20b9a91 Merge pull request #2159 from bnbarham/update-codeowners
Add more code owners
2025-05-15 11:01:34 +02:00
Alex Hoppen
a9094391f0 Pass cancelOnSubsequentRequest: 0 to all requests that support it
Adopt the option introduced by https://github.com/swiftlang/swift/pull/81507. SourceKit-LSP uses explicit cancellation and perform any implicit cancellation inside sourcekitd.

Fixes #2021
rdar://145871554
2025-05-15 10:42:07 +02:00
Ben Barham
8e8016e024 Merge pull request #2150 from bnbarham/relative-swiftpm-paths
Resolve paths passed in the SwiftPM configuration to the project root
2025-05-14 14:29:14 -07:00
Ben Barham
f65bb76afe Add more code owners 2025-05-14 10:22:44 -07:00
Alex Hoppen
188e174cde Merge pull request #2094 from ahoppen/contextual-sourcekitd-request
Log contextual requests that affect sourcekitd’s global state
swift-DEVELOPMENT-SNAPSHOT-2025-05-14-a
2025-05-14 19:12:58 +02:00
Alex Hoppen
be5ae8cf1c Merge pull request #2153 from ahoppen/check-shutdown
Do not schedule any new tasks in `TaskScheduler` if it has been shut down
2025-05-14 19:12:41 +02:00
Alex Hoppen
a78bc5e240 Merge pull request #2152 from ahoppen/cancellation-missed
Fix race condition that causes task cancellation to be missed in `TaskScheduler`
2025-05-14 18:51:43 +02:00
Alex Hoppen
f3153ba955 Merge pull request #2140 from ahoppen/log-launch-path
Log the path that SourceKit-LSP was launched from
2025-05-13 20:21:19 +02:00
Wilfred Hughes
8797f9ca85 Fix Package.swift warnings
Previously Package.swift referred a non-existent CMakeLists.txt file
and used old URLs for the swift-tools-support-core repository, leading
to the following build warnings:

    warning: 'sourcekit-lsp': Invalid Exclude '/Users/wilfred/src/sourcekit-lsp/Sources/DocCDocumentation/CMakeLists.txt': File not found.
    warning: 'swift-package-manager': 'swift-package-manager' dependency on 'https://github.com/swiftlang/swift-tools-support-core.git' conflicts with dependency on 'https://github.com/apple/swift-tools-support-core.git' which has the same identity 'swift-tools-support-core'. this will be escalated to an error in future versions of SwiftPM.
    warning: 'swift-driver': 'swift-driver' dependency on 'https://github.com/swiftlang/swift-tools-support-core.git' conflicts with dependency on 'https://github.com/apple/swift-tools-support-core.git' which has the same identity 'swift-tools-support-core'. this will be escalated to an error in future versions of SwiftPM.
2025-05-13 16:56:59 +01:00
Alex Hoppen
ba1fb5de07 Do not schedule any new tasks in TaskScheduler if it has been shut down
This is what `shutDown()` is documented to do. I also remember having this check before, it might have gotten lost during a rebase when I was working on https://github.com/swiftlang/sourcekit-lsp/pull/2081.

I noticed this while investigating https://github.com/swiftlang/sourcekit-lsp/pull/2152: In this case `buildTarget/prepare` was cancelled because the SourceKit-LSP server was shut down but indexing of a file was still started after the shutdown now that preparation had finished (because it was cancelled).
2025-05-13 17:29:44 +02:00
Alex Hoppen
47a940d8bd Fix race condition that causes task cancellation to be missed in TaskScheduler
A queued task might have been cancelled after the execution ask was started but before the task was yielded to `executionTaskCreatedContinuation`. In that case the result task will simply cancel the await on the `executionTaskCreatedStream` and hence not call `valuePropagatingCancellation` on the execution task. This means that the queued task cancellation wouldn't be propagated to the execution task. To address this, check if `resultTaskCancelled` was  set and, if so, explicitly cancel the execution task here.

Fixes an issue I saw in CI during PR testing.
2025-05-13 17:24:45 +02:00
Alex Hoppen
6e09a215a0 Log the path that SourceKit-LSP was launched from
Generally helpful to get a hint about whether an open source toolchain is used and to help with toolchain discovery issues.
2025-05-13 15:55:55 +02:00
Ben Barham
385f8ae79f Resolve paths passed in the SwiftPM configuration to the project root
Resolves #2148.
2025-05-12 18:16:57 -07:00
Alex Hoppen
3f1568c68d Merge pull request #2144 from ahoppen/refresh-semantic-tokens
Send `workspace/semanticTokens/refresh` to client when build settings have changed
2025-05-12 19:16:42 +02:00
Alex Hoppen
d63419de73 Address review comments 2025-05-12 15:48:45 +02:00
Alex Hoppen
da90f34e10 Add contextual request support to sourcekit-lsp diagnose
Teach `sourcekit-lsp diagnose` how to extract contextual requests from the system log and use them to reduce sourcekitd crashes.
2025-05-12 15:39:52 +02:00
Alex Hoppen
69ab356b36 Log contextual requests that affect sourcekitd’s global state
This way we can log them when a sourcekitd request crashes and we can thus replay these contextual requests when diagnosing the crash.
2025-05-12 15:39:52 +02:00
Alex Hoppen
863c0e2cdf Merge pull request #2137 from ahoppen/terminate-unresponsive-clangd-sourcekitd
If sourcekitd or clangd don’t respond to a request for 5 minutes, terminate them and use crash recovery to restore behavior
2025-05-12 15:13:30 +02:00
Alex Hoppen
2c7ecffab4 Merge pull request #2143 from ahoppen/resolve-swiftly
Resolve swiftly when referenced in compile commands
2025-05-12 15:13:14 +02:00
Alex Hoppen
0951f1d6fc Merge pull request #2142 from dschaefer2/swift-asn1-take-2
Add SwiftASN1 as an explicit dependency on BuildSystemIntegration
swift-DEVELOPMENT-SNAPSHOT-2025-05-10-a swift-DEVELOPMENT-SNAPSHOT-2025-05-11-a swift-DEVELOPMENT-SNAPSHOT-2025-05-12-a
2025-05-09 15:04:16 +02:00
Alex Hoppen
1bc7d85dbd Send workspace/semanticTokens/refresh to client when build settings have changed
Similar to how we send a `workspace/diagnostic/refresh` request to the client when we get new build settings, we need to send a `workspace/semanticTokens/refresh` to the client to reload semantic tokens when builds settings change. This is particularly important so that we reload semantic tokens from real build setting after a SwiftPM package has finished loading (we previously used fallback settings).

Fixes #2141
rdar://150934682
2025-05-09 13:33:35 +02:00
Alex Hoppen
a26b0b7b3a Resolve swiftly when referenced in compile commands
When the compiler in `compile_commands.json` references a `swift` executable that’s a symlink to `swiftly`, SourceKit-LSP got confused because the `swift` executable doesn’t reside in a real toolchain, causing us to not provide any semantic functionality.

When we discover that the `swift` executable reference in compile commands references a `swiftly` executable, use `swiftly use -p` to resolve the binary in the real toolchain and continue operating based on that.

Fixes #2128
rdar://150301344
2025-05-09 09:12:21 +02:00
Doug Schaefer
3113bdbcc0 Add SwiftASN1 as an explicit dependency on BuildSystemIntegration
The SwiftPM smoke test still fails to build. I see the SwiftASN1
modules aren't getting added to the include path. Hopefully an
explicit dependency will fix that.
2025-05-08 15:08:38 -04:00
Alex Hoppen
8fe1b2ebfc Merge pull request #2139 from dschaefer2/swiftpm-swiftasn1
Add SwiftASN1 as dep in CMakeLists file
2025-05-08 14:42:05 +02:00
Alex Hoppen
276ac80585 Merge pull request #2096 from ahoppen/dlhandle-close
Ensure the `DLHandle` passed to `SourceKitD.init(dlhandle:path:pluginPaths:initialize:)` gets closed if the initializer fails
2025-05-08 13:12:02 +02:00
Alex Hoppen
14cfd50582 If sourcekitd or clangd don’t respond to a request for 5 minutes, terminate them and use crash recovery to restore behavior
This should be a last stop-gap measure in case sourcekitd or clangd get stuck, don’t respond to any requests anymore and don’t honor cancellation either. In that case we can restore SourceKit-LSP behavior by killing them and using the crash recovery logic to restore functionality.

rdar://149492159
2025-05-07 13:43:28 +02:00
Doug Schaefer
e840daba20 Add SwiftASN1 as dep in CMakeLists file
SwiftPM has added Crypto related functionality to Workspace to
support signing of the swift-syntax prebuilts manifest signing.
This breaks sourcekit-lsp builds on Windows complaining about
SwiftASN1 being missing. Adding a clause here to match the one
in SwiftPM's CMakeLists.txt file.
2025-05-06 22:56:58 -04:00
Alex Hoppen
71c205df72 Merge pull request #2124 from MahdiBM/fix-experimenta-features-flag
Fix `experimentalFeatures` command line flag and description
swift-DEVELOPMENT-SNAPSHOT-2025-05-08-a
2025-04-29 22:42:31 +02:00
Alex Hoppen
d97b005335 Merge pull request #2123 from MahdiBM/patch-2
Fix logging docs for on-Apple platforms
2025-04-29 22:40:07 +02:00
Max Desiatov
b921e940e9 NFC: Create .editorconfig (#2125)
This sets formatting preferences automatically for editors that support this config file.
2025-04-28 11:38:36 -07:00
MahdiBM
efe6c7f318 Fix experimental feature command line flag + other improvements 2025-04-28 15:38:41 +03:30
Mahdi Bahrami
227ab8feb7 Correct logging docs 2025-04-28 15:11:35 +03:30
Alex Hoppen
242609dcad Merge pull request #1959 from matthewbastien/markdown-documentation
Handle Markdown and Tutorial files in textDocument/doccDocumentation
2025-04-26 08:54:10 +02:00
Matthew Bastien
ab64878389 Merge pull request #2120 from matthewbastien/launch-config
Update launch configuration for Swift extension v2.2.0
2025-04-25 13:21:08 -05:00
Matthew Bastien
17daedd961 add LRUCache to CMakeLists 2025-04-25 09:56:27 -04:00
Alex Hoppen
ae7f80f97a Merge pull request #2121 from ahoppen/missing-dependencies
Add missing dependency declarations to Package.swift
2025-04-24 20:44:29 +02:00