Commit Graph

152 Commits

Author SHA1 Message Date
Alex Hoppen
d9055b798d Remove client-side filtering for code completion
`SKCompletionOptions.serverSideFiltering` is `true` by default and I know of no editor that disables it. Delete it.

Fixes #863
rdar://116703670
2023-10-16 09:55:22 -07:00
Alex Hoppen
f960d7ed9b Change logging to use OSLog
OSLog is the suggesting logging solution on Apple platforms and we should be using it there, taking advantage of the different log levels and privacy masking.

Switch sourcekit-lsp to use OSLog on Apple platforms and implement a logger that is API-compatible with OSLog for all uses in sourcekit-lsp and which can be used on non-Darwin platforms.

The goal of this commit is to introduce the new logging API. There are still improvements about what we log and we can display more privacy-insensitive information after masking. Those changes will be in follow-up commits.
2023-10-13 13:46:32 -07:00
Alex Hoppen
c4ff9d0592 Fix race conditions in code completion 2023-10-12 08:28:06 -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
0b8611b156 Don't hop on background queue to run onExit
Since we use Swift Concurrency now, we no longer need to be worried about queues blocking each other, so the queue hopping is no longer necessary.
2023-10-09 15:41:13 -07:00
Alex Hoppen
4495256b35 Remove the queue parameter from Connection.send
We don’t actually care about the queue that we receive the reply on anymore since we migrated everything™ to actors/async/await.
2023-10-06 18:07:20 -07:00
Alex Hoppen
203d585b77 Remove some dead completion handler code 2023-10-06 18:07:20 -07:00
Alex Hoppen
db1c48b419 Remove withLanguageServiceAndWorkspace
This function was never called
2023-10-06 18:06:55 -07:00
Alex Hoppen
556a58a05e Make DocumentSnapshot not have a reference to its originating Document
The reference just isn’t needed and this makes everything clearer.
2023-10-06 07:26:27 -07:00
Alex Hoppen
da8f46b05d Asyncify handling of TypeHierarchySubtypesRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
d6f4ccd1b2 Asyncify handling of TypeHierarchySupertypesRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
cc91ecdb42 Asyncify handling of CallHierarchyOutgoingCallsRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
fa6e9f867b Asyncify handling of CallHierarchyIncomingCallsRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
58db28d22b Asyncify handling of PollIndexRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
d2de1a2ad7 Asyncify handling of WorkspaceSymbolsRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
c4155bc893 Asyncify handling of ShutdownRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
8a2215d37b Asyncify handling of InitializeRequest 2023-10-05 13:31:49 -07:00
Alex Hoppen
ecc72a9074 Only pass the NotificationType to notification handlers, not the entire Notification
None of the fields in `Notification` are needed to handle the notification.
2023-10-05 13:31:49 -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
d6101a1c56 Merge pull request #848 from ahoppen/ahoppen/minor-cleanups
Fix a couple `FIXME: (async)`
2023-10-03 07:59:50 -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
1f02b95e55 Shift responsibility for in-order message handling from Connection to SourceKitServer
This generally seems like the cleaner design because `SourceKitServer` is actually able to semantically inspect the message and decide whether it can be handled concurrently with other requests.
2023-10-03 07:56:49 -07:00
Alex Hoppen
0c30951ed4 Inline _handleUnknown
Since `ClangLanguageServerShim` calls directly into `SourceKitServer` we also no longer need the logic to forward a message from clangd to the editor in `handle`.
2023-10-02 17:04:08 -07:00
Alex Hoppen
abf456aa5b Make reloadPackageStatusCallback async 2023-10-02 17:00:04 -07:00
Alex Hoppen
eb597fd0a7 Remove a couple of async wrapper functions
These are no longer needed as all callers are async now.
2023-10-02 17:00:04 -07:00
Alex Hoppen
c642b37a96 Remove tracking of file build settings status in SourceKitServer and BuildSystemManager
The core idea here is that the toolchain language servers always call into `BuildSystemManager` and `BuildSystemManager` will always reply with build settings. If it hasn’t computed them yet, it will reply with fallback settings.

With that assumption, we can remove the `documentToPendingQueue` from `SourceKitServer` since there are no longer any documents that are pending – everything has a build settings immediately.

Similarly, `BuildSystemManager.mainFileStatuses` also isn’t needed anymore.

And lastly, since we know that `BuildSystemManager.buildSettings` will always return a value `registerForChangeNotifications` is changed not call `fileBuildSettingsChanged` immediately. Instead, it will only cause `fileBuildSettingsChanged` to be called when the file’s build settings change after the `registerForChangeNotifications` call.
2023-10-02 09:53:25 -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
607f040c28 Remove tracking of RequestCancelKey to CancellationToken
We want to implement cancellation on top of Swift concurrency’s cancellation, which will most likely need a completely different paradigm.
2023-10-02 09:49:01 -07:00
Alex Hoppen
54e6d958d6 Make all methods on BuildSystem async
This is the prerequisite for making the build systems actors.
2023-10-02 09:47:21 -07:00
Alex Hoppen
443fc7a776 Make BuildSystemManager an actor
Again, fairly straightforward.
2023-10-02 09:47:17 -07:00
Alex Hoppen
5952ddda24 Fix typos 2023-10-02 09:44:18 -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
09dc0bc82f Make SourceKitServer an actor
Unfortuantely, we have a few potential out-of-order exeuction possibilities while we migrate everything else to also be asyncronous. But those should be low-probability issues that we can fix in follow-up commits, so I think it’s fine for now. All of these places are marked with `FIXME: (async)`
2023-10-02 09:43:42 -07:00