New folders do not register in the jdt.ls workspace #10115#10893
New folders do not register in the jdt.ls workspace #10115#10893tsmaeder merged 1 commit intoeclipse-che:5730_java_ls_pocfrom
Conversation
|
Can one of the admins verify this patch? |
2 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
| <groupId>commons-io</groupId> | ||
| <artifactId>commons-io</artifactId> | ||
| </dependency> | ||
| <dependency> |
There was a problem hiding this comment.
- The formatting seems wrong here
- Why do we need annotation API?
There was a problem hiding this comment.
- I don't have those tabs in my code... Looks like they were there for some time, but after I fixed them locally git ignores the fix. I'll try to fix
- Probably because of:
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
in PlainJavaProjectSourceFolderWatcher
| projectExplorer.waitAndSelectItem(PATH_TO_FILE); | ||
|
|
||
| // As FileTreeWalker's period is 10 secs - wait for the folders to be finally reported to jdt.ls | ||
| WaitUtils.sleepQuietly(11); |
There was a problem hiding this comment.
Isn't there a condition we can wait for?
There was a problem hiding this comment.
Right answer is yes, we're waiting for a condition but, during the test, the content of 'Move'-dialog's tree is not updated. This sleepQuitely() call allows all the required changes to happen before the dialog is invoked.
| * @param projectPath project path | ||
| * @return source folder locations | ||
| */ | ||
| public List<String> getAllSourceFoldersLocations(String projectPath) { |
There was a problem hiding this comment.
Source folders are package fragement roots, not package fragments. I dont' think the command you introduced does what you think it does.
There was a problem hiding this comment.
Should read as "every location in source folder"...
If we have a project tree like:
Project
+-- SourceFolder
+-- org.pack.age
+-- org.pack.house
With this method I'm going to get the list consisting of the following paths:
/projects/Project/SourceFolder/org/pack/age
/projects/Project/SourceFolder/org/pack/house
in order to make them accepted by FileWatcherByPathMatcher.
If I don't do this, any file/folder that is not created during the working session (any existing path of a project) is never being reported as Updated or Deleted and, as such, will never be refreshed on jdt.ls workspace. As result, every such path (package) deleted by user, despite of its deletions, will appear in Move-dialog as an existing package.
| return result.stream().map(LanguageServiceUtils::removePrefixUri).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
JavaLanguageServerExtensionService is made for communication with the browser. That's one reason why the methods are synchronous. This method here is NOT for that purpose, so should be somewhere else.
| private void setInitialPathsToWatch(String projectUri) { | ||
| List<String> sourceFolderLocations; | ||
| try { | ||
| sourceFolderLocations = extensionService.getAllSourceFoldersLocations(projectUri); |
There was a problem hiding this comment.
We should not use a synchronous call here, rather use the promise we get from "WorkspaceService.executeCommand()". Then we can get rid of the executor service.
| watcherIds.stream().forEach(id -> manager.unRegisterByMatcher(id)); | ||
| } | ||
|
|
||
| private void onServerInitialized(LanguageServerInitializedEvent event) { |
There was a problem hiding this comment.
No need to collect all language servers here. We only want to notify the java language server, and we can find that one by id.
There was a problem hiding this comment.
We don't need to listen to language server start events. There is supposed to be a way to just ask for a language server by id. No need to remember it here.
There was a problem hiding this comment.
It's done exactly the same way here:
https://github.com/eclipse/che/blob/master/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerFileWatcher.java#L82
If I won't wait for LS start, the obtaining of Java LS will be failed - not sure if it's a good trying to do anything with LS before it's started...
I don't know... Maybe I can use someow org.eclipse.che.api.languageserver.FindServer.byId(String) - but again - it could return null (if it is allowed t use it from che-plugin-java-plain-server)
| } | ||
|
|
||
| private void send(LanguageServer server, String path, FileChangeType changeType) { | ||
| RegisteredProject project = projectManager.getClosestOrNull(path); |
There was a problem hiding this comment.
Why is this check necessary?
There was a problem hiding this comment.
Not cleaned up code. sorry.
| } | ||
|
|
||
| private PathMatcher folderMatcher() { | ||
| return it -> isSourceFolder(it); |
There was a problem hiding this comment.
This is causing us to communicate with jdt.ls for every folder change in the file system. I think it would be more efficient to send every folder change to jdt.ls and let jdt.ls do the filtering.
Also, are we interested in every change or only in create/delete?
There was a problem hiding this comment.
Yes, you're right, I think we can reduce this check to just isDirectory(it) call. And we don't need to send Update as jdt.ls just ignores this event for folders.
ade6988 to
b6379dc
Compare
|
@tsmaeder I've re-implemented the fix based on your comments. Please review. |
b3033ac to
9d7bee0
Compare
b6379dc to
71d86a7
Compare
...ava/org/eclipse/che/plugin/java/plain/server/inject/PlainJavaProjectSourceFolderWatcher.java
Show resolved
Hide resolved
| watcherIds.stream().forEach(id -> manager.unRegisterByMatcher(id)); | ||
| } | ||
|
|
||
| private void onServerInitialized(LanguageServerInitializedEvent event) { |
There was a problem hiding this comment.
We don't need to listen to language server start events. There is supposed to be a way to just ask for a language server by id. No need to remember it here.
...ava/org/eclipse/che/plugin/java/plain/server/inject/PlainJavaProjectSourceFolderWatcher.java
Show resolved
Hide resolved
...ava/org/eclipse/che/plugin/java/plain/server/inject/PlainJavaProjectSourceFolderWatcher.java
Show resolved
Hide resolved
549b240 to
6c2d0b9
Compare
This adds the reporting creation/modification/deletion of source folders to jdt.ls Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
71d86a7 to
99bf160
Compare
|
@tsmaeder I've rebased and modified this PR - now it tries to find Java LS when it's needed by its ID (JavaModule.LS_ID) |
This adds the reporting creation/modification/deletion of source folders to jdt.ls
Signed-off-by: Victor Rubezhny vrubezhny@redhat.com
What does this PR do?
Fix adds a listener for changes inside source folders (Create/Update/Delete) in order to report them to jds.ls.
What issues does this PR fix or reference?
Fixes #10115
Depends on eclipse-che/che-ls-jdt#70
Depends on eclipse-jdtls/eclipse.jdt.ls#755
Release Notes
Docs PR