-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New folders do not register in the jdt.ls workspace #10115 #10893
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? |
@@ -38,6 +42,14 @@ | |||
<groupId>commons-io</groupId> | |||
<artifactId>commons-io</artifactId> | |||
</dependency> | |||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The formatting seems wrong here
- Why do we need annotation API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
@@ -90,6 +94,10 @@ public void checkMoveJavaClassInNewSourceFolder() { | |||
// move java file into new source folder | |||
projectExplorer.waitItem(PROJECT_NAME); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a condition we can wait for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -456,6 +457,20 @@ private ClasspathEntry fixEntry(ClasspathEntry e) { | |||
return result.stream().map(LanguageServiceUtils::removePrefixUri).collect(Collectors.toList()); | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
private void setInitialPathsToWatch(String projectUri) { | ||
List<String> sourceFolderLocations; | ||
try { | ||
sourceFolderLocations = extensionService.getAllSourceFoldersLocations(projectUri); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-implemented
watcherIds.stream().forEach(id -> manager.unRegisterByMatcher(id)); | ||
} | ||
|
||
private void onServerInitialized(LanguageServerInitializedEvent event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not cleaned up code. sorry.
} | ||
|
||
private PathMatcher folderMatcher() { | ||
return it -> isSourceFolder(it); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Outdated
Show resolved
Hide resolved
watcherIds.stream().forEach(id -> manager.unRegisterByMatcher(id)); | ||
} | ||
|
||
private void onServerInitialized(LanguageServerInitializedEvent event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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) |
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
Signed-off-by: Victor Rubezhny <[email protected]>
This adds the reporting creation/modification/deletion of source folders to jdt.ls
Signed-off-by: Victor Rubezhny [email protected]
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