-
Notifications
You must be signed in to change notification settings - Fork 890
Language Server Protocol client #629
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
Conversation
Only to let you know: https://issues.apache.org/jira/browse/NETBEANS-180 So this PR will resolve, more or less, this ticket. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider importing Eclipse OSGi bundles as OSGi bundles.
release.external/guava-21.0.jar=modules/ext/guava-21.0.jar | ||
release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar | ||
release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar | ||
release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these libraries are themselves OSGi bundles. If so, I prefer to package them and consume them like OSGi bundles. Just like Mylyn does with its OSGi bundles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I guess a question here is if we want to export this APIs, and be liable for it. The advantage of wrapping the jars is that we can limit the exposure of the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the context of friend dependencies discussion (raging on in parallel), I see an attempt to bring private only copy of popular libraries like gson
or guava
going the exactly opposite way. Attitude like this brought NetBeans to the "overuse of friend deps" which leads to hacks and tricks to workaround it.
I prefer exposing popular 3rd party libraries (especially those packaged as OSGi bundles) as reusable components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a significant difference between e.g. html.editor and guava. It is not reasonably possible to have multiple copies of html.editor in the IDE, while the side-effects of having multiple copies of guava should be fairly limited. I.e. if some other module needs guava, there's no need to do "hacks and tricks", it can have its own copy.
I wonder if there may be multiple versions of an OSGi module under the NB-OSGi combined module system, and if it will select the proper one based on dependencies.
If not, then with too much reusing, we may putting ourselves into a corner where upgrading various libraries will lead to significant amount of time spent ensuring things still work after the upgrade. And the time, I think, might be better spent on actual features and bugfixes of this project.
@ActionRegistration( | ||
displayName = "#CTL_ConnectToLanguageServer" | ||
) | ||
@Messages("CTL_ConnectToLanguageServer=Connect to Language Server") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a natural place for this action could be a pop-up menu on the non-recognized data objects. E.g. if the IDE doesn't know a .kt
file it's popup menu would suggest to connect to a language server.
A few observations:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great, what needs to be done for a first release of this feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OSGi bundles would better be used as OSGi bundles, not as a wrapped JARs. Edit: turns out that except missing ide/c.google.gson/build.xml
, it is already prepared as OSGi bundle.
* @return a collection of {@code NavigatorPanel}s for the given file | ||
* null is allowed | ||
*/ | ||
public @CheckForNull Collection<? extends NavigatorPanel> panelsFor(@NonNull FileObject file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first place in the spi.navigator
API where FileObject
is exposed. Until now the navigator API (not implementation) was FileSystem API free.
lsp.client/nbproject/project.xml
Outdated
</dependency> | ||
</module-dependencies> | ||
<friend-packages> | ||
<friend>org.netbeans.modules.kotlin.support</friend> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearly this module shall serve as an API for many projects to hook in. It is not only for few "friends" - expose the API in a regular way. Use arch.xml
to specify the stability category (under development, I assume). Provide some documentation and initial version of apichanges.xml
. Let the module be visible in the overall Javadoc (e.g. change nbbuild/build.properties
).
@@ -46,13 +46,13 @@ public void testGetProviders () throws Exception { | |||
ProviderRegistry providerReg = ProviderRegistry.getInstance(); | |||
|
|||
System.out.println("Asking for non-existent type..."); | |||
assertEquals(0, providerReg.getProviders("image/non_existent_type").size()); | |||
assertEquals(0, providerReg.getProviders("image/non_existent_type", null).size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only existing tests shall be fixed, but new one(s) covering the DynamicRegistration
shall be added.
…ion, as noted by jtulach.
How will syntax highlighting work? I mean how to get it from the LS @jlahoda? |
Not supported yet by LSP: microsoft/vscode-languageserver-node#367 |
The simple answer is that the LSP does not support highlighting at this point. So no highlighting through the LSP. See for example: This may get into the protocol eventually, see: |
Ok, thx. |
Great work! FWIW, for all on a sensible OS, there is no need to clone and build |
@rkraneis - thanks for the pointer, didn't know about the tool! Thanks! |
Hi This feature can will be used ti support freemarker like eclipse do? Jbosstools use lsp ti support freemarker and NetBeans freemarker plugin is outdated and with dime bugs |
This is a crude prototype of a Language Server Protocol client for NetBeans.
It currently supports:
-diagnostics from the server
-go-to-declaration
-code completion
It uses the Eclipse LSP4J (https://github.com/eclipse/lsp4j) to handle the protocol and to provide the model for the messages (I used to have a custom implementation of the protocol, but it seemed wasteful to maintain that).
There are currently two ways to use a server from the IDE:
-a module provides bindings for a particular language, starts and registers a LS. I have a crude prototype of such a module using KotlinLanguageServer, but not good enough to that publish, yet.
-the user starts the LS manually somehow, and then binds the IDE to the running LS.
To see the client in action using the latter approach, the following can be used:
-clone https://github.com/fwcd/KotlinLanguageServer
--build it (gradle install)
--unpack build/distributions/kotlin-language-server-0.1.1.zip somewhere
-clone https://github.com/jlahoda/nb-lsp-helpers
--build it (ant jar in run-lsp)
--go to run-lsp/dist and run: "java -jar run-lsp.jar /bin/kotlin-language-server"
-run NetBeans, be sure there are no files opened in the editor, use the search feature in the top right corner, type "Connect", select "Connect to Language Server" action. Fill in your project's root (e.g. the path to the checked-out KotlinLanguageServer), port is 9965, extensions "kt". In a while the IDE should connect to a the LS. Then open a kt file (from the specified project), and the above features should work.