Skip to content
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

add command to build workspace #326

Closed
wants to merge 9 commits into from
Closed

Conversation

ansyral
Copy link
Contributor

@ansyral ansyral commented Aug 14, 2017

Signed-off-by: xuzho [email protected]

@eclipse-ls-bot
Copy link

Can one of the admins verify this patch?

@ansyral
Copy link
Contributor Author

ansyral commented Aug 14, 2017

@ansyral ansyral closed this Aug 15, 2017
@ansyral ansyral reopened this Aug 15, 2017
@eclipse-ls-bot
Copy link

Can one of the admins verify this patch?

@ansyral
Copy link
Contributor Author

ansyral commented Aug 17, 2017

@fbricon @gorkem

@fbricon fbricon requested review from gorkem and snjeza August 17, 2017 06:46
Copy link
Contributor

@snjeza snjeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ansyral It works fine. Could you create a test?

@gorkem
Copy link
Contributor

gorkem commented Aug 17, 2017

Can you remind me, what is the reason for having this extension?

@ansyral
Copy link
Contributor Author

ansyral commented Aug 18, 2017

@gorkem , i opened an issue here

@ansyral
Copy link
Contributor Author

ansyral commented Aug 23, 2017

@snjeza , I added the tests.

@snjeza
Copy link
Contributor

snjeza commented Aug 23, 2017

@ansyral tests fail

Running org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.21 sec <<< FAILURE! - in org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest
testCanceledCase(org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest)  Time elapsed: 0.086 sec  <<< ERROR!
org.eclipse.core.internal.resources.ResourceException: Cannot create linked resource '/jdt.ls-java-project/src/home/snjeza/projects/eclipse.jdt.ls/org.eclipse.jdt.ls.tests/target/workingProjects/singlefile/s1.java'.  The parent resource is not accessible.
	at org.eclipse.core.internal.resources.Resource.assertLinkRequirements(Resource.java:175)
	at org.eclipse.core.internal.resources.Resource.createLink(Resource.java:640)
	at org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest.linkFilesToDefaultProject(AbstractProjectsManagerBasedTest.java:116)
	at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest.setUp(BuildWorkspaceHandlerTest.java:42)

testFailedCase(org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest)  Time elapsed: 0.048 sec  <<< ERROR!
org.eclipse.core.internal.resources.ResourceException: Cannot create linked resource '/jdt.ls-java-project/src/home/snjeza/projects/eclipse.jdt.ls/org.eclipse.jdt.ls.tests/target/workingProjects/singlefile/s1.java'.  The parent resource is not accessible.
	at org.eclipse.core.internal.resources.Resource.assertLinkRequirements(Resource.java:175)
	at org.eclipse.core.internal.resources.Resource.createLink(Resource.java:640)
	at org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest.linkFilesToDefaultProject(AbstractProjectsManagerBasedTest.java:116)
	at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest.setUp(BuildWorkspaceHandlerTest.java:42)

testSucceedCase(org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest)  Time elapsed: 0.065 sec  <<< ERROR!
org.eclipse.core.internal.resources.ResourceException: Cannot create linked resource '/jdt.ls-java-project/src/home/snjeza/projects/eclipse.jdt.ls/org.eclipse.jdt.ls.tests/target/workingProjects/singlefile/s1.java'.  The parent resource is not accessible.
	at org.eclipse.core.internal.resources.Resource.assertLinkRequirements(Resource.java:175)
	at org.eclipse.core.internal.resources.Resource.createLink(Resource.java:640)
	at org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest.linkFilesToDefaultProject(AbstractProjectsManagerBasedTest.java:116)
	at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandlerTest.setUp(BuildWorkspaceHandlerTest.java:42)

@ansyral
Copy link
Contributor Author

ansyral commented Aug 24, 2017

@snjeza unfortunately i cannot repro it locally. BTW, do you know why jenkins build isn't enabled for this pr?

@gorkem
Copy link
Contributor

gorkem commented Aug 24, 2017

ok to test Jenkins

@ansyral ansyral force-pushed the eclipse branch 5 times, most recently from 38913f6 to 20ed6b7 Compare August 25, 2017 12:06
* @see org.eclipse.jdt.ls.core.internal.JavaProtocolExtensions#buildWorkspace(java.lang.String)
*/
@Override
public CompletableFuture<BuildWorkspaceResult> buildWorkspace(String type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the expected values for type? At the moment it looks like it is not used, we need to clarify its purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be removed

@NonNull
private BuildWorkspaceStatus status;

private String details;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be better if details is an array of org.eclipse.lsp4j.Diagnostic instead of an concatenated list of compiler error strings.

}
} catch (CoreException e) {
logException("Failed to build workspace.", e);
return new BuildWorkspaceResult(BuildWorkspaceStatus.FAILED, String.format("Exception: %s.", e.getMessage()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we distinguish between a build failure and a build that returns errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice~ I'll add another status to tell the two

@fbricon
Copy link
Contributor

fbricon commented Sep 13, 2017

@ansyral any update?

@ansyral
Copy link
Contributor Author

ansyral commented Sep 19, 2017

@gorkem added a new iteration and rebased on the master branch

private static List<IMarker> getBuildErrors(IProgressMonitor monitor) throws CoreException {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
List<IMarker> errors = new ArrayList<>();
for (IProject project : projects) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check is monitor is cancelled

for (Map.Entry<IResource, List<IMarker>> entry : map.entrySet()) {
IResource resource = entry.getKey();
IFile file = resource.getAdapter(IFile.class);
if (file != null && JavaCore.isJavaLikeFileName(file.getName())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will miss build files. Check with ProjectsManager#isBuildFile

@@ -0,0 +1,7 @@
public class s1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Java conventions: Pascal cased files and class names.

@ansyral
Copy link
Contributor Author

ansyral commented Sep 20, 2017

One concern is that right now language server only publish syntax-like problems for user edit/save. while this command would send all errors to problem panel. Seems inconsistent, @fbricon @gorkem any idea why LS only reports syntax-like problems?

*/
public enum BuildWorkspaceStatus {

FAILED, SUCCEED, WITHERROR, CANCELLED,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WITH_ERROR

@fbricon
Copy link
Contributor

fbricon commented Sep 21, 2017

We should probably report some progress to the client, not sure how though. But I know vscode supports it

@fbricon
Copy link
Contributor

fbricon commented Sep 21, 2017

@ansyral the reason why we only report syntax errors on standalone java files is explained here.

Indeed, workspace builds should report the same errors for standalone files (i.e attached to the default project)

@ansyral
Copy link
Contributor Author

ansyral commented Sep 22, 2017

@fbricon added the progress in the pr redhat-developer/vscode-java#298

@ansyral
Copy link
Contributor Author

ansyral commented Oct 25, 2017

@fbricon do you have more comments about the pr? could you please help merge the pr if no more comments? Thanks.

Copy link
Contributor

@fbricon fbricon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR cannot be rebased cleanly


public BuildWorkspaceStatus buildWorkspace(IProgressMonitor monitor) {
try {
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be a full build? or even better, have the build kind be received as a command parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a parameter

return to;
}

private static void createFolders(IContainer folder, IProgressMonitor monitor) throws CoreException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be replaced by a call to JDTUtils.createFolders

@fbricon
Copy link
Contributor

fbricon commented Oct 26, 2017

@tsmaeder is this something Che would use? If yes, can you check the API matches your expectations?

@fbricon
Copy link
Contributor

fbricon commented Oct 27, 2017

I noticed that if you delete some packages from CLI (outside vscode), the missing classes are not picked up, so no compilation errors. Calling the build command won't actually show any compilation either. You need to restart vscode. I think the workspace needs to be refreshed before the build is triggered

@ansyral
Copy link
Contributor Author

ansyral commented Oct 30, 2017

@fbricon seems like a known issue of vscode

}

public BuildWorkspaceStatus buildWorkspace(boolean forceReBuild, IProgressMonitor monitor) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling

ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);

here, fixes the issues with out-of-synch file system.

@fbricon
Copy link
Contributor

fbricon commented Oct 31, 2017

merged as 11f2f46 (via #414)

@fbricon fbricon closed this Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants