Skip to content

Detect lightweight java language server#14

Merged
datho7561 merged 1 commit intoredhat-developer:masterfrom
rzgry:detect-lightweight
Aug 27, 2020
Merged

Detect lightweight java language server#14
datho7561 merged 1 commit intoredhat-developer:masterfrom
rzgry:detect-lightweight

Conversation

@rzgry
Copy link
Copy Markdown
Collaborator

@rzgry rzgry commented Aug 6, 2020

Fixes #12

Detects if java ls started in lightweight mode and prompts user to switch to standard. The user ends up getting a second prompt from vscode-java to ask if they are sure.

Screen Shot 2020-08-06 at 11 06 31 AM

Screen Shot 2020-08-06 at 10 53 27 AM

@rzgry rzgry requested a review from xorye August 6, 2020 15:08
@datho7561 datho7561 self-requested a review August 10, 2020 14:55
Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

This is pretty helpful for switching to the full Java language server from the lightweight mode. Before the user responds to the dialog box, NPEs will be generated, since the client program doesn't wait for the user to respond before starting lsp4mp. If 'no' is selected in the first dialog, then the microprofile server is left running, which means NPE are still generated.

Comment thread src/extension.ts Outdated
@angelozerr
Copy link
Copy Markdown
Contributor

@fbricon could you give us feedback please about this fix.

@fbricon
Copy link
Copy Markdown
Collaborator

fbricon commented Aug 11, 2020

See microsoft/vscode-java-debug@20cd68c for reference

@rzgry
Copy link
Copy Markdown
Collaborator Author

rzgry commented Aug 11, 2020

I agree with trying to avoid starting up lsp4mp if the java language server is in lightweight mode.

I opened an issue redhat-developer/vscode-java#1571 to try and get some clarifications about the best way to go about implementing this. I can detect the current server mode on start up. But since vscode-java can start in lightweight and switch over to standard after activation, if we detect lightweight at start up it can display a warning to switch to standard even though vscode-java is in the process of switching over to Standard which i dont think makes for a good UX.

@rzgry
Copy link
Copy Markdown
Collaborator Author

rzgry commented Aug 12, 2020

After some discussion in this issue: redhat-developer/vscode-java#1571 It seems that it can be problematic to check the java language server mode immediately on extension activation. This is because when you import a new project vscode-java starts off in lightweight mode and prompts the user to switch to standard.

The flow for importing a new java project seems to be:
Someone imports a new Java project. -> Java language server starts in Lightweight. They are then prompted to import the project. If they click yes -> Java language server will switch to Hybrid as it starts up the Standard server, and then to Standard once the standard LS is ready.

So for new Java projects, if we check the mode immediately on extension activation it will return lightweight, even though the user could be in the process of switching to standard mode using the prompt from vscode. Which means we could end up displaying an unnecessary warning message.

For an example:

I click yes to import the project and switch to standard. But since immediately at activation vscode-java returns Lightweight we end up with a warning message from vscode-microprofile to switch to standard.

output

It seems for all the other Java extensions, they detect server mode only when java features are needed instead of immediately on extension activation.

My thoughts are that would could do something like only check the Java language server mode after a user has opened a file or something similar.

Any thoughts @fbricon @angelozerr @datho7561 ?

@rzgry rzgry force-pushed the detect-lightweight branch from d48c15b to 38f669b Compare August 20, 2020 14:48
@rzgry
Copy link
Copy Markdown
Collaborator Author

rzgry commented Aug 20, 2020

Update the PR to only start the MicroProfile language server once the java language server is in hybrid mode.

After testing redhat-developer/vscode-java#1581 it fixed the problem when a new importing a project for the most part.

If someone selects yes to import a new project before vscode-java is done activating, they will no longer receive a second prompt while the standard server is in the process of launching.

You can still get two prompts when importing a project if the user has not selected Yes to import the project by the time vscode-java has finished activating. But i think this is acceptable?

Ex:
Screen Shot 2020-08-20 at 10 43 45 AM

@fbricon
Copy link
Copy Markdown
Collaborator

fbricon commented Aug 20, 2020

I think we can start that way.

@rzgry rzgry force-pushed the detect-lightweight branch from 38f669b to ad0632b Compare August 20, 2020 14:59
@rzgry
Copy link
Copy Markdown
Collaborator Author

rzgry commented Aug 20, 2020

Updated the options for the prompt to switch to Standard to be Yes and Later to match vscode-java.

Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

Works well for me. The behaviour is pretty intuitive.

Comment thread src/util/javaServerMode.ts
@rzgry rzgry force-pushed the detect-lightweight branch from ad0632b to 353261f Compare August 20, 2020 18:19
@datho7561 datho7561 merged commit 443aa99 into redhat-developer:master Aug 27, 2020
@angelozerr angelozerr added the bug Something isn't working label Sep 11, 2020
@angelozerr angelozerr added this to the 0.1.0 milestone Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE during completion when Java language server is started in LightWeight mode

4 participants