Commit Graph

369 Commits

Author SHA1 Message Date
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
Alex Hoppen
f293741dca Merge pull request #981 from ahoppen/ahoppen/never-error-for-diagnostics-request
Never return error for diagnostics request
2023-12-05 10:03:45 -08:00
Alex Hoppen
c7bd8c9e8f Consider all symbol replies from clangd dynamic 2023-12-04 18:49:36 -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
1ffa825b3f Remove extractIndexedOccurences
`extractIndexedOccurences` mostly dealt with how to create a fallback value and we didn’t support fallback values in 3/4 cases. Remove it, simplifying the callers of `extractIndexedOccurances` along the way.
2023-11-29 09:02:19 -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
49d4db32d3 Merge pull request #974 from ahoppen/ahoppen/build-settings-for-workspace-folder
Add support for different arguments per workspace
2023-11-28 18:57:40 -08:00
Alex Hoppen
33f4612243 Add support for different arguments per workspace
Fixes #663
rdar://101815704
2023-11-28 11:19:09 -08:00
Alex Hoppen
4c8aea29c3 Never return error for diagnostics request
VS Code does not request diagnostics again for a document if the diagnostics request failed. Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable. Instead of returning an error, return empty results.
2023-11-27 19:39:22 -08:00
Alex Hoppen
b85f3afc10 Report MARK comments in the document symbols request
Fixes #963
rdar://117811210
2023-11-27 15:55:50 -08:00
Alex Hoppen
9595498dae Don’t include local variables in document symbols
Fixes #962
rdar://117810784
2023-11-27 15:38:36 -08:00
Alex Hoppen
e6cf72317d Merge pull request #975 from ahoppen/ahoppen/normalize-identifier-start
Support cursor info-based requests when cursor is placed at the end of an identifier
2023-11-27 15:36:19 -08:00
Alex Hoppen
9aee36b0ee Merge pull request #972 from ahoppen/ahoppen/cancel-on-subsequent-request
Don't cancel cursor info and related identifiers requests on subsequent requests
2023-11-27 14:04:43 -08:00
Alex Hoppen
f5e26e4b95 Support cursor info-based requests when cursor is placed at the end of an identifier
VS Code considers the position after an identifier as part of an identifier. Ie. if you have `let foo| = 1`, then it considers the cursor to be positioned at the identifier. This scenario is hit, when selecting an identifier by double-clicking it and then eg. performing jump-to-definition. In that case VS Code will send the position after the identifier.
`sourcekitd`, on the other hand, does not consider the position after the identifier as part of the identifier.
To bridge the gap here, normalize any positions inside, or directly after, an identifier to the identifier's start.

Fixes #820
rdar://115557453
2023-11-23 20:22:05 -08:00
Alex Hoppen
2aedb85a1f Don't cancel cursor info and related identifiers requests on subsequent requests
SourceKit-LSP supports explicit cancellation and thus we don’t need to do the implicit cancellation of cursor info and related identifiers on subsequent requests.
2023-11-21 17:45:10 -08:00
Alex Hoppen
d2e79c8128 Add @retroactive annotations 2023-11-21 17:40:17 -08:00
joehsieh
a095810af8 Implement an initializer of CodeAction with the FixIt from swift-syntax
Finetune the code

Finetune the code

Finetune the code

Update the code per comments

Use location marker instead of hard coded indexes

Update the test to align the code convention

Rename a variable

Correct unit tests

Format the code

Update Package.swift
2023-11-08 18:09:38 +09:00
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
3ba15e1997 Merge pull request #955 from ahoppen/ahoppen/format
Format sources with swift-format
2023-10-31 21:48:03 -07:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00
Alex Hoppen
d4f304ebcc Uppercase first letter of diagnostics
sourcekitd returns diagnostics with the first letter lowercase. Xcode, for example, shows the messages with the first letter uppercases. I think that looks nicer and we should also uppercase the first letter in sourcekit-lsp.
2023-10-31 19:28:04 -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
9919d038ee Merge pull request #947 from ahoppen/ahoppen/skip-semantic-tokens-tests
Skip semantic tokens tests if sourcekitd doesn't support the semantic tokens request
2023-10-31 15:09:27 -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
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
1a23153fd5 When sourcekitd crashes, log the file contents with which it crashed and the request
This should make it a lot easier to reproduce sourcekitd crashes.
2023-10-31 08:30:54 -07:00
Alex Hoppen
33fa4c5487 Merge pull request #951 from ahoppen/ahoppen/signpost
Emit signposts for request handling
2023-10-31 08:27:24 -07:00
Alex Hoppen
ecc550eb53 Skip semantic tokens tests if sourcekitd doesn't support the semantic tokens request
When running sourcekit-lsp’s tests using Xcode 15, they fail because the sourcekitd in Xcode 15 does not contain the semantic tokens request. The intended workaround/fix is to dowload a recent Swift development snapshot from swift.org and set it as `SOURCEKIT_TOOLCHAIN_PATH` when running tests. But that’s not a great experience for new contributors. Instead, if sourcekitd doesn’t support the semantic tokens request, simply skip the test.

This also changes the implementation of the semantic tokens LSP request slightly: When the sourcekitd request to get semantic tokens fails, we now fail the entire LSP request, instead of returning the tokens from the synax tree. I think that’s reasonable because the editor did ask for semantic tokens, not syntactic tokens.

Fixes #940
rdar://117590581
2023-10-31 08:26:55 -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
Alex Hoppen
c37b4b8a8c Always require a prefix for orLog calls
Otherwise it’s very easy to end up with log messages like `requestCancelled` for which it’s not clear where they are coming from.
2023-10-30 16:55:50 -07:00
Alex Hoppen
9f7ff0891a Merge pull request #944 from ahoppen/ahoppen/declname
Rename `qualifiedDeclName` to `declName` in document symbols
2023-10-30 14:25:42 -07:00
Alex Hoppen
f4a07df3c5 Merge pull request #943 from ahoppen/ahoppen/latest-snapshot-throw
Make `DocumentManager.latestSnapshot` throw if no snapshot exists for the URI
2023-10-30 13:56:01 -07:00
Alex Hoppen
47e7a13ce6 Emit signposts for request handling
This allows you to trace sourcekit-lsp in Instruments to get a feeling for how long requests take to be handled.
2023-10-30 13:53:59 -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
9cd33a6511 Merge pull request #924 from ahoppen/ahoppen/capture-clangd-stderr
Capture stderr from clangd and forward it to the logger
2023-10-27 14:04:11 -07:00
Alex Hoppen
8d71b317a4 Merge pull request #946 from ahoppen/ahoppen/remove-connection-sendsync
Remove `Connection.sendSync`
2023-10-27 14:04:00 -07:00
Alex Hoppen
57fc1614b8 Merge pull request #942 from ahoppen/ahoppen/log-less-noisy
Make logs less noisy
2023-10-27 14:03:43 -07:00
Alex Hoppen
96e0e48b0d Make DocumentManager.latestSnapshot throw if no snapshot exists for the URI
This simplifies most calls that would log an error + return an empty response if no document was found.
2023-10-27 12:59:44 -07:00
Alex Hoppen
4ad1c83639 Merge pull request #934 from ahoppen/ahoppen/no-sendsync
Remove `SourceKitD.sendSync`
2023-10-27 12:50:49 -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
02606d22fa Rename qualifiedDeclName to declName in document symbols
`qualifiedDeclName` wasn’t the correct term here.
2023-10-27 10:11:38 -07:00
Alex Hoppen
8286113fef Set the build system to nil if no compilation database can be loaded
When we couldn’t start a build server or find a SwiftPM package, we currently always create a `CompilationDatabaseBuildSystem`, even if no `compile_commands.json` or `compile_flags.txt` exits. Every request for build settings would then log an error that the compilation database can’t be opened, which was very spammy. Instead, if the compilation database can’t be loaded, just set the build system to `nil` and log a single error message.
2023-10-27 09:45:34 -07:00
Alex Hoppen
81589bca4c Capture stderr from clangd and forward it to the logger
Previously, we were forwarding clangd’s stderr to sourcekit-lsp’s stderr. We should pipe it through the logger so that it ends up in OSLog on Darwin.
2023-10-27 09:14:17 -07:00
Alex Hoppen
204b1ce8ba Merge pull request #935 from ahoppen/ahoppen/throw-error-instead-of-fallback
Remove the fallback value from `SourceKitServer.handleRequest`
2023-10-27 06:02:39 -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
6d2709d46f Remove the fallback value from SourceKitServer.handleRequest
It’s not entire clear why we have a fallback value if no document service can serve a request and I checked that VS Code behaves if we return empty results for jump to definition or if we return an error. To simplify the codebase, we should just throw an error here and remove the `fallback` parameter from `handleRequest`.

Resolves #862
rdar://116703662
2023-10-26 21:42:53 -07:00
Alex Hoppen
5bdd6f253b Refactor SwiftLanguageServer to be able to call the async version of SourceKitD.send
Resolves #869
rdar://116703689
2023-10-26 21:38:25 -07:00