Repository navigation
Conversation
…t moved to API package.
JaroslavTulach
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Was this class ever meant to be an API? It is an interface. How do you plan to evolve it in the future?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Eh ;) bad example then. Let's pick a message that is NOT bridged from regular NetBeans APIs, e.g. disposeTextEditorDecoration or notifyNodeChange.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
org.netbeans.modules.java.lsp.server.ui already marked as public ?
The PR starts to separate (so far) internal NBLS APIs from the implementation classes. Two refactorings are here:
CodeActionsProviderwas misused in the past to serve as a SPI for adding commands. The interface was split into twoNbCodeLanguageClient,NbCodeClientCapabilitiesandLspServerUtilswere moved to an API package.