Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 7385 Details for
Bug 37432
quick assist: invert equals() [quick assist]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
now handles equals(x) and x.equals(this)
37432c.txt (text/plain), 3.47 KB, created by
Sebastian Davids
on 2004-01-08 21:25:15 EST
(
hide
)
Description:
now handles equals(x) and x.equals(this)
Filename:
MIME Type:
Creator:
Sebastian Davids
Created:
2004-01-08 21:25:15 EST
Size:
3.47 KB
patch
obsolete
>Index: ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >=================================================================== >retrieving revision 1.37 >diff -u -r1.37 QuickAssistProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 8 Jan 2004 17:37:43 -0000 1.37 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 9 Jan 2004 02:19:00 -0000 >@@ -702,34 +702,50 @@ > if (!"equals".equals(method.getName().getIdentifier())) { //$NON-NLS-1$ > return false; > } >- Expression left= method.getExpression(); //always non-null > List arguments= method.arguments(); > if (arguments.size() != 1) { //overloaded equals w/ more than 1 arg > return false; > } > Expression right= (Expression) arguments.get(0); > ITypeBinding binding = right.resolveTypeBinding(); >- if (!(binding.isClass() || binding.isInterface())) { //overloaded equals w/ non-class/interface arg >+ if (!(binding.isClass() || binding.isInterface())) { //overloaded equals w/ non-class/interface arg or null > return false; > } >- >- ASTRewrite rewrite= new ASTRewrite(method); >- >- if (left instanceof ParenthesizedExpression) { >- Expression ex = ((ParenthesizedExpression) left).getExpression(); >- rewrite.markAsReplaced(right, rewrite.createCopy(ex)); >+ Expression left= method.getExpression(); >+ >+ ASTRewrite rewrite; >+ if (left == null) { // equals(x) -> x.equals(this) >+ rewrite= new ASTRewrite(method.getParent()); >+ AST ast= rewrite.getAST(); >+ MethodInvocation replacement= ast.newMethodInvocation(); >+ replacement.setName((SimpleName) rewrite.createCopy(method.getName())); >+ replacement.arguments().add(ast.newThisExpression()); >+ replacement.setExpression((Expression) rewrite.createCopy(right)); >+ rewrite.markAsReplaced(method, replacement); >+ } else if (right instanceof ThisExpression) { // x.equals(this) -> equals(x) >+ rewrite= new ASTRewrite(method.getParent()); >+ MethodInvocation replacement= rewrite.getAST().newMethodInvocation(); >+ replacement.setName((SimpleName) rewrite.createCopy(method.getName())); >+ replacement.arguments().add(rewrite.createCopy(left)); >+ rewrite.markAsReplaced(method, replacement); > } else { >- rewrite.markAsReplaced(right, left); >- } >- if ((right instanceof CastExpression) >- || (right instanceof Assignment) >- || (right instanceof ConditionalExpression) >- || (right instanceof InfixExpression)) { >- ParenthesizedExpression paren = method.getAST().newParenthesizedExpression(); >- paren.setExpression((Expression) rewrite.createCopy(right)); >- rewrite.markAsReplaced(left, paren); >- } else { >- rewrite.markAsReplaced(left, right); >+ rewrite= new ASTRewrite(method); >+ if (left instanceof ParenthesizedExpression) { >+ Expression ex= ((ParenthesizedExpression) left).getExpression(); >+ rewrite.markAsReplaced(right, rewrite.createCopy(ex)); >+ } else { >+ rewrite.markAsReplaced(right, rewrite.createCopy(left)); >+ } >+ if ((right instanceof CastExpression) >+ || (right instanceof Assignment) >+ || (right instanceof ConditionalExpression) >+ || (right instanceof InfixExpression)) { >+ ParenthesizedExpression paren= rewrite.getAST().newParenthesizedExpression(); >+ paren.setExpression((Expression) rewrite.createCopy(right)); >+ rewrite.markAsReplaced(left, paren); >+ } else { >+ rewrite.markAsReplaced(left, rewrite.createCopy(right)); >+ } > } > > String label= CorrectionMessages.getString("QuickAssistProcessor.invertequals.description"); //$NON-NLS-1$
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 37432
:
7360
|
7368
| 7385 |
7403