Open ThatMG393 opened 1 year ago
JDT-LS is just a bundle within an Eclipse OSGi runtime, so it would be difficult to use from your project unless your project was also an OSGi bundle. What particular functionality are you trying to use ? You might be able to use https://github.com/eclipse-jdt/eclipse.jdt.core directly.
However, JDT-LS is really meant to be used through the language server protocol, and it's certainly possible to do so through LSP4J. Have a look at https://github.com/redhat-developer/eclipseide-jdtls (particularly https://github.com/redhat-developer/eclipseide-jdtls/blob/dba58ae15f53256c6f44f64f64ca987b14e4b8bc/com.redhat.eclipseide.jdtlsclient/src/com/redhat/eclipseide/jdtlsclient/InProcessJDTLSConnectionProvider.java#L38 ). If you started JDT-LS as a binary, you could create a connection to it and communicate that way.
I want to use JDTLS on my Android project
Are there any particular features of JDT-LS you want to use ? I think starting JDT-LS as a separate application (mentioned in my above comment) is worth trying.
@rgrunber This is the features I want to use:
Standalone Java files support
As-you-type reporting of syntax and compilation errors
Code completion
Javadoc hovers
Organize imports
Type search
Code actions (quick fixes, source actions & refactorings)
Code outline
Code folding
Code navigation
Code lens (references/implementations)
Code formatting (on-type/selection/file)
Code snippets
Highlights (semantic highlighting)
Semantic selection
Diagnostic tags
Call Hierarchy
Type Hierarchy
Starting JDTLS as a separate app means I need to package a Java Runtime inside the application, I want to make the application size small as possible. (If you meant the "InProcess" method, I'm already using that)
I don't think you need to package a separate Java Runtime as long as there is a JRE >= 11 on the Android target (is this the case?). JDT-LS should be able to run with any JRE >= 11 on the system.
@rgrunber I cannot run JDTLS as a separate application if I don't have the JRE installed (unless I packaged JDTLS as a library), also I have managed to make JDTLS connect but it throws me a lot of java.lang.reflect.InvocationTargetException
Are you including the entire product when you include it as a library ? It could be some issue with how everything is being packaged, but I can't tell from just the exception name.
@rgrunber When I package everything it still doesn't work because it cannot properly handle the Android App Packaging system so I just launched it as a separate application and connected it using STDIN and STDOUT. But when it connects it throws a lot of java.lang.reflect.InvocationTargetException
. It also return an empty "signature".
I want to use this in my Java project instead of starting it as a binary, I want to start it using LSP4J