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

Alternative ProjectProblems presenter for LSP server. #3568

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Feb 8, 2022

Project problems are presented in a rich UI dialog in NB, but that's not suitable for LSP protocol that only allows for limited dialogs or quickpicks. Instead of a rich-interaction view, this PR replaces (just for the LSP !!) the process by a series of dialogs.

  • Errors are presented all at once, with some limit (~10). If there are more errors, they're displayed as soon as the user closes/confirms earlier messages.
  • Fixable problems are presented one by one: each confirmation offers the possibility to fix rest of the issues without asking
  • If an error occurs during a fix (the resolution is not "resolved"), the err message is printed, and the user is asked to cancel or continue with fixes
  • If a new unfixable problem appears during the process, the error is displayed before the next confirmation/question

There's a timeout implemented for the user's response to questions or messages; the process will continue after the timeout. This is because the LSP client user may completely ignore (even not cancel) the messages, but I'd still want the identified errors to be displayed.

A showAlert API call will immediately continue the problem resolution process, as if the timeout had elapsed; for example on project reload or reopen. But ony problems not yet presented to the user are processed.

A showCustomizer API call will restart the whole process with all the currently known problems (incl. the already shown ones, if they still exist).

This alternative implementation is present in java/java.lsp.server module, but the implementation is only registered in nbcode/integration module which is part of nbcode distribution (published as Apache NetBeans Language Server extension for vscode).

@sdedic sdedic self-assigned this Feb 8, 2022
@sdedic sdedic added enhancement LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests labels Feb 8, 2022
@sdedic sdedic added this to the NB14 milestone Feb 8, 2022
Copy link
Member

@ppisl ppisl left a comment

Choose a reason for hiding this comment

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

Currently I don't see any problem.

@sdedic
Copy link
Member Author

sdedic commented Feb 23, 2022

Consolidated fixes ... actually everything into a single commit.

@sdedic
Copy link
Member Author

sdedic commented Feb 23, 2022

I'd like to hold this PR for a moment - during testing, I've encountered NETBEANS-5846 this time even in vscode; together with this PR, NETBEANS-5846 looks rather ugly (several dialogs displayed on project open). I'd prefer to fix NETBEANS-5846 first the way @lkishalmi suggested there.

Tracked as #3668

@sdedic sdedic added do not merge Don't merge this PR, it is not ready or just demonstration purposes. and removed do not merge Don't merge this PR, it is not ready or just demonstration purposes. labels Feb 23, 2022
@sdedic
Copy link
Member Author

sdedic commented Feb 28, 2022

Prerequisite PR #3668 merged, so this is ready.

@sdedic
Copy link
Member Author

sdedic commented Mar 1, 2022

Just random failures from ServerTest / ProjectViewTest. Merging.

* displayed
* @author sdedic
*/
// BAD BAD BAD - DO NOT REGISTER THIS IN LSP SERVER, put it in the integration module !!!

Choose a reason for hiding this comment

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

Would making this class abstract with protected constructor help to remove the BAD BAD message?

Choose a reason for hiding this comment

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

But how can the integration module access this class, when it is not in public package?

Copy link
Member Author

@sdedic sdedic Mar 1, 2022

Choose a reason for hiding this comment

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

Would making this class abstract with protected constructor help to remove the BAD BAD message?

It would not :) it's there just for case that someone won't get the great idea to add @ServiceProvider since the lsp.server module is a part of NetBeans IDE distro and this override would screw the IDE up.

The integration module uses an explicit META-INF/Services registration that references this class by name. For that the default constructor has to be public. If too ugly, the alternative would be to expose a factory method for the implementation as an API, but I really do not want to expose the implementation class in the APIs.

Choose a reason for hiding this comment

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

There is a common pattern used for this kind of registrations and there are multiple AbstractLspXYZ classes. What is so special on this class that requires a special treatment?

Unless you have some intrinsic answer to the above question, then I suggest to create AbstractLspProjectProblemsImplementation, make it abstract, have protected constructor like other implementations do. However, it is just a suggestion, do as you like.

Copy link
Member Author

@sdedic sdedic Mar 2, 2022

Choose a reason for hiding this comment

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

Dear colleague(s). Your peristence in commenting my laziness finally worked... So this should be fixed in 033b943

* @since 1.19
* @author sdedic
*/
public abstract class AbstractLspBrokenReferences implements ProjectProblemsImplementation {

Choose a reason for hiding this comment

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

Great!

private final BrokenReferencesImpl delegate;

protected AbstractLspBrokenReferences() {
delegate = new BrokenReferencesImpl();

Choose a reason for hiding this comment

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

Possibly check for allowed subclasses in the constructor...

@sdedic sdedic force-pushed the projects/broken-references branch from 033b943 to 540fb3e Compare March 4, 2022 08:27
@sdedic sdedic merged commit d9bd08e into apache:master Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants