Commit Graph

60 Commits

Author SHA1 Message Date
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
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
Alex Hoppen
fa67c22235 Merge pull request #2277 from ahoppen/bsp-timeouts
Add a timeout for `workspace/buildTargets` and `buildTarget/sources` requests
2025-09-20 13:13:40 +02:00
Alex Hoppen
78608933ba Guarantee that all files in a UpdateIndexStoreTaskDescription have the same language
It doesn’t make sense to try and index files with different langauges in a single compiler invocation.
2025-09-03 17:51:18 +02:00
Alex Hoppen
dddc983dd2 Make BuildServerManager.toolchain only take a target, no document
The document wasn’t used in here.
2025-09-03 08:39:59 +02:00
Alex Hoppen
d73433128d Make the build/logMessage conform to the BSP spec
When I added the log structure to `build/logMessage` in #2022 I must have assumed that the entire BSP notifciation was an extension defined by SourceKit-LSP and didn’t realized that this was actually a change that made the notification non-compliant with BSP. Change it up a little bit to make it compliant again.
2025-09-02 20:41:40 +02:00
Alex Hoppen
c142b601ff Add a timeout for workspace/buildTargets and buildTarget/sources requests
This allows us to provide functionality based on fallback settings for unresponsive BSP servers.

Fixes #2252
2025-09-01 16:12:41 +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
1aae2a4c32 Merge pull request #2266 from ahoppen/bsp-failed-to-initialize
If a BSP server fails to initialize, show the error message to the user
2025-08-31 08:22:56 +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
Alex Hoppen
d9046e4737 Fix issue that caused targets to be sorted top-down instead of bottom-up for background indexing
This sign flip slipped in with https://github.com/swiftlang/sourcekit-lsp/pull/1674.

There was also a non-determinism in the prepration schedule order.
2025-08-30 20:49:55 +02:00
Alex Hoppen
3f9dedd663 If a BSP server fails to initialize, show the error message to the user
When the BSP server fails to initialize, it can’t give us any compiler arguments and we won’t be able to provide semantic functionality. Show the message to the user so they can do something about fixing it instead having to dig into SourceKit-LSP logs.
2025-08-28 16:42:38 +02:00
Matthew Bastien
58096eb822 cache snapshots opened in sourcekitd by textDocument/doccDocumentation requests 2025-08-27 15:30:50 +02:00
Alex Hoppen
35556757e7 Merge pull request #2254 from ahoppen/remove-pound-if 2025-08-26 07:27:52 +02:00