Commit Graph

743 Commits

Author SHA1 Message Date
Pavel Yaskevich
38ce1c230e [CodeCompletion] Implement completions in using declaration's specifier position
(cherry picked from commit 816ea9fda6)
2025-06-04 13:16:55 -07:00
Alex Hoppen
b3d9155b7d Merge pull request #81605 from ahoppen/6.2/allow-disabling-implicit-cancellation
[6.2][SourceKit] Allow passing `cancel_on_subsequent_request: 0` for all requests that use a OncePerASTToken
2025-05-22 07:36:51 +02:00
Ben Barham
03ca9ea0a5 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.

(cherry picked from commit 381684a389)
2025-05-19 14:48:46 -07:00
Alex Hoppen
5bd9e439ee [SourceKit] Allow passing cancel_on_subsequent_request: 0 for all requests that use a OncePerASTToken
We need this option for `collectVariableType` (aka inlay type hints) but since I’m at it, I’m adding an option to disable the implicit request cancellation for all requests that have it since we don’t want it in LSP at all.

Prerequisite to fixing https://github.com/swiftlang/sourcekit-lsp/issues/2021 / rdar://145871554, need to adopt this option in SourceKit-LSP.
2025-05-19 13:45:50 +02:00
Allan Shortlidge
8c54a354e3 SourceKit: Fix an unused variable warning in XPCService.cpp. 2025-03-28 12:33:40 -07:00
Ben Barham
652da5555f [SourceKit] Do not hardcode the XPC service name
Write the service name into a resource file rather than have it
hardcoded, allowing it to be updated post-build if necessary.
2025-02-28 21:19:45 -08:00
Alastair Houghton
ab8e561583 Merge pull request #78516 from al45tair/eng/PR-124913332
[Backtracing] Implement API per SE-0419
2025-01-28 10:48:33 +00:00
Alex Hoppen
d5a6ff2d3a Merge pull request #78686 from ahoppen/explicit-enum-type
[SourceKit] Explicitly specify the type of enums in CodeCompletinSwiftInterop.h
2025-01-24 22:28:07 -08:00
Saleem Abdulrasool
1d2eb3bc2c SourceKit: correct the macro definitions to avoid warnings on Windows
This silences a large number of warnings due to
`-Winconsistent-dllimport`. While it is possible to support the library
to be built statically, that is not currently supported by the build
system, so simply leave that unsupported for decoration.

An option here for ELF targets would be to use
`__attribute__((__visibility__("default")))` and enable hidden
visibility by default enabling a small bit of optimization.
2025-01-22 14:00:46 -08:00
Alastair Houghton
18496c5626 [Backtracing] Remove support for implicit import of _Backtracing.
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alex Hoppen
3e3e33fc13 [SourceKit] Explicitly specify the type of enums in CodeCompletinSwiftInterop.h
To match the definition in SourceKit-LSP, which were needed because enums default to `int32_t` on Windows.
2025-01-16 11:31:28 -08:00
Alex Hoppen
c0ad0b62b6 [SourceKit] Support Windows for the SourceKit plugin 2025-01-10 19:21:20 +01:00
Alex Hoppen
21b729f195 Fix test failures of SourceKit plugin on Linux 2025-01-07 12:25:48 -08:00
Alex Hoppen
aeac681bae [SourceKit] Make the SourceKit plugin infrastructure buildable on Linux and Windows 2025-01-06 13:57:57 +01:00
Alex Hoppen
40b91aa97a Share logic to load dynamic libraries between SourceKit plugins and macro plugins 2025-01-03 16:23:16 +01:00
Alex Hoppen
6d0463ad82 [SourceKit] Apply clang-format to the SourceKit plugin sources 2025-01-03 15:24:52 +01:00
Alex Hoppen
b6c94aecc3 [SourceKit] Add mechanism to load plugins for request handling into SourceKit
This allows us to load plugins into the sourcekitd service to handle requests (currently only used for code completion). This allows us to implement parts of sourcekitd in Swift and outside of the compiler repository, making it easier to iterated on them because the compiler doesn’t need to be rebuilt.
2025-01-03 15:24:52 +01:00
swift-ci
cf77b1938f Merge remote-tracking branch 'origin/main' into rebranch 2024-09-27 16:16:39 -07:00
Rose
10107c534d Use xpc_dictionary_create_empty to create empty dictionaries
xpc_dictionary_create has Nonnull annotated for some of its parameters. We should just do xpc_dictionary_create_empty to avoid warnings and be safe.
2024-09-22 16:51:46 -04:00
swift-ci
763c61f92f Merge remote-tracking branch 'origin/main' into rebranch 2024-08-30 18:13:35 -07:00
Jim M. R. Teichgräber
f2e57d8c76 [SourceKit] Add optional declarations array to interface gen request (#75802)
Introduces the new DeclarationsArrayBuilder and adds it to the
EditorConsumer. Declaration info always includes a kind, offset, and
length, and includes a USR where applicable.
As the USR is already available for editor.open.interface type requests,
this doesn't compute any new information, it just exposes more of what's
there already.
2024-08-30 18:04:12 -07:00
swift-ci
21712d92b7 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-31 10:34:44 -07:00
Alex Hoppen
27fd76da9c [SourceKit] Run interface generation request on a deep stack
Building the generated interface for WinSDK can overflow the stack.
Treat it as a semantic request to run it on a large stack.

Fixes swiftlang/sourcekit-lsp#1115
rdar://123944504
2024-07-30 18:03:37 -07:00
swift-ci
deb4d86f60 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-11 16:35:36 -07:00
Alexander Cyon
4a2942bb4e Fix typos in: cmake, tools, utils, unittests, validation-test
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2024-07-12 02:34:00 +03:00
swift-ci
7b5298cd01 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-02 03:15:34 -07:00
Hamish Knight
e710b50255 [SourceKit] Remove cached AST by default on close
This isn't actually used for anything currently,
future requests will always have mismatching
stamps. As such, remove for now.

rdar://127353509
2024-05-01 12:24:13 +01:00
swift-ci
22d81cbbd2 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-01 04:14:10 -07:00
Hamish Knight
de9806e2fa [SourceKit] Introduce key for cancelling on close
Defaults to `true`.
2024-04-30 21:13:20 +01:00
Ben Barham
acd0efa67f Migrate to common OptTable macros
`OptTable` was a source of consistent churn due to new arguments to the
`OPTION` macro. LLVM 3f092f37b7362447cbb13f5502dae4bdd5762afd extracted
the handling of the common option parts (eg. an ID and an info) out into
separate macros to reduce this - use those here (since unsurprisingly,
more arguments were added).
2024-04-08 08:58:58 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Alex Hoppen
ed58b9ac4e Merge pull request #72170 from ahoppen/ahoppen/enable-barrier-race
[SourceKit] Set `RequestBarriersEnabled` as early as possible
2024-03-07 19:56:32 -08:00
Alex Hoppen
44bbe6a4f9 [SourceKit] Set RequestBarriersEnabled as early as possible
We were only setting `RequestBarriersEnabled` after dispatching the request to `requestQueue`. This left a brief gap where new requests could come in that wouldn’t see `RequestBarriersEnabled = true`.
2024-03-07 15:57:21 -08:00
Hamish Knight
09052c5977 [SourceKit] Fix an xpc_object leak
Make sure we release the `event` for cancellation
requests. This also ensures the `xpc_transaction`
for the request is ended.
2024-03-06 22:07:31 +00:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Alex Hoppen
32c305fb9c Merge pull request #71831 from ahoppen/ahoppen/raw-doc-comment
[SourceKit] Add the raw doc comment to the cursor info response
2024-02-24 17:55:53 -08:00
Alex Hoppen
873ed19786 [SourceKit] Add the raw doc comment to the cursor info response
SourceKit-LSP currently parses the XML comment to generate Markdown again but round-tripping a (probably markdown) doc comment to XML to Markdown is lossy in many cases and unnecessary work. Include the comment as it is spelled in source in the cursor info response so that sourcekit-lsp can display it.

Part of rdar://120685874
2024-02-24 08:41:08 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Alex Hoppen
104ee1336a Merge pull request #71824 from ahoppen/ahoppen/abort
[SourceKit] Exit the `SourceKitService` process on a SIGTERM
2024-02-23 17:04:52 -08:00
Alex Hoppen
6d23bf63a7 [SourceKit] Abort the SourceKitService proces on a SIGTERM
Sending a `SIGTERM` to sourcekitd XPC service lead to very surprising results: XPC thought that the process was about to die and sends a Connection Interrupted notification to the client. But other than that, we didn’t actually handle the signal and the service stayed alive. This caused us to send a `sema_disabled` notification to the client but since the service never got relaunched, we never sent the corresponding `sema_enabled` notification.

To fix this, just properly die on `SIGTERM` by calling `abort`.
2024-02-22 16:58:47 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Ben Barham
0755fd3259 Merge pull request #69076 from barinsim/local-symbols
[SourceKit] Add option to index local symbols to IndexSource request
2024-02-20 14:54:07 -08:00
Alex Hoppen
f0ea24dd29 [SourceKit] Fix a crash when performing related identifers request on self
Performing a related identifiers request on `self` returns an empty result because `self` is not an identifier. We thus can’t retrieve the first location to compute the old name.

rdar://121668042
2024-01-29 15:51:27 -08:00
Sam Kortekaas
1fe5f04574 [SourceKit] Use req options instead of compiler arguments for controlling index-to-store behavior 2024-01-11 17:13:03 +01:00
honghoker
2fdb8b0481 Fix typo whiteSpace between line comment 2023-12-24 00:05:57 +09:00
Alex Hoppen
a24c563d70 [SourceKit] Allow references to non-editable base names to be returned by the related identifiers request
While we don't want to return non-editable base names for Edit-All-In-Scope, we do want to return them if the related identifiers response is used as the input for find-syntactic-rename-ranges.
2023-12-07 13:12:12 -08:00
Alex Hoppen
ddf4a2e3fb [SourceKit] Return the old name from the related identifiers response 2023-12-07 13:12:11 -08:00
Alex Hoppen
143dccbdf5 [SourceKit] Return RenameLocUsage in related identifiers response
This will allow us to get syntactic rename ranges from the locations returned by related identifiers.
2023-12-07 09:04:24 -08:00
Alex Hoppen
e538a5ed61 [SourceKit] Merge RenameLoc and RenameLocation
It’s easier to understand the code if we don’t have these two nearly, but not quite, identical types.
2023-12-06 14:33:14 -08:00