-
Notifications
You must be signed in to change notification settings - Fork 442
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
Auto add brackets to if/else/while/do when format code #2846
Comments
@CsCherrYY could you provide some advice on this issue? |
@CsCherrYY @houtaru @testforstephen We could add the control statements cleanup (Use blocks in if/while/for/do statements).
|
@snjeza I just tried and it works in eclipse using clean up👍 Clean up is a great feature, and I think we still have two things to do:
cc @rgrunber @datho7561 who contributed the clean up feature for further suggestion. |
Looks like this will require a eclipse.jdt.ui PR to access, since the ICleanUpFix class is in the ui package. When I talked with Roland, he was interested mainly in migrating the clean ups that don't address formatting. I think his reasoning is that any clean ups that fix formatting should really be a part of the formatter instead.
From my understanding, the main benefit of the clean ups is that they are run automatically when you save. If you have to perform additional steps to use them, in my opinion they are no longer clean ups, but instead they are closer to something like quick fixes or source actions. I think it's worth discussing if any of the clean ups that we have should be available through other means, like as source actions or through a command. |
@datho7561 I think the clean ups can be a part of the current source actions (like what we see in eclipse), and there is also an existing request for this: #1626. We can also implement a webview to help users to configure available clean ups (like eclipse ui), showing all available clean ups in jdtls. So that there would be only one extra source action: "Clean Up...", and vscode-java behaves like eclipse in the clean up field (available in both source action and save action) |
I'm completely open to migrating the control statement fix, provided there is demand for it. We've migrated plenty of cleanups so it shouldn't be too difficult. I agree with improving the discoverability. When we did Lastly, https://github.com/redhat-developer/vscode-java/blob/master/document/_java.learnMoreAboutCleanUps.md was just a workaround for lack of proper UI for it on the vscode-java side. We need a UI that displays an editor showing the before/after state of code that is affected by each cleanup. i think we've discussed this before, and there might be some POC for it ? |
Is there a way to add brackets to the if/else/while/do statement when we use format code?
Environment
Steps To Reproduce
Right-click -> Choose
Format Doccment
Current Result
Expected Result
Additional Informations
The text was updated successfully, but these errors were encountered: