Commit Graph

30 Commits

Author SHA1 Message Date
Rintaro Ishizaki f84abc1eb2 Use 'weak let' for immutable weak references (SE-0481)
Replace 'weak var' with 'weak let' for weak reference properties that are
set in init and never reassigned, using the Swift 6.3 feature introduced
by SE-0481.
2026-05-18 09:28:10 -07:00
Owen Voorhees f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07: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
Alex Hoppen 131dc69c79 Improve Indexing: Scheduling tasks message
The majority of the work here is getting the list of files to index from the build server. Let’s rename the message to reflect that.
2025-08-31 08:21:54 +02: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
Alex Hoppen d10c868497 Support indexing a file in the context of multiple targets
If a source file is part of multiple targets, we should index it in the context of all of those targets because the different targets may produce different USRs since they might use different build settings to interpret the file.
2025-03-14 15:49:59 -07:00
Alex Hoppen 55b514f6a4 Log the source files that are marked in-progress when updating the index status
If we have a bug in index status tracking, this helps figure out which files are considered to be currently indexed.
2025-03-11 08:31:21 -07:00
Alex Hoppen 655a93f05a Add structure to the index logs
When the client supports it, communicate the structure of tasks that were stared during background indexing or by the build server to the client. If there are multiple operations happening in parallel, this allows the client to display them in separate log tracks instead of interspersing them with the emoji prefixes like we do today.
2025-03-04 16:36:26 -08:00
Alex Hoppen 697e65acdc Improve logic for build graph generation status
`generateBuildGraph` was named misleadingly because the primary purpose of these tasks was to schedule indexing tasks and generating the build graph was just a necessary step for this. Also update it to take into account that multiple tasks scheduling indexing tasks might be running in parallel.
2024-12-06 09:07:18 -08:00
Alex Hoppen 8c2def8ef9 Rename SKSupport to LanguageServerProtocolExtensions 2024-11-13 16:53:58 -08:00
Alex Hoppen 1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08:00
Alex Hoppen 6cc2cc4e95 Implement reloadPackageStatusCallback using BSP messages 2024-09-15 16:28:12 -07:00
Alex Hoppen 6d34d70883 Split SourceKitLSPOptions out of SKCore
This only leaves build system functionality in SKCore, which allows us to rename SKCore.
2024-07-25 09:11:13 -07:00
Alex Hoppen 8c34a76f59 Rename LSPLogging to SKLogging 2024-07-25 09:11:13 -07:00
Alex Hoppen d8e0fff6da Make background indexing a proper option in SourceKitLSPOptions
This allows us to flip the default in the future more easily. It also allows users to disable background indexing when it’s enabled by default.

rdar://130280855
2024-06-28 10:23:29 +02:00
Alex Hoppen 3003fe19e5 Allow prefixing of the token for a WorkDoneProgress with a custom string
This allows VS Code to detect when sourcekitd has crashed and prompt the user to gather a diagnostic report + file an issue about the crash.

rdar://129678779
Fixes #1476
2024-06-20 09:05:18 -07:00
Alex Hoppen 3fc03e9f0d Debounced the Reloading Package work done progress 2024-06-08 14:36:20 -07:00
Alex Hoppen 5bf62339cd Debounce the creation of work done progress for indexing
This avoids us from showing a work done progress for short-lived index tasks that take less than a second.

Fixes #1298
rdar://128071328
2024-06-08 14:36:06 -07:00
Alex Hoppen b479b2e874 Create a SwiftExtensions module
This allows us to share common Swift utility functions between SourceKit-LSP and LSPLogging.
2024-06-04 07:06:44 -07:00
Alex Hoppen b3fab6b19f Remove showActivePreparationTasksInProgress experimental feature
The `showActivePreparationTasksInProgress` didn’t turn out to be terribly useful and with the streaming index log (https://github.com/apple/sourcekit-lsp/pull/1382), we should have the functionality to view which index tasks are currently running. So, we should remove the feature.

rdar://129109830
2024-06-02 22:27:38 -07:00
Alex Hoppen c4e6e85ce8 Show “Preparing targets” as index status if we only have preparation tasks and no index tasks
I was wondering for a while why we were showing “Indexing 0 / 0” as the index progress. I think it’s if we only have a preparation task but no index tasks running. I’m not entirely sure how this happens because preparation should only happen for two reasons:
- We are preparing a target so we can index a files -> We should have an active index task
- We are preparing a file for editor functionality of the current file -> we should have a `inProgressPrepareForEditorTask`

Maybe I’ll understand it once we have this change in. It seems like a worthwhile change in any way.
2024-06-01 22:41:28 -07:00
Alex Hoppen eb304c4759 Add a general notion of experimental features to sourcekit-lsp
Background indexing probably won’t be the last experimental feature in sourcekit-lsp that we want to gate behind a feature flag. Instead of adding new parameters ad-hoc, introduce a general notion of experimental features.
2024-06-01 08:35:31 -07:00
Alex Hoppen ecacd7ba2c Show work done progress while a source file is being prepared for editor functionality
While `SemanticIndexManager.inProgressPrepareForEditorTask` is not `nil`, show a work done progress in the editor that the current file is being prepared for editor functionality.

I decided to use the indexing progress indicator for this for now because I think it’s too spammy if SourceKit-LSP has two different progress indicators for preparation and indexing. I’ll need to see how this feels like in practice.

rdar://128722609
2024-05-25 10:40:35 -07:00
Alex Hoppen 1ea20eb28f Show a work done progress while the semantic index is rebuilding a build graph
Rebuilding the build graph can take a while (initial loading of the build graph takes ~7s for sourcekit-lsp) and it’s good to show some progress during this time.
2024-05-24 11:23:15 -07:00
Alex Hoppen bc1cd2cb71 Merge pull request #1332 from ahoppen/review-comments-1322-1326
Address review comments to #1322 and #1326
2024-05-22 15:35:02 -07:00
Alex Hoppen 328a02ada5 Fix a race condition that caused IndexProgressManager to create two WorkDoneProgress 2024-05-22 10:41:18 -07:00
Alex Hoppen 8f8ff454d7 Address review comments to #1326 2024-05-22 09:14:31 -07:00
Alex Hoppen a88798129d Add an option to show the files that are currently being index / targets being prepared in the work done progress 2024-05-21 22:09:22 -07:00
Alex Hoppen e295a4e95a Split up-to-date status tracking and index progress tracking
We were mixing the up-to-date status and in-progress status of an index task in `SemanticIndexManager`. This meant that a single `QueuedTask` in the task scheduler could be needed for eg. both preparation for editor functionality in a file of that target and to re-index a file in that target. This dual ownership made it unclear, which caller would be entitled to cancel the task. Furthermore, we needed to duplicate some logic from the preparation task dependencies in `SemanticIndexManager.prepare`.

To simplify things:
- Split the up-to-date status and the in-progress status into two different data structures
- Make the caller of `prepare` and `scheduleIndex` responsible for cancellation of the task it has scheduled. `TaskScheduler` might receive more scheduled tasks this way but the additional tasks should all be no-ops because the status is known to be up-to-date when they execute.
2024-05-20 21:01:40 -07:00
Alex Hoppen a6389e58e2 Show a work done progress that shows the index progress
This makes it a lot easier to work on background indexing because you can easily see how background indexing is making progress.

Resolves #1257
rdar://127474057
2024-05-14 06:39:48 -07:00