Commit Graph

1269 Commits

Author SHA1 Message Date
Alex Hoppen
53ac4ca1f2 Merge pull request #2396 from DPrakashh/refactor/document-manager-queue
#1597 - Migrate DocumentManager to use ThreadSafeBox
2026-01-03 20:28:10 +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
74b1ee503f additonal fixes 2025-12-22 18:57:30 +05:30
Divya Prakash
0ca0660d99 Refactor DocumentManager threading for Swift 6
Replaces DispatchQueue with ThreadSafeBox, relaxes T: Sendable constraints, and removes @unchecked Sendable from Document.
2025-12-21 19:26:02 +05:30
loveucifer
8fc9f1ccaf compiler fix 2025-12-21 17:45:50 +05:30
Divya Prakash
d9072850e0 Mark Document as @unchecked Sendable to allow storage in ThreadSafeBox 2025-12-20 09:55:20 +05:30
Divya Prakash
447393e085 Refactor DocumentManager to use ThreadSafeBox for document storage 2025-12-20 09:49:54 +05:30
loveucifer
29b1f4c449 few more fixes 2025-12-19 19:52:17 +05:30
loveucifer
f3237fad74 more and more fixes 2025-12-18 21:03:50 +05:30
loveucifer
21adc24144 some more fixes 2025-12-17 19:57:52 +05:30
loveucifer
d254ce1b5d Update Sources/SourceKitLSP/SourceKitLSPServer.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-16 08:16:07 +05:30
loveucifer
71374c1a04 Update Sources/SourceKitLSP/SourceKitLSPServer.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-16 08:15:41 +05:30
loveucifer
2d8c993712 Address remaining code review feedback
- Refactor supertypes/subtypes to use indexToLSPTypeHierarchyItem helper
  instead of duplicating ~80 lines of TypeHierarchyItem creation code
- Remove unused workaround helper functions (indexToLSPLocation2,
  indexToLSPTypeHierarchyItem2)
- Fix test ordering: use deterministic sorted order instead of Set comparison
- Enable testFindImplementationInCopiedHeader test
- Add implementation request support for C/C++/ObjC functions with
  separate declaration and definition (finds definition when declarations
  exist without definitions at the same location)
- Fix whitespace/indentation issues
2025-12-16 08:11:38 +05:30
Adam Ward
64ac7f3f46 Don't scan for playgrounds if swift-play not in the toolchain 2025-12-11 14:29:20 -05: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
5689018f6b Fix build 2025-12-08 15:16:36 -05:00
Adam Ward
25da841307 Revert deduplicate 2025-12-08 15:16:36 -05:00
Adam Ward
3abbffb61f Deduplicate file events 2025-12-08 15:16:36 -05:00
Alex Hoppen
b033b8393b Address my own review comments 2025-12-08 15:16:36 -05:00
Adam Ward
158529270c Only scan tests if part of a test target 2025-12-08 15:16:36 -05:00
Adam Ward
9ba107d0c5 Fix some failing tests 2025-12-08 15:16:36 -05:00
Adam Ward
3d7fd2101e Rename to SyntacticIndex to acknowledge any language code be scanned 2025-12-08 15:16:36 -05:00
Adam Ward
866bc74874 Don't always assume Swift language when scanning 2025-12-08 15:16:36 -05: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
1b7e5a8dfe Fix CMake files 2025-12-08 15:16:36 -05:00
Adam Ward
45fec7fbff Only advertise workspace/playgrounds capability if swift-play is in the preferred toolchain 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
Adam Ward
22421b7ce3 Rename to SwiftSyntacticIndex 2025-12-08 15:16:36 -05:00
Adam Ward
eb47fdf927 Rename SyntacticTestIndex to just SyntacticIndex 2025-12-08 15:16:36 -05:00
Alex Hoppen
d449cb78be Merge pull request #2294 from josh-arnold-1/preparation-batch-size 2025-12-06 10:04:55 +01:00
Alex Hoppen
0c8ae92665 Log an error when ignoring an unknown notification sent by the client
Just noticed that we don’t emit a log message here while reviewing the new SwiftPM BSP server.
2025-12-04 11:11:04 +01: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
Josh Arnold
668aab32ac Support custom preparationBatchSize defined via SourceKit's options 2025-12-03 13:37:25 -06: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
6b19657739 Enable ExistentialAny 2025-12-02 12:27:27 +00:00
Owen Voorhees
f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07: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
4fe68eebfb Use activeProcessorCount instead of processorCount in short-lived use-cases
According to https://developer.apple.com/documentation/foundation/processinfo/activeprocessorcount

> Whereas the processorCount property reports the number of advertised processing cores, the activeProcessorCount property reflects the actual number of active processing cores on the system. There are a number of different factors that may cause a core to not be active, including boot arguments, thermal throttling, or a manufacturing defect.

For short-lived workloads like `concurrentMap` we want to parallelize across the number of cores that are currently active, so use `activeProcessorCount` instead. The only case where we want to continue using `processorCount` is the computation of concurrent tasks for `TaskScheduler` because the value is stored for the lifetime of the SourceKit-LSP process and we don’t want to limit parallelism if SourceKit-LSP was launched during a time of thermal throttling.

I stumbled across this while working on #2302
2025-09-22 09:51:41 +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
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 Elrefaey
a5854f4ecf Add signature help LSP request support (#2250)
Depends on https://github.com/swiftlang/swift/pull/83378

---

Adds support for the LSP signature help request.

> [!NOTE]
> As of https://github.com/swiftlang/swift/pull/83378, SourceKitD still
doesn't separate parameter documentation from the signature
documentation and thus parameters don't have their own separate
documentation. This should just work once SourceKitD implements this
functionality and we'll only need to modify the tests.
2025-09-05 14:52:56 +01: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
6301397c37 Merge pull request #2279 from ahoppen/log-bsp-compliant
Make the `build/logMessage` conform to the BSP spec
2025-09-03 02:27:23 +02:00