-
Notifications
You must be signed in to change notification settings - Fork 408
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
Recognize new maven, gradle, eclipse project(s) after first init #901
Conversation
@@ -251,6 +251,9 @@ public void fileChanged(String uriString, CHANGE_TYPE changeType) { | |||
return; | |||
} | |||
IResource resource = JDTUtils.isFolder(uriString) ? JDTUtils.findFolder(uriString) : JDTUtils.findFile(uriString); | |||
if (resource == null && changeType == CHANGE_TYPE.CREATED) { |
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 believe it should be moved to the if (isBuildFile(..)
block, L283
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.
so this doesn't work if you want to create a new module within an existing maven structure
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 believe it should be moved to the if (isBuildFile(..) block, L283
We will not come to L283 if a resource is null
@@ -302,6 +305,26 @@ public void fileChanged(String uriString, CHANGE_TYPE changeType) { | |||
} | |||
} | |||
|
|||
private IResource refreshRootFolders(String uriString) { |
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 think automatic detection is probably not always safe (might break Che's use case, we'd need @tsmaeder, @svor or @tolusha 's feedback on that), or could be unreliable (here it doesn't detect a new pom under a parent project).
So at the very least, we should expose a new import command, users could call explicitly. che-jdt-ls might have something already they could contribute back.
If we do automatic project import, it should be enabled via a preference
Java: Refresh workspace?
'java.import.new.project.enabled', default: false ? |
Java: detect and import Java projects
java.import.newprojects: automatic/interactive/disabled |
@fbricon I have updated the PR. |
@snjeza please rebase against master |
@fbricon I have rebased the PR. |
@fbricon At this moment I can not test it on che side, we still depend on 0.5.0 version of lsp4j. So at first we need to solve eclipse-che/che#12262. |
We use a fixed version of jdt.ls in Che 6, so we should not be broken. Che 7 uses vscode-java anyway. So I think Che 6 should not block progress on this. |
I have updated the PR. I have tested in the following way:
You can also test in VS Code. |
test this please |
@@ -119,6 +119,13 @@ | |||
CREATED, CHANGED, DELETED | |||
}; | |||
|
|||
//@formatter:off | |||
private static final List<String> buildFiles = Arrays.asList( |
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 list of interesting build files should be provided by each project importer instance, as to minimize coupling with build systems here
* | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class ImportNewProjectsTest extends AbstractProjectsManagerBasedTest { |
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.
need to check a new build file added to a build directory of an existing project doesn't trigger project import (think test pom.xml processed during a build)
|
I'm thinking that do we need to add the configuration( IMO, I think just providing the import command to the users will be enough. Since the configuration may confuse the users in the following scenarios:
|
How is everything @snjeza 😃 Just would like to ask if you will continue working on this PR? And if you've already planned for other works, would you mind me to take over it? Thanks. |
No, go ahead. I have rebased the PR. |
@snjeza Oops... I found that I have no permission to update commits into your branch. |
Thank you @snjeza, I can update now. 😄 Let's first introduce the import project command to unblock the users. And please feel free to let me know if you have any concerns. // BTW, the permission of the vscode-client repo is needed as well. 😄 |
@@ -192,6 +213,8 @@ public void cleanupResources(IProject project) throws CoreException { | |||
File f = new File(cu.getUnderlyingResource().getLocationURI()); | |||
if (!f.exists()) { | |||
cu.delete(true, null); | |||
} else { | |||
JDTUtils.resolveCompilationUnit(f.toURI()); |
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.
@snjeza Do you remember why this line is needed?
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.
You can check the issue by adding che (https://github.com/eclipse/che) to a workspace.
try { | ||
importProjects(preferenceManager.getPreferences().getRootPaths(), monitor); | ||
} catch (OperationCanceledException e) { | ||
JavaLanguageServerPlugin.logInfo("Initialization has been cancelled."); |
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.
Importing projects job has been cancelled.
} catch (OperationCanceledException e) { | ||
JavaLanguageServerPlugin.logInfo("Initialization has been cancelled."); | ||
} catch (CoreException e) { | ||
JavaLanguageServerPlugin.logException("Initialization failed ", e); |
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.
Importing projects failed
Signed-off-by: Sheng Chen <[email protected]>
Signed-off-by: Sheng Chen <[email protected]>
@fbricon, ping... |
@fbricon, ping... |
test this please |
Signed-off-by: Sheng Chen <[email protected]>
When triggering the import command but there's no more projects to import, this is logged:
|
try { | ||
importProjects(preferenceManager.getPreferences().getRootPaths(), monitor); | ||
} catch (OperationCanceledException e) { | ||
JavaLanguageServerPlugin.logInfo("Importing projects job has been cancelled."); |
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.
return failed status
importProjects(preferenceManager.getPreferences().getRootPaths(), monitor); | ||
} catch (OperationCanceledException e) { | ||
JavaLanguageServerPlugin.logInfo("Importing projects job has been cancelled."); | ||
} catch (CoreException e) { |
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.
return failed status
} catch (CoreException e) { | ||
JavaLanguageServerPlugin.logException("Importing projects failed.", e); | ||
} | ||
return null; |
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.
return Status.OK_STATUS
Signed-off-by: Sheng Chen <[email protected]>
Fixes #144
Requires redhat-developer/vscode-java#746
Signed-off-by: Snjezana Peco [email protected]