Commit Graph

277 Commits

Author SHA1 Message Date
Alex Hoppen
e0fe9d6aa1 Merge pull request #1012 from krzyzanowskim/marcin/semantictokentypes
Refactor SemanticTokenTypes, SemanticTokenModifiers
2024-01-08 18:14:28 -08:00
Marcin Krzyzanowski
1e799a8cd3 Document deprecated property 2024-01-08 23:44:11 +01:00
Marcin Krzyzanowski
c7b0a68b4f add deprecated serverSideFiltering for backward compatibility 2023-12-28 00:10:27 +01:00
Marcin Krzyzanowski
0797a361d8 Add files to CMake files 2023-12-27 20:23:44 +01:00
Marcin Krzyzanowski
2c616f7838 Refactor SemanticTokenTypes, SemanticTokenModifiers 2023-12-26 22:55:12 +01:00
Alex Hoppen
e4c2a3fe32 Merge pull request #1002 from krzyzanowskim/marcin/missing-initializers-2
More public initializers
2023-12-20 14:13:54 -08:00
Marcin Krzyzanowski
11d6e55f49 Update formatting 2023-12-16 16:18:11 +01:00
Alex Hoppen
4f5186e1d2 Merge pull request #997 from krzyzanowskim/marcin/missing-initializer-worskapce-folders 2023-12-14 17:16:23 -08:00
Marcin Krzyzanowski
a8cd9bfe05 More public initializers 2023-12-14 21:08:45 +01:00
Marcin Krzyzanowski
8eeec74904 Add public initializer 2023-12-13 21:46:45 +01:00
Alex Hoppen
5a7a91027a Merge pull request #995 from krzyzanowskim/marcin/missing-initializer
WillSaveTextDocumentNotification public initializer
2023-12-13 12:44:21 -08:00
Marcin Krzyzanowski
c614d6bd56 Public initializer 2023-12-13 15:31:13 +01:00
Alex Hoppen
d931806c69 Merge pull request #988 from z2oh/configure-workspace-type
Allow configuring workspace type via flag
2023-12-12 10:50:52 -08:00
Alex Hoppen
ce9fdf9258 Merge pull request #990 from ahoppen/ahoppen/rename
Implement local rename within the current file
2023-12-11 19:39:35 -08:00
Alex Hoppen
8acc5bd999 Factor related identifiers request into a separate file
This allows use to re-use related identifiers when implementing rename
2023-12-09 08:34:40 -08:00
Jeremy Day
c006421667 Switch to more descriptive case names 2023-12-08 15:23:03 -08:00
Jeremy Day
3278ff0612 Enable per-workspace configuration of default workspace type 2023-12-08 11:06:11 -08:00
Alex Hoppen
96905aaf16 Add a request to get all tests within a file 2023-12-06 17:40:21 -08:00
Alex Hoppen
446f9280da Add a request to list all the tests within the current workspace
Fixes #611
rdar://98710526
2023-12-06 17:40:21 -08:00
Alex Hoppen
ed410e6503 Merge pull request #977 from ahoppen/ahoppen/jump-to-override
Show overriden functions when performing jump-to-definition on a dynamic call
2023-12-05 16:18:46 -08:00
Marcin Krzyzanowski
b7cc49bcfa Decode RegistrationOptions (#980) 2023-11-30 00:46:03 -08:00
Alex Hoppen
84fdea9e05 Filter overrides in DefinitionRequest by receiver types 2023-11-29 09:03:36 -08:00
Alex Hoppen
4052465905 Show overriden functions when performing jump-to-definition on a dynamic call
Fixes #809
rdar://114864256
2023-11-29 09:02:02 -08:00
Alex Hoppen
33f4612243 Add support for different arguments per workspace
Fixes #663
rdar://101815704
2023-11-28 11:19:09 -08:00
Max Desiatov
d5831963cd Fix typo in LanguageServerProtocol/Error.swift (#970) 2023-11-27 10:08:02 +05:30
Saleem Abdulrasool
8f53d08b50 build: correct dependencies
The changes in #945 changed the dependencies but did not correct them in
the CMakeLists.txt resulting in a broken build.  Resynchronise the
dependencies across Package.swift and CMake.
2023-11-01 11:12:08 -07:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00
Alex Hoppen
e0173c8740 Merge pull request #956 from ahoppen/ahoppen/dont-log-error-for-unknown-notifications
Reduce logging level for unknown notifications or requests
2023-10-31 17:05:43 -07:00
Alex Hoppen
9a87691853 Merge pull request #945 from ahoppen/ahoppen/language-server-protocol-dependency-free
Make the `LanguageServerProtocol` module dependency-free
2023-10-31 16:02:50 -07:00
Alex Hoppen
aa70fc0e8d Make the LanguageServerProtocol module dependency-free
Shuffle a few types around so that the `LanguageServerProtocol` has no more dependencies.

Fixes #938
rdar://117565087
2023-10-31 13:22:38 -07:00
Alex Hoppen
389cb914c6 Merge pull request #918 from JCWasmx86/main
Validate ClangWorkspaceSettings before preferring it over unknown WorkspaceSettingsChanges
2023-10-31 13:18:01 -07:00
Alex Hoppen
35c52c7590 Allow creation of TaskMetadata for all known notification and request types
Previously, we would sometimes log errors for example for the `setTrace` notification sent by VS Code. To avoid those logs, add cases for all known requests and notifications to the `TaskMetadata` initializers.
2023-10-31 09:12:24 -07:00
Alex Hoppen
cc40dfb1d8 Merge pull request #937 from ahoppen/ahoppen/remove-request-type
Change the `Request` type to be a fileprivate `RequestAndReply` in `SourceKitServer`
2023-10-31 08:25:49 -07:00
JCWasmx86
6e632129aa Validate ClangWorkspaceSettings before preferring it over unknown WorkspaceSettingsChanges
Basically everything will be decoded as ClangWorkspaceSettings, even if it has nothing to
do wit hit, yielding for example:
```
clangd(LanguageServerProtocol.ClangWorkspaceSettings(compilationDatabasePath: nil, compilationDatabaseChanges: nil))
```
This breaks at least my case of using WorkspaceSettingsChange. This patch adds a - maybe bandaid - fix for that.

Furthermore I removed one Test, as it - AFAIU - broke the invariant that none of the attributes
of ClangWorkspaceSettings may be nil.
2023-10-31 07:34:02 +01:00
Alex Hoppen
3c83777dda Merge pull request #948 from ahoppen/ahoppen/cleanup
Two minor improvements
2023-10-30 13:54:43 -07:00
Alex Hoppen
324a7daddd Change the Request type to be a fileprivate RequestAndReply in SourceKitServer
Since asyncifying all the request handling, `Request` only had a few lingering uses. Remove most of them and shrink it down to a type that only contains the request’s parameters and the reply block of the corresponding type.

And while we’re doing this, also move `NotificationType.forLogging` out of the `LanguageServerProtocol` module to remove the dependency from `LanguageServerProtocol` on `LSPLogging`.

Resolves #881
Resolves #936
rdar://116705662
rdar://117562587
2023-10-30 13:45:16 -07:00
Alex Hoppen
98d4fcfb5f Add WillSaveTextDocument and DidSaveTextDocument to the known requests 2023-10-27 13:04:57 -07: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
8457f84b12 Merge pull request #930 from ahoppen/ahoppen/log-reply
Increase log level for request responses
2023-10-27 06:01:51 -07:00
Alex Hoppen
204236792e Merge pull request #931 from ahoppen/ahoppen/remove-notification-type
Remove the `Notification` type
2023-10-27 06:01:43 -07:00
Alex Hoppen
b88977201e Increase log level for request responses
The request responses are interesting to see to diagnose issues. Log them at the `log` instead of `debug` level instead.
2023-10-26 21:34:14 -07:00
Alex Hoppen
9abcd2a3a3 Remove the Notification type
`Notification` is just a wrapper around `NotificationType` and there’s no reason for it to exist anymore.

Resolves #880
rdar://116705670
2023-10-26 18:28:10 -07:00
Alex Hoppen
996df8c597 Introduce a BarrierRequest that ensures all messages are handled before it replies
We could get into a race condition in `testAddFile` where the `DidChangeWatchedFilesNotification` would get handled after we try getting completion results that rely on it.

In a real-world use case, this is OK. Completion might still be incorrect until `DidChangeWatchedFilesNotification` gets handled but it will catch up eventually  - usually earlier than later because in real-world scenarios the `DidChangeWatchedFilesNotification` and completion request are more than a few milliseconds apart.

In test, however, we need to guarantee deterministic ordering. Introduce a `BarrierRequest` that has `TaskMetadata.globalConfigurationChange` and thus ensures that all notifications and requests before it have finished before returning. We can run this fake request after sending the `DidChangeWatchedFilesNotification` to make sure that it is handled.

An alternative would be to mark `DidChangeWatchedFilesNotification` as `TaskMetadata.globalConfigurationChange`. But I would really like to avoid introducing a global ordering barrier between requests for a notification that is, for example, sent whenever a `.swift` file in the `.build` directory changes (e.g. on every package update).
2023-10-26 18:23:41 -07:00
Alex Hoppen
9c424d8740 Define sources of implementation tests inline with the test cases
Also split them up for better readability.
2023-10-26 18:23:41 -07:00
Alex Hoppen
d043dc068d Merge pull request #860 from ahoppen/ahoppen/cancellation
Implement request cancellation
2023-10-26 15:34:38 -07:00
Alex Hoppen
f7572c4035 Factor withCancellableCheckedThrowingContinuation into a separate function 2023-10-26 11:03:15 -07:00
Alex Hoppen
b41f6af59d Avoid a potential race condition in which a sourcekitd/clangd request wouldn't get cancelled 2023-10-26 11:03:15 -07:00
Alex Hoppen
71dfd489ae Remove CancellationToken
This is no longer needed because we handle cancellation on the `Task` level.
2023-10-26 11:03:15 -07:00
Alex Hoppen
3d17caded6 Implement request cancellation
When receiving a `CancellationNotification`, we cancel the task that handles the request with that ID.

This will cause `cancel_notification` to be sent to sourcekitd or a `CancellationNotification` to be sent to `clangd`, which ultimately cancels the request.

rdar://117492860
2023-10-26 11:03:15 -07:00
Alex Hoppen
9f3bc4a8b5 Sort the JSON keys when logging a request
Otherwise, we get non-deterministic ordering of keys, which makes it harder to compare requests
2023-10-26 09:37:10 -07:00