What are features supported by idea-extensions/idea-boot-java ? And any planned development on this extension for future ?
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:
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.
So if i build and run the master branch i should be able to try these features out right ?
Ideally, yes, the extension should be functional. It was in the working state...
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 ?
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"
)))
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.
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
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...
@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.
@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)
@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 ?
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.
@BoykoAlex Also, is it possible to add a provision download the plugin directly from intellij instead of manual work on the part of developers?
@BoykoAlex any updates on the progress of this plugin ?
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.
@BoykoAlex Any new progress in this area ?
@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.
@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)
@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.
@BoykoAlex any reason for using scala for this ? are you ok if we change it to pure java if it is possible.
The intellij client is in Scala... it's fine if you just write in Java
@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.
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?
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/
That is for just getting the compilation right by providing the required dependencies.
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)
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.
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.
Did you mean
IntelliJ Client
is it the LSP Plugin or the STS plugin ?
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
@BoykoAlex Created a PR for highlights https://github.com/spring-projects/sts4/pull/216
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.
@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 ?
@BoykoAlex i think we can implement codelens using Idea InLays like below

What do you think ?
@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.
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.
Seems like the same above problems can be seen in Eclipse as well :(
application.properties and application.yml is provided by the same language server right ?
Yes
Then i think we have another issue with completions in IDEA LSP Support plugin. I will check with the plugin author
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
@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 ?
@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
@gayanper thank you very much for your PRs!-) I have merged them both!
@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.
@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 ?
@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
@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.
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 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.
Aren't we missing the gradle wrapper file?
@BoykoAlex yes sorry i have accidentally ignored it. Just add in the latest PR
@martinlippert Yes it seems that it works fine with non-springboot projects in vscode and eclipse. Can this be due to not passing any of the configurations into the language server in IDEA plugin ?
@gayanper The default value for the indexing of the Spring XML config files is "off", so you have to enable that via the configuration params to get that working. The indexing of the Spring annotations in non-boot projects should work out-of-the-box, there is no configuration option for that as far as I remember.
@BoykoAlex will you be able to check the latest code with the changes from last PR and see why the symbols are not analyzed for none spring boot app. I'm kind if lost here why the symbols are not shown.
@BoykoAlex and @martinlippert never mind its working, seems like its a IDEA LSP Client issue how the classpath is resolved in a multi module.
@martinlippert seems like the IDEA plugin doesn't send sts.java.addClasspathListener, seems like the language server some how picks the projects pom.xml as a fallback, is that how it is working ?
seems like the IDEA plugin doesn't send sts.java.addClasspathListener
That would make sense. This is something that has been implemented specifically for Eclipse and Vscode environments. In Eclipse it directly ties into Eclipse JDT. In vscode it works by contributing an extension to the redhat Java language server (which is also essentially Eclipse JDT).
It might be possible to implement something similar for IntelliJ... but I haven't got good ideas on how to do this. I would guess that there's nothing resembling the JDT language server around in IntelliJ.
language server some how picks the projects pom.xml as a fallback, is that how it is working ?
Correct. We do want to get away from this at some point. But for the time being probably its the only realistic option in IntelliJ to rely on this.
Yes, that is correct. It shouldn't send that message because there is no JDT LS running along side to provide the classpath nor there is support on the IntelliJ client to send this message. The message is an extension to LSP.
Therefore, the fallback mechanism is used which lives within spring boot LS. It runs maven to determine the classpath. See https://github.com/spring-projects/sts4/blob/master/headless-services/commons/commons-maven/src/main/java/org/springframework/ide/vscode/commons/maven/java/MavenProjectClasspath.java#L83
If you see highlights and code lenses I'd say classpath calculations is working... If it's about the non-boot spring projects XML not scanned then you need to send a config message to the server from the client... Examples:
https://github.com/spring-projects/sts4/blob/master/eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/DelegatingStreamConnectionProvider.java#L167
https://github.com/spring-projects/sts4/blob/master/atom-extensions/atom-spring-boot/lib/spring-boot-language-client.ts#L21
Every thing is working fine, there was a problem with the pom.xml pickup on intellij multi module project, i will investigate that, seems something related to how workspace to LS is defined in intellij plugin.
At the same time a ver y promising LS client implementation is going on called LSP4IntelliJ. https://github.com/NipunaRanasinghe/lsp4intellij
This is going to be backed by a well known OSS company WSO2. I'm gonna try to port this plugin to this inside my fork and see how well it work. Atleast we can get fixed approved in the lsp4intellij than the current plugin. :crossed_fingers:
@gayanper Its much better if the plugin is created using lsp4intellij as all developers will be able to contribute this plugin as its written completely in Java unlike the other library which is written in scala
@thekalinga yes i'm in the process of migration of this plugin to lsp4intellij. I will commit some working state after i have the symbol support from lsp4intellij on my private fork.
What are these methods defined in org.springframework.ide.vscode.commons.protocol.STS4LanguageClient. I mean the methods which take in JavaDataParams as parameters. Do they really need to implemented for the LS to work in non JDT environment ? what are their purpose ?
@martinlippert @BoykoAlex
@gayanper As you noticed Spring Boot LS requires quite a bit of "Java knowledge" such as search for type given fully qualified name, access getters/setters on a java type, javadoc for various Java artifacts etc.
At first we have implemented support for "Java knowledge" ourselves and use Jandex to index java classes:
The projects above is the result of that work.
Obviously, having support for Java indexing, search etc in the Spring Boot LS isn't ideal since this is the duplication of a Java LS extension features. Therefore, it'd be nice to get all java data either from JDT LS or simply JDT in the Eclipse case.
Later, we've discovered a way to communicate with JDT LS to fetch exactly the data we needed using JST LS extension plugins. The communication with JDT LS is done via the client. The messages sent to the client to get various java data are LSP extension messages and they are all in STS4LanguageClient interface (non-Java messages are: highlights, move cursor and progress. The rest are Java related)
There are 2 implementations for obtaining the Java data at the moment:
sts/addClasspathListener request succeeds. Otherwise 2. is used as a fallback.I believe in your case of IntelliJ extension the fallback implementation 2. is being used. It should work as most of our unit tests use the fallback implementation 2. Please double-check that you hit a breakpoint here https://github.com/spring-projects/sts4/blob/master/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguageServerParams.java#L120
However, it's desirable to switch to 1. for IntelliJ Boot extension. Therefore, ideally, we'd want to add support for all Java related messages from STS4LanguageClient in the IntelliJ extension's StsLanguageClientImpl class. It should be possible because all the Java data we'd like to have in Spring Boot LS is available in IntelliJ itself (its Java IDE plugin)
If you're to start working on switching IntelliJ to 1. let me know I'll post instructions and sequence what's best to do first and what later.
Great, i have converted the idea-plugin to java by integrating lsp4intellij LSP client library. I will send my work for you to review on my branch once lsp4intellij take all my PRs in and do a release. They we can start working on from their onward.
@BoykoAlex
I'm planning to start working on option 1 for Intellij. Do we have the documentation about it ? If we do this we can support for multiple modules in single project in idea as well like in eclipse right ?
I'd have to write the documentation. We didn't document our LSP extensions unfortunately. It is time to do so however. The documentation will appear on the wiki under STS LSP Extensions. I'll post here when it is completed.
Not sure about the second question, but I think it is reasonable to expect it to be on the same level as in Eclipse.
@gayanper I have added documentation for STS4 LSP Java message extensions: https://github.com/spring-projects/sts4/wiki/Java-Messages
There is still a part missing for Communication with JDT LS but it's irrelevant to IntelliJ's Spring Boot extension as you should be able to find all Java data with IntelliJ Java plugin. Let me know if anything is missing or needs clarification.
@BoykoAlex i started implementing the classpath listeners, i have few questions
Trying to answer question 1.
The output folder is where the compiled classes end up. So it would never be a folder that contains source code, even if the source code is technically generated and, from some point of view, might be thought of as 'output'. For a generated source folder, you should figure out where it's compiled classes end up (since I assume the classes will get compiled), and that would be the corresponding output folder of that source folder.
In Eclipse not all source folders have explicit output folders. A project may also have a 'default' output folder, and this is considered implicitly as the output folder for any source folders that don't have an explicit output folder.
I don't quite understand question 2, so can't answer it. Maybe Alex can.
@gayanper I'll try to answer the question 2.
Source - yes, Javadoc - not really as long as you implement the javadoc messages from STS4 protocol extension.
Is IDEA library correspond to Eclipse "container"?... For example your IDEA library is a JRE/JDK lib with a bunch of JRE jars (for java 1.8 at least)? If yes, then each JAR is a classpath entry. For JRE/JDK JAR you'd need to set system flag to true
@kdvolder and @BoykoAlex do i need the source and javadoc uris for libraries to start with ?
I think to get started on this you not necessarily need the source and javadoc. You can add source later and leave javadoc out even.
@BoykoAlex if implement add and remove classpath messages, do i also need to implement all other java messages as well ?
@gayanper Not right away. It'll work overall but some features won't work. Like javadoc for example that is used in boot properties hovers. For that to work you'd either need to add javadoc location for claspath or implement the javadoc message handling. The hyperlinks to java resources from hovers won't work, go to definiton for boot properties etc.
@BoykoAlex what should i set for TypeData.flags, is there any mapping to access modifiers to int values that STS LS understand ? How to represent public abstract ? Do i need to perform a BitWise operations like a binary bitwise OR to store multiple flags ?
@BoykoAlex is the
FieldData
declaringType: string; // Declaring type (in case of the current type being a nested type) binding key
is correct ?
@BoykoAlex Do we have any utility classes to convert FQN to JVMNames (typebindings) and vise versa. Because there seems to be no utilities to JVM name of Fields and Methods in IntelliJ :(
@gayanper
TypeData.flags. The flags should be standard for all IDEs i thought (since they seem to come from ASM). STS4 commons-java should be able to interpret that field: https://github.com/spring-projects/sts4/blob/master/headless-services/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/java/Flags.javaFieldData.declaringType - copy/paste error. Should simply be the type in which the field is declared. Self-explanatory.@BoykoAlex perfect, thanks i will try to use them.
@BoykoAlex what do you think about implementing this plugin with kotlin ? Since idea recommend to use kotlin 馃檪
Great idea! Initially it was a mix of Scala and Java because the language client lib API was Scala and I'm familiar with Java but Kotlin is the right choice i think.
@BoykoAlex is the declaringType for
@gayanper JVMName (binding key)
@BoykoAlex @martinlippert It seems my IDEA implementation just take symboles from all LS instances i start to Properties, YAML and Java. So i get duplicate entries. How you have solved this in vscode implementation ?
How you have solved this in vscode implementation ?
I don't think we ever had that problem. The vscode client generally doesn't start more than one instance. So maybe that is why. Is the IDEA LSP client starting one instance for every file you open or something?
@kdvolder
I start a Lang server for each language id which are JAVA, PROPERTIES and YAML, can i start a single server with all those lang ids ? So when i open all file types, that is a java file, a properties file and a yaml file there are 3 lang servers running.
can i start a single server with all those lang ids ?
That's how its meant to work. And that's how it is in vscode and also in Eclipse. I don't know how the setup is in IDEA (i.e the mechanics of how language server is started there, when you open a file that it cares about) so I don't know if that's possible there. If it isn't... then that's a problem and something that should be adressed somehow.
@kdvolder Thanks for help, i fixed it :). Had to send a PR to the lsp4intellij to change how language id is handled which was done by myself few months back :).
@BoykoAlex does sts4 language server provide diagnostic messages for yaml or property files ? If so in which cases does it provide ?
@gayanper yes, it does. If you enter server.port=blah the value blah should be underlined as an error because the number value is expected not a string. Unknown property keys would be underlined as warnings with quick fix available to add new property key to additional metadata file.
@BoykoAlex what are the correct JSON configurations i should pass into language server to get xml support like content assist on spring configuration xml ? Does this support on fallback mode on the language server as well where i don't provide classpath entries ?
XML support is enabled-disabled via workspace/didChangeConfiguration messages. The contents of these messages have the JSON object with various settings. Usually client has settings UI where LS settings are contributed. Once settings on the client change the config changed message is sent. The config message is also sent once LS and client are initialized.
See org.springframework.ide.vscode.boot.app.BootJavaConfig for the details on the format of the configuration JSON.
Typical configuration message looks like:
{
"jsonrpc": "2.0",
"method": "workspace/didChangeConfiguration",
"params": {
"settings": {
"boot-java": {
"boot-hints": {
"on": true
},
"support-spring-xml-config": {
"content-assist": "true",
"scan-folders-globs": "**/src/main/**",
"hyperlinks": "true",
"on": true // <--- XML support on/off
},
"remote-apps": [],
"scan-java-test-sources": {
"on": false
},
"change-detection": {
"on": false
}
}
}
}
}
@BoykoAlex thanks, i tried it and seems that it requires the sts4 specific java messages to be implemented to support content assistance on xml
@gayanper Can you plz share what is pending w.r.t this new extension. May be others might be able help
Thanks!
@thekalinga You can see the changes here, this is kind of messed up branch which i do hackings, since i wanted to share the changes i just pushed the stuff. let me know if you are planning to contribute i can create the more cleaner branch to work with.
https://github.com/gayanper/sts4/tree/lsp4intellij/idea-extensions/idea-boot-java
I still believe the new idea LSP plugin which i use here is not live enough for this. Recently the activity of the plugin is really low. I was planning to create my own LSP plugin with the required changes to STS4 to start with. I'm open for volunteers who would like to work on it and keep it rolling without delays.
@BoykoAlex i have implemented java message in https://github.com/gayanper/sts4/tree/java-messages. But i still get
WARNING: Unsupported request method: sts/addClasspathListener
12:45:28.501 [pool-3-thread-1] ERROR o.s.i.v.b.jdt.ls.JdtLsProjectCache - Unexpected error registering classpath listener with JDT. Fallback classpath provider will be used instead.
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Unsupported request method: sts/addClasspathListener
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
at org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner.lambda$null$2(LanguageServerRunner.java:224)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
12:45:28.502 [pool-3-thread-1] ERROR o.s.i.v.c.l.u.SimpleLanguageServer -
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Unsupported request method: sts/addClasspathListener
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
at org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner.lambda$null$2(LanguageServerRunner.java:224)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The Spring Boot IntelliJ extension should support sts/addClasspathListener and sts/removeClasspathListener requests. See how this is done for VSCode: https://github.com/spring-projects/sts4/blob/master/vscode-extensions/commons-vscode/src/classpath.ts
The example closer to IntelliJ would be Eclipse's handling of these requests:
https://github.com/spring-projects/sts4/blob/master/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java#L396
Follow the code starting from the line above.
@BoykoAlex i added a debug point at my sts/addClasspathListener method implementation and i don't get a request into that. any reason for that ?
Where is the method implementation for sts/addClasspathListener?
I'd expect it to be on the IntelliJ side not the LS side...
As far as I understand Spring Boot LS sends sts/addClasspathListener request message successfully to the client. However the client on the IntelliJ side (extension of LSP client for IntelliJ) does not have a handler for the sts/addClasspathListener request and hence sends no response for the request. Therefore lsp4j blows up with org.eclipse.lsp4j.jsonrpc.ResponseErrorException
If I understand correctly you should investigate a bit how to extend IntelliJ LSP client to add handlers for custom request messages such as sts/addClasspathListener... should be doable... think I've added some handlers for highlight notification messages to the plugin in the past...
@BoykoAlex i have implemented the STS4LanguageClient. Here is my client file https://github.com/gayanper/sts4/blob/java-messages/idea-extensions/idea-boot-java/src/org/spring/tools/boot/java/ls/StsLanuageClient.java
@gayanper Hmm... i'm not really sure... I guess the handler for the sts/addClasspathListener is not invoked on the client side... is that correct? Not really sure why it wouldn't be invoked if it's true... Maybe lsp4j doesn't see that the handler method is annotated... Try adding @JsonRequest("sts/addClasspathListener") over the handler method perhaps... just a guess...
@BoykoAlex It was a error in how i have registired the method handlers. Now my method handlers are registered correctly. But now when the LS is started it hangs with the following messages.
21:44:30.975 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Starting LS
21:44:30.975 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Connected to parent using stdio
@BoykoAlex I got the LS started, it was a issue in the plugin. But now i get this error
21:18:14.201 [main] INFO o.s.i.v.b.a.BootLanguagServerBootApp - Starting BootLanguagServerBootApp on Dellbox with PID 9660 (/home/abc/Projects/sts/sts4/idea-extensions/idea-boot-java/build/idea-sandbox/plugins/idea-boot-java/lib/server/language-server.jar/BOOT-INF/classes started by abc in /home/abc/Projects/spring-boot/demo)
21:18:14.212 [main] INFO o.s.i.v.b.a.BootLanguagServerBootApp - No active profile set, falling back to default profiles: default
21:18:15.300 [main] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - added listener - now listeners registered: 1
21:18:15.856 [main] INFO o.s.i.v.boot.app.SpringSymbolIndex - project listener registered
21:18:17.243 [main] INFO o.s.i.v.b.a.BootLanguagServerBootApp - Started BootLanguagServerBootApp in 4.614 seconds (JVM running for 13.644)
21:18:17.245 [LanguageServerApp-lifecycle] INFO o.s.i.v.c.l.LanguageServerRunner - Server ready to start after 13647 ms
21:18:17.251 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Starting LS
21:18:17.251 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Connected to parent using stdio
21:18:17.539 [pool-3-thread-1] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Initializing
21:18:17.598 [pool-3-thread-1] INFO o.s.i.v.c.l.u.CompletionServerCapabilityRegistration - hasDynamicCompletionRegistration = false
21:18:17.601 [pool-3-thread-1] INFO o.s.i.v.c.l.u.CompletionServerCapabilityRegistration - Registering Completion Capability Statically
21:18:17.601 [pool-3-thread-1] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Returning server capabilities to client
21:18:17.951 [Simple-Language-Server main thread] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Initialization completed after 14353 ms
21:18:18.204 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - Project Created: /home/abc/Projects/spring-boot/demo/.idea/misc.xml
21:18:18.204 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - Classpath has 68 entries
21:18:18.204 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - listeners registered: 1
21:18:18.205 [Simple-Language-Server main thread] INFO o.s.i.v.b.j.l.JavaProjectsServiceWithFallback - Project created: /home/abc/Projects/spring-boot/demo/.idea/misc.xml
21:18:18.211 [Simple-Language-Server main thread] INFO o.s.i.v.boot.app.SpringSymbolIndex - project created event: demo
21:18:18.233 [Simple-Language-Server main thread] INFO o.s.i.v.b.j.u.SpringLiveHoverWatchdog - project created event: demo
21:18:18.246 [Simple-Language-Server main thread] INFO o.s.i.v.b.a.BootLanguageServerInitializer - A project changed demo, triggering reconcile on all project's open documents
21:18:26.585 [parallel-1] ERROR o.s.i.v.b.jdt.ls.JdtLsProjectCache - Unexpected error registering classpath listener with JDT. Fallback classpath provider will be used instead.
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 5000ms in 'ignoreThen' (and no fallback has been configured)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:288)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:273)
at reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:390)
at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:73)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
21:18:28.200 [parallel-1] ERROR o.s.i.v.c.l.u.SimpleLanguageServer -
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 5000ms in 'ignoreThen' (and no fallback has been configured)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:288)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:273)
at reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:390)
at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:73)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
21:18:28.871 [parallel-1] WARN o.s.i.v.b.j.l.JavaProjectsServiceWithFallback - JDT-based JavaProject service not available, will use fallback service
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 5000ms in 'ignoreThen' (and no fallback has been configured)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.handleTimeout(FluxTimeout.java:288)
at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.doTimeout(FluxTimeout.java:273)
at reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber.onNext(FluxTimeout.java:390)
at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:73)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
@gayanper
Actually that is encouraging, I think you are nearly there! Looks like classpath listener was actually registered and is already sending back some classpath data! (So I'd say its a major breakthrough :-).
I think perhaps however the 'addClasspathListener' message that was sent to register the listener... while it did seem to get processed... didn't actually send back a a response. (The server expects some type 'okay I added your listener' response back... and I think that's what is timing out).
I am guessing a litlle but this my reasoning:
@kdvolder It worked i had to return a new Object as the response, figured our after looking at the typescript implementation. Now there are no errors but no completions either for any of the configuration file types. Seems like the java messages are not getting called either or any indexing is not happening.
Can't give very precise pointers but maybe try to figure out if the SpringPropertyIndex is being created properly and if not... why not. Some of the classes involved in this (in the server) are:
org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexorg.springframework.ide.vscode.boot.metadata.SpringPropertiesIndexManagerorg.springframework.ide.vscode.boot.metadata.DefaultSpringPropertyIndexProviderI think indexes for properties are only created 'on demand'. So only when you open a .properties file. They are not created as a response to classpath events (the events are used however to clear cached property indexes so they get rebuilt next time).
If all is working then when you open a propreties or boot yaml file you should see some messages in server log like:
Indexing Spring Boot Properties for <name>
Indexing Spring Boot Properties for <name> DONE
Indexed <number> properties.
If you don't see this, then try to determine if the client is communicating properly with the server.
I think i had a issue in the code, i have commented out the send command of classpath message. After enabling it i get the same issue again, i will try to get a LSP release and commit my code into my fork branch, so may be one of you guys can try this out and see what going wrong
@kdvolder this is the log now, i fixed the error by running the classpath message command as a async operation to the addClasspath notification
public CompletableFuture<Object> addClasspathListener(ClasspathListenerParams params) {
return CompletableFuture.supplyAsync(() -> {
ClasspathListener classpathListener = ClasspathListener.from(params, getContext().getProject());
classpathListenerMap.put(params.getCallbackCommandId(), classpathListener);
classpathListener.register(getContext().getRequestManager());
return new Object();
});
}
But still no completions
22:21:10.126 [main] INFO o.s.i.v.b.a.BootLanguagServerBootApp - Started BootLanguagServerBootApp in 3.867 seconds (JVM running for 7.289)
22:21:10.152 [LanguageServerApp-lifecycle] INFO o.s.i.v.c.l.LanguageServerRunner - Server ready to start after 7314 ms
22:21:10.166 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Starting LS
22:21:10.166 [LanguageServerApp-lifecycle] INFO o.s.ide.vscode.commons.util.Log - Connected to parent using stdio
22:21:10.360 [pool-3-thread-1] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Initializing
22:21:10.396 [pool-3-thread-1] INFO o.s.i.v.c.l.u.CompletionServerCapabilityRegistration - hasDynamicCompletionRegistration = false
22:21:10.399 [pool-3-thread-1] INFO o.s.i.v.c.l.u.CompletionServerCapabilityRegistration - Registering Completion Capability Statically
22:21:10.399 [pool-3-thread-1] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Returning server capabilities to client
22:21:10.766 [Simple-Language-Server main thread] INFO o.s.i.v.c.l.u.SimpleLanguageServer - Initialization completed after 7929 ms
22:21:10.834 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - Project Created: /home/gayanper/Projects/spring-boot/demo/.idea/misc.xml
22:21:10.834 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - Classpath has 77 entries
22:21:10.836 [Simple-Language-Server main thread] INFO o.s.i.v.b.jdt.ls.JdtLsProjectCache - listeners registered: 1
22:21:10.836 [Simple-Language-Server main thread] INFO o.s.i.v.b.j.l.JavaProjectsServiceWithFallback - Project created: /home/gayanper/Projects/spring-boot/demo/.idea/misc.xml
22:21:10.837 [Simple-Language-Server main thread] INFO o.s.i.v.boot.app.SpringSymbolIndex - project created event: demo
22:21:10.843 [Simple-Language-Server main thread] INFO o.s.i.v.b.j.u.SpringLiveHoverWatchdog - project created event: demo
22:21:10.845 [Simple-Language-Server main thread] INFO o.s.i.v.b.a.BootLanguageServerInitializer - A project changed demo, triggering reconcile on all project's open documents
22:21:24.031 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:24.034 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:24.040 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:29.232 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:29.232 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:29.233 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:32.277 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:32.278 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:32.278 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:33.559 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:33.559 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:33.562 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:34.429 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:34.429 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:34.431 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:34.852 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:34.852 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:34.857 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:35.123 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:35.124 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:35.124 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:37.189 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:37.189 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:37.190 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:38.261 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:38.262 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:38.262 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:38.757 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:38.757 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:38.758 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:38.792 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:38.792 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:38.799 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:39.660 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:39.660 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:39.662 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:51.746 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:51.746 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:51.747 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:21:53.926 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:21:53.926 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:21:53.927 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:02.204 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:02.231 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:02.232 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:10.099 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:10.102 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:10.103 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:45.823 [Simple-Language-Server main thread] INFO o.s.i.v.c.l.u.SimpleTextDocumentService - Closed: file:///home/gayanper/Projects/spring-boot/demo/src/main/resources/application.properties
22:22:51.607 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:51.609 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:51.612 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:52.257 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:52.258 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:52.259 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:52.571 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:52.573 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:52.574 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:52.780 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:52.782 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:52.783 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
22:22:53.109 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
22:22:53.110 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Got 0 completions
22:22:53.116 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Completion handling terminated!
Okay... hmm... It seems like everything is in place. Completions are being requested, classpath data is received. File change events also seem to be sent.
Not sure why there are no completions. At this point I would have to start looking inside the language server and step the completion handling with a debugger / breakpoints to try and see where it going wrong.
One thing I do not see in your logs is the messages about indexing properties. These should have come.
When we are working with Eclipse we have our ways to set things up and attach debugger to language server, you may have to figure out some way to do this for your setup too, Or alternatively you could try and put more detailed logging statements inside of the completion handler.
A hunch.... maybe double-check somehow if document content types are correct. Since the boot language server handles multple types of files. It does care about the language-ids for documents. (I.e. completions for some place in a document depend on what type of stuff is in that particular document).
Mayne the client is not setting the correct language-ids and so the server does not think the file is a 'boot properties' file and so doesn't actually try to compute any completions.
This would explain why you not getting completions and why index is not being built (since there's no reason to build the index if the file is of the wrong type and doesn't need valdations or completions).
@gayanper I just added some extra logging to print language id. This might help you to check if it is set correctly in this commit: https://github.com/spring-projects/sts4/commit/a89e5a04dbd6f4b6d4b3274f6002748eccfd65c0
When working correctly it should print something like this:
11:57:42.521 [elastic-2] INFO o.s.i.v.c.l.c.VscodeCompletionEngineAdapter - Starting completion handling
11:57:42.521 [elastic-2] INFO o.s.i.v.c.l.c.CompositeLanguageServerComponents - languageId = LanguageId [spring-boot-properties]
The problem was the classpath entries, the file path were not sanitized. But i still have a problem with the indexing, seems like the typebinding i have made it not compatible. if there are any good souls who can help me out with that, may be this will be ready for prime time use. The code can be found here https://github.com/gayanper/sts4/tree/java-messages and the lsp4intellij releases can be found here https://github.com/ballerina-platform/lsp4intellij. Even though i'm using a local build version, the latest snapshot from ci builds should be fine as well.
It may take me sometime to setup the IntelliJ dev environment properly... Any hint on where to look for intelliJ LSP client snapshot builds?
Meanwhile, you may try perhaps to write some unit tests for type data you produce from intelliJ client. See https://github.com/spring-projects/sts4/blob/master/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons.test/src/org/springframework/tooling/ls/eclipse/commons/test/JavaLangugeClientTest.java
Tests use eclipse JDT to produce TypeData then serialize it to JSON and compare to expected JSON files content. Perhaps running tests against expected JSON files here would help to move this forward: https://github.com/spring-projects/sts4/tree/master/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons.test/java-data-json
You need to do the following changes in the build.gradle by going through the https://jitpack.io/#ballerina-platform/lsp4intellij/next-release-SNAPSHOT
And then change the
localPath '/opt/ideaIC-2019'
to point to your local intellij installation. So you don't need to download another as a gradle dependency to run the plugin.
Change the following dependency
compile 'org.wso2.lsp4intellij:lsp4intellij:8.0.1-SNAPSHOT'
to
compile 'org.wso2.lsp4intellij:lsp4intellij:next-release-0.93.0-g88258c4-1'
Copy the language server folder into idea-boot-java/server as language-server.jar so the final path should look like
idea-boot-java/server/language-server.jar
Hope these steps will get you the plugin up and running.
If you want to debug the server you can enable it from the
org.spring.tools.boot.java.ls.StsPreloadingActivity#preload by using the org.spring.tools.boot.java.ls.StsServiceDefinitionBuilder#enableDebugging on the builder.
@BoykoAlex were you able to try the my branch out ? How did the IntelliJ setup went ?
@gayanper couldn't set it up... I have created a symlink for my IntelliJ app folder at /opt/ideaIC-2019. Now gradle build complains:
A problem occurred configuring root project 'idea-boot-java'.
> /opt/ideaIC-2019/build.txt (No such file or directory)
I have built lsp4intellij distro and copied it under IntelliJ plugins folder. Now ideally if I'll be able to compile the extension and then launch it as runtime workbench it'd work.
I noticed that tests were failing when I attempted to build Boot LS. Is that expected?
@BoykoAlex strange the error your getting. Can you just provide the path of your intellij and try with adding a symlink ? What you mean by Boot LS tests ?
Lsp4intellij is just a library. It doesn't get loaded as a plugin. I mean it doesn't have functionality own its own. It is designed to work as a library.
@gayanper:
/opt/ideaIC-2019 to intellij app. However the layout of the intellij file/folder structure might be different as i'm on mac... i don't see build.txt file at all...lsp4intellij is a plugin and should live in the target platform (similar to Eclipse) against which the plugin code is compiled in IntelliJ... That's how i ran it before. Do you add it to the target somehow when you launch boot plugin as intellij plugin? Or how do you launch it?@gayanper If I remove the localpath '/opt-ideaIC-2019' then the build goes further to the next error (probably ok for mac not to point to specific intellij path). Current problem is it cannot find commons-java version 1.10 and the lsp4intellij lib even if i don't toch dependencies and repo urls...
@BoykoAlex
commons-java you can update from the spring repo to which is latest available. The lsp4intellij please try the wiki page of the project i mentioned in my previous comment. You can use the latest release and update the version to that
@gayanper think now everything compiles with gradle and in intellij IDE. How should i be launching it? As a plugin i assume? The project looks like a regular java project in the IDE not a plugin project... Any instructions on creating a launch config for the extension? Think I most struggled with this part all the time... If I am to launch it as IntelliJ plugin then I'd need to convert this project to plugin project somehow... correct?
@gayanper any chance you could push the idea-boot-java.iml file and perhaps the gradle file tweaks i had to do to properly find dependencies? It seems that the idea-boot-java.iml would contain stuff to get the project seen as a plugin in IntelliJ and would save time setting up the project for proper launch. I still cannot launch it...
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63085,suspend=y,server=n -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea -Didea.config.path=/Users/aboyko/Library/Caches/IntelliJIdea2018.1/plugins-sandbox/config -Didea.system.path=/Users/aboyko/Library/Caches/IntelliJIdea2018.1/plugins-sandbox/system -Didea.plugins.path=/Users/aboyko/Library/Caches/IntelliJIdea2018.1/plugins-sandbox/plugins -Didea.classpath.index.enabled=false -Didea.required.plugins.id=com.your.company.unique.plugin.id -Didea.smooth.progress=false -Dapple.laf.useScreenMenuBar=true -Dapple.awt.fileDialogForDirectories=true -javaagent:/Users/aboyko/Library/Caches/IntelliJIdea2018.1/groovyHotSwap/gragent.jar -javaagent:/Users/aboyko/Library/Caches/IntelliJIdea2018.1/captureAgent/debugger-agent.jar=file:/private/var/folders/ks/1ds4bg156ls0xbgcgxfdh2x80000gq/T/capture.props -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/log4j.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/jdom.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/trove4j.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/openapi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/util.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/extensions.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/bootstrap.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/idea_rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/idea.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar" com.intellij.idea.Main
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=250m; support was removed in 8.0
objc[9471]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java (0x1036454c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1037324e0). One of the two will be used. Which one is undefined.
Connected to the target VM, address: '127.0.0.1:63085', transport: 'socket'
Error: Could not find or load main class com.intellij.idea.Main
Disconnected from the target VM, address: '127.0.0.1:63085', transport: 'socket'
Process finished with exit code 1
@gayanper it finally launched but I don't see LS process started after opening boot properties or yaml files in their default editors and plain text editors... I have idea-boot-java/server/language-server.jar and i also added it in under modules dependencies settings just in case... Not sure why it's not started... I'll try to debug a bit the client side...
@BoykoAlex Do you get any error ? i mean the red dot in the status bar ?
@BoykoAlex by the way you should launch it using the gradle task called runIde in the gradle task list.
@gayanper thanks very much! I have successfully launched the extension.
I do get the completion proposals:

Do you open the boot properties and YAML files with plain text editor? I think it is important to open with plain text editor otherwise language features won't work...
Otherwise I saw some NPE in findType(...) in the log I'll investigate a bit where they come from...
The NPE for findType(...) coming from:
SEVERE: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
at org.wso2.lsp4intellij.client.languageserver.wrapper.MessageHandler.lambda$apply$0(MessageHandler.java:41)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor198.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.ide.vscode.commons.java.JavaUtils
at org.spring.tools.boot.java.ls.java.TypeProvider.processTypeInfo(TypeProvider.java:76)
at org.spring.tools.boot.java.ls.java.TypeProvider.lambda$typeDataFor$5(TypeProvider.java:71)
at com.intellij.openapi.application.ex.ApplicationUtil.lambda$tryRunReadAction$0(ApplicationUtil.java:20)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1106)
at com.intellij.openapi.application.ex.ApplicationUtil.tryRunReadAction(ApplicationUtil.java:25)
at com.intellij.openapi.application.ex.ApplicationUtil.tryRunReadAction(ApplicationUtil.java:20)
at org.spring.tools.boot.java.ls.java.TypeProvider.typeDataFor(TypeProvider.java:71)
at org.spring.tools.boot.java.ls.StsLanuageClient.javaType(StsLanuageClient.java:123)
... 16 more
In other words JavaUtils class from commons-java cannot be found for some reason... not sure about this one... maybe it needs to be added to the classpath explicitly... i.e. jar downloaded by the build and added to the classpath like it's done for Eclipse plugins. Are you getting the same exception or am I launching incorrectly again?
@BoykoAlex are using idea community or ultimate. In community there is no problem the editor you choose. Because we only look at the extensions not the language of the file.
CNFE might be because the dependencies are not copied to sandbox dir. Try running thr reimport gradle function in gradle tool window. It should update and make sure you have the commons-java as a dependency in your gradle file. May be the commons-java is not resolved. That might be the reason or the latest content has been changed.
@gayanper What was the initial problem? Wasn't it that proposals were always empty although classpath received was ok?
I think the CNFE in JavaUtils happens because of the slfj Logger static variable, class cannot be initialized. I copied JavaUtils into idea-boot-java extension source and replced the slf4j logger with IntelliJ logger and now I'm over CNFE to the next problem.
The next problem is NPE:
aused by: java.lang.NullPointerException
at org.spring.tools.boot.java.ls.java.TypeProvider.findCPE(TypeProvider.java:120)
at org.spring.tools.boot.java.ls.java.TypeProvider.processTypeInfo(TypeProvider.java:100)
at org.spring.tools.boot.java.ls.java.TypeProvider.lambda$typeDataFor$5(TypeProvider.java:70)
at com.intellij.openapi.application.ex.ApplicationUtil.lambda$tryRunReadAction$0(ApplicationUtil.java:20)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1106)
at com.intellij.openapi.application.ex.ApplicationUtil.tryRunReadAction(ApplicationUtil.java:25)
at com.intellij.openapi.application.ex.ApplicationUtil.tryRunReadAction(ApplicationUtil.java:20)
at org.spring.tools.boot.java.ls.java.TypeProvider.typeDataFor(TypeProvider.java:70)
at org.spring.tools.boot.java.ls.StsLanuageClient.javaType(StsLanuageClient.java:123)
... 16 more
How can i debug the client when launching via Gradle task?
@BoykoAlex yes this is the issue i also get. When you right click runIdea task you will get the option to run in debug mode in the gradle tool window.
If you you to debug the language server you can do it by enabling debug mode from my server definition builder. I have written the info on one of my previous comments.
@gayanper is the issue to look at: no completion proposals shown? I presume it only happens under some special circumstances, right (seems like it is working for me so far)? Or I saw that you were complaining that the indexing of spring properties wasn't working?
@gayanper I run ./gradlew runIde from the terminal. If I attempt to run via Gradle tooling in IntelliJ i get CNFE like this one: java.lang.NoClassDefFoundError: com/apple/eawt/OpenURIHandler when trying to open the project :-(
To run debug mode from command line try
gradle nameOfTask -Dorg.gradle.debug=true --no-daemon
The completions are now working, i solve the classpath issue which had a problem with the paths so that the language server was unable to identify if the project is a spring project. Now the index is building. The problem now i have is with xml configuration completions which uses the java messages i implemented.
@BoykoAlex how was it ? Did you got the client and server in debug mode ?
@gayanper Re: XML:
I've been trying this Spring project https://github.com/spring-projects/sts4/tree/master/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-xml-hyperlinks
XML beans file: src/main/webapp/WEB-INFspring/root-context.xml
Content assist in class attribute values not working (<bean id="simpleObj" class="^"></bean>). This is because there is yet another LSP extension message being used: sts/javaCodeComplete. The Java search was taking long and the results it was returning were for quite a lose search term... I believe implementation of the https://github.com/spring-projects/sts4/blob/master/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java#L531 is based on some lower level code completion and is simpler and faster (please correct if I'm wrong @martinlippert)
Content assist in bean ref attributes didn't work for me (<property name="simple" ref="^"></property>). There is an exception happening while indexing XML files: java.lang.RuntimeException: Duplicate key for values 1557330545000 and 1557330545000
I got around it while things are written to index but now it happens when the index is retrieved next time the project is opened. Investigating this now...
@BoykoAlex What do you meant by "This is because there is yet another LSP extension message being used: sts/javaCodeComplete. The Java search was taking long and the results it was returning were for quite a lose search term" ?
@gayanper Fixed the duplicate files in XML indexing: 1200bf2c8b34006bfc41bfc778d09a1e8fc6177f
I mean that the message sts/javaCodeComplete was introduced fairly recently to provide CA for java types in XML files. The reason for this new message was that the sts/javaSearchTypes wasn't good for it. Hope that makes more sense.
StsLanguageClient from idea-boot-java should have implementation for javaCodeComplete(JavaCodeCompleteParams params) then java type CA in XML would start working.
@BoykoAlex didn't you get a AIOBE from typebindings ? It was seems to be some bindings i have made was wrong pattern. Couldn't remember when i got it. May be property completion in beans in xml files
@gayanper Nope... don't think I saw any AIOBEs... It could be your specific test project having a type on the classpath for which incompatible type data is generated. Perhaps attach your project and I'll have a look at it.
@BoykoAlex
The exception is
java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:824)
at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:212)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
at org.springframework.ide.vscode.commons.languageserver.LanguageServerRunner.lambda$null$2(LanguageServerRunner.java:224)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1967)
at org.springframework.ide.vscode.commons.java.JavaUtils.typeBindingKeyToFqName(JavaUtils.java:127)
at org.springframework.ide.vscode.commons.jdtls.JdtLsIndex.toTypeFromDescriptor(JdtLsIndex.java:101)
at org.springframework.ide.vscode.commons.jdtls.JdtLsIndex.convertTypeDescriptors(JdtLsIndex.java:173)
at org.springframework.ide.vscode.commons.jdtls.JdtLsIndex.lambda$null$16(JdtLsIndex.java:198)
at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822)
... 14 common frames omitted
I did some fixes to run some of the actions inside IntelliJ read actions. So you can take the updates from my java-messages branch.
Sample project that i'm using. Try to complete the datasource properties you will get the above error.
demo.zip
@BoykoAlex have had time to check the issue and sample code i mentioned above ?
I'm not getting StringIndexOutOfBoundsException... what property prefix do you have exactly? What do you have typed before invoking CA?
I'm only getting these warnings when i have spring.datas^:
2019-09-10 14:52:06,496 [ 497728] WARN - p4intellij.utils.DocumentUtils - LSPPOS outofbounds : Position [
line = 1
character = 36
] line : spring.datasource.tomcat.data-source column : 36 offset : 66
2019-09-10 14:52:09,855 [ 501087] WARN - p4intellij.utils.DocumentUtils - LSPPOS outofbounds : Position [
line = 1
character = 13
] line : spring.dataso column : 13 offset : 43
2019-09-10 14:52:09,856 [ 501088] WARN - p4intellij.utils.DocumentUtils - LSPPOS outofbounds : Position [
line = 1
character = 13
] line : spring.dataso column : 13 offset : 43
Also i was getting NPE's in TypeProvider on the client side around getting CPE and sometimes PsiClass is null. I made the LS side to check if CPE is not null (not pushed, just local). This got me over numerous NPEs occurring during CA computations.
@BoykoAlex
tried the property CA without a prefix. I'm not sure what exactly causing the NPE. But if you get the class name, try to see if you can open that class from Open Type popup.
@gayanper I put some logging at places that causing NPEs for me. Here are some log outputs:
Overall:
LibraryUtil.findLibraryByClass(psiClass.getQualifiedName(), psiClass.getProject()); returns nullLjava/lang/String[] are hust wrong to ask the type for.Therefore I think that :
null from TypeProvider#processTypeInfo(...) as for some bindings classes cannot be found - valid use case. IntelliJ open type doesn't find class so should we.Ljava/lang/String[])Still not a single StringIndexOutOfBoundsException
@BoykoAlex hope you have update the project sdk and module sdk in project/module settings. And SIOOBE i will recheck with latest ls server.
@BoykoAlex will you fix the current type resolving problems you mentioned ?
@gayanper
@BoykoAlex sure lets proceed like that. You put a PR to my fork let keep in java-messages branch until we stabilize it.
@gayanper I cannot create PRs against the fork... therefore i have created a patch that you could hopefully apply to your code base and out it in:
Patch for 2. + some changes to make it work on my machine:
0001-IntelliJ-client-adjustments.txt
@BoykoAlex i have added you permission to push to this fork https://github.com/gayanper/sts4/invitations
@BoykoAlex i will update the patch for now and sync the fork with the sts4 repo
@BoykoAlex I fixed the SIOB exception as well. Its was due to returning "" instead of null for classnames. Now when i open symbols i see 4 BasicDataSource beans instead of 2. Do you see the same in my sample demo project with latest Spring Boot LS ?
@BoykoAlex Seems like the XML symbol index is not updating when the file content is changed. Untile the LS is restarted the xml symbols are same as it was opened in the Symbol List. For java base configuration it is working as expected.
@gayanper listeners to XML files were not added properly. Fixed with: 63a5a7ecbb5687eb64300651a5a9b489faefacb3
Note that if you are trying that with IntelliJ client the file changes may not be sent from the client.
Depends if client:
workspace/didChangeWatchedFiles messagesclient/registerCapability message (dynamic registration)@gayanper I saw 4 BasicDataSource beans as well in IntelliJ... I've tried Eclipse and it is 2 only... Debugging shows only 2 in the symbols cache (Debugging Boot LS process working with eclipse client)... Try to debug the client then... start with the message and check how many you get with the workspace symbols message...
@BoykoAlex I actually fixed the datasource issue. It was a problem in how lspclient processed Symbols.
The file changes are submitted the the LS. Because for java files it work fine.
@BoykoAlex Seems still the xml file changes are not picking up. the ilsp4intellij sends the DidSaveTextDocumentParams message when the file is saved. This is the save way the java files are handled as well. But for java symbols there are getting updated but not the xml symbols.
If the lsp4intellij sends a DidChangeWatchedFilesParams message then the xml symbols are updated. But lsp4intellij has decided not to send this message for some reason. And i'm still thinking how it works for java files.
@BoykoAlex With the latest snapshot with your changes, it seems the java symbols are missing now and the content CA for xml files bean properties :(.
@BoykoAlex The Symbol index and java property CA in xml files seems to be broken by the last commit which is 63a5a7ecbb5687eb64300651a5a9b489faefacb3
@BoykoAlex i started a CI pipeline for this from my fork. i have done the required changes in the java-message branch so you can grab and have looked at the pimped buid.gradle. It also uses my own builds of lsp4intellij since i have done some fixes on it. until the official release is there with those fixes we can work with my builds.
I also recreated the java-messages branch. So you might need drop the branch and pull and checkout again.
@gayanper not sure why the fix for xml config file change didn't work for you... worked fine for me with Eclipse and IntelliJ. I have pushed a less radical fix hope it works for you too now.
The only difference from the original is file listeners added within the future that updates the scan folder globs.
One more thing. When you bring up IntelliJ open type dialog I pick "Symbols" tab and then type '*' in the search then i see the spring symbols. The bean i comment out disappears as it should. It worked for me the previous commit as well though. Did you verify that stepping back one commit makes everything work again?
@BoykoAlex the fix didn't work for xml because i had also a problem in lsp4intellij. I fixed it and now everything works.
I have mentioned the commit which stopped java symbols in my above comment https://github.com/spring-projects/sts4/issues/63#issuecomment-531470918
@gayanper sounds like I'm ok to go with commit 63a5a7ecbb5687eb64300651a5a9b489faefacb3. is that right?
@BoykoAlex the commit in my last comment had stop presenting java symbols. I normally open the xml file and list symbols i only see xml symbols. After opening a java file and list symbols i still only see symbols from xml. Sorry i was not clear in my previous comment
@gayanper I suspect that you server code wasn't up to date for a while and now it is. There are no java symbols indexed because foldersToScan(...) method returns empty list: https://github.com/spring-projects/sts4/blob/master/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerJava.java#L527
It is empty list because list of classpath entries is filtered to source folders that belong to the current project (might be source folders from a dependecy project which is present in the workspace). Determining whether a classpath entry is a "source" entry from the current project is based on the data in the CPE object.
Namely:
kind: string - either "binary" or "source"isOwn: boolean - 'true' if source folder belongs to the projectisJavaContent: boolean - 'true' if it is a source code folder rather than a resource folderThese should be rather easy to add support for in the the ClasspathListener i think (kind is there I believe, but the rest isn't)
It's also rather important to support these:
isTest: boolean - true for a test source folderisSystem: boolean - should be true for a JAR coming from JREAdd support for data above in the TypeProvider when CPE is created and Java symbols will show up.
@BoykoAlex thanks i will check on that. I think i might had a old server before, Thanks to my new CI setup now i can work with latest LS always.
@BoykoAlex So strange after re-importing my sample project into IDE every thing is working. What should we focus next before merging back to sts4 repo ? i mean how should i proceed with the contribution ?
@gayanper Create a PR, state the current state of things and will try to merge it.
Why are we based off lsp4intellij https://github.com/ballerina-platform/lsp4intellij rather than https://github.com/gtache/intellij-lsp? I suspect there were some fixes/features put into lsp4intellij that are missing in the original repo from which it was forked. Or is it only Java implementation vs Scala? Any chance lsp4intellij can be merged with the original intellij-lsp?
@BoykoAlex the original intellij-lsp had issues and it was not actively developed. So WSO2 decided to create a java version out of it with many fixes. I think this new lsp client is something we can count on since WSO2 will be using the same lib for their ballarina plugin in future for intellij.
@BoykoAlex i think time to time the addClasspath request fails. I have a project which i cannot share. But its works with eclipse but fails with idea plugin . The client even doesn't receive the request
@gayanper I might have seen something similar with IntelliJ client... You should see some messages and stack traces in the log when that happens and that fallback mechanism will be used... It felt to me that handler for the java-messages on the client side is registered after the messages are sent...
@BoykoAlex
I fixed some classapth entry issues, but still i don't get the complete list of properties for BasicDataSource in my sample project. i only get two properties, And i don't get any properties for beans that are define in the project it self either. Can you check what going on ?
@gayanper I'll have a look (tomorrow most likely)... Is is the same project you attached here previously?
@BoykoAlex yes it is the same project.
@gayanper To see boot properties defined in the project you'd have to add this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
(Maven example)
Don't forget @ConfigurationProperties over the class defining properties in the project.
Regarding data source properties... What do you need to type to see them?
I've tried datasource and got:

Also tried data and got:

Note that there is a maximum of 100 completion proposals that LS send while there could over 1000 completions available. This is done not to overload the connection with lots of data. If you type something more specific you'd see a 100 or less (if applicable) completions more specific to the prefix.
@BoykoAlex the boot properties are working. What's not working is the completions inside the xml files. You can try the sample xml bean file in my project. Also it will work some times but after restarting the IDE the xml completions just stop or only few are shown for some beans.
@gayanper All super types message handler on the client was missing support for includeFocusType parameter. I have added it with 21573d716833d8380ef2412fcd9563b54652d686 Should work now.
@BoykoAlex awesome its working now thanks alot. I will try to cleanup some more remaining things and create PR during next week, i also want to get the lsp4intellij change i did integrated as well. So then we can have a working sts4 mvp
@BoykoAlex Why the textDocument/definition returns a Either instead of the Location[] ? The specification says it can be a Location or Location[] or LocationLink in the latest specification. But the STS4 sends a Either with Location[]. Any reason for this change ?
And the uri of the definition has JDT as the protocol, any reason it is not file:// ?
@gayanper We are aware we should switch to LocationLink as it allows to properly underline the term for which definition is computed. There is a story for that: https://www.pivotaltracker.com/story/show/165911996. The reason for Location[] to be returned is this is from the previous version of the spec.
JDT url is retuned by Java LS or Eclipse which are both based on JDT. Therefore the URL able to navigate to Java artifact (method, class, etc) is that client understands.
Implement support for sts/javaLocation on the IntelliJ client side to return url appropriate to IntelliJ java tools. It might a file or jar protocol url...
@BoykoAlex the textDocument/definition returns a JsonRpc Either structure instead of Location[] :(
@BoykoAlex it returns Either because the spec supports sending both Location and LocationLink. It comes from LSP4J... There should be plenty of Either constructs on the server side.
We are going to switch to sending LocationLink[] in the Either in a short term... LocationLink only has highlight range property otherwise it is really the same Location. Support for both of these is almost identical...
@BoykoAlex seems like the LS is not calling my sts/javaLocation method, any reason for this ?
@BoykoAlex seems like the problem is here, i will try to simulate at VSCode and see how it works https://github.com/spring-projects/sts4/blob/0290842dfb68f8ec93197cef99946595ea20400c/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/BootLanguagServerBootApp.java#L147
@gayanper my impressions is that textDocument/definition message is never sent to the LS. If I open spring properties file hold Ctrl (or 'Cmd' on mac) key and hover over property key I don't hit the breakpoint here https://github.com/spring-projects/sts4/blob/sprotty/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java#L361
@BoykoAlex after simulation of vscode as i mentioned i got the javalocation message working. I didn't tried properties. But xml properties seems to work
@BoykoAlex can you check why the symbol labels are different than eclipse symbol labels. I have not appended the file name into labels, but some other information is also missing it seems from java files. any reason ?
@gayanper I've been trying to launch the intellij boot extension unsuccessfully today... Pulled the latest from java-messages branch, built and launched as usual. It fails to start the LS jar on my machine for some reason:
rawCommand : /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/bin/java -classpath /Users/aboyko/git/sts4/idea-extensions/idea-boot-java/build/idea-sandbox/plugins/idea-boot-java/lib/server/language-server.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/../lib/tools.jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=1044 -Dsts.lsp.client=vscode org.springframework.boot.loader.JarLauncher is not initialized after 60 seconds
I'll try again later... maybe it's something silly... there is nothing changed in that area in the IntelliJ extension land, right?
Which symbols specifically were you interested in? I was about to look at spring-petclinic project and compare symbols i get in IntelliJ and Eclipse... just plain compare of the label text i get in the symbols dialog.
@BoykoAlex seems like the debug is enabled. Can you removed enableDebugging from here https://github.com/gayanper/sts4/blob/f1170b347a112f722ebc72fbf2c281f3af61a090/idea-extensions/idea-boot-java/src/org/spring/tools/boot/java/ls/StsPreloadingActivity.java#L59
@BoykoAlex the symboles which are coming from java files seems to be different. For some of the symbols i only see the annotation name.
@gayanper Thanks! I had debug enabled and I wanted it to be enabled just forgot that suspend is on. Anyway, working now.
Symbols
They are cached in a file: ~/.sts4/.symbolCache. Either wipe out that folder to re-index them or in SymbolCacheOnDisc class on the Boot LS side make retrieve(...) return null for now such that symbols are always indexed at the startup - just will be easier to work with symbols indexing for now.
I dug into the indexing code and what seems to to be missing from the IntelliJ client classpath is tha JDK/JRE entries. The Boot LS creates ASTs for java files being indexed. Those ASTs are created but some (many) types are not resolved because classpath is incomplete. Therefore, the @Controller being annotated with @Component is missing the fact that it is annotated with @Component and hence doesn't show up in the symbols... I'm sure there are more cases not handled because of the incomplete classpath. Try getting the JRE/JDK classpath entries into the classpath and will what happens.
@BoykoAlex Its working as expected now :). But it seems it only works with java 8 JDKs or below where there are jar files int he classpath. For JDK9 and above it doesn't work, because the JDK files are just modules. How should be handled by Spring LS ?
@gayanper Java 9 and higher is supported... There is a "file system" jar for JDK 9 and above. Include that jar in the classpath entries and Boot LS should figure out modules from that jar.
The JAR is jrt-fs.jar
@BoykoAlex got it working thanks :+1:
@BoykoAlex do we have support for gradle projects as well ? Also please suggest me a good icon (modern) for symbols, i just added the old sts3 bean icon for now.
@gayanper i think so. Gradle support is implicit really. It comes either from the Java server or the client (JDT in Eclipse). The support is implicit because LS cares about the classpath only which is built by maven or gradle either by the client or Java server.
Regarding the icons... The old bean icons sound good to me... Don't think we have any new bean icons...
@BoykoAlex to show spring runtime info in documentation on hover over annotations, do i need to implement the javadoc java messages ?
@martinlippert @BoykoAlex any reason sts boot ls returns markdown text as plain text as part of hover response ?
@BoykoAlex i also don't get URL for beans and bean resource is hover content. Any reason for that ?
@gayanper
JavaServerSourceLinks. Ensure that support for sts/javadocHoverLink is there. You have to know what kind of URL IntelliJ supports as well... for VSCode and Theia it is the jdt url, for Eclipse it is some special javadoc url used in hovers... I have no idea what it is in IntelliJ@BoykoAlex i think now i have a most functionality done with spring ls support for language server. if i make a PR will there be resource from sts4 team to keep on maintaining it and releasing to intellij plugins site ? Otherwise i can actually start my own spin of a plugin with spring support for idea. What do you think ?
Any update on my above comment ? I was thinking to start up new project for idea boot ls support with adding some other features like the startup project creation support through idea project wizard. So i thought before doing that to check with you if you like to keep on supporting for idea as well like you do with other IDEs.
@gayanper My apologies for not replying to this earlier... We were thinking that the intelliJ integration would be purely managed by the community with some minor help from our side (review the code, merge PRs mostly).
Maybe @martinlippert has something to add but my understanding was it is a community thing...
Will you manage releasing and publishing to intellij plugin market place with new ls releases ? If you cannot commit to this thats fine as well since this depends on another 3rd party ls support which we cannot predict how fast we can get releases. I think then i will start my own spin with kotlin and may at some future point in time we can see again if we can merge. We can keep in touch about the progress
@gayanper we don't have any plans to release and publish the IntelliJ integration to the marketplace as an "officially provided" plugin for IntelliJ, but we would be happy to help you (and the wider community) to continue your work on this. So if you (or someone from the wider community) want to publish the IntelliJ integration to their marketplace, please feel free to do so.
I think it would be a good idea to distinguish more clearly between "officially" supported plugins that we provide (Eclipse, VSCode, Theia, maybe others in the future) and those that are provided and maintained by the community (like the IntelliJ integration that you worked on). This could involve to move the code into a separate community-driven repository. This repository could also serve as hub for people from the community who are interested in integrating the Spring language server tooling into other editors, IDEs, and environments.
What do you think?
I think i will start the intellij support as a separate repo since i can manage the lifecycle and releases without effecting the sts4 project. But if sts4 decide to support intellij at any point i would happily move the code to sts4 repo. What do you think about my suggestion ?
To support this development i guess you will keep on deploying LS artifact to current maven repo as it is right @martinlippert ?
If i start a project with Apache License 2.0 does it introduce any licensing issues if i package the spring language server inside the distribution of that plugin with STS4 licensing ? @martinlippert @BoykoAlex
To support this development i guess you will keep on deploying LS artifact to current maven repo as it is right @martinlippert ?
The plan is to publish the Spring Boot Language Server as a maven artifact, but we haven't done the full automation for that in the build process yet, so it might take a while before you can grab those dependencies from maven central.
If i start a project with Apache License 2.0 does it introduce any licensing issues if i package the spring language server inside the distribution of that plugin with STS4 licensing ? @martinlippert @BoykoAlex
I am not a lawyer and I cannot give you legal advice on licensing questions. Here is some advice from Apache how to deal with third-party code and licenses, maybe that helps: https://www.apache.org/legal/resolved.html
Its roughly ~2 years since this issue is raised. Will the intellij support ever see the light of day?
No spring tools will not support intellij IDE.
Not even language server integration?
No the main reason is IntelliJ doesn't support LSP. And IntelliJ Commercial version already have sprint tool support. I personally don't see that IntelliJ will add support for LSP at all.
As mentioned in https://github.com/spring-projects/sts4/issues/63#issuecomment-578641606 we do not officially ship support for IntelliJ, but support the community if there are volunteers who want to make this real. I think @gayanper spend quite some time on this and got very far ahead with this. @gayanper do you still plan to work on this and ship something as a plugin for IntelliJ as a community thing? Would love to see that. Let us know if there is anything that we can do to help with this.
@martinlippert yes i'm planning to release as a separate plugin. The problem that i have is the support that we will get from the https://github.com/ballerina-platform/lsp4intellij. I will start up a project in github and add the code that i have work so far into it.
@thekalinga A new project for Spring Tools is spawned up https://github.com/gayanper/idea-spring-tools. I will probably start a community around like a gitter channel. @BoykoAlex @martinlippert you all invited to provide feedback.
@gayanper This is awesome and great to see that all the work for an IntelliJ connection for the Spring Tools 4 language server now continues in that new place.
BUT: Please make sure to keep the copyright header in those files that you copied from this repository, this is an important legal requirement. I am not a lawyer (and this is not legal advice), but removing the copyright header of open-source files is (as far as I know) strictly prohibited. This is super important.
Also, please make sure to add the correct copyright headers to the files that you authored.
I have only one file from your original code which is the SpringBootGutterIconRenderer.java. It doesn't have a copyright header. other files i have not carried on to the new project. I had a unwanted file and i just removed it. What should i do about that file ? And my new project license is Apache 2.0. Your copyright is for EPL. How to handle that ?
@gayanper feel free to put the proper license header according to your new setup (Apache 2.0 license?).
@BoykoAlex do you suggest something like this
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* (the "License")
* which accompanies this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
@gayanper Don't think you need to keep Pivotal there at all... I think it should just be the same header you have in all other files - there is nothing special in that file and unlikely our intelliJ experiment will go any further. Thus that file is a candidate to be removed in the future from our repo. Therefore, I'd just add the same header as you have for other files unless @martinlippert objects?
@martinlippert Please let me know, i will wait till your feedback without applying the copyrights into the files.
@gayanper You are right, we indeed missed to add copyright headers to a few files, that was our mistake. Strictly speaking, having no copyright on the file means that copying and/or distributing that code is forbidden (and copying the file and adding your own copyright header would be even worse from the open-source-licensing point of view, as far as I understand, but again, I am not a lawyer and this is not legal advice).
To solve this mistake on our side and provide you with an easy and clean way to continue to re-use that code, I added an open-source-friendly license header to those files (in our repository), so those files are now available as open-source under the Apache 2 license... :-)
To move forward, you should grab a fresh copy of that file from our repo and re-use that in your project at your convenience.
Again, it is absolutely awesome that you take this integration for IntelliJ forward. If you need any help with this, let us know, always happy to help.
@martinlippert @BoykoAlex I copied the files headers for file that exist in my repo one to one matching from this repo. But there are few files which were scala in this repo but I rewrote them in java. So for those I might not need to use the same headers right? Please check the sources in my repo and if you have any concerns please let me know.
No concerns