Closed ferranmarlet closed 1 year ago
You'll need some sort of gradle or maven configuration that sets up the dependencies accordingly.
I couldn't make it work, but I think that it is because I'm struggling to set up gadle dependencies correctly in a very large project. I think that If I cannot fix that by tomorrow, I will close the issue.
Thank you for taking your time to look into this.
I'm closing the issue, and I will keep trying to fix my gradle setup whenever I can. Thank you for the guidance :)
For anyone else, I got the same error but wasn't using multi-modules. Purging the project-specific workspace
directory (the one passed to the jdtls java
command via the -data
argument) made the error go away.
Just expanding on how I think it came about, I got some "import ... cannot be resolved" errors reported by JDTLS on my code the very first time I opened a JAVA file up in a freshly checked-out GIT project that I never built before (so the JAR dependencies weren't downloaded by maven yet).
Then I built the project and reopened the JAVA source in neovim and could still see the "import ... cannot be resolved" error . Snooping the LspLog I saw this error, and purging the workspace directory made it go away and also made the falsely reported "import ... cannot be resolved" errors go away too.
I'm using the AstroNvim JAVA pack (which uses the wonderful JDTLS) without modification.
LSP client configuration
First, thank you very much to anyone looking into this :bow:
Eclipse.jdt.ls version
No response
Steps to Reproduce
JDTLS works as expected in my system (Ubuntu 22.04), I installed the snapshot jdt-language-server-1.22.0-202303170534, and if I run
LspInfo
I see:Which I think is correct, and it works on several simple projects I have tried. But in some projects fails to fins certain classes, maybe due the project and package structure.
In a project using gradle 7.5.1 that has the following directory structure:
Where ClassA, ClassB and ClassC belong to the same package, let's say that all of them start with:
And then, try to use one class inside another, for example in ClassA:
Expected Result
I expected to see no errors or warnings, and I expected autocompletion to work for ClassB methods.
Actual Result
I see a diagnostic that says:
Java: ClassB cannot be resolved to a type
. And completion for ClassB doesn't work.Also, if I try to run:
I get the error:
But all the information I found to fix the build path refers to the eclipse UI.
Also, in the LspLog I see lots of messages like:
This message is repeated several times, for every class in the project including another class in the same package but in a folder outside of the /application folder.
Nothing changes if I restart the Lsp or if I delete the project's jdtls workspace folder.
Thank you very much to anyone who took the time to read this far :pray: