Commit Graph

2505 Commits

Author SHA1 Message Date
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
84007caf6e Merge pull request #1343 from ahoppen/generating-build-graph-logging 2024-05-24 22:09:40 -07:00
Alex Hoppen
069e8a2ca4 Call indexProgressManager.indexStatusDidChange when workspaces in the SourceKitLSPServer are modified
`IndexProgressManager` iterates over all workspaces in the SourceKitLSPServer. Modifying workspaces might thus update the index progress status.
2024-05-24 17:31:00 -07:00
Alex Hoppen
2b04ad6c32 Merge pull request #1347 from ahoppen/cancel-builds-0-on-close
Set `cancelBuilds` to 0 on close instead of open
2024-05-24 17:15:22 -07:00
Alex Hoppen
ea6a585c02 Merge pull request #1335 from ahoppen/task-scheduler-logging
Add some logging to `TaskScheduler` again
2024-05-24 12:37:35 -07:00
Alex Hoppen
6103661636 Merge pull request #1346 from ahoppen/reveal-diag-bundle
On macOS, reveal diagnostic bundle in Finder after it has been created
2024-05-24 12:37:20 -07:00
Alex Hoppen
eb784ebdd7 Log when the build graph starts being generated and when it finishes
The signposts aren’t easily visible in the log (you need to add `--signpost` to `log show`) and don’t get logged on non-Darwin platforms at all. Add logging for it.
2024-05-24 11:24:32 -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
31a8cf333f Merge pull request #1345 from ahoppen/reset-workdoneprogress-state
Reset the state of `WorkDoneProgressState` when the progress has ended
2024-05-24 11:01:52 -07:00
Alex Hoppen
7fbb39e8f8 Merge pull request #1344 from ahoppen/update-indexstore-db-before-deciding-what-to-index
Ensure that the indexstore-db is up-to-date before deciding which source files we need to re-index
2024-05-24 11:01:41 -07:00
Alex Hoppen
cdc4f2b732 Set cancelBuilds to 0 on close instead of open 2024-05-24 10:10:53 -07:00
Alex Hoppen
8cb61367fe On macOS, reveal diagnostic bundle in Finder after it has been created
Removes a step to copy paste the bundle path to find it in Finder.
2024-05-24 07:39:51 -07:00
Alex Hoppen
88de421495 Reset the state of WorkDoneProgressState when the progress has ended
Otherwise, we will never show the progress again.
2024-05-24 07:34:46 -07:00
Alex Hoppen
4ad6eb3733 Ensure that the indexstore-db is up-to-date before deciding which source files we need to re-index
Waiting for the indexstore-db to be updated is cheaper than potentially not knowing about unit files, which causes the corresponding source files to be re-indexed.

rdar://128645743
2024-05-23 23:22:31 -07:00
Alex Hoppen
7cf9f15d85 Merge pull request #1340 from ahoppen/watch-for-source-file-changes
Watch for changes to source files
2024-05-23 23:16:30 -07:00
Alex Hoppen
cb24ce93eb Skip testTasksWithElevatedPrioritiesGetExecutedFirst if the host OS doesn’t support task priority elevation 2024-05-23 21:22:50 -07:00
Alex Hoppen
3300c7754c Merge pull request #1339 from ahoppen/dont-cancel-sourcekitd-request-on-close 2024-05-23 18:36:45 -07:00
George Lyon
ba7b03c444 Add a VSCode devcontainer definition (#916) 2024-05-23 15:50:49 -07:00
Alex Hoppen
83b8be8ad0 Add a withTaskPriorityChangedHandler function and use it in TaskScheduler
We need this function anyway to escalate process priorities when we set `nice`ness values for them. It also simplifies the task scheduler and I’m hoping that it fixes a non-deterministic failure that causes task priority elevation to not work properly.
2024-05-23 14:05:50 -07:00
Alex Hoppen
8a413d206b Add some logging to TaskScheduler again
Turns out that some of logging from task scheduler would have been useful to debug a recent test failure. This adds some logging into `TaskScheduler` again and, most importantly, adds log messages to `ClosureTaskDescription` in `TaskSchedulerTests`.
2024-05-23 14:05:50 -07:00
Alex Hoppen
5fffb0a4c9 Watch for changes to source files
We used to only watch for file creation and deletion because that might modify build settings but for background indexing, we also need to watch for changes to the files, so we can invalidate the up-to-date status of the target.
2024-05-23 14:03:33 -07:00
Alex Hoppen
00aebd6659 Don’t cancel build when closing a document
In SourceKit-LSP, we can get into the following situation:
1. We open A.swift
2. We issue a request for A.swift, the request takes a while to execute
3. The dependencies of A.swift are updated, which causes us to reopen the document in sourcekitd, so that the AST is rebuilt
4. This shouldn’t cause the request from (2) to be cancelled. We should continue executing it and only re-open the document after the request from (2) has finished

rdar://127475366
2024-05-23 13:59:39 -07:00
Alex Hoppen
c5e29b19fa Don’t load the syntax map etc when re-opening a file 2024-05-23 13:54:49 -07:00
Alex Hoppen
76da45444f Re-generate sourcekitd UIDs 2024-05-23 13:41:40 -07:00
Alex Hoppen
a671e5a70d Merge pull request #1338 from ahoppen/fix-work-done-progress-test-failure
Fix a non-deterministic failure of `testBackgroundIndexingStatusWorkDoneProgress`
2024-05-23 13:03:49 -07:00
Alex Hoppen
9f0fce1ab7 Fix a non-deterministic failure of testBackgroundIndexingStatusWorkDoneProgress
We didn’t take into account that there are also work done progress notifications for package reloading. Only listen for
2024-05-23 09:14:56 -07:00
Hamish Knight
ed7a1d209d Merge pull request #1337 from hamishknight/disable-test
Disable `testTasksWithElevatedPrioritiesGetExecutedFirst`
2024-05-23 12:09:53 +01:00
Hamish Knight
828be488ff Disable testTasksWithElevatedPrioritiesGetExecutedFirst
rdar://128601797
2024-05-23 12:09:11 +01:00
Alex Hoppen
ed5655a5ac Merge pull request #1328 from ahoppen/parallel-indexing 2024-05-22 22:53:26 -07:00
Alex Hoppen
69a584c80e Merge pull request #1334 from ahoppen/respect-failed-work-done-progress-creation
Respect failed work done progress creation
2024-05-22 15:35:55 -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
3f7d9a7b76 Fix a non-deterministic test failure in testPrepareTargetAfterEditToDependency
We could get a `DiagnosticsRefreshRequest` before the modified target had been re-prepared.
2024-05-22 14:46:03 -07:00
Alex Hoppen
9e49f67455 Rename TestSourceKitLSPClient.handleNextRequest to handleSingleRequest
Since `handleNextRequest` handling doesn’t have to be in the order that the request handlers were specified anymore, the naming was misleading.
2024-05-22 13:31:58 -07:00
Alex Hoppen
950a74a260 Fix a negation issue that prevented parallel indexing 2024-05-22 13:31:58 -07:00
Alex Hoppen
927056b7e9 Merge pull request #1327 from ahoppen/signposts
Add signposts for background preparation and indexing
2024-05-22 13:30:13 -07:00
Alex Hoppen
0615cb2dbc Merge pull request #1333 from ahoppen/index-progress-manager-creates-two-workdoneprogress
Fix a race condition that caused `IndexProgressManager` to create two `WorkDoneProgress`
2024-05-22 13:30:00 -07:00
Alex Hoppen
406fb7eed9 Merge pull request #1331 from ahoppen/await-scheduling
Fix a non-deterministic test failure in the task scheduler
2024-05-22 12:45:57 -07:00
Alex Hoppen
60864fe864 Respect failed work done progress creation
When the client replies with an error to the `CreateWorkDoneProgressRequest`, we shouldn’t be sending updates for it.
2024-05-22 10:55:57 -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
9757181dea Fix a non-deterministic test failure in the task scheduler
We were calling `TaskScheduler.schedule` inside a `Task` in `TaskSchedulerTests`. This means that Swift concurrency could re-order the execution of those tasks and thus change the order in which tasks were enqueued to the `TaskScheduler`.

Caused by e295a4e95a (diff-6a451b3244d65ded9386e2816360b7b1debbe6a519e3795d2046c7dbefa7a7d7R351)
2024-05-22 09:16:57 -07:00
Alex Hoppen
8f8ff454d7 Address review comments to #1326 2024-05-22 09:14:31 -07:00
Alex Hoppen
04d8c6be9a Address review comments to #1322 2024-05-22 08:52:26 -07:00
Alex Hoppen
82637937f6 Add signposts for background preparation and indexing
This allows nice visualization of the indexing progress in Instruments.
2024-05-22 06:46:06 -07:00
Alex Hoppen
814f3c5afc Merge pull request #1329 from ahoppen/index-subcommand
Add a development subcommand to index a project
2024-05-22 06:43:33 -07:00
Alex Hoppen
30a16ec94c Merge pull request #1326 from ahoppen/index-log
Produce an index log for the client
2024-05-22 06:41:11 -07:00
Alex Hoppen
6aecd22120 Merge pull request #1330 from ahoppen/non-deterministic-task-scheduler-test
Fix a non-deterministic test failure of `testTaskSuspension`
2024-05-22 01:28:24 -07:00
Alex Hoppen
2036729f42 Fix a non-deterministic test failure of testTaskSuspension 2024-05-21 22:45:27 -07:00
Alex Hoppen
da96d45443 Add a development subcommand to index a project
This allows us to run `sourcekit-lsp index --project /path/to/project` to index a project. Intended to debugging purposes, eg.
- Profile the time it takes to index a project
- See if the project can be indexed successfully
- Look at signposts generated during indexing in Instruments to see whether indexing or preparation is the bottleneck and how well we can parallelize tasks.
2024-05-21 22:29:52 -07:00
Alex Hoppen
3e6319c3b9 Produce an index log for the client
This allows a user of SourceKit-LSP to inspect the result of background indexing. This allows a user of SourceKit-LSP to inspect the result of background indexing. I think this gives useful insights into what SourceKit-LSP is indexing and why/how it fails, if it fails, also for users of SourceKit-LSP.

rdar://127474136
Fixes #1265
2024-05-21 22:18:06 -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