Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a work done progress that shows the index progress #1275

Merged
merged 7 commits into from
May 14, 2024

Conversation

ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented May 10, 2024

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

Comment on lines 188 to 229
for file in files {
if case .scheduled(let task) = self.indexStatus[file] {
self.indexStatus[file] = .executing(task)
}
}
case .cancelledToBeRescheduled:
for file in files {
if case .executing(let task) = self.indexStatus[file] {
self.indexStatus[file] = .scheduled(task)
}
}
case .finished:
for file in files {
self.indexStatus[file] = .upToDate
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log an error or something if a file is in an unexpected state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍🏽

}

func startProgressImpl(server: SourceKitLSPServer) async {
await server.waitUntilInitialized()
activeTasks += 1
guard await server.capabilityRegistry?.clientCapabilities.window?.workDoneProgress ?? false else {
// If the client doesn't support workDoneProgress, keep track of the active task count but don't update the state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment talks about handling the case where this is called before initialization finishes, I guess that's no longer relevant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted 👍🏽

@ahoppen ahoppen changed the title Show a work done progress that shows the index progress 🚥 #1273 Show a work done progress that shows the index progress May 13, 2024
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 13, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 13, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 13, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test Windows

1 similar comment
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test

This fixes a bug where `indexTaskDidFinish` would also get called when a task is cancelled to be rescheduled.
…lback

This follows the general paradigm that callbacks shouldn’t carry much state and instead only notify an observer that state has changed, which the observer can then poll.
…an be executed before SourceKit-LSP is initialized
This makes it a lot easier to work on background indexing because you can easily see how background indexing is making progress.

Resolves apple#1257
rdar://127474057
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test

@ahoppen ahoppen changed the title Show a work done progress that shows the index progress Add a work done progress that shows the index progress May 14, 2024
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test Windows

1 similar comment
@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit ba56bae into apple:main May 14, 2024
3 checks passed
@ahoppen ahoppen deleted the index-progress branch May 14, 2024 18:54
Comment on lines +149 to +151
reloadPackageStatusCallback: @Sendable @escaping (ReloadPackageStatus) async -> Void,
indexTasksWereScheduled: @Sendable @escaping (Int) -> Void,
indexTaskDidFinish: @Sendable @escaping () -> Void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need a ServerCallbacks struct soon 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report indexing progress to the editor
3 participants