Bug 367631 - Eclipse Clean-up "use blocks in if/while/for/do statements" does not work
Summary: Eclipse Clean-up "use blocks in if/while/for/do statements" does not work
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-29 12:54 EST by Juris Sudmalis CLA
Modified: 2012-01-23 03:14 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juris Sudmalis CLA 2011-12-29 12:54:17 EST
Build Identifier: 20110916-0149

For some weird reason this setting does not work for me at all.
When removing the checkbox for it, even if I put braces around a for loop manually, it still removed them.
If I check it and select "Always" or "Always, except...", it still always REMOVES the braces.
Checked on a clean project with no project-specific preferences.

Reproducible: Always

Steps to Reproduce:
1. create a new Java project
2. make a new class containing this code:

public static void main(final String[] args) throws Exception
{
	for (int i = 0; i < 10; i++)
		if (true)
			System.out.println(i);
}

3. go to Eclipse Code Style>Clean Up>Edit...>Code Style, check "Use blocks in if/while/for/do statements" and select "Always".
4. save the settings, go back to the newly created class and tap Ctrl+Shift+F (or right-click and choose Source>Format).

At this point it should format the IF statement and the FOR loop to have braces, but for me it doesn't do it!
Comment 1 Stephan Herrmann CLA 2011-12-29 13:03:37 EST
Please note the difference between formatting and Clean Ups.
Formatting only changes white space, whereas clean ups may also modify
the actual code, which is what you need for adding braces.

Can you please confirm that "Source > Clean Up ..." works as expected?
Comment 2 Juris Sudmalis CLA 2011-12-29 13:20:26 EST
Ahh... So the Additional save actions in Editor>Save Actions are not the same as Clean Up preferences... That is weird tbh.

Yes, it works.
Comment 3 Juris Sudmalis CLA 2011-12-29 13:22:37 EST
If it is possible, I would suggest adding a drop-down list of clean-up profiles when selecting the Additional save actions. Otherwise, as you can see, it can get confusing.
Comment 4 Stephan Herrmann CLA 2011-12-29 13:34:50 EST
(In reply to comment #2)
> Ahh... So the Additional save actions in Editor>Save Actions are not the same
> as Clean Up preferences... That is weird tbh.
> 
> Yes, it works.

Thanks, based on this I'm closing the bug as invalid.

(In reply to comment #3)
> If it is possible, I would suggest adding a drop-down list of clean-up profiles
> when selecting the Additional save actions. Otherwise, as you can see, it can
> get confusing.

Please feel free to chime in on bug 178429 which seems to cover
your suggestions.
Comment 5 Srikanth Sankaran CLA 2012-01-23 03:14:21 EST
Verified by submitter in comment# 2