Open l0rd opened 5 years ago
cc @tsmaeder @tolusha
It looks like the project which was cloned after initializing jdt.ls workspace, isn't recognized as maven/gradel project. After reloading the browser tab or restarting jdt.ls (Clean the Java Language server workspace command), it works well. It is also reproducible in local theia instance: just need to start Theia with empty workspace folder and clone some java project.
So it looks like a concurrency problem: if the project takes time to be cloned, and JDT LS in the meantime get started, the project won't be indexed correctly. A possible solution would be to guarantee that a LS is started only once the cloning operation has completed: @evidolob @benoitf what's your opinion?
From my point of view, JDT LS should assume that project might not be ready when it starts and try to initialize it later
@l0rd I think the LS is receiving multiple events. I'm unsure that it's possible to wait clone before sending events. All is asynchronous so you could have multiple clones over the lifecycle and you may have finished to clone a project before cloning a new one so it's better to work totally asynchronously.
@benoitf @l0rd this is really the expected behaviour: many language servers (jdt.ls being one) will not pick up on new projects being created in the workspace root (in our case: /projects). The user is expected to reopen the folder or "add folder to workspace". Expecting the language servers to pick this case up consistently is going to be a losing battle, IMO. We currently have some kind of franken-UI: we still have the "Open Folder" menu, but we really expect projects to be in /projects and changes there to be picked up automatically. I think there are a couple of things we could do:
Alternative would be to treat each folder in /projects as a workspace root. When detecting a new folder, we would notify the IDE that a new root has been added. But:
@tsmaeder I don't want to clone the git repo before the IDE is started because that means that the start of a workspace may take even more. What about restarting Theia (just restarting the pod or restarting the node app) once the cloning is done?
We don't need to restart the pod or back end, a reload of the window is sufficient (reopen the /projects folder programmatically, even).
Please test https://github.com/eclipse/eclipse.jdt.ls/pull/901, ask @snjeza for details
We've done some experiments, and the verdict is mixed: the following language servers pick up new projects: PHP, Go, Typescript the following do not: Java, Python, C#
The picture is evenly split, I don't think we can expect language servers to pick up changes in general. That means we'll have to restart the language servers, which usually is done by doing a reload of the front end (which will trigger new copies of the back end plugins)
@tsmaeder Java, with @snjeza fix, is now is picking up the new projects. But we still have Python and C# that do not behave as we would expect. So we should decide if, having an automatic refresh when one of these 2 LS is enabled, should be considered mandatory or not for Che 7 GA right?
@l0rd jdt.ls does not detect this: there is a long-standing PR, but it would need some serious attention and testing before it can be merged. And as I argued above, it's not a solution for any other language servers out there. I would be strongly opposed to any solution that involves knowledge of a particular language server: we need to get away from the assumption that we know the set of plugins that are running on Che. So if we do a refresh, we need to do it for every type of project.
@tsmaeder what's your proposal to mitigate the problem for Che 7.0.0?
As we fix https://github.com/eclipse/che/issues/13784, I would replace the "confusing" actionable notification that says something like: "Some tools will not detect newly detect cloned projects: would you like to refresh the IDE?" I don't see that as mitigation to be fixed later, but as the right thing to do, as I've argued in a mail to the che-dev mailing list.
@fbricon @tsmaeder @tolusha @svor @l0rd I have updated: https://github.com/eclipse/eclipse.jdt.ls/pull/901 and https://github.com/redhat-developer/vscode-java/pull/746
"Some tools will not detect newly detect cloned projects: would you like to refresh the IDE?"
You can use the "Detect and import Java projects" command.
No, I cannot, because it won't work for anything other than Java. Let's stop thinking like a product and start thinking like a platform. @snjeza I greatly applaud your efforts to make this happen in jdt.ls, but it won't change anything for python, c# and other language servers. The fact that the git plugin explicitly wants to add newly cloned stuff to the VS Code workspace is another indicator to me that we need to accept the fact that language servers not picking up new stuff is not a bug, but to be expected and dealt with.
@tsmaeder @snjeza I've tested it on the next way:
Now
on the windoe with text: A new file was added. Do you want to import projects?
Verdict: After some time all projects were detected and imported but there was no information about the process of importing and it was hard to understand that jdt.ls was working and importing dependencies.
@svor I see the Java LS progress messages ( Importing Maven Projects, Building workspace ...) when testing in VS Code or theia. Will check in minishift.
Since this is the last blocker I wanted to do a write up explaining everything I’ve found so far:
First, I’m not sure if the issue has disappeared as a result of some other fix or if there’s another issue that’s the problem such as internet speed etc because I cannot reproduce on 7.0.0 rc 5 with latest che-theia using the devfile given. However, I can reproduce the issue by changing the devfile to clone no projects and then running > git clone https://github.com/spring-projects/spring-petclinic
in the command palette when theia is loaded.
But in an attempt to switch to multi root workspaces to mitigate this in the future, with the multi root workspace code Thomas gave me [1] there seems to be a race condition between when the git clone happens and when the java language server registers the workspace/didUpdateWorkspaceFolders with the client. It seems to me that if a project is finished cloning before the java language server sends client/registerCapability with workspace/didUpdateWorkspaceFolders to the client then the client doesn’t actually send the changed folder to the java language server. I believe this is the reason why cloning a small java project such as the https://github.com/che-samples/console-java-simple will get a classpath issue with these new code changes. However, if you are trying to clone a larger java project, such as https://github.com/angelozerr/lsp4xml it does not seem to be the case and you won’t get the classpath issue.
I believe this issue is caused because che-7.0.0 theia branch does not have the vscode activation events implemented and thus vscode-java is getting started on workspace start which is then starting the java language server, rather than vscode-java waiting to start by using the activation events defined in the plugin. My thoughts are that if activation events were working the java language server would not start eagerly. Then we can trigger the cloning of all projects and then update the workspace root. Then and only then, the language server initialization would start (because the activation events would be triggered), rather than it starting eagerly like it does now. If all the projects are cloned before the server is started then the workspaceFolders in initialialization will be sent correctly to the server and then all will proceed as expected. Additionally, if any projects are cloned after this, the client would then send a workspace/updateWorkspaceFolders event and the language server will handle the new folder. I believe this should resolve the race condition.
Just from quickly inspecting a few of the vscode language plugins supported in Che, it seems like they have reasonable activation events such as activating when a language (such as python) is selected, or activating on command, workspace contains etc.
I’d like to know what other peoples opinions are on this.
[1] - https://github.com/JPinkney/che-theia/commits/workspace_roots_che
@JPinkney Is there a branch where the activation events are implemented?
@JPinkney @tsmaeder I have tested with Che nightly and the stack "Java with SpringBoot and MySQL" and I am not able to reproduce this issue anymore.
@rhopp can you verify if this issue is still reproduced in the Che 7 happy path scenario?
@l0rd Will do that today.
Hello,
I've just tested the changes with some of the stacks. I tried to test as many language servers as I could and here are the result with the code changes:
👍 - means that validation, hover, document symbols, auto completion are working for the stack
Stack | Working or Problems/Comments |
---|---|
Java Maven | We believe this has a race condition. Investigating whether the race is in languageserver-node library or jdt ls |
Python | 👍 |
.NET Core | Nothing is working |
Go | 👍 |
NodeJS Express Web Application | 👍 |
PHP | validation and auto completion are working. Document symbols and hover were not |
Stacks were tested by adding a reference to a meta.yaml:
- type: cheEditor
reference: >-
https://gist.githubusercontent.com/JPinkney/fd653195c71604e3b3002e46393b0f18/raw/a06f2f9d762f37138de18919365ea915e2020bb6/reference.yaml
into the devfile.
The meta.yaml references a test image called jpinkney/che-theia-test11:latest which is just the resulting image of building the che-theia theia dockerfile with these changes
We're running into https://github.com/eclipse/eclipse.jdt.ls/issues/1148
@JPinkney what were you steps to test the language servers? How did you create workspaces, projects, etc?
Timing issue is well known: https://github.com/microsoft/vscode-languageserver-node/issues/451
Based on length conversations today, this isn't ready for 7.0. Will aim for 7.1 but might be 7.2 depending on delivery of upstream requirements.
@nickboldt @rhopp @slemeur does it mean that this is not considered a blocker anymore (we are ok to release 7.0.0 even if the issue is still here) or that the issue described above is not reproducible anymore (we keep it open just to track the work on multi-root workspaces)?
@rhopp @dmytro-ndp @eclipse/eclipse-che-qa are you still able to reproduce this issue?
@l0rd: we didn't encounter that issue in Happy path tests since Che 7.0.0.GA.
@rhopp @dmytro-ndp @eclipse/eclipse-che-qa @l0rd I guess we can close that issue and do not merge https://github.com/eclipse/che-theia/pull/412
I have tested on che.openshift.io but not able to reproduce there neither. Closing.
We still want to move to a system that manages workspace roots: language servers are not certain to pick up new projects in a root folder.
@tsmaeder it looks like you are talking about a different issue. This one is about Java LS "Classpath is incomplete".
We need to wait for a new release of vscode-languageserver-node and a rebuild of vscode-java in order to proceed with moving to a multi-root based che workspace
Reactivating: I suspect with the later activation of the plugins, our use cases should work. Retest and move towards a merge: However: need to collect feedback from dev team about readiness for multi-root workspace.
Blocked until tasks work with multi-root.
Issues go stale after 180
days of inactivity. lifecycle/stale
issues rot after an additional 7
days of inactivity and eventually close.
Mark the issue as fresh with /remove-lifecycle stale
in a new comment.
If this issue is safe to close now please do so.
Moderators: Add lifecycle/frozen
label to avoid stale mode.
Blocked until tasks work with multi-root.
This is no longer the case right? I think we should be unblocked now cc @tsmaeder
This should be fixed.
Description
After I have created a workspace using the following devfile
a classpath incomplete warning is shown every time a Java file is opened:
Reproduction Steps
Start a workspace using this devfile:
OS and version:
macOS / minikube / nightly che-server / chectl / helm / jtd ls 0.45.0