499 Commits

Author SHA1 Message Date
Rintaro Ishizaki
2d699a1b86 Merge pull request #2482 from rintaro/testsupport-no-gpg-sign
[TestSupport] Don't try to GPG-sign commits
2026-02-16 10:20:23 -08:00
Rintaro Ishizaki
c802fa995b [TestSupport] Don't try to GPG-sign commits
When `commit.gpgsign = true` is enabled globally, signing fails because
the author 'Dummy <noreply@swift.org>' likey has a no configured GPG
key, causing test failures.
2026-02-14 07:10:13 -08:00
Hamish Knight
b2f42a1c48 Test to make sure sourcekitd doesn't change working directory
Ensure that the working directory remains consistent across the
lifetime of `TestSourceKitLSPClient`.
2026-02-09 10:05:13 +00:00
Alex Hoppen
596a51619d Merge pull request #2419 from ahoppen/remove-test-connection
Remove `TestJSONRPCConnection`
2026-01-16 07:42:20 +01:00
Karan Lokchandani
473088afe6 Add position markers in the expected ranges (#2449)
this should make tests more readable, follow up to this pr
https://github.com/swiftlang/sourcekit-lsp/pull/2435
reference comment here
https://github.com/swiftlang/sourcekit-lsp/pull/2435#discussion_r2670161613

---------

Signed-off-by: Karan <karanlokchandani@protonmail.com>
2026-01-13 23:06:06 +01:00
Alex Hoppen
24941a4af7 Remove TestJSONRPCConnection
This isn’t used anywhere. Noticed this while trying to fix a build warning in the file.
2026-01-04 09:51:26 +01:00
Alex Hoppen
219428328c Address my own review comments
Apply the following changes:
- Check for the presence of `#Playgrounds` textually before getting the module name in `SwiftPlaygroundsScanner`. This is important because getting the module name requires us to get build settings for the file, which can be expensive. Do the cheaper check first
- Make `syntacticTests` and `syntacticPlaygrounds` closures capture the workspace instead of passing the workspace from the `SwiftSyntacticIndex` back out. I like this better because now we can’t accidentally pass the wrong workspace to a `SwiftSyntacticIndex`, eg. to `buildTargetsChanges`.
- Capture the initialize result in `TestSourceKitLSPClient` instead of using `postInitialization` to capture the result
- Minor cleanup of unnecessary abstractions, likely artifacts of earlier iterations
- Restructure tests so that every test has its own list of source files, allowing for easier local reasoning – turns out some of these tests didn’t even need to open a workspace, just to check the initialize response
2025-12-08 15:16:36 -05:00
Adam Ward
60289cdfd6 Add tests 2025-12-08 15:16:36 -05:00
Anthony Latsis
d1b9c27b95 Merge pull request #2366 from AnthonyLatsis/jepa
Enable some Swift 7 mode features
2025-12-02 17:37:01 +00:00
Anthony Latsis
6b19657739 Enable ExistentialAny 2025-12-02 12:27:27 +00:00
Ben Barham
525af90c11 Revert "Temporarily skip macro tests on Amazon Linux" 2025-11-21 08:42:47 +10:00
Adam Ward
ddcddded67 Support swift.play in textDocument/codelens request
- New `swift.play` CodeLens support that is an experimental feature while [swift play](https://github.com/apple/swift-play-experimental/) is still experimental
- Add #Playground macro visitor to parse the macro expansions
- File must `import Playgrounds` to record the macro expansion
- The `swift-play` binary must exist in the toolchain to
- TextDocumentPlayground will record the id and optionally label to match detail you get from
```
$ swift play --list
Building for debugging...
Found 1 Playground
* Fibonacci/Fibonacci.swift:23 "Fibonacci"
```
- Add LSP extension documentation for designing pending `workspace/playground` request
- Add new parsing test cases
- Update CMake files

Issue: #2339 #2343

Add column to unnamed label

Update Sources/SwiftLanguageService/SwiftCodeLensScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Tests/SourceKitLSPTests/CodeLensTests.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Address review comments

Fix test failures

Fix more review comments

Update for swift-tools-core
2025-11-07 15:51:17 -05:00
Ben Barham
d046c7be2d Temporarily skip macro tests on Amazon Linux
These are failing on the 2023 bootstrap job, skip for now to allow
getting a toolchain out.
2025-11-06 07:15:10 +10:00
Owen Voorhees
f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07:00
Alex Hoppen
c34d9e20fe Interpret the working directories in compile_commands.json relative to the directory that contains compile_commands.json
Fixes #1908
2025-10-30 08:38:08 +01:00
Alex Hoppen
abf98b9283 Merge pull request #2314 from ahoppen/new-upcoming-features
Enable `InferIsolatedConformances` and `NonisolatedNonsendingByDefault`
2025-10-09 20:46:03 +02:00
Alex Hoppen
9dff775010 Enable InferIsolatedConformances and NonisolatedNonsendingByDefault
This allows us to easily get rid of some `@_inheritActorContext`. The others seem to be a little more tricky and I haven’t spent too much time at trying to figure out how to remove the attribute from those.
2025-10-09 00:46:48 +02:00
Doug Gregor
555816c651 Merge pull request #2312 from DougGregor/swift-if-config-dependency
Add SwiftIfConfig as a dependency for macro testing
2025-09-30 18:08:20 -07:00
Doug Gregor
8f6da7c439 Add SwiftIfConfig as a dependency for macro testing 2025-09-30 09:20:29 -07:00
Alex Hoppen
6b494ddf95 Flush logs at the end of test execution
Otherwise it sometimes happens that shutdown and other messages are logged during the next test’s execution, which makes it harder to diagnose issues.
2025-09-29 13:51:09 +02:00
Alex Hoppen
95538e7de9 Migrate appendingPathComponent to appending(component:)
`appending(component:)` is the more modern API and can take multiple path components at the same time.
2025-09-23 16:57:56 +02:00
Alex Hoppen
078a996dac Merge pull request #2293 from ahoppen/multi-file-indexing
Support indexing of mulitple Swift files within the same compiler invocation
2025-09-22 09:02:03 +02:00
Alex Hoppen
d1981debec Do not cancel update index store tasks in favor of a task with fewer files
We should not take the number of files in an `UpdateIndexStoreTaskDescription` as an indication on how important the task is. If we do need this functionality, eg. because we want to update the index of files with syntactic matches for a rename term, this should be communicated using a specific purpose similar to `TargetPreparationPurpose`. Since the only reason we update the index store for a file right now is background indexing, such a check is not needed.
2025-09-20 16:26:26 +02:00
Alex Hoppen
a005021666 Support indexing of mulitple Swift files within the same compiler invocation
Fixes #1268
2025-09-20 16:26:26 +02:00
Hamish Knight
2aa09ae0a1 Fix sourcekitdSupportsFullDocumentationInCompletion to not rely on ideApi
`ideApi` is only available within the plugin itself, it's not available
to sourcekitd. Switch to sending a completion request and checking
that we get full documentation back.
2025-09-19 17:13:18 +01:00
Alex Hoppen
346c978576 Merge pull request #2290 from ahoppen/custom-build-server-test-project
Use `CustomBuildServerTestProject` in `BuildServerTests`
2025-09-13 11:55:47 +02:00
Alex Hoppen
daf16c4909 Use CustomBuildServerTestProject in BuildServerTests
I suspect that we don’t wait for `TestSourceKitLSPClient` to finish deinitializing (and thus waiting for the shutdown response) when we destroy it in `tearDown` based on the logs in https://ci.swift.org/job/oss-swift-incremental-RA-macos-apple-silicon/9004 (rdar://160344405).

Since I generally dislike the `setUp` and `tearDown` methods and we have `CustomBuildServerTestProject` now to model a setup of a SourceKitLSP server with a custom build server, use that instead of manually hooking up the build server through a workspace.
2025-09-12 08:37:57 +02:00
Ahmed Mahmoud
8c1ea67fc0 Skip signature help tests if not supported in sourcekitd 2025-09-06 00:53:16 +03:00
Ahmed Elrefaey
1982798b5d Fetch full documentation in code completion (#2207)
When resolving documentation for code completion items, we fetch full
documentation through the newly added
`swiftide_completion_item_get_doc_full_copy` SourceKitD function, if not
found we fallback to brief documentation as before using
`swiftide_completion_item_get_doc_brief`.

> [!NOTE]
> Unlike brief documentation, SourceKitD doesn't cache full
documentation for completion results to avoid bloating memory with a lot
of large strings.
>
> As of now, SourceKit-LSP doesn't cache completion item documentation
either, should we introduce a new full documentation cache (e.g. using
`LRUCache`)?
2025-09-04 19:42:37 +01:00
Alex Hoppen
56fa14a687 Merge pull request #2274 from ahoppen/empty-target
Fix issue that caused the index progress indicator to get stuck if there are no sources in a target
2025-09-01 17:16:29 +02:00
Alex Hoppen
b88543954c Merge pull request #2271 from ahoppen/copied-files
Add support for copied header files to SourceKit-LSP
2025-09-01 12:48:58 +02:00
Alex Hoppen
e758b5711b Fix issue that caused the index progress indicator to get stuck if there are no sources in a target 2025-08-31 08:54:36 +02:00
Alex Hoppen
882c990cae Add support for copied header files to SourceKit-LSP
If a build server copies files (eg. header) to the build directory during preparation and those copied files are referenced for semantic functionality, we would currently jump to the file in the build directory. Teach SourceKit-LSP about files that are copied during preparation and if we detect that we are jumping to such a file, jump to the original file instead.

So far only the definition request checks the copied file paths. Adding support for copied file paths in the other requests will be a follow-up change.
2025-08-30 23:35:14 +02:00
Ben Barham
7bc85e7457 Pass objects to linker flags as is in macro test projects
These are absolute paths, no "-l" is necessary here and is actually an
error with eg. `ld.bfd`.
2025-08-29 20:32:09 -07:00
Alex Hoppen
65a3402ee1 Merge pull request #2253 from ahoppen/fix-warnings 2025-08-26 07:28:09 +02:00
Alex Hoppen
509ac6f9be Replace a couple of #if conditions by runtime checks
This ensures that we build all branches on all platforms, reducing the likelihood of build failures on other platforms.
2025-08-25 23:33:17 +02:00
Alex Hoppen
3762e7a2a4 Fix all warnings
Fixes all warnings when building on macOS and Linux using Swift 6.1, Swift 6.2 and SDKs from Xcode 16.2 and Xcode 16.3
2025-08-25 14:40:16 +02:00
Alex Hoppen
64fe439f24 Make DocumentationLanguageService the only module that imports DocCDocumentation 2025-08-21 10:10:54 +02:00
Alex Hoppen
c14f5dd7fd Move SwiftLanguageService into its own module 2025-08-14 11:12:31 +02:00
Alex Hoppen
d887490990 Merge pull request #2231 from ahoppen/exhaustive-swift-format
Apply exhaustive swift-format configuration from swift-syntax
2025-08-11 21:02:32 +02:00
Ben Barham
16c30a658c Merge pull request #2230 from bnbarham/disable-raw-test-pre-6.2
Only run raw identifier tests for >= 6.2
2025-08-11 09:03:33 -07:00
Alex Hoppen
98cd30bb1c Apply exhaustive swift-format configuration from swift-syntax
Apply the exhaustive swift-format configuration from https://github.com/swiftlang/swift-syntax/pull/3117 to sourcekit-lsp. Also apply all automatic formattings.
2025-08-11 09:23:39 +02:00
Ben Barham
bd5b6afb4a Only run raw identifier tests for >= 6.2
Raw identifiers were only added in 6.2, don't check for them before
then.
2025-08-08 21:45:18 -07:00
Alex Hoppen
c692a83f43 Construct LanguageServiceRegistry outside of SourceKitLSP module 2025-08-04 11:44:04 +02:00
Alex Hoppen
4f792e8781 Register language services in a dynamic registry 2025-08-04 11:44:04 +02:00
Alex Hoppen
7f4f92e5bd Rename build system to build server in most cases
The term *build system* predated our wide-spread adoption of BSP for communicating between SourceKit-LSP to the build system and was never really the correct term anyway – ie. a `JSONCompilationDatabaseBuildSystem` never really sounded right. We now have a correct term for the communication layer between SourceKit-LSP: A build server. Rename most occurrences of *build system* to *build server* to reflect this. There are unfortunately a couple lingering instances of *build system* that we can’t change, most notably: `fallbackBuildSystem` in the config file, the `workspace/waitForBuildSystemUpdates` BSP extension request and the `synchronize-for-build-system-updates` experimental feature.
2025-08-02 08:45:01 +02:00
Owen Voorhees
dd5800c712 Port SwiftPMBuildSystemTests to Swift Testing 2025-06-15 16:35:29 -07:00
Alex Hoppen
69ab356b36 Log contextual requests that affect sourcekitd’s global state
This way we can log them when a sourcekitd request crashes and we can thus replay these contextual requests when diagnosing the crash.
2025-05-12 15:39:52 +02:00
Alex Hoppen
863c0e2cdf Merge pull request #2137 from ahoppen/terminate-unresponsive-clangd-sourcekitd
If sourcekitd or clangd don’t respond to a request for 5 minutes, terminate them and use crash recovery to restore behavior
2025-05-12 15:13:30 +02:00
Alex Hoppen
a26b0b7b3a Resolve swiftly when referenced in compile commands
When the compiler in `compile_commands.json` references a `swift` executable that’s a symlink to `swiftly`, SourceKit-LSP got confused because the `swift` executable doesn’t reside in a real toolchain, causing us to not provide any semantic functionality.

When we discover that the `swift` executable reference in compile commands references a `swiftly` executable, use `swiftly use -p` to resolve the binary in the real toolchain and continue operating based on that.

Fixes #2128
rdar://150301344
2025-05-09 09:12:21 +02:00