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 157143 Details for
Bug 297183
[quick fix] "Add unimplemented methods" should add methods from top of hierarchy first
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]
Fix
297183_patch.txt (text/plain), 9.22 KB, created by
Markus Keller
on 2010-01-25 12:45:32 EST
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2010-01-25 12:45:32 EST
Size:
9.22 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: core extension/org/eclipse/jdt/internal/corext/util/MethodsSourcePositionComparator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/MethodsSourcePositionComparator.java,v >retrieving revision 1.1 >diff -u -r1.1 MethodsSourcePositionComparator.java >--- core extension/org/eclipse/jdt/internal/corext/util/MethodsSourcePositionComparator.java 9 Nov 2009 13:08:56 -0000 1.1 >+++ core extension/org/eclipse/jdt/internal/corext/util/MethodsSourcePositionComparator.java 25 Jan 2010 17:43:53 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -32,15 +32,16 @@ > * <li><code>m1</code> and <code>m2</code> are defined in the same type (<code>T</code> or any > * supertype of <code>T</code>), that type doesn't have a source attachment and name of > * <code>m1</code> alphabetically precedes name of <code>m2</code></li> >- * <li><code>m1</code> is defined in <code>T</code> and <code>m2</code> is defined in any supertype >+ * >+ * <li><code>m2</code> is defined in <code>T</code> and <code>m1</code> is defined in any supertype > * of <code>T</code></li> >- * <li><code>m1</code> is defined in a superclass of <code>T</code> and <code>m2</code> is defined >+ * <li><code>m2</code> is defined in a superclass of <code>T</code> and <code>m1</code> is defined > * in a superinterface of <code>T</code></li> > * <li><code>m1</code> and <code>m2</code> are defined in different superclasses of <code>T</code> >- * and a class which defines <code>m2</code> extends class which defines <code>m1</code> >+ * and a class which defines <code>m1</code> extends class which defines <code>m2</code> > * <li><code>m1</code> and <code>m2</code> are defined in different superinterfaces of >- * <code>T</code> and an interface which defines <code>m1</code> appears before an interface which >- * defines <code>m2</code> in <code>implements</code> clause of declaration of type <code>T</code></li> >+ * <code>T</code> and an interface which defines <code>m2</code> appears before an interface which >+ * defines <code>m1</code> in <code>implements</code> clause of declaration of type <code>T</code></li> > * </ul> > */ > public class MethodsSourcePositionComparator implements Comparator { >@@ -71,10 +72,10 @@ > } > > if (firstMethodType.equals(fTypeBinding)) { >- return -1; >+ return 1; > } > if (secondMethodType.equals(fTypeBinding)) { >- return 1; >+ return -1; > } > > ITypeBinding type= fTypeBinding; >@@ -89,22 +90,22 @@ > count++; > } > if (firstCount != -1 && secondCount != -1) { >- return -(firstCount - secondCount); >+ return (firstCount - secondCount); > } > if (firstCount != -1 && secondCount == -1) { >- return -1; >+ return 1; > } > if (firstCount == -1 && secondCount != -1) { >- return 1; >+ return -1; > } > > ITypeBinding[] interfaces= fTypeBinding.getInterfaces(); > for (int i= 0; i < interfaces.length; i++) { > if (firstMethodType.equals(interfaces[i])) { >- return -1; >+ return 1; > } > if (secondMethodType.equals(interfaces[i])) { >- return 1; >+ return -1; > } > } > return 0; >#P org.eclipse.jdt.ui.tests >Index: ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest.java,v >retrieving revision 1.10 >diff -u -r1.10 AddUnimplementedMethodsTest.java >--- ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest.java 14 Sep 2009 10:37:34 -0000 1.10 >+++ ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest.java 25 Jan 2010 17:43:54 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -51,6 +51,7 @@ > import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser; > import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; > import org.eclipse.jdt.internal.corext.util.JavaModelUtil; >+import org.eclipse.jdt.internal.corext.util.Strings; > > import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jdt.ui.PreferenceConstants; >@@ -236,12 +237,47 @@ > testHelper(testClass); > > IMethod[] methods= testClass.getMethods(); >- checkMethods(new String[] { "b", "foo", "equals", "clone", "toString", "finalize", "hashCode" }, methods); >+ checkMethodsInOrder(new String[] { "foo", "b", "clone", "equals", "finalize", "hashCode", "toString"}, methods); > > IImportDeclaration[] imports= cu.getImports(); > checkImports(new String[0], imports); > } > >+ public void testBug297183() throws Exception { >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package ibm.util;\n"); >+ buf.append("interface Shape {\r\n"); >+ buf.append(" int getX();\r\n"); >+ buf.append(" int getY();\r\n"); >+ buf.append(" int getEdges();\r\n"); >+ buf.append(" int getArea();\r\n"); >+ buf.append("}\r\n"); >+ fPackage.createCompilationUnit("Shape.java", buf.toString(), false, null); >+ >+ buf= new StringBuffer(); >+ buf.append("package ibm.util;\n"); >+ buf.append("interface Circle extends Shape {\r\n"); >+ buf.append(" int getR();\r\n"); >+ buf.append("}\r\n"); >+ buf.append("\r\n"); >+ fPackage.createCompilationUnit("Circle.java", buf.toString(), false, null); >+ >+ buf= new StringBuffer(); >+ buf.append("package ibm.util;\n"); >+ buf.append("public class DefaultCircle implements Circle {\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= fPackage.getCompilationUnit("DefaultCircle.java"); >+ IType testClass= cu.createType(buf.toString(), null, true, null); >+ >+ testHelper(testClass, -1, false); >+ >+ IMethod[] methods= testClass.getMethods(); >+ checkMethodsInOrder(new String[] { "getX", "getY", "getEdges", "getArea", "getR"}, methods); >+ >+ IImportDeclaration[] imports= cu.getImports(); >+ checkImports(new String[0], imports); >+ } >+ > public void testInsertAt() throws Exception { > fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); > assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); >@@ -336,6 +372,14 @@ > JavaModelUtil.reconcile(testClass.getCompilationUnit()); > } > >+ private void checkMethodsInOrder(String[] expected, IMethod[] methods) { >+ String[] actualNames= new String[methods.length]; >+ for (int i= 0; i < actualNames.length; i++) { >+ actualNames[i]= methods[i].getElementName(); >+ } >+ assertEquals(Strings.concatenate(expected, ", "), Strings.concatenate(actualNames, ", ")); >+ } >+ > private void checkMethods(String[] expected, IMethod[] methods) { > int nMethods= methods.length; > int nExpected= expected.length; >Index: ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java,v >retrieving revision 1.161 >diff -u -r1.161 LocalCorrectionsQuickFixTest.java >--- ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java 13 Jan 2010 19:43:04 -0000 1.161 >+++ ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java 25 Jan 2010 17:43:54 -0000 >@@ -2078,14 +2078,14 @@ > buf.append("import test2.InterImpl;\n"); > buf.append("public class E extends InterImpl {\n"); > buf.append("\n"); >+ buf.append(" public int getCount(Object[] o) throws IOException {\n"); >+ buf.append(" return 0;\n"); >+ buf.append(" }\n"); >+ buf.append("\n"); > buf.append(" @Override\n"); > buf.append(" protected int[] getMusic() throws IOException {\n"); > buf.append(" return null;\n"); > buf.append(" }\n"); >- buf.append("\n"); >- buf.append(" public int getCount(Object[] o) throws IOException {\n"); >- buf.append(" return 0;\n"); >- buf.append(" }\n"); > buf.append("}\n"); > String expected2= buf.toString(); > >@@ -2598,12 +2598,12 @@ > buf.append("package test;\n"); > buf.append("enum TestEnum implements Runnable {\n"); > buf.append(" A {\n"); >+ buf.append(" public void run() {\n"); >+ buf.append(" }\n"); > buf.append(" @Override\n"); > buf.append(" public boolean foo() {\n"); > buf.append(" return false;\n"); > buf.append(" }\n"); >- buf.append(" public void run() {\n"); >- buf.append(" }\n"); > buf.append(" };\n"); > buf.append(" public abstract boolean foo();\n"); > buf.append("}\n");
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 297183
: 157143