| Summary: | [quick assist] join if sequence in if-else-if forces braces one me | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Dani Megert <daniel_megert> |
| Component: | UI | Assignee: | Martin Aeschlimann <martinae> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | Konstantin.Scheglov |
| Version: | 3.1 | ||
| Target Milestone: | 3.1 M6 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
brackets are good! And I think they are even required in the case of
if (a == 1)
System.out.println("a == 1");
else if (a == 2) {
System.out.println("a == 2");
} else
System.out.println("a == 3");
To make sure that the else does not bind to the inner if.
Hm... I don't know. In general yes, this is not very good, that quick assist
changes style of code, but I also think that brackets are good.
Possible solution here is to keep existing style of code, where possible, i.e.
always, except case when 'then' statement is 'if' statement without 'else'. In
this case we have choice: convert all 'then' statements in block, or convert
only this one. Your decision?
Plus, I think that I could add two more "deep search" (i.e. for selected part
of compilation unit) quick assists for converting all single statements in
control statements ('if', 'for', 'while') in blocks, and reverse - convert all
such blocks with single statement in such single statement. Something like
"Convert control statement bodies in blocks" and "Convert single-statement
blocks in single statement".
> Hm... I don't know. In general yes, this is not very good, that quick assist >changes style of code, but I also think that brackets are good. OK, then assume, Quick Fix removes all your braces when applied - would you be happy and use such Quick Fixes? ;-) > Possible solution here is to keep existing style of code, where possible, i.e. >always, except case when 'then' statement is 'if' statement without 'else'. In >this case we have choice: convert all 'then' statements in block, or convert >only this one. Your decision? Yes, sounds good. -1 one for the deep search quick assists. I want to solve these 'code style trasformation' in an own action. Other candidates would be Replace all fully qualified types in code with imports Qualify all field references with this. Force naming conventions (field -> fFieled) Introduce / remove brackets ... Similar to code formatting but not just whitespace. Help of course welcome. I'm not yet sure if I will have time for this new action. fixed with patch in 82220 > 20050228 correcting target milestone |
I20050215-2300 The join if sequence in if-else-if Quick Fix adds unwanted braces: if (a == 1) System.out.println("a == 1"); if (a == 2) System.out.println("a == 2"); becomes: if (a == 1) { System.out.println("a == 1"); } else if (a == 2) { System.out.println("a == 2"); } instead of: if (a == 1) System.out.println("a == 1"); else if (a == 2) System.out.println("a == 2");