-
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
Provide 'clean build' quickfix #1440
Conversation
Signed-off-by: Sheng Chen <[email protected]>
// Add proposals related with project steup, like: clean build, clean workspace, etc... | ||
switch(id) { | ||
case IProblem.ImportNotFound: | ||
CleanBuildSubProcessor.cleanBuildForUnresolvedImportProposals(context, problem, proposals); |
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.
please indent properly
if (type != null) { | ||
ICompilationUnit compilationUnit = (ICompilationUnit) type.getAncestor(IJavaElement.COMPILATION_UNIT); | ||
IClassFile cf = (IClassFile) type.getAncestor(IJavaElement.CLASS_FILE); | ||
if (compilationUnit != null && cf == 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.
you need to check if the client supports that command
test this please |
Signed-off-by: Sheng Chen <[email protected]>
Signed-off-by: Sheng Chen <[email protected]>
@@ -639,5 +640,12 @@ private void process(IInvocationContext context, IProblemLocationCore problem, C | |||
// } | |||
// ConfigureProblemSeveritySubProcessor.addConfigureProblemSeverityProposal(context, | |||
// problem, proposals); | |||
|
|||
// Add proposals related with project steup, like: clean build, clean workspace, etc... |
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.
setup
import org.junit.Test; | ||
|
||
public class CleanBuildQuickFixTest extends AbstractQuickFixTest { | ||
|
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 test when(clientPreferences.isClientBuildCommandSupported()).thenReturn(false);
Signed-off-by: Sheng Chen <[email protected]>
@fbricon Want to listen your suggestion about this: When we detect that an unresolvable import is caused by missing .class file. Should be provide the quickfix as this PR shows, or directly trigger full build automatically? Follow-up question: If we choose to way to provide quickfix, the current relevance value (0) is suitable or not? Personally I prefer to put this quickfix at a higher position. |
No! it's a surefire way to end up with infinite build loop!
No, this quickfix is a hack, this is a last resort measure so should have the lowest relevance IMO |
@fbricon I see, make sense. |
Doesn't work if the missing class is from the same package, so there's no import error |
The fact the code action only shows up on import statements definitely feels confusing |
@fbricon This is to open the chances to help users setup their projects. We can definitely add more scenarios like |
Can we do the following: if type is missing (import or otherwise), then check project's source directories (then dependency projects' source directories), find if there's an existing matching foo/bar/Type.java, THEN, propose the code action |
@fbricon Yes, that's much better than current solution! Let me think more about how to better expose this command. I'm now having the same feeling that put it in the quickfix might not be a good idea... |
Close it for now... |
Somehow mitigate redhat-developer/vscode-java#314
We can leverage the quickfix to help user discover the command
clean build
in more scenarios.Step to validate
WorkspaceDiagnosticHnadler.resourceChanged()
client: redhat-developer/vscode-java#1450
Signed-off-by: Sheng Chen [email protected]