sts4 icon indicating copy to clipboard operation
sts4 copied to clipboard

code-insiders support for spring-boot with kotlin

Open cirix opened this issue 5 years ago • 14 comments

Hi guys, is there any view on making kotlin files that belong to a spring-boot application to be parsed and enhanced as you do with the .java files(run/debug support for import of java classes needed it). In general provide the same support the plugins have for intellij and spring-boot and kotlin to code?

kr Nik

cirix avatar Dec 08 '18 22:12 cirix

We briefly explored having STS4 Boot features for Kotlin files (i.e. workspace symbols, live boot hints etc.). It would require a good amount of time invested to get it done. Think the timeline for this to be implemented would depend on our current priorities and demand from the Spring community...

BoykoAlex avatar Dec 09 '18 16:12 BoykoAlex

Hey @cirix, I am not totally sure what you are asking for. Are you referring the general Kotlin coding support in STS4 (like compilation, content-assist, etc.) for those mixed projects, you would need to regular Kotlin plugin for Eclipse to be installed into STS4.

Or are you asking for the quick navigation support that we do for Spring Boot (go to symbol, for example) as well as the live hover to show runtime bean information? For that, I would like to second that @BoykoAlex mentioned. It would indeed be great to implement, but it is quite an effort.

Would love to hear from you what you meant and what you would love to see implemented first in this area (what is most important for you). Might help us to prioritize... :-)

martinlippert avatar Dec 09 '18 17:12 martinlippert

HI, currently when using vscode there are plugins from the team to manage classes with spring boot annotations. For example my class with @SpringBootApplication on code-insiders, allows me to run/debug the application with symbols. Also the spring-dashboard plugin from microsoft understand the spring-boot start applications. I am asking the same support if a spring boot is totally coded using kotlin. I would be willing to commit and help here, going throughout the code on the sts parts. I will try to give it a shoot.

cirix avatar Dec 16 '18 08:12 cirix

Hey @cirix, awesome to hear that you would be interested to taking a look at this, let us know if we can provide any help here. From my perspective, there are three different areas that you might want to take a look at (from what you describe):

  • the general launch/run support in VS Code: this is done as part of the Java Debug support extension for Visual Studio Code (also by Microsoft), so you might want to dive into the code for that here: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug + https://github.com/Microsoft/vscode-java-debug

  • the spring boot dashboard (with its run/launch support) would be the next part to look at for running your apps in VS Code: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-spring-boot-dashboard + https://github.com/Microsoft/vscode-spring-boot-dashboard

If you want to dive into the symbol extortion and navigation for Spring Boot (our analysis of the Spring annotations and the generated symbols for VSCode), this is a totally different beast. We do that by walking over the source files and by parsing them into real ASTs (using a full-blown Java parser) with type resolving. Doing that for Kotlin would mean to re-use something like a parser for Kotlin. @BoykoAlex did some experiments on this a while ago (as far as I remember), so he might be able to provide a few pointers. But it is not an easy thing to do.

But I totally agree, it would be super awesome to have all that for Kotlin boot apps...!!! Let me know if we can provide additional help. The people from Microsoft are also very helpful (if you start to tackle the run/launch support).

martinlippert avatar Dec 17 '18 09:12 martinlippert

Hi guys, sorry for reporting late, but my day time job takes it's tool on me :). I have already figured the above parts already by looking into the devel guide of plugins from @Microsoft. If the AST's are created with antlr and we have the grammar in g4 or any BNF then it should not be that hard. I will dive on the details this weekend. Thanks very much for the pointers.Chicken and the egg problem I will be developing on code-insiders +1 the plugin for it. I will update you on Monday 👍

cirix avatar Jan 11 '19 16:01 cirix

Any progress on this? Its the only thing keeping me from using vs-code full time (which their remote tools make a big win). Lack of kotlin completions + spring integration hurts

jeffzoch avatar Jun 13 '19 17:06 jeffzoch

I would also be interested, @cirix ... :-)

martinlippert avatar Jun 17 '19 12:06 martinlippert

Definite gap and need here. I will probably have to jettison use of vscode and move over to intellij to work with a batch of kotlin-boot apps we have going. Would be super interested in any progress here.

cdbyrd avatar Sep 13 '19 15:09 cdbyrd

Just linking this issue on the vscode-spring-boot-dashboard extension, which is related to this one.

Interest in improving kotlin support with spring boot in vscode is growing. Thanks to everyone who is investing time on this!

yairkukielka avatar Nov 29 '19 09:11 yairkukielka

I would also interested getting support for kotlin spring boot application support to STS4 language server. With this plugin in place https://plugins.jetbrains.com/plugin/14279-spring-tools we can have nice Spring tool experience for kotlin since IJ support kotlin out of the box and its THE tool for kotlin right now.

gayanper avatar Jun 16 '20 16:06 gayanper

@martinlippert if the plugin provides proper symbol info for the STS4 java messages protocol with kotlin files, will STS4 will be able to show live boot info and symbols ? What i'm thinking is since i have the intellij plugin which does classpath and source translation for java messages with all method, class details, if i process the kotlin files in the same way, will sts4 language server be able to process the application ?

gayanper avatar Sep 10 '20 18:09 gayanper

@gayanper The symbols and live hovers require the language server itself to parse the source code. This is what we do for the Java source files. The language server internally uses a Java parser implementation to convert the source file into an AST (with types resolved) and uses that AST to extract the symbols from as well as put the live hovers on the right positions.

Thinking about Kotlin support, this would require two things, I think:

  • the language server itself to be able to parse Kotlin source files. I think this could be implemented using the existing open-source Kotlin parser that the Kotlin language server uses internally (for example). This would also require a few refactorings inside of the language server to enable it for Kotlin source files and to turn the live hover implementation into something that could work with multiple languages at the same time (maybe in the same way I refactored the symbol infrastructure a while ago to be able to deal with different languages).
  • the client integration would need to be able to deliver the project information to the language server (the classpath of the project, etc.)

And we need to keep in mind that the support should be enabled and implemented for Eclipse and VSCode as well. This brings the Kotlin support for those environments into play. Extracting, for example, the classpath and project information for those Kotlin projects should interact nicely with those existing Kotlin support extensions and probably communicate with them to use the same information - much in the same way we do that for the Java case (extending Eclipse and the VSCode Java language server to communicate with us for this information).

So all in all, not a trivial task, but certainly possible. Just hasn't been done yet. If you are interested, we could try to tackle this by joining forces while moving forward.

martinlippert avatar Sep 11 '20 06:09 martinlippert

@martinlippert Is there a timeline for this improvement? How can we progress on this?

gmrizzo avatar Sep 26 '22 08:09 gmrizzo

@gusi1994 There is no timeline for this from the Spring Tools 4 perspective. However, when looking into this, it seems to me like the Kotlin Language Server and corresponding VSCode plugin already got support and some interoperability with the Java LS and the Java extension for VSCode, which seems to be a good basis.

If you would like to help here @gusi1994 , setting up a number of sample projects that you would like to see working in this environment would be great. First step would be to make sure and document somewhere how they work within VSCode with the Java and the Kotlin extensions installed. Next step would be identify the missing pieces that do not work from the Spring Tools perspective. WDYT?

martinlippert avatar Sep 27 '22 08:09 martinlippert