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 new API to wait for standard server ready #2461

Merged
merged 1 commit into from
May 24, 2022

Conversation

jdneo
Copy link
Collaborator

@jdneo jdneo commented May 20, 2022

  • Add serverReady() which returns a promise. The promise will
    only be resolved when the standard server is ready.

Currently we have the API serverMode to denote which mode the current language server is working on. But so far there is no API to let other extensions know when the standard server is ready. (Ready means it's ok to send request to server and an immediate response should be returned)

The newly added API can be used by all the side extensions (test runner, intellicode, ...), to let them only register their components after the standard server is ready. This can avoid lots of LSP requests pending when the server is building the project during startup.

A sample usage for the API could be:

if (extensionApi.serverMode == LanguageServerMode.LightWeight) {
    if (extensionApi.onDidServerModeChange) {
        const onDidServerModeChange: Event<string> = extensionApi.onDidServerModeChange;
        context.subscriptions.push(onDidServerModeChange(async (mode: string) => {
            if (mode === LanguageServerMode.Standard) {
                registerComponents();
            }
        }));
    }
} else {
    await extensionApi.serverReady();
    registerComponents();
}

Signed-off-by: sheche sheche@microsoft.com

- Add waitForServerReady() which returns a promise. The promise will
  only be resolved when the standard server is ready.

Signed-off-by: sheche <sheche@microsoft.com>
Copy link
Collaborator

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

LGTM

@testforstephen testforstephen added this to the Early June 2022 milestone May 24, 2022
@testforstephen testforstephen merged commit 34d7bcf into redhat-developer:master May 24, 2022
@jdneo jdneo deleted the cs/server-ready-api branch May 26, 2022 02:38
@jdneo
Copy link
Collaborator Author

jdneo commented May 26, 2022

Note: The API is renamed to serverReady() in #2469

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.

None yet

2 participants