### Eclipse Workspace Patch 1.0 #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 04:48:40 -0000 @@ -13576,5 +13576,50 @@ "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(); + ICompilationUnit imported = null; + try { + Hashtable options = new Hashtable(this.oldOptions); + options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED); + JavaCore.setOptions(options); + + imported = getWorkingCopy( + "/Completion/src/a/A.java", + "package a;\n" + + "public class A{\n" + + "public static void testMethodWithLongName(){}\n" + + "}}"); + + this.wc = 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.wc.getSource(); + String completeBehind = "tMWLN"; + int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); + this.wc.codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "testMethodWithLongName[METHOD_REF]{testMethodWithLongName(), La.A;, ()V, testMethodWithLongName, null, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM_CONSTANT + R_QUALIFIED + R_NON_RESTRICTED) + + "}", requestor.getResults()); + } finally { + if (imported != null) { + imported.discardWorkingCopy(); + } + JavaCore.setOptions(this.oldOptions); + } +} } #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.392 diff -u -r1.392 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 6 Apr 2009 10:12:04 -0000 1.392 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 16 Apr 2009 04:48:55 -0000 @@ -390,6 +390,22 @@ return result; } + private static char[] getTypeName(TypeReference typeReference) { + char[] typeName = CharOperation.concatWith(typeReference.getTypeName(), '.'); + int dims = typeReference.dimensions(); + if (dims > 0) { + int length = typeName.length; + int newLength = length + (dims*2); + System.arraycopy(typeName, 0, typeName = new char[newLength], 0, length); + for (int k = length; k < newLength; k += 2) { + typeName[k] = '['; + typeName[k+1] = ']'; + } + } + + return typeName; + } + private static boolean hasStaticMemberTypes(ReferenceBinding typeBinding, SourceTypeBinding invocationType, CompilationUnitScope unitScope) { ReferenceBinding[] memberTypes = typeBinding.memberTypes(); int length = memberTypes == null ? 0 : memberTypes.length; @@ -5244,41 +5260,48 @@ guessedType = ref.resolveType((ClassScope)scope); break; } - } finally { - this.lookupEnvironment.nameEnvironment = oldNameEnvironment; - } + - if (guessedType != null && guessedType.isValidBinding()) { - if (guessedType instanceof SourceTypeBinding) { - SourceTypeBinding refBinding = (SourceTypeBinding) guessedType; - - refBinding.methods(); // force resolution - if (refBinding.scope == null || refBinding.scope.referenceContext == null) return null; - TypeDeclaration typeDeclaration = refBinding.scope.referenceContext; - AbstractMethodDeclaration[] methods = typeDeclaration.methods; - next : for (int i = 0; i < methods.length; i++) { - AbstractMethodDeclaration method = methods[i]; + if (guessedType != null && guessedType.isValidBinding()) { + if (guessedType instanceof SourceTypeBinding) { + SourceTypeBinding refBinding = (SourceTypeBinding) guessedType; - if (method.binding == null || !method.isConstructor()) continue next; + if (refBinding.scope == null || refBinding.scope.referenceContext == null) return null; - Argument[] arguments = method.arguments; - int argumentsLength = arguments == null ? 0 : arguments.length; - if (parameterCount != argumentsLength) continue next; + TypeDeclaration typeDeclaration = refBinding.scope.referenceContext; + AbstractMethodDeclaration[] methods = typeDeclaration.methods; - for (int j = 0; j < argumentsLength; j++) { - if (!CharOperation.equals(CharOperation.concatWith(arguments[j].type.getTypeName(), '.'), parameterTypes[j])) { - continue next; + next : for (int i = 0; i < methods.length; i++) { + AbstractMethodDeclaration method = methods[i]; + + if (!method.isConstructor()) continue next; + + Argument[] arguments = method.arguments; + int argumentsLength = arguments == null ? 0 : arguments.length; + + if (parameterCount != argumentsLength) continue next; + + for (int j = 0; j < argumentsLength; j++) { + char[] argumentTypeName = getTypeName(arguments[j].type); + + if (!CharOperation.equals(argumentTypeName, parameterTypes[j])) { + continue next; + } } + + refBinding.resolveTypesFor(method.binding); // force resolution + if (method.binding == null) continue next; + return getSignature(method.binding); } - - return getSignature(method.binding); } } + } finally { + this.lookupEnvironment.nameEnvironment = oldNameEnvironment; } return null; } - + private void findConstructorsOrAnonymousTypes( ReferenceBinding currentType, Scope scope, @@ -7066,8 +7089,8 @@ 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(),