### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.393 diff -u -r1.393 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 14 Apr 2009 13:57:11 -0000 1.393 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 16 Apr 2009 14:34:50 -0000 @@ -7089,11 +7089,11 @@ if(proposeMethod && !insideAnnotationAttribute) { MethodBinding methodBinding = (MethodBinding)binding; if ((exactMatch && CharOperation.equals(token, methodBinding.selector)) || - !exactMatch && CharOperation.prefixEquals(token, methodBinding.selector)) { - + !exactMatch && CharOperation.prefixEquals(token, methodBinding.selector) || + (this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, methodBinding.selector))) { findLocalMethodsFromStaticImports( - methodBinding.selector, - methodBinding.declaringClass.methods(), + token, + methodBinding.declaringClass.getMethods(methodBinding.selector), scope, exactMatch, methodsFound, @@ -8704,7 +8704,13 @@ } } - // Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean) + /** + * Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean) + * Note that the method doesn't do a comparison of the method names and expects the client to handle the same. + * + * @methodName method as entered by the user, the one to completed + * @param methods a resultant array of MethodBinding, whose names should match methodName. The calling client must ensure that this check is handled. + */ private void findLocalMethodsFromStaticImports( char[] methodName, MethodBinding[] methods, @@ -8735,9 +8741,10 @@ if (this.options.checkVisibility && !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next; - if (!CharOperation.equals(methodName, method.selector, false /* ignore case */) - && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) - continue next; + // This check is already handled by the invoking client. +// if (!CharOperation.equals(methodName, method.selector, false /* ignore case */) +// && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) +// continue next; for (int i = methodsFound.size; --i >= 0;) { Object[] other = (Object[]) methodsFound.elementAt(i); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v retrieving revision 1.112 diff -u -r1.112 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 4 Mar 2009 11:57:11 -0000 1.112 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 16 Apr 2009 14:35:07 -0000 @@ -13576,5 +13576,47 @@ "ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=246832 + * To test whether camel case completion works for imported static methods + */ +public void testCamelCaseStaticMethodImport() throws JavaModelException { + this.oldOptions = JavaCore.getOptions(); + this.workingCopies = new ICompilationUnit[2]; + try { + Hashtable options = new Hashtable(this.oldOptions); + options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED); + JavaCore.setOptions(options); + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/a/A.java", + "package a;\n" + + "public class A{\n" + + "public static void testMethodWithLongName(){}\n" + + "public static void testMethodWithLongName2(){}\n" + + "}}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/b/B.java", + "import static a.A.testMethodWithLongName;\n" + + "public class B {\n" + + "public void b() {\n" + + "tMWLN \n" + + "}}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2( + true); + String str = this.workingCopies[1].getSource(); + String completeBehind = "tMWLN"; + int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); + this.workingCopies[1].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "testMethodWithLongName[METHOD_REF]{testMethodWithLongName(), La.A;, ()V, testMethodWithLongName, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + requestor.getResults()); + } finally { + JavaCore.setOptions(this.oldOptions); + } +} }