spring-projects / sts4

The next generation of tooling for Spring Boot, including support for Cloud Foundry manifest files, Concourse CI pipeline definitions, BOSH deployment manifests, and more... - Available for Eclipse, Visual Studio Code, and Theia
https://spring.io/tools
Eclipse Public License 1.0
869 stars 203 forks source link

[Question] What are the features that are supported by idea-extensions/idea-boot-java #63

Closed gayanper closed 4 years ago

gayanper commented 6 years ago

What are features supported by idea-extensions/idea-boot-java ? And any planned development on this extension for future ?

BoykoAlex commented 6 years ago

I believe most of the features from the same named extension for Eclipse, VSCode and Atom are there. There are limitations coming from the intellij LS client thus there are bugs... As far as I remember boot live hints are showing but there is no hover content for them... If you open the same file with a TextEditor rather than Java then you'd see the hovers as well... There are more bugs of similar kind... Also navigation to source code from hovers isn't working. It has been a long time since the last time I've tried it because didn't seem like there is a lot of movement on intellij LS client side... Currently this extension is in POC type of state...

The plan for the intellij extension of the boot tooling is:

  1. IntelliJ LS client has the bugs fixed... if there is another intellij LS client we can try it instead
  2. Keep up with the features put in extensions for other IDEs

The plan has no strict timeframe though...

If you are interested or actively using this extension for IntelliJ please let us know :-) We'll have another look at the IntelliJ LS client and perhaps push on fixing stuff in the client to progress with this extension.

gayanper commented 6 years ago

So if i build and run the master branch i should be able to try these features out right ?

BoykoAlex commented 6 years ago

Ideally, yes, the extension should be functional. It was in the working state...

gayanper commented 6 years ago

I followed the README file and setup the plugin and ran a sample spring boot rest app. In visual studio code it successfully shows the gutter icons and hover information. But when i run the same app in intelliJ with this plugin i don't get any gutter icons or hover information. I tried debuging the method which responsible for receiving the highlight ranges, seems that the language server is sending a empty highlight range. Anything i'm missing ?

gayanper commented 6 years ago

I also tried the spring boot application.properties file as well, seems like the language server is not even taking the properties file in. It worked as expected in vscode but not in intelliJ. Seems like the language server registration is done only for java file.

LanguageServerDefinition.register(
      new StsServerDefinition("java", Array(
        javaExec.toString(),
        "-Xdebug",
        "-agentlib:jdwp=transport=dt_socket,server=y,address=7999,suspend=n",
        "-cp",
        classpath,
        "org.springframework.boot.loader.JarLauncher"
      )))
BoykoAlex commented 6 years ago

It's a boot-java extension created in Jan 2018 before we merged boot-properties and boot-java extensions into a single spring-boot extension. Therefore, it is just for Java currently and we should do the same and add boot properties support to it as well. I'm going through the steps in the README to launch it and see if boot hints are showing or not. Will report here later on today.

BoykoAlex commented 6 years ago

I'm stuck with IntelliJ not compiling Scala files :-( Don't think i ever had this issue... I see that others have faced it too when upgrading IntelliJ from one version to another, but no solution specified. While I'm trying to figure that out perhaps you could debug it on your end a bit. If you are building the LS jar to copy under resources/server/ then build from the latest STS4 source. Also don't forget to rename the file to resources/server/language-server.jar. Also I've noticed that launching of that jar has changed. Think it should be this:

    LanguageServerDefinition.register(
      new StsServerDefinition("java", Array(
        javaExec.toString(),
        "-Xdebug",
        "-agentlib:jdwp=transport=dt_socket,server=y,address=7999,suspend=n",
        getClass().getResource("/server/language-server.jar").getPath()
      )))

no need to specify classpath and special launcher. It should all be defined in the jar file. See what's in the log. The debug console in IntelliJ should print where the LS jar logs are (in the temp folder). When I started debugging I saw that beans JSON format was not compatible with the format handled buy the old LS jar, hence I started updating it and ended with Scala sources not being compiled :-( Anyway, try it out, see where you get with it. If it doesn't work we'll create an issue to bring that extension up-to-date and fit it in our schedule

BoykoAlex commented 6 years ago

I've tried it with the latest LS jar and looks like there is quite a bit of adoption to be done. Feels like there are changes in the LS client as well... For example i couldn't set the classpath for the LS jar that was launched... I had to hack the extension to launch with Java 9-10 that have tools.jar on the classpath... Even when i did that i noticed that our new server relies on the delivery of https://microsoft.github.io/language-server-protocol/specification#initialized message... Doesn't seem like intelliJ client is sending that message... it's been added in LSP spec 3.0... Think we are out of luck getting it to work quickly...

gayanper commented 5 years ago

@BoykoAlex the idea plugin is now active at https://github.com/intellij-lsp/intellij-lsp-plugin, may be idea plugin support can be continued with the help of this project.

BoykoAlex commented 5 years ago

@gayanper This is the plugin that has been used to implement the current extension. As you can see the one you pasted has been forked from gtache/intellij-lsp. Looking at the number of commits since forking the plugin should have evolved greatly... I'll give it another look soon (number of commit give me hope, but the screenshots show the old problems, hope screenshots are old)

gayanper commented 5 years ago

@BoykoAlex will you be able to make the sts4/idea project a gradle project so that it can be easily imported as a plugin module to idea and start working on it or may be commit the plugin project files ?

BoykoAlex commented 5 years ago

Once we get it to work with the new server JAR and with the new intellij LS plugin we'll make it either gradle or maven project and setup the CI build for it.

thekalinga commented 5 years ago

@BoykoAlex Also, is it possible to add a provision download the plugin directly from intellij instead of manual work on the part of developers?

gayanper commented 5 years ago

@BoykoAlex any updates on the progress of this plugin ?

BoykoAlex commented 5 years ago

Unfortunately, there were other items for STS4 4.1.0 that took priority over this. The only progress i can report so far is that my instructions for launching the plugin from the dev environment don't work for some reason... :-( We should have some downtime during the holidays which I'll use to get this plugin up and running again i hope.

gayanper commented 5 years ago

@BoykoAlex Any new progress in this area ?

gayanper commented 5 years ago

@BoykoAlex Seems that the intelliJ LSP plugin is back under active development. Do you think you can make the STS idea plugin buildable as gradle idea plugin module, so that we can get more contributions from contributors like me :). I'm mainly interested in this since i'm looking for using Idea Community Version for some development and lack of spring supports keep me back. But if we have this it will be a feature complete transition.

thekalinga commented 5 years ago

@gayanper Sorry for the plug. Not sure if this can alleviate your pain in the interim. But you can use my plugin just for auto completion of spring boot yml files (which is the biggest pain in community edition)

https://plugins.jetbrains.com/plugin/10229-spring-assistant

BoykoAlex commented 5 years ago

@gayanper I got stuck with IntelliJ plugin in the infrastructure... I followed my own instructions and placed the new LSP plugin in my target, but now somehow my lsp integration plugin doesn't start and I don't know why... Once that "infrastructure" problem is resolved it should be rather easy to add Boot properties support. The next thing would be check if the client send "initialized" message that our Boot LS server expects to start finding projects for documents.

I cannot get to this work item at the moment, but if you'd like to help I'll try to guide you through the process. The first thing would be to get around the issue I'm stuck with: place the new ImntelliJ LSP plugin in the target and try to launch Boot java plugin with it. At least the plugin should be started and then we can start making fixes to make it work again.

gayanper commented 5 years ago

@BoykoAlex any reason for using scala for this ? are you ok if we change it to pure java if it is possible.

BoykoAlex commented 5 years ago

The intellij client is in Scala... it's fine if you just write in Java

gayanper commented 5 years ago

@BoykoAlex If i get the lang server up and running within IDEA will the default LSP symbol view show me the spring language server symbols ? In eclipse i think spring has written a separate symbol dialog.

BoykoAlex commented 5 years ago

Yes, it should show the symbols... At least it did when it was working. It is stated here (https://github.com/gtache/intellij-lsp) "Use Goto file/class/symbol (Ctrl(+Shift+Alt)+N by default)"

If you execute jps command in the console do you see the spring boot ls process running?

When i had the extension staring in IntelliJ (before i ran into this "infrastructure" problem with IntelliJ) I noticed that IntelliJ LSP client never sends the initialized notification https://microsoft.github.io/language-server-protocol/specification#initialized This notification is expected to get spring boot ls ProjectService activated. This service is essential to find projects for document URIs and hence get classpaths for projects, create java index etc.

Can you post instructions how to get the extension to start again please? For me it jsut doesn't start after i follow my instructions from the git repo page readme... Anything you did differently?

gayanper commented 5 years ago

https://github.com/gtache/intellij-lsp/issues/34

If you look at the and apply the last patch i have provided we should get the Initialized Message support and i'm happy to say that the idea plugin symbols works, But there are some NPEs here and there in the highlight handling.

Well it seems you don't need to copy the LSP to system plugins folder. Just extract the zip file to your /home//./system/plugins-sandbox/plugins and add the following files to your IntellijSDK

That is for just getting the compilation right by providing the required dependencies.

gayanper commented 5 years ago

This is the issue i told you about

java.lang.NullPointerException
    at org.spring.tools.boot.java.ls.StsLanguageClientImpl$$anon$1.run(StsLanguageClientImpl.scala:47)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
gayanper commented 5 years ago

I also had to remove the following two lines

        "-Xdebug",
        "-agentlib:jdwp=transport=dt_socket,server=y,address=7999,suspend=n",

from the org.spring.tools.boot.java.ls.BootJavaPreloadingActivity#preload method. Didn't investigate what is the real issue with trying to enabling the debug agent in startup.

BoykoAlex commented 5 years ago

NPEs for highlights are expected. The LS implementation has evolved and the message the client receives is different now. I'll reference VSCode client code: https://github.com/spring-projects/sts4/blob/master/vscode-extensions/commons-vscode/src/highlight-service.ts

In short the message format has changed and would need to be adopted by the IntelliJ client. Nevertheless, you should be able to have support for Boot properties fully working... The only thing is server definition registration for boot properties files.

gayanper commented 5 years ago

Did you mean

IntelliJ Client

is it the LSP Plugin or the STS plugin ?

BoykoAlex commented 5 years ago

I mean our IntelliJ plugin for Spring Boot. These need to be changed: https://github.com/spring-projects/sts4/blob/master/idea-extensions/idea-boot-java/src/org/spring/tools/boot/java/ls/HighlightParams.java https://github.com/spring-projects/sts4/blob/master/idea-extensions/idea-boot-java/src/org/spring/tools/boot/java/ls/StsLanguageClientImpl.scala

gayanper commented 5 years ago

@BoykoAlex Created a PR for highlights https://github.com/spring-projects/sts4/pull/216

gayanper commented 5 years ago

The https://plugins.jetbrains.com/plugin/10209-lsp-support/update/59353 1.5.4 version has supports Initialized message. So you can use that version to test this.

gayanper commented 5 years ago

@BoykoAlex have you had time to look at the PR ?

By the way how do think we should implement the code lens. Because Idea doesn't have code lens support i was thinking to implement it as tooltips on gutter icon. What do you think ?

gayanper commented 5 years ago

@BoykoAlex i think we can implement codelens using Idea InLays like below image What do you think ?

BoykoAlex commented 5 years ago

@gayanper Yes, inLays is the right idea. Thanks very much for the highlights PR!-)

When you'll be trying out CodeLenses try typing something fast in the file and check if those CodeLenses jump around a bit. It may happen because document version changes after every little change, yet CodeLenses received from the LS for each change not right away but with a delay. Therefore, hightlights/CodeLenses message often arrives for an already old document version in the case of quick typing. To fix that you'd need to look at the Document version from VersionedTextDocumentIdentifier. The highlights/CodeLens message has VersionedTextDocumentIdentifier already. The only thing to do is to change HighlightParams doc field and its getters and setters to VersionedTextDocumentIdentifier. Then you'd need to compare the versioned of the document from the message with the current doc version and ignore the highlight message if they are not equal. The interesting part of course is find out how to get current document version from the IntelliJ LSP client.

gayanper commented 5 years ago

Seems like the highlightings as the same problem when changing the code fast. So may be we could work on a solution which will solve both of the problems. I will check with the LSP Support Plugin author for the possibility.

gayanper commented 5 years ago

Seems like the same above problems can be seen in Eclipse as well :(

gayanper commented 5 years ago

application.properties and application.yml is provided by the same language server right ?

martinlippert commented 5 years ago

Yes

gayanper commented 5 years ago

Then i think we have another issue with completions in IDEA LSP Support plugin. I will check with the plugin author

gayanper commented 5 years ago

I have created serveral PRs for idea-extension, please have a look and provide your feedback if any @BoykoAlex https://github.com/spring-projects/sts4/pull/260 https://github.com/spring-projects/sts4/pull/261

gayanper commented 5 years ago

@martinlippert How can i enabled non spring boot app support and spring xml support in the language server i;m starting in this plugin, are they by default enabled ?

martinlippert commented 5 years ago

@gayanper The scanning of the XML bean config files is not enabled by default, you have to enable this via the preferences, as described here: https://github.com/spring-projects/sts4/wiki/Navigation#bean-definitions-from-spring-xml-config-files-new-in-411

BoykoAlex commented 5 years ago

@gayanper thank you very much for your PRs!-) I have merged them both!

BoykoAlex commented 5 years ago

@gayanper I'm thinking that maybe .idea folder that you have is worth pushing in the repo as well since it would probably make the dev environment setup for the intellij LSP spring-boot extension easier.

gayanper commented 5 years ago

@martinlippert How about getting the support for none spring boot apps, do i need to send some configurations for that as well through the DidChangeConfigurationParams message structure ? If so what is the preference that we should use ?

martinlippert commented 5 years ago

@gayanper The config to enable the symbol parsing for Spring XML config files is this: https://github.com/spring-projects/sts4/blob/e5fd15e66bf46b51bb219099b2de60fdab6d647f/vscode-extensions/vscode-spring-boot/package.json#L75

gayanper commented 5 years ago

@martinlippert Does this option controls for none spring boot apps as well ? Because currently idea extension i can get symbols for spring boot app but not for a none spring boot app.

martinlippert commented 5 years ago

This option controls whether the SymbolIndexer looks into XML config files or not while scanning for source files for Spring specific symbols. This was already opened up for non-boot Spring projects some time ago so also provide annotation-based symbols for regular Spring projects. Therefore there is no real limitation on Spring Boot projects anymore in the code base.

Not sure how things are working for the IDEA integration, but it should be opened up to let the language server be active for any kind of spring project, not just boot projects - I would say.

gayanper commented 5 years ago

@gayanper I'm thinking that maybe .idea folder that you have is worth pushing in the repo as well since it would probably make the dev environment setup for the intellij LSP spring-boot extension easier.

I didn't commit the .idea folder since it might contains environment specific data. But since now we have the gradle in place its easy setup the plugin. Now only need to create a server folder in the idea project root and copy the lang server jar with the same naming convention as before. Gradle will take care of copy it into the lib directory.

BoykoAlex commented 5 years ago

Aren't we missing the gradle wrapper file?