Commit Graph

57 Commits

Author SHA1 Message Date
Alex Hoppen
527600e977 Support the prepare rename request
This allows us to return the current compound decl name when renaming a function, which will get populated as the default value for the text field in which the user enters the new symbol name.

rdar://118995649
2023-12-20 09:43:26 -08:00
Alex Hoppen
997ef38916 Support rename across Swift files
rdar://118995700
2023-12-12 17:34:34 -08:00
Alex Hoppen
777f1dc463 Add support for rename within the current file
rdar://117822427
2023-12-09 08:35:13 -08:00
Alex Hoppen
baa450a602 Remove Connection.sendSync
All callers should call the async version `Connection.send`.
2023-10-27 10:42:00 -07:00
Alex Hoppen
d0fc00ce98 Format using swift-format
Add `.swift-format` to the repo and format the repo with `swift-format`.

This commit does not add any automation to enforce formatting of sourcekit-lsp in CI. The goal of this commit is to get the majority of source changes out of the way so that the diff of actually enforcing formatting will have fewer changes or conflicts.
2023-10-10 13:44:47 -07:00
Alex Hoppen
56713cb2ab Asyncify symbolInfo and definition 2023-10-05 13:31:49 -07:00
Alex Hoppen
599d47798a Asyncify declaration 2023-10-05 13:31:49 -07:00
Alex Hoppen
e3087b03fe Asyncify executeCommand 2023-10-05 13:31:49 -07:00
Alex Hoppen
411ded77a9 Asyncify documentDiagnostic 2023-10-05 13:31:49 -07:00
Alex Hoppen
9a05e5bc31 Asyncify inlayHints 2023-10-05 13:31:48 -07:00
Alex Hoppen
a2e2c563d9 Asyncify colorPresentation 2023-10-05 13:31:22 -07:00
Alex Hoppen
bfa8d321ed Asyncify documentSemanticTokens* 2023-10-05 13:31:22 -07:00
Alex Hoppen
84404215b6 Asyncify documentColor 2023-10-05 13:31:22 -07:00
Alex Hoppen
669b22f4df Asyncify documentSymbol 2023-10-05 13:31:22 -07:00
Alex Hoppen
377f7bafbd Asyncify documentSymbolHighlight 2023-10-05 13:31:22 -07:00
Alex Hoppen
fea9dfe564 Asyncify openInterface 2023-10-05 13:31:15 -07:00
Alex Hoppen
19e22c57fa Asyncify codeCompletion 2023-10-05 13:30:41 -07:00
Alex Hoppen
479d54b89f Asyncify code actions 2023-10-03 08:09:00 -07:00
Alex Hoppen
6e7b5db9a2 Make hover return the request result as a return value 2023-10-03 08:09:00 -07:00
Alex Hoppen
1b6015f8aa Make the folding range request return the request result as an async return value 2023-10-03 07:56:49 -07:00
Alex Hoppen
dffcc939f7 Change the build system to only notify delegate about changed files, not about new build settings
This defines away an entire class of data races if delegate callbacks are delivered out-of-order. If we aren’t providing the new build settings in the delegate callback, then it doesn’t matter if two `fileBuildSettingsChanged` calls change order since they don’t carry any state.
2023-10-02 09:53:25 -07:00
Alex Hoppen
ebcdbb6839 Make SwiftLanguageServer and ClangLanguageServerShim call directly into SourceKitServer instead of through a LocalConnection
`LocalConnection` with its dynamic registration of a message handler made the overall design unnecessarily complicated. If we just call `SourceKitServer` from `ClangLanguageServerShim` and `SwiftLanguageServer` directly, it’s a lot more obvious, what’s going on, IMO.
2023-10-02 09:49:12 -07:00
Alex Hoppen
07eb45bb56 Wait for documents to be re-opened before setting the clangd status to be connected again 2023-10-02 09:44:14 -07:00
Alex Hoppen
dd8231315b Migrate ClangLanguageServerShim to be an actor
Fairly straightforward since we have all the infrastructure now.
2023-10-02 09:44:06 -07:00
Alex Hoppen
f1548bd757 Call into the BuildSystemManager from SwiftLanguageServer to get build settings
Instead of storing build settings inside the language servers based on update notifications from the build system, always call into the `BuildSystemManager` to get the build settings.

Overall, I think this is a much clearer separation of concerns and will allow us to remove `SourceKitServer.documentToPendingQueue` in a follow-up commit as `SwiftLanguageServer` can always directly call into `BuildSystemManager` to get build settings and we don’t need to wait for the initial notification to receive the first build settings.

This requies `BuildServerBuildSystem` to keep track of the build settings it has received from the BSP server.

`ClangLanguageServer` still caches build settings locally. `ClangLanguageServer` will change to the same pull-based model in a follow-up commit.
2023-10-02 09:44:01 -07:00
Alex Hoppen
c4e50974d1 Make all the methods in ToolchainLanguageServer async
This is a preparation step for making `SwiftLanguageServer` and `ClangLanguageServerShim` actors.
2023-10-02 09:43:51 -07:00
Alex Hoppen
b22af35eb1 Revert asyncificaiton changes
The asyncification changes caused some non-deterministic test failures. I believe that some of these are due to race conditions that are the result of the partial transition to actors.

Instead of merging the asyncification piece by piece, I will collect the changes asyncification changes in a branch and then qualify that branch througougly (running CI multiple times) before merging it into `main`.
2023-09-30 10:09:59 -07:00
Alex Hoppen
cc5a83bc40 Wait for documents to be re-opened before setting the clangd status to be connected again 2023-09-28 22:37:57 -07:00
Alex Hoppen
33cf8ccf36 Migrate ClangLanguageServerShim to be an actor
Fairly straightforward since we have all the infrastructure now.
2023-09-28 22:37:57 -07:00
Alex Hoppen
23b2db0588 Call into the BuildSystemManager from SwiftLanguageServer to get build settings
Instead of storing build settings inside the language servers based on update notifications from the build system, always call into the `BuildSystemManager` to get the build settings.

Overall, I think this is a much clearer separation of concerns and will allow us to remove `SourceKitServer.documentToPendingQueue` in a follow-up commit as `SwiftLanguageServer` can always directly call into `BuildSystemManager` to get build settings and we don’t need to wait for the initial notification to receive the first build settings.

This requies `BuildServerBuildSystem` to keep track of the build settings it has received from the BSP server.

`ClangLanguageServer` still caches build settings locally. `ClangLanguageServer` will change to the same pull-based model in a follow-up commit.
2023-09-28 22:37:57 -07:00
Alex Hoppen
0b345738a6 Make all the methods in ToolchainLanguageServer async
This is a preparation step for making `SwiftLanguageServer` and `ClangLanguageServerShim` actors.
2023-09-28 22:37:41 -07:00
Ben Barham
762532539e Revert "Make all the methods in ToolchainLanguageServer async"
This reverts commit a8b84256b3.
2023-09-28 15:51:21 -07:00
Ben Barham
15bdcc42e1 Revert "Call into the BuildSystemManager from SwiftLanguageServer to get build settings"
This reverts commit 9dd38798bb.
2023-09-28 15:51:07 -07:00
Ben Barham
212c497eb0 Revert "Migrate ClangLanguageServerShim to be an actor"
This reverts commit d699645a5f.
2023-09-28 15:51:01 -07:00
Ben Barham
cd4e733de2 Revert "Wait for documents to be re-opened before setting the clangd status to be connected again"
This reverts commit b9fa20303d.
2023-09-28 15:50:45 -07:00
Alex Hoppen
b9fa20303d Wait for documents to be re-opened before setting the clangd status to be connected again 2023-09-27 16:51:54 -07:00
Alex Hoppen
d699645a5f Migrate ClangLanguageServerShim to be an actor
Fairly straightforward since we have all the infrastructure now.
2023-09-27 16:20:53 -07:00
Alex Hoppen
9dd38798bb Call into the BuildSystemManager from SwiftLanguageServer to get build settings
Instead of storing build settings inside the language servers based on update notifications from the build system, always call into the `BuildSystemManager` to get the build settings.

Overall, I think this is a much clearer separation of concerns and will allow us to remove `SourceKitServer.documentToPendingQueue` in a follow-up commit as `SwiftLanguageServer` can always directly call into `BuildSystemManager` to get build settings and we don’t need to wait for the initial notification to receive the first build settings.

This requies `BuildServerBuildSystem` to keep track of the build settings it has received from the BSP server.

`ClangLanguageServer` still caches build settings locally. `ClangLanguageServer` will change to the same pull-based model in a follow-up commit.
2023-09-27 16:20:53 -07:00
Alex Hoppen
a8b84256b3 Make all the methods in ToolchainLanguageServer async
This is a preparation step for making `SwiftLanguageServer` and `ClangLanguageServerShim` actors.
2023-09-27 16:20:52 -07:00
Tristan Labelle
0da6291d22 Use CapabilityRegistry in ToolchainLanguageServer implementations 2023-05-26 10:35:26 -04:00
Tristan Labelle
1077ea39a7 Add boilerplate for pull-model diagnostics 2023-05-03 11:25:28 -04:00
Bart Whiteley
d2f7f2f3c6 Generate textual Swift interfaces for module references 2022-12-12 12:45:21 -07:00
Robert Widmann
0b89da4920 Implement textDocument/declaration
A declaration request is similar to a definition request, except that it is expected to return (potentially) many results across the workspace for a given reference. For example, an inline function or macro may have many declarations in the workspace, but only one "good" or canonical definition. For now, this is only implemented by forwarding the request on to clangd since I'm unfamiliar with a SourceKit query for this.

For languages like Swift that lack such a sharp declaration/definition split, we could potentially use this request to provide navigable metadata on linked definitions. For example, the declaration for a type reference would include all extensions of that type in the workspace.
2022-10-10 11:29:07 -07:00
fwcd
818c44d990 Migrate to upstream LSP inlay hints
- Use official textDocument/inlayHint request
- Rename InlayHintCategory to InlayHintKind
- Additionally, represent it using an Int, as in the proposed LSP API.
- Add inlay hint client capabilities
- Add inlay hint server capabilities
- Add dynamic registration of inlay hint request
- Rename InlayHintsRequest -> InlayHintRequest
  This is to be consistent with the request itself being named in singular
  in LSP and the other requests (e.g. DocumentSymbolRequest).
- Forward inlay hint requests to clangd
- Add colon before inlay hints
- Add other properties to InlayHint
- Add InlayHintLabel structures
- Conform InlayHintLabel to ExpressibleByStringX protocols
- Attach TextEdit to inlay hints for committing them
- Add InlayHint.data
- Fix InlayHintTests
  We need to include text edits in the expected inlay hints.
2022-05-24 16:50:17 +02:00
Alex Hoppen
2f1930c8a3 Make each toolchain language server keep track which workspaces it can open documents for
This will allow us to start multiple `clangd` instances for each workspaces root once we start supporting multiple workspace roots.
2022-05-04 14:48:31 +02:00
Alex Hoppen
b2f4fe0e29 Refactor the way toolchain language servers are created
Mostly cleanup
2022-05-04 14:48:31 +02:00
Ben Langmuir
3927e639be Revert "Support opening multiple workspaces in a single sourcekit-lsp instance" 2022-05-03 13:47:19 -07:00
Alex Hoppen
437275e44a Make each toolchain language server keep track which workspaces it can open documents for
This will allow us to start multiple `clangd` instances for each workspaces root once we start supporting multiple workspace roots.
2022-04-29 14:33:01 +02:00
Alex Hoppen
32c1f6d88a Refactor the way toolchain language servers are created
Mostly cleanup
2022-04-29 14:33:01 +02:00
Alex Hoppen
34abbdf2b5 Only send response to ShutdownRequest when all toolchain servers have shut down
Especially in test we would sometimes end up in situations where the SourceKitServer (i.e. the main sourcekit-lsp handler) is being deallocated before clangd has finished shutting down. This can result in clangd sending us notifications while SourceKitServer is halfway deallocated and thus cause crashes due to memory corruption.

To fix the issue, wait until all toolchain servers have shut down before sending a response to the ShutdownRequest.
2022-02-24 17:34:50 +01:00