Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332019 - [quick assist] Exchange operands must add parentheses sometimes
Summary: [quick assist] Exchange operands must add parentheses sometimes
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-07 09:03 EST by Markus Keller CLA
Modified: 2011-01-19 13:35 EST (History)
0 users

See Also:


Attachments
fix + tests (6.31 KB, patch)
2011-01-19 13:31 EST, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-12-07 09:03:48 EST
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);
	}
Comment 1 Deepak Azad CLA 2010-12-07 09:53:17 EST
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);
	}
Comment 2 Deepak Azad CLA 2011-01-19 13:31:05 EST
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.
Comment 3 Deepak Azad CLA 2011-01-19 13:35:47 EST
Fixed in HEAD.