Commit Graph

81 Commits

Author SHA1 Message Date
Alex Hoppen
76da45444f Re-generate sourcekitd UIDs 2024-05-23 13:41:40 -07:00
Alex Hoppen
70e373c1fa Make all non-test modules except for SourceKitLSP build in Swift 6 mode
This would have caught a race condition in background indexing that was caused by accessing `CheckedIndex` from multiple threads despite it not being thread-safe.
2024-05-13 10:05:25 -07:00
Alex Hoppen
611f9b5db1 Don’t use @retroactive when building with a Swift 5.10 compiler
This fixes a building using a Swift 5.10 compiler.
2024-03-22 07:43:32 +01:00
Alex Hoppen
f1b34b1c9b Make SKD{Request,Response}{Dictionary,Array} Sendable 2024-03-20 11:48:50 +01:00
Alex Hoppen
e8d0a0d431 Make SourceKitD build with strict concurrency enabled 2024-03-12 14:46:34 -07:00
Alex Hoppen
bad10cd761 Make SourceKitDRegistry an actor 2024-03-12 14:38:00 -07:00
Alex Hoppen
331f16dca7 Merge pull request #1091 from ahoppen/ahoppen/markdown-documentation
Emit raw documentation comments instead of parsing XML
2024-03-01 14:05:12 -08:00
Alex Hoppen
d12b258d99 Rename SourceKitDImpl to DynamicallyLoadedSourceKitD
This makes it clearer how exactly `SourceKitDImpl` interacts with sourcekitd.
2024-02-28 09:28:59 -08:00
Alex Hoppen
a6b8cbecad Emit raw documentation comments instead of parsing XML
Fixes #1014
rdar://120685874
2024-02-26 19:55:23 -08:00
Alex Hoppen
5f69147bf9 Remove logging dependency from SourceKitD
Make logging protocol requirements on `SourceKitD` so that implementers of the protocol can decide how to log requests. This allows us to add different kinds of sourcekitd connections that behave differently in the future, for example one that dynamically links against sourcekitd instead of loading it it using `dlopen`.
2024-02-24 09:27:02 -08:00
Alex Hoppen
f5fb23ad4c Rename sourcekitd_ to sourcekitd_api_ and add nullability annotations to sourcekit_functions.h
Naming types in sourcekitd_functions.h `sourcekit_api_` instead of `sourcekitd_` indicates that these are types to be used with dynamically loaded sourcekitd libraries. It avoids confusion if sourcekitd is also linked, which adds the `sourcekitd_` symbols.

Adding nullability annotations to it is also just nice.

And some improved formatting never hurts.
2024-02-23 09:13:42 -08:00
Alex Hoppen
6f98029ff7 Rename SKDValue to SKDRequestValue
`SKDValue` is only used for requests and the name should reflect that.
2024-02-15 21:30:29 -08:00
Alex Hoppen
b5fd79fbb9 Generate sourcekitd UIDs instead of manually maintaining the list
rdar://121953119
2024-02-14 16:33:34 -08:00
Alex Hoppen
d73f44c447 Support cross-language rename between Swift and clang languages
This adds support for name translation between Swift anc clang languages to allow renaming across those language boundaries.

Rename is always initiated at the symbol’s definition, so when renaming an Objective-C symbol from Swift, the user is prompeted to enter the new Objective-C method name.

rdar://118996461
2024-01-31 10:51:03 -08:00
Alex Hoppen
f2e1707010 Make forEach and map on SKDResponseArray rethrowing 2024-01-25 18:44:43 -08:00
Alex Hoppen
1e72500f1a Merge pull request #1017 from ahoppen/ahoppen/secondary-cursor-info-results
Report secondary cursor info results
2024-01-11 09:30:10 -08:00
Alex Hoppen
7572fb96ee Report secondary cursor info results
rdar://119163908
2024-01-10 21:05:31 -08:00
Alex Hoppen
3991fae867 Define methods on SourceKitD to create arrays and dictionaries instead of using skd postfix syntax 2024-01-08 18:06:31 -08:00
Alex Hoppen
f901cc9250 Support creation of SKDRequest(Dictionary|Array) from literals
IMO this makes it a lot clearer which keys are present in the request dictionaries because we are no longer mutating them on the fly.
2023-12-22 22:29:11 -08:00
Alex Hoppen
34a36b44e6 Refactor rename to support index-based discovery of rename locations 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
8857a08940 Parse information from related identiers that is needed to perform local rename 2023-12-09 08:34:41 -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
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
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
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
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
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
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
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
ffbf025896 Open and edit documents in syntactic-only mode in sourcekitd
With this change, opening and editing a document no longer causes a non-cancellable AST build. Instead, all semantic information is retrieved via requests that can be cancelled (after we implement cancellation).
2023-10-20 09:38:35 -07:00
Alex Hoppen
080e664363 Load semantic tokens from a document using a sourcekitd request instead of the 0,0 edit
This allows us to cancel the semantic tokens request. It is also the last step to allow us to open and edit documents in syntactic-only mode.

It also means that we no longer need to send a `WorkspaceSemanticTokensRefreshRequest` to the client after sourcekitd has updated its semantic tokens since with the new design the `DocumentSemanticTokensRangeRequest` will simply return the results once it has the updated semantic token.
2023-10-19 17:46:58 -07:00
Alex Hoppen
0a18628f04 Simplify sending of sourcekitd requests
Hoist some of the logic out of `withCheckedContinuation` to make the code easier to read.
2023-10-18 21:46:55 -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
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
9e07784fb8 Remove the version of SourceKitD.send that took a completion handler 2023-10-06 18:07:19 -07:00
Alex Hoppen
97a6e1c617 Handle notifications from sourcekitd on a serial queue 2023-10-06 10:49:03 -07:00
Alex Hoppen
6e7b5db9a2 Make hover return the request result as a return value 2023-10-03 08:09:00 -07:00
Max Desiatov
66f1c0dbf2 Add support for Musl libc with canImport(Musl) checks (#772)
Since Musl is sufficiently different from Glibc (see https://wiki.musl-libc.org/functional-differences-from-glibc.html), it requires a different import, which now should be applied to files that have `import Glibc` in them.

Musl is a low footprint libc that's used in Linux distributions such as Alpine Linux, which allows producing fairly small container images. Additionally, unlike Glibc, musl allows full static linking, meaning apps can be easily distributed to an arbitrary Linux distribution that may have a version of Glibc incompatible with the one that Swift is usually built with or no Glibc installed at all.
2023-07-18 22:51:26 +01:00
Alex Hoppen
7c15ba8731 Highlight references to actors like references to classes
We weren’t semantically highlighting references to actors because we missed the `ref_actor` case from the sourcekitd `annotations` response.

Fixes #694
rdar://104573568
2023-06-27 20:57:04 +02:00
Tristan Labelle
542a29db2b Implement pull-model documentDiagnostics 2023-05-26 10:35:26 -04:00
Adam Fowler
0da1d40a28 Move module name split into OpenInterfaceRequest
Use group names when running open interface request
2023-05-21 10:26:00 +01:00
Adam Fowler
45adabb3e5 Extend OpenInterface to also seatch for a symbol 2023-05-16 19:32:29 +01:00
Saleem Abdulrasool
b55057a1a1 build: repair the build after the TSCUtility changes
SKSupport now requires a link against Foundation, update the build
system to track that dependency.

Co-authored-by: Max Desiatov <m_desiatov@apple.com>
2023-01-04 21:28:10 -08:00
Saleem Abdulrasool
4bbd74f105 SourceKit: sever dependency on TSCUtility
The dependency on `TSCUtility` was strictly for identifying the platform
of execution. This logic is relatively self-contained and effectively an
extension over an enumeration. Replicate this logic with updates for new
syntactic improvements. This allows us to partially reduce dependency on
swift-tools-support-core. The dependency on TSCBasic is more complicated
to remove due to the extensive use of `AbsolutePath`.

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
2023-01-02 12:30:28 -08:00
Bart Whiteley
d2f7f2f3c6 Generate textual Swift interfaces for module references 2022-12-12 12:45:21 -07:00
Saleem Abdulrasool
7d1bcee1b0 explicitly import TSCBasic types
Explicitly import interfaces from TSCBasic which now allows us to
identify all the swift-tools-support-core interfaces which are in
use in SourceKit-LSP.
2022-09-10 12:53:30 -07:00