Set path for the invisible project
Hello,
I didn't find any documentation related to how/when an invisible project is created, is there any way to know or set the path of the invisible project or maybe skip the invisible project and just stick to the original project?
- Add a new file to the original project, the invisible project is not updated unless 'textDocument/didOpen' request is sent for that particular file, there is some kind of caching that needs invalidation.
- Add a library to the 'lib' folder of the original project, the invisible project is not updated unless it's recreated again by the language server after I delete it.
Thank you.
Workaround for this is to delete the folder **/.metadata/.plugins/org.eclipse.core.resources, the .classpath updates, and the invisible project is recreated automatically at the language server next launch.
Not an ideal solution though.
You can run Java: Clean the Java language server workspace and click Restart and delete. See Clean the workspace directory
I am not using Visual Studio Code :), trying to integrate Java Language Server with an IDE.
The communication with the Java Language Server is done through a client socket using Language Server Protocol requests.
I believe the general rule is if a project is not recognized as a Gradle, Maven, or an Eclipse project, then it will be imported as an "Invisible" project. This is essentially an Eclipse project with the underlying metadata hidden from users. This uses some basic assumptions about the location of source paths / libraries to produce a project that can be supported by the language support. We do have https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/plugin.xml#L111-L130 that allows extending supported projects.
Regarding the actions (add file, add library) that don't seem to update the project : Have you tried modifying java.project.sourcePaths, java.project.referencedLibraries and sending a didChangeConfiguration(..) with the new values ? See https://github.com/redhat-developer/vscode-java#supported-vs-code-settings . They're listed on vscode-java but the properties are supported in the language server.
I don't think we have any commands on the language server side that would clean out the workspace storage folder as requested by a client.
The hover now shows documentation after attaching the library sources to the .classpath of the original project, by inserting sourcepath into the classpathentry of the target library:
<classpathentry kind="lib" path="lib/gson-2.8.6.jar" sourcepath="lib/gson-2.8.6-sources.jar"/>
Requesting workspace/didChangeWorkspaceFolders on the project directory was key for the server to reload the .classpath file and recognize the changes accordingly.
I made several tests on changing configuration with workspace/didChangeConfiguration, java.project.sourcePaths, and java.project.referencedLibraries, and turned out that it has no effect. Though, I've received log messages from the server acknowledging the configuration changes.
Although this may work, I don't think this is the right approach. Generally the .classpath file should only be modified by the language server itself using calls from the client side. There's no guarantee any changes made directly to .classpath would persist.
If it helps at all, I took a simple project and added java.project.referencedLibraries = [ "lib/gson-2.8.6.jar" ] and looked at what the client/server interaction. I've trimmed out some unnecessary things but this is what I saw : https://pastebin.com/PpNTuuLG