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 7368 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]
fixed String concatenation, object assignment,tenary operator
37432b.txt (text/plain), 4.78 KB, created by
Sebastian Davids
on 2004-01-08 11:32:01 EST
(
hide
)
Description:
fixed String concatenation, object assignment,tenary operator
Filename:
MIME Type:
Creator:
Sebastian Davids
Created:
2004-01-08 11:32:01 EST
Size:
4.78 KB
patch
obsolete
>Index: ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties >=================================================================== >retrieving revision 1.102 >diff -u -r1.102 CorrectionMessages.properties >--- ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties 4 Dec 2003 14:53:18 -0000 1.102 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties 8 Jan 2004 16:21:43 -0000 >@@ -186,7 +186,7 @@ > QuickAssistProcessor.replaceelsewithblock.description=Change else statement to block > QuickAssistProcessor.replacebodywithblock.description=Change body statement to block > >- >+QuickAssistProcessor.invertequals.description=Invert equals > > LinkedNamesAssistProposal.proposalinfo=Link all references for a local rename (does not change references in other files) > LinkedNamesAssistProposal.description=Local Rename >Index: ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java >=================================================================== >retrieving revision 1.36 >diff -u -r1.36 QuickAssistProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 21 Dec 2003 01:36:36 -0000 1.36 >+++ ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java 8 Jan 2004 16:21:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * Copyright (c) 2000, 2004 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.text.correction; > >@@ -56,7 +57,8 @@ > || getAddFinallyProposals(context, coveringNode, null) > || getAddElseProposals(context, coveringNode, null) > || getSplitVariableProposals(context, coveringNode, null) >- || getAddBlockProposals(context, coveringNode, null); >+ || getAddBlockProposals(context, coveringNode, null) >+ || getInvertEqualsProposal(context, coveringNode, null); > } > return false; > } >@@ -82,6 +84,7 @@ > getAddFinallyProposals(context, coveringNode, resultingCollections); > getAddElseProposals(context, coveringNode, resultingCollections); > getAddBlockProposals(context, coveringNode, resultingCollections); >+ getInvertEqualsProposal(context, coveringNode, resultingCollections); > } > return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]); > } >@@ -690,6 +693,51 @@ > return true; > } > >- >- >+ private boolean getInvertEqualsProposal(IInvocationContext context, ASTNode node, Collection resultingCollections) throws CoreException { >+ ASTNode parent= node.getParent(); >+ if (!(parent instanceof MethodInvocation)) { >+ return false; >+ } >+ MethodInvocation method= (MethodInvocation) parent; >+ 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 >+ return false; >+ } >+ >+ ASTRewrite rewrite= new ASTRewrite(method); >+ >+ if (left instanceof ParenthesizedExpression) { >+ Expression ex = ((ParenthesizedExpression) left).getExpression(); >+ rewrite.markAsReplaced(right, rewrite.createCopy(ex)); >+ } 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); >+ } >+ >+ String label= CorrectionMessages.getString("QuickAssistProcessor.invertequals.description"); //$NON-NLS-1$ >+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); >+ >+ LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image); >+ proposal.ensureNoModifications(); >+ resultingCollections.add(proposal); >+ return true; >+ } > }
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