eclipse-jdtls / eclipse.jdt.ls

Java language server
1.75k stars 390 forks source link

Library version of JDTLS? #2729

Open ThatMG393 opened 1 year ago

ThatMG393 commented 1 year ago

I want to use this in my Java project instead of starting it as a binary, I want to start it using LSP4J

rgrunber commented 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.

ThatMG393 commented 1 year ago

I want to use JDTLS on my Android project

rgrunber commented 1 year ago

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.

ThatMG393 commented 1 year ago

@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)

rgrunber commented 1 year ago

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.

ThatMG393 commented 1 year ago

@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

rgrunber commented 1 year ago

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.

list ``` ch.qos.logback.classic_1.2.12.jar ch.qos.logback.core_1.2.12.jar com.google.gson_2.10.1.v20230109-0753.jar com.google.guava_30.1.0.v20221112-0806.jar com.sun.jna_5.13.0.jar com.sun.jna.platform_5.13.0.jar jakarta.annotation-api_1.3.5.jar javax.inject_1.0.0.v20220405-0441.jar org.apache.ant_1.10.12.v20211102-1452.jar org.apache.aries.spifly.dynamic.bundle_1.3.6.jar org.apache.commons.cli_1.5.0.jar org.apache.commons.codec_1.14.0.v20221112-0806.jar org.apache.commons.lang3_3.1.0.v201403281430.jar org.apache.felix.scr_2.2.6.jar org.eclipse.ant.core_3.7.100.v20230617-1158.jar org.eclipse.buildship.compat_3.1.7.v20221108-1729-s.jar org.eclipse.buildship.core_3.1.7.v20221108-1729-s.jar org.eclipse.compare.core_3.8.100.v20230621-0939.jar org.eclipse.core.commands_3.11.0.v20230317-0802.jar org.eclipse.core.contenttype_3.9.100.v20230617-1158.jar org.eclipse.core.expressions_3.9.100.v20230617-1158.jar org.eclipse.core.filebuffers_3.8.100.v20230619-2026.jar org.eclipse.core.filesystem_1.10.100.v20230617-1158.jar org.eclipse.core.jobs_3.14.100.v20230622-0920.jar org.eclipse.core.net_1.5.100.v20230621-0939.jar org.eclipse.core.net.linux_1.0.200.v20220812-1406.jar org.eclipse.core.net.win32_1.1.100.v20230617-1158.jar org.eclipse.core.net.win32.x86_64_1.2.100.v20230617-1158.jar org.eclipse.core.resources_3.19.100.v20230622-0513.jar org.eclipse.core.runtime_3.28.0.v20230621-0752.jar org.eclipse.core.variables_3.6.100.v20230617-1345.jar org.eclipse.debug.core_3.21.100.v20230617-1345.jar org.eclipse.equinox.app_1.6.300.v20230614-1449.jar org.eclipse.equinox.common_3.18.100.v20230622-2056.jar org.eclipse.equinox.frameworkadmin_2.2.100.v20220817-1208.jar org.eclipse.equinox.frameworkadmin.equinox_1.2.400.v20230617-1417.jar org.eclipse.equinox.launcher_1.6.500.v20230622-2056.jar org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.700.v20221108-1024.jar org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.700.v20221108-1024.jar org.eclipse.equinox.launcher.win32.win32.x86_64_1.2.700.v20221108-1024.jar org.eclipse.equinox.preferences_3.10.300.v20230617-1305.jar org.eclipse.equinox.registry_3.11.300.v20230622-2056.jar org.eclipse.equinox.security_1.4.0.v20230616-1215.jar org.eclipse.equinox.security.linux_1.1.0.v20230616-1215.jar org.eclipse.equinox.security.macosx_1.102.0.v20230616-1215.jar org.eclipse.equinox.security.win32.x86_64_1.2.0.v20230616-1215.jar org.eclipse.equinox.simpleconfigurator_1.4.300.v20230609-1344.jar org.eclipse.equinox.simpleconfigurator.manipulator_2.2.100.v20221117-1044.jar org.eclipse.jdt.apt.core_3.8.0.v20230413-1556.jar org.eclipse.jdt.apt.pluggable.core_1.4.0.v20230323-1537.jar org.eclipse.jdt.core_3.35.0.v20230623-1427.jar org.eclipse.jdt.core.compiler.batch_3.35.0.v20230622-1425.jar org.eclipse.jdt.core.manipulation_1.19.100.v20230622-2106.jar org.eclipse.jdt.debug_3.21.100.v20230621-1113.jar org.eclipse.jdt.junit.core_3.12.0.v20230323-1830.jar org.eclipse.jdt.junit.runtime_3.7.100.v20230115-0919.jar org.eclipse.jdt.launching_3.20.100.v20230620-1522.jar org.eclipse.jdt.launching.macosx_3.6.0.v20230328-1614.jar org.eclipse.jdt.ls.core_1.26.0.202307061308.jar org.eclipse.jdt.ls.filesystem_1.26.0.202307061308.jar org.eclipse.jdt.ls.logback.appender_1.26.0.202307061308.jar org.eclipse.lsp4j_0.21.0.v20230517-2120.jar org.eclipse.lsp4j.jsonrpc_0.21.0.v20230517-2120.jar org.eclipse.ltk.core.refactoring_3.14.0.v20230323-1830.jar org.eclipse.m2e.apt.core_2.2.100.20230520-0934.jar org.eclipse.m2e.core_2.0.8.20230520-0934.jar org.eclipse.m2e.jdt_2.3.0.20230523-2033.jar org.eclipse.m2e.maven.runtime_3.9.100.20230519-1558.jar org.eclipse.m2e.workspace.cli_0.3.1.jar org.eclipse.osgi_3.18.500.v20230622-2056.jar org.eclipse.osgi.compatibility.state_1.2.800.v20221116-1440.jar org.eclipse.osgi.services_3.11.100.v20221006-1531.jar org.eclipse.text_3.13.0.v20230316-1200.jar org.eclipse.xtext.xbase.lib_2.30.0.v20230227-1111.jar org.gradle.toolingapi_7.4.2.v20220712-0930-s.jar org.hamcrest.core_1.3.0.v20180420-1519.jar org.junit_4.13.2.v20211018-1956.jar org.objectweb.asm_9.5.0.jar org.objectweb.asm.commons_9.5.0.jar org.objectweb.asm.tree_9.5.0.jar org.objectweb.asm.tree.analysis_9.5.0.jar org.objectweb.asm.util_9.5.0.jar org.osgi.service.cm_1.6.1.202109301733.jar org.osgi.service.component_1.5.1.202212101352.jar org.osgi.service.device_1.1.1.202109301733.jar org.osgi.service.event_1.4.1.202109301733.jar org.osgi.service.metatype_1.4.1.202109301733.jar org.osgi.service.prefs_1.1.2.202109301733.jar org.osgi.service.provisioning_1.2.0.201505202024.jar org.osgi.service.upnp_1.2.1.202109301733.jar org.osgi.service.useradmin_1.1.1.202109301733.jar org.osgi.service.wireadmin_1.0.2.202109301733.jar org.osgi.util.function_1.2.0.202109301733.jar org.osgi.util.promise_1.3.0.202212101352.jar org.slf4j.api_1.7.30.v20221112-0806.jar slf4j.api_2.0.7.jar slf4j.nop_2.0.7.jar ```
ThatMG393 commented 1 year ago

@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".