Skip to content

ClientCommandProvider split from CodeActionsProvider. NbLanguageClient moved to API package. - #3653

Open
sdedic wants to merge 1 commit into
apache:masterfrom
sdedic:lsp/codeaction-refactor
Open

sdedic wants to merge 1 commit into
apache:masterfrom
sdedic:lsp/codeaction-refactor

Conversation

@sdedic

@sdedic sdedic commented Feb 21, 2022

Copy link
Copy Markdown
Member

The PR starts to separate (so far) internal NBLS APIs from the implementation classes. Two refactorings are here:

  • CodeActionsProvider was misused in the past to serve as a SPI for adding commands. The interface was split into two
  • NbCodeLanguageClient, NbCodeClientCapabilities and LspServerUtils were moved to an API package.

@sdedic sdedic added work-in-progress API Change [ci] enable extra API related tests Code cleanup Label for cleanup done on the Netbeans IDE do not merge Don't merge this PR, it is not ready or just demonstration purposes. wait-for-feedback labels Feb 21, 2022

@JaroslavTulach JaroslavTulach left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for picking up this challenge, @sdedic ! It is desperately needed to turn the currently hard-coded commands into such ClientCommandProvider abstraction and de-couple them as much as possible from the actual server implementation.

* from the official LSP protocol.
* @author sdedic
*/
public interface NbCodeLanguageClient extends LanguageClient {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Was this class ever meant to be an API? It is an interface. How do you plan to evolve it in the future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It has to (somehow) - otherwise the code wouldn't be able to call things like showInputBox. Additional messages can be added as default methods throwing UnsupportedOpEx. There are two additional ways: final class with protocol messages that will delegate all methods to NbCodeLanguageClient (internal API). Or the same with the Context proposed below.

@JaroslavTulach JaroslavTulach Feb 21, 2022 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not call DialogDisplayer.getDefault().notifyFuture(new NotifyDescriptor.InputLine(...)) instead of showInputBox?

I know: It is not nice to loose the context and resort back to a singleton, but it is a standard way to show dialogs in NetBeans and unless we want to switch fully to some form of dependency injection, it is better to stick to existing API/concepts than to mix them with new ones.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Eh ;) bad example then. Let's pick a message that is NOT bridged from regular NetBeans APIs, e.g. disposeTextEditorDecoration or notifyNodeChange.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you want to expose whole LSP - then providing access to LanguageClient may be the right thing. If you want to expose it including NetBeans extensions, possibly exposing NbCodeLanguageClient is the right thing - but then the protocol has to become (relatively) stable API - a review of our adhoc messages may be desirable (that's what we haven't paid much attention to yet).

* commands for the LSP client.
* @return Set of supported commands.
*/
public Set<String> getCommands();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some annotation based registration would be preferable - especially if multiple modules start to contribute these commands.

<package>org.netbeans.modules.java.lsp.server.ui</package>
<package>org.netbeans.api.lsp.server</package>
<package>org.netbeans.spi.lsp.server</package>
<package>org.netbeans.modules.java.lsp.server.ui</package>

@dbalek dbalek Mar 9, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

org.netbeans.modules.java.lsp.server.ui already marked as public ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Change [ci] enable extra API related tests Code cleanup Label for cleanup done on the Netbeans IDE do not merge Don't merge this PR, it is not ready or just demonstration purposes. wait-for-feedback work-in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants