Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319722

Summary: [clean up] Provide refactoring option for converting var.equals(const) to const.equals(var)
Product: [Eclipse Project] JDT Reporter: Ankur Sharma <ankur_sharma>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P5 CC: deepakazad, markus.kell.r
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ankur Sharma CLA 2010-07-13 09:57:57 EDT
This goes specially for String type

Provide a refactoring option for converting the condition tests

variable.equals(SOME_CONSTANT) to SOME_CONSTANT.equals(variables)

This is also help quickly fixing some of the NPEs.
Comment 1 Markus Keller CLA 2010-07-13 10:45:55 EDT
We already have a Quick Assist (Ctrl+1) called "Invert equals" that helps doing this manually.

Doing this automatically for a whole project is dangerous, since it doesn't have to be semantically preserving. You never know how equals(..) is implemented in the two involved types, and some code could even expect to get NPEs.

If we implement this, it will most likely be a Clean Up, not a Refactoring.
Comment 2 Ankur Sharma CLA 2010-07-13 11:21:22 EDT
I did not know this. In fact, I thought Ctrl+1 works only on problem markers. It is good enough for me.