| Summary: | [quick assist] Exchange operands must add parentheses sometimes | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | UI | Assignee: | Deepak Azad <deepakazad> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7 M5 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
This is not a new problem, it was always there for == operator
static void foo(int a, long b) {
System.out.println(b == 0 == (a == b));
System.out.println(b == 0 == true);
}
Created attachment 187136 [details]
fix + tests
With the patch parenthesis will be added for both of the following statements.
static void foo(int a, long b) {
System.out.println(b != 0 != (a == b)); // Ctrl+1 on second !=
System.out.println(b > 0 != (a == b)); // Ctrl+1 !=
}
I think it is better to add extra parenthesis in some cases, than produce code with errors.
Fixed in HEAD. |
I20101206-1800 Exchange operands quick assist must add parentheses sometimes, e.g. when invoked on the second != in these statements: static void foo(int a, long b) { System.out.println(b != 0 != (a == b)); System.out.println(b != 0 != true); }