Progress Bar for Code Gen

i need a progress bar for code generation process in theia editor.

on clicking generate java code button in theia editor
it’s calling registry command in command contribution in theia.
registry command is hitting IExecutableCommandService in backend LSP to generate java code.

now i need value of execution progress in theia editor so that i can implement that in progress bar.

Hey @Siddharth,

so in theory, you could solve this in the same way that you invoke the generator in the language server:

Every time you advance with the progress in your language server, you send a custom notification back to your language client (the vscode extension running in Theia). You need to register a handler for that on the language client side.

The handler for this notification would then take the arguments and update a vscode.window.withProgress notification.

It’s basically the same way you call the generator in the first place, but in reverse.

isn’t vscode.window.withProgress shows the progress of opening window instance

but i need progress of codegen execution running in my LSP server

isn’t vscode.window.withProgress shows the progress of opening window instance

It shows whatever progress you want, see here. The idea that I’ve outlined uses the function to display the progress of codegen that is sent via a notification to the language client. The only reason why it’s in the window namespace is explained here:

window: Namespace for dealing with the current window of the editor. That is visible and active editors, as well as, UI elements to show messages, selections, and asking for user input.

is there any example of registering handler from client side?

@Siddharth Assuming you’re using the vscode-languageclient package, you can do something like this:

client.onNotification(new NotificationType<number>('progress'), percentage => {
    // percentage is in the range of 0 - 100
    reportProgress(percentage);
});