question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export public API in LightWeight mode

See original GitHub issue

Background

We recently introduced LightWeight mode in VS Code Java. The LightWeight mode is used for those who just want to do some ‘easy’ work in VS Code, for example: reading the code…

But the users might find that if they take a certain action (i.e. starting a debug session) in LightWeight mode, nothing happens…

Root Cause

In the activate() method of VS Code Java, we will return the public APIs as a promise, which will only be resolved when the Standard language server is ready. That means the promise will never be resolved if VS Code Java is in LightWeight mode. Thus, the extension will be in an inactivated status (You can tell it by triggerring the command Developer: Show Running Extensions). All the third-party extensions which depend on VS Code Java will then, keep waiting.

Proposed change

Also resolve the public API in whatever server mode, besides that, adding the following new API:

{
  serverMode: ServerMode
  onDidServerModeChange: Event<ServerMode>
}

Note:

  • The APIs like: getProjectSettings, getClasspaths, isTestFile and onDidClasspathUpdate will return an empty-like value in LightWeight mode, since so far there is no scenarios shows these APIs need to work in LightWeight mode. (We can change the impelmentation when necessary)
  • In LightWeight mode, all the calls to the command: java.execute.workspaceCommand will just show a warning message in the console and directly return.
  • It’s recommended for all the the third-party extensions to consume the serverMode field in the APIs set and change the behavior if it’s LightWeightServiceReady.

How to adopt the new APIs

Check the serverMode when get the resolved extension API, and run properly. For example, you may not want to provide some features when Java Language Server is in lightweight mode.

Also do not forget to register a listener to listen the server mode changing event:

const extension: Extension<any> | undefined = extensions.getExtension('redhat.java');
if (extension && extension.isActive) {
    const extensionApi: any = extension.exports;
    if (!extensionApi) {
        return;
    }

    if (extensionApi.onDidChangeServerMode) {
        const onDidChangeServerMode: Event<string> = extensionApi.onDidChangeServerMode;
        context.subscriptions.push(onDidChangeServerMode(async (mode: string) => {
            // do something according to current server mode
        }));
    }
}

@fbricon @snjeza @akaroml @testforstephen @Eskibear

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jdneocommented, Jul 16, 2020

@jblievremont Yes, so far VS Code Java supports switch from LightWeight mode to Standard mode without a restart. User can achieve this by for example, click the 🚀 button in the status bar(when the user is in LightWeight).

0reactions
jblievremontcommented, Jul 16, 2020

Thank you @jdneo, I can indeed see the server switching to Hybrid and then Standard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing and Exporting Projects - MuleSoft Documentation
Exporting a Studio Project to a Shareable Lightweight Package. Select Export from the File menu. In the Import wizard, click to expand the...
Read more >
REST API Handbook - WordPress Developer Resources
The WordPress REST API provides an interface for applications to interact with your ... JSON is an open standard data format that is...
Read more >
API v2 Reference - About Crowdin Apps
The Crowdin API clients are the lightweight interfaces developed for the ... Defines whether to export only translated file ... Cost Estimate Fuzzy...
Read more >
Download Formatted Excel Reports Using the Reports REST ...
You can use the Reports REST API to request reports in printer-friendly Excel format. To execute a report and obtain the results, the...
Read more >
Using LightCells API - Aspose Documentation
In this mode, therefore, memory is saved when importing and exporting ... the data provider for saving large spreadsheet files in light-weight mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found