Commit Graph

72 Commits

Author SHA1 Message Date
Kavon Farvardin e45119ea18 Merge pull request #2416 from ahoppen/any-error
Allow `QueueBasedMessageHandler.handle` to return `any Error` instead of `ResponseError`
2026-04-02 08:55:26 -07:00
Owen Voorhees 8b352cce0a Merge pull request #2577 from owenv/reviewfeedback
Address review feedback from https://github.com/swiftlang/sourcekit-lsp/pull/2561
2026-03-31 09:14:25 -07:00
Owen Voorhees bab011f8ba Address review feedback from https://github.com/swiftlang/sourcekit-lsp/pull/2561 2026-03-30 19:44:13 -07:00
Alex Hoppen 9d7e7f3c30 Provide semantic functionality in copy destinations
If we have a source item `include/Test.h` that gets copied to `build/Test.h`, we currently don’t provide any semantic functionality for `build/Test.h`. Improve the build settings fallback logic to construct fallback build settings for `build/Test.h` based on `include/Test.h`.
2026-03-23 17:23:54 +01:00
Alex Hoppen 7afb68a02e Merge pull request #2564 from ahoppen/pass-sdk-swiftpm
Add SourceKit-LSP configuration option to pass `--sdk` to the SwiftPMBuildServer
2026-03-23 17:20:38 +01:00
Alex Hoppen dfde91bdde Merge pull request #2413 from ahoppen/check-if-original-exists
Only adjust location for copied files if the original file exists
2026-03-23 11:52:32 +01:00
Alex Hoppen d803a4b757 Add SourceKit-LSP configuration option to pass --sdk to the SwiftPMBuildServer 2026-03-23 11:34:28 +01:00
Owen Voorhees 12c6a983c3 Merge pull request #2561 from owenv/owenv/buildsysteminference
When background indexing is disabled, attempt to infer the SwiftPM build system
2026-03-20 09:07:36 -07:00
Owen Voorhees 7e853de0ce When background indexing is disabled, attempt to infer the SwiftPM build system 2026-03-18 18:19:25 -07:00
Alex Hoppen 8ee7f9a63b Only adjust location for copied files if the original file exists
If the original file does not exist, it is preferable to jump to a file generated by the build system instead of trying to jump to a file that the editor can’t open. This will become important when using the copied file logic to jump to files in `.build/checkouts` instead of `.build/index-build/checkouts` in a follow-up PR.
2026-03-16 08:27:12 +01:00
Owen Voorhees 8cb9276cc6 Explicitly pass --build-system native when preparing using the builtin SwiftPMBuildServer 2026-03-15 19:19:13 -07:00
Alex Hoppen f21da6b574 Merge pull request #2415 from ahoppen/main-files-provider-nil
Do not log fault if `BuildServermanager.mainFilesProvider` is `nil`
2026-01-16 07:41:59 +01:00
Alex Hoppen a008e516e5 Allow QueueBasedMessageHandler.handle to return any Error instead of ResponseError
Update for the API changed in https://github.com/swiftlang/swift-tools-protocols/pull/33.
2026-01-04 08:44:11 +01:00
Alex Hoppen 66398cc2f9 Do not log fault if BuildServermanager.mainFilesProvider is nil
It’s perfectly fine for `mainFilesProvider` to be `nil` if we don’t have an index. We shouldn’t log a fault for that.
2026-01-04 07:46:45 +01:00
Alex Hoppen 4029dd5449 Use for loops to accumulate SourceItem elements in SwiftPMBuildServer
This seems cleaner than having multiple map calls that then get concatenated.
2026-01-03 19:59:53 +01:00
Alex Hoppen 2aea93dac8 Merge pull request #2385 from loveucifer/feature/file-mapping-all-requests
Extend copied file mapping to all LSP requests returning locations
2026-01-03 19:59:29 +01:00
loveucifer 29b1f4c449 few more fixes 2025-12-19 19:52:17 +05:30
loveucifer 21adc24144 some more fixes 2025-12-17 19:57:52 +05:30
Ben Barham 538e5927c5 Merge pull request #2371 from award999/workspace-playgrounds
`workspace/playgrounds` request
2025-12-13 15:40:29 +10:00
Owen Voorhees 260b4df07a Allow opting in to using the new SwiftPM BSP when opening a package 2025-12-10 13:17:25 -08:00
loveucifer cae01c623d Apply code review fixes for copied file handling
- Remove async from workspaceEditAdjustedForCopiedFiles
- Refactor to use uriAdjustedForCopiedFiles helper
- Update dictionary update logic with +=
- Adjust LocationLink creation to use adjusted ranges
- Ensure selectionRange adjustment in prepareCallHierarchy
- Provide default WorkspaceEdit in ClangLanguageService
- Revert asyncMap to map and remove await in SourceKitLSPServer
- Chain workspace and index retrieval in incomingCalls
- Use indexToLSPCallHierarchyItem and shared helper for CallHierarchyItem
- Fix indentation and remove duplicated detail setting
- Use shared helper for TypeHierarchyItem
- Remove .sort() from expected array in tests
- Enable testFindImplementationInCopiedHeader
- Add await for actor-isolated BuildServerManager calls
2025-12-10 23:47:52 +05:30
loveucifer 70d900e799 Extend copied file mapping to all LSP requests returning locations
This addresses issue #2276 by ensuring that all LSP requests that return source file locations
map copied header files back to their original locations, not just jump-to-definition.

Previously, only the definition request applied this mapping. Now, the following requests
also adjust locations for copied files:
- textDocument/references
- textDocument/implementation
- workspace/symbol
- callHierarchy/prepare
- callHierarchy/incomingCalls
- callHierarchy/outgoingCalls
- typeHierarchy/prepare
- typeHierarchy/supertypes
- typeHierarchy/subtypes

This provides consistent navigation behavior, ensuring users are always taken to the original
source files instead of build artifacts when possible.
2025-12-09 12:52:12 +05:30
Adam Ward 158529270c Only scan tests if part of a test target 2025-12-08 15:16:36 -05:00
Adam Ward 308375a135 Move syntactic index back to Workspace 2025-12-08 15:16:36 -05:00
Adam Ward 9602433d2a Add new workspace/playgrounds request 2025-12-08 15:16:36 -05:00
Ben Barham 9c145fd9a2 Merge pull request #2375 from bnbarham/pass-toolset-through
Pass toolsets through to preparation for the SwiftPM build server
2025-12-04 07:46:36 +10:00
Ben Barham 8ac9cd640d Resolve /usr/bin/* shims on macOS
CMake was previously doing this itself before 4.0, but seems to be
inserting `/usr/bin/*` now. Resolve the `/usr/bin` trampoline ourselves
in a similar fashion to swiftly (but with xcrun).

Resolves rdar://163462990.
2025-12-03 12:37:07 +10:00
Ben Barham 9952a11f4b Pass toolsets through to preparation for the SwiftPM build server
Also adds some logging to the synchronize request so that it's obvious
when background indexing is being skipped.

Fixes #2373
Resolves rdar://165519940
2025-12-03 10:19:49 +10: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
Alex Hoppen 99f2bb3915 Merge pull request #2364 from ahoppen/no-optional-map
Don’t use `Optional.map` or `Optional.flatMap`
2025-12-02 00:01:23 +01:00
Alex Hoppen 0e061c5c10 Merge pull request #2363 from ahoppen/preparation-status-trailing-slash
Fix issue that caused the target preparation status to not be cleared when workspace root did not have trailing slash
2025-11-21 06:08:01 +01:00
Alex Hoppen f9f13a4105 Don’t use Optional.map or Optional.flatMap
Replace usages of `Optional.map` and `Optional.flatMap` by if expressions or other expressions.

I personally find `Optional.map` to be hard to read because `map` implies mapping a collection to me. Usually the alternative constructs seem clearer to me.
2025-11-20 09:47:21 +01:00
Alex Hoppen 05b290ea9d Fix issue that caused the target preparation status to not be cleared when workspace root did not have trailing slash
If a workspace was opened as `/path/to/workspace` instead of `/path/to/workspace/` (notice the trailing slash), the check for `url.deletingLastPathComponent() == self.projectRoot` failed because deleting the last path component always produces a URL with a trailing slash and URL considers two path different if they mismatch in their trailing slash usage.

Use `DocumentURI` for equality checking, which is a little more lenient with declaring equality, including with regard to trailing slashes, and whose equality definition aligns better with what we want in SourceKit-LSP.

I searched for other usages of `==` between URLs and there doesn’t seem to be any similar issues.
2025-11-20 09:21:47 +01:00
Ben Barham b3cb43fb74 Ensure the string passed to PathIsRelativeW is null terminated
`CompilationDatabaseTests` have been flakey on Windows since
https://github.com/swiftlang/sourcekit-lsp/pull/2334. This didn't really
introduce the failure though - it just added tests that now catch it.

The underlying cause is that `filename.isAbsolutePath` sometimes returns
`true` for a relative path, which then causes the CWD to be prepended
instead of the given `compileCommandsDirectory`.

`PathIsRelativeW` requires a null terminated string, so presumably we
were hitting junk after the initial path that sometimes turned it into
an absolute path. From the Windows docs:
> A pointer to a null-terminated string of maximum length MAX_PATH that
contains the path to search.

Fixes #2360
Resolves rdar://165006835
2025-11-20 13:43:49 +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 76847dbf27 Do not try to infer build settings from a sibling file if determining the target timed out 2025-10-16 07:44:54 +02:00
Alex Hoppen c360cfa8c1 Make buildSettings(for:in:langauge:fallbackAfterTimeout:) require a target
This simplifies the control flow to get build settings slightly.
2025-10-11 12:20:13 +02:00
Alex Hoppen f7dba31ac9 Infer build settings from a sibling file if current file doesn’t have build settings 2025-10-11 12:20:12 +02:00
Alex Hoppen 331f15659c Merge pull request #2311 from ahoppen/long-build-server-init
Do not block SourceKit-LSP functionality when a build server takes long to initialize
2025-09-30 08:22:24 +01:00
Alex Hoppen a6c291b84e Do not block SourceKit-LSP functionality when a build server takes long to initialize
We previously waited for the initialization response from the build server during the creation of a `Workspace` so that we could create a `SemanticIndexManager` with the index store path etc. that was returned by the `build/initialize` response. This caused all functionality (including syntactic) of SourceKit-LSP to be blocked until the build server was initialized.

Change the computation of the `SemanticIndexManager` and related types to happen in the background so that we can provide functionality that doesn’t rely on the build server immediately.

Fixes #2304
2025-09-29 13:02:08 +01:00
Ben Barham 8c4f1ad847 Log when absolute compilation DB search paths are skipped
Absolute search paths were being ignored without logging, which makes it
somewhat difficult to diagnose. Log when they're skipped.

Also remove a duplicate options merging block - both
`createWorkspaceWithInferredBuildServer` and `findImplicitWorkspace`
(the only callers of `createWorkspace`) already merge in the workspace
options.
2025-09-26 14:25:55 -07: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 32e919c0cd Merge pull request #2302 from ahoppen/multi-file-indexing-batch-size
Match the batch size for multi-file indexing to the driver's batch size
2025-09-23 16:53:57 +02:00
Alex Hoppen aa7ff70042 Merge pull request #2300 from ahoppen/drop-6.1
Drop support for building with Swift 6.1
2025-09-22 14:16:39 +02:00
Alex Hoppen 05c04decf2 Match the batch size for multi-file indexing to the driver's batch size
Until we have better measurements that would motivate a different batching strategy, copying the driver’s batch size seems like the most reasonable thing to do.
2025-09-22 09:52:44 +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 c7ca73aecb Drop support for building with Swift 6.1
Swift 6.2 has been released, so we no longer need to support building and testing SourceKit-LSP using Swift 6.1
2025-09-20 16:37:24 +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