Commit Graph

1166 Commits

Author SHA1 Message Date
Max Desiatov
d6ae933591 6.2: Fix semantic tokens out-of-sync in neovim after changes on disk (#2224)
Cherry-pick of #2223, merged as 45534b0b90
**Explanation**: When neovim detects a change of the document on-disk (eg. caused by git operations). It closes the document and re-opens it with the same document version but different contents. We didn’t clear the swift-syntax tree of a document when it was closed, so we re-used the old syntax tree for the re-opened document. Ensure we clear the syntax tree when the document is closed so we build a new tree when it is re-opened.
**Scope**: Limited to `closeDocument` notification.
**Risk**: Low due to limited scope, additional testing, and small size of the change.
**Testing**: Added an additional automated test case.
**Issue**: rdar://157046766
**Reviewer**: @bnbarham
2025-07-30 05:47:37 -07:00
Matthew Bastien
b4e5d8995b Merge pull request #2198 from matthewbastien/docc-swift-symbols
Always try to render some documentation for Swift files
2025-07-16 10:03:04 -04:00
Ben Barham
99cb47276d Run formatting after swift-format changes 2025-07-11 10:13:50 +01:00
Hamish Knight
263341d871 Correctly handle raw identifier test suite names
Missed this in my previous patch, make sure we also add backticks
to test suite names when they use raw identifiers.
2025-06-25 22:54:21 +01:00
Hamish Knight
4c71f22a98 NFC: Add comment for swift-testing display name logic 2025-06-25 22:54:21 +01:00
Hamish Knight
21515be31b Correctly handle raw identifiers for swift-testing
Make sure we insert backticks if needed for the test identifier, and
drop the parameter names from the display name if a raw identifier
is used.
2025-06-24 12:18:15 +01:00
Hamish Knight
1ddda8afde Merge pull request #2183 from hamishknight/2175-6.2 2025-06-19 08:19:29 +01:00
lijunliang.9819
5d20cf127b Fix the issue of indexPrefixMap being unordered, which causes the IndexStoreDB path to be unpredictable. 2025-06-18 15:46:35 +01:00
Ben Barham
7221a87198 Handle both file paths and URLs from educational notes
sourcekitd was recently switched to returning the swift.org URL for
diagnostics groups/educational notes. Handle either an absolute path
or URL.
2025-06-18 15:38:35 +01:00
Hamish Knight
976d7a4ec2 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-06 18:39:52 +01:00
Ben Barham
f22e13db38 Merge pull request #2162 from bnbarham/20250519-manual-merge
Merge main into release/6.2
2025-05-21 17:00:27 -07:00
Ben Barham
a0a8f1eca4 Revert "Merge pull request #2094 from ahoppen/contextual-sourcekitd-request"
This reverts commit 188e174cde, reversing
changes made to be5ae8cf1c. Should be a
fairly harmless change, but it's also quite large. Skipping for 6.2.
2025-05-20 15:57:42 -07: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
Alex Hoppen
188e174cde Merge pull request #2094 from ahoppen/contextual-sourcekitd-request
Log contextual requests that affect sourcekitd’s global state
2025-05-14 19:12:58 +02:00
Ben Barham
fde7d70db1 Revert "Merge pull request #2137 from ahoppen/terminate-unresponsive-clangd-sourcekitd"
This change is too risky for 6.2 at this point.
2025-05-12 16:35:59 -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
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
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
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
Alex Hoppen
f433f58448 Miscellaneous small cleanups 2025-04-23 18:54:45 +02:00
Alex Hoppen
82c5fa9789 Remove snapshotFromDisk
The function isn’t used anymore
2025-04-23 18:54:45 +02:00
Alex Hoppen
d8aeeaffe6 Only pass key and not value to LRUCache.removeAll(where:)
The value isn’t needed here and the calls become cleaner if only the key is passed.
2025-04-23 18:54:45 +02:00
Alex Hoppen
bc4d9c78e7 Remove public modifiers from MarkdownTitleFinder 2025-04-23 18:54:45 +02:00
Alex Hoppen
1355b203c0 Use on-disk contents of a source file to get the position of a symbol occurrence
The index refers to on-disk locations and since the cursor info below also operates on the on-disk contents, we should use the on-disk contents of the file to convert the symbol occurrence location to a `Position`.
2025-04-23 18:54:45 +02:00
Alex Hoppen
024efc2fa1 Remove dependency from SourceKitLSP on swift-docc-symbolkit
This way all dependencies on the `docc` libraries are wrapped inside the `DocCDocumentation` module.
2025-04-23 18:54:45 +02:00
Alex Hoppen
bbbc93ea01 Refactor cursorInfoFromDisk to share the underlying logic of invoking cursor info 2025-04-23 18:54:42 +02:00
Matthew Bastien
4fb5323bd4 add cursorInfoFromDisk() to SwiftLanguageService 2025-04-22 15:14:36 -04:00
Matthew Bastien
2ae2e709b3 add LRUCache struct to SKUtilities 2025-04-17 13:46:01 -04:00
Matthew Bastien
c24f92d73e add documentation for certain functions 2025-04-16 15:13:04 -04:00
Matthew Bastien
c37c596562 fix newline matching 2025-04-16 14:54:55 -04:00
Matthew Bastien
131c8113d5 add logging to SwiftLanguageService.doccDocumentation(_:) 2025-04-16 14:54:55 -04:00
Matthew Bastien
1c65bda727 remove some nesting levels in DocumentationLanguageService.doccDocumentation(_:) 2025-04-16 14:54:55 -04:00
Matthew Bastien
0ea0e00c55 use LinkCompletionTools to parse SwiftDocC symbol links 2025-04-16 14:44:13 -04:00
Matthew Bastien
4e06c36c70 organize imports 2025-04-16 14:44:13 -04:00
Matthew Bastien
8c15e27959 use a helper document in cursorInfo() 2025-04-16 14:44:12 -04:00
Matthew Bastien
1ca1441054 fix some review comments 2025-04-16 14:44:12 -04:00
Matthew Bastien
0adaf2581f more robust searching for DocC catalogs 2025-04-16 14:44:12 -04:00
Matthew Bastien
a8eae3c6d8 remove protocols from DocCDocumentation module 2025-04-16 14:44:12 -04:00
Matthew Bastien
c1a6e65efd add CMake build to DocCDocumentation module 2025-04-16 14:44:11 -04:00
Matthew Bastien
49b3f531eb move SwiftDocC related functionality into its own module 2025-04-16 14:44:11 -04:00
Matthew Bastien
24118ebc78 cleanup unused code 2025-04-16 14:44:11 -04:00
Matthew Bastien
39bf4852b0 handle Markdown and Tutorial files in textDocument/doccDocumentation 2025-04-16 14:44:11 -04:00
Alex Hoppen
254b42a406 Merge pull request #2098 from ahoppen/swift-format-crashing
Don’t crash SourceKit-LSP if swift-format crashes while we write the source file to stdin
2025-03-28 14:17:51 -07:00
Alex Hoppen
24f361cda2 Merge pull request #2093 from ahoppen/remove-dynamically-loaded-sourcekitd
Remove the split between `SourceKitD` and `DynamicallyLoadedSourceKitD`
2025-03-28 14:17:27 -07:00
Alex Hoppen
f3daf21802 Don’t crash SourceKit-LSP if swift-format crashes while we write the source file to stdin
When swift-format crashes before we send all data to its stdin, we get a SIGPIPE when trying to write more data to its studio on Linux. This, in turn, takes SourceKit-LSP down.

Do the same trick that we do when launching `JSONRPCConnection` of disabling SIGPIPE globally if we can’t disable it for individual pipes.

rdar://147665695
2025-03-27 21:47:33 -07:00
Alex Hoppen
374554bde7 Merge pull request #2092 from ahoppen/official-synchronization
Make `workspace/synchronize` a non-experimental request
2025-03-27 15:05:22 -07:00
Alex Hoppen
92aa94fa43 Remove the split between SourceKitD and DynamicallyLoadedSourceKitD
There is only one real class that implements the `SourceKitD` protocol, so there really isn’t any need for the protocol + class split at all. Unify them to make code simpler to reason about.
2025-03-27 11:05:24 -07:00
Alex Hoppen
e474354bca Merge pull request #2051 from ahoppen/build-graph-generation
Don't wait for build graph generation when file is changed
2025-03-26 14:40:06 -07:00
Alex Hoppen
73016af24e Make workspace/synchronize a non-experimental request
This request is generally useful, not only for tests within SourceKit-LSP but also:
- In editor tests that want to test the integration with SourceKit-LSP
- In code analysis tools that want to gather project information using SourceKit-LSP and need an up-to-date index for that.

Remove the experimental feature guard from `workspace/_synchronize`, consequently rename it to `workspace/synchronize` and only guard the `buildServerUpdates` option on the synchronize request by an experimental feature because its long-term usefulness is still not fully understood yet.
2025-03-26 10:08:20 -07:00