View | Details | Raw Unified | Return to bug 246832 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-9 / +11 lines)
Lines 7089-7099 Link Here
7089
							if(proposeMethod && !insideAnnotationAttribute) {
7089
							if(proposeMethod && !insideAnnotationAttribute) {
7090
								MethodBinding methodBinding = (MethodBinding)binding;
7090
								MethodBinding methodBinding = (MethodBinding)binding;
7091
								if ((exactMatch && CharOperation.equals(token, methodBinding.selector)) ||
7091
								if ((exactMatch && CharOperation.equals(token, methodBinding.selector)) ||
7092
										!exactMatch && CharOperation.prefixEquals(token, methodBinding.selector)) {
7092
										!exactMatch && CharOperation.prefixEquals(token, methodBinding.selector) ||
7093
7093
										(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, methodBinding.selector))) {
7094
									findLocalMethodsFromStaticImports(
7094
									findLocalMethodsFromStaticImports(
7095
											methodBinding.selector,
7095
											token,
7096
											methodBinding.declaringClass.methods(),
7096
											methodBinding.declaringClass.getMethods(methodBinding.selector),
7097
											scope,
7097
											scope,
7098
											exactMatch,
7098
											exactMatch,
7099
											methodsFound,
7099
											methodsFound,
Lines 8704-8710 Link Here
8704
			}
8704
			}
8705
		}
8705
		}
8706
8706
8707
	// Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean)
8707
	/**
8708
	 * Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean)
8709
	 * Note that the method doesn't do a comparison of the method names and expects the client to handle the same.
8710
	 * 
8711
	 * @methodName method as entered by the user, the one to completed
8712
	 * @param methods a resultant array of MethodBinding, whose names should match methodName. The calling client must ensure that this check is handled.
8713
	 */
8708
	private void findLocalMethodsFromStaticImports(
8714
	private void findLocalMethodsFromStaticImports(
8709
		char[] methodName,
8715
		char[] methodName,
8710
		MethodBinding[] methods,
8716
		MethodBinding[] methods,
Lines 8735-8744 Link Here
8735
			if (this.options.checkVisibility
8741
			if (this.options.checkVisibility
8736
				&& !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next;
8742
				&& !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next;
8737
8743
8738
			if (!CharOperation.equals(methodName, method.selector, false /* ignore case */)
8739
					&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector)))
8740
				continue next;
8741
8742
			for (int i = methodsFound.size; --i >= 0;) {
8744
			for (int i = methodsFound.size; --i >= 0;) {
8743
				Object[] other = (Object[]) methodsFound.elementAt(i);
8745
				Object[] other = (Object[]) methodsFound.elementAt(i);
8744
				MethodBinding otherMethod = (MethodBinding) other[0];
8746
				MethodBinding otherMethod = (MethodBinding) other[0];
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+43 lines)
Lines 13576-13580 Link Here
13576
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13576
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13577
			requestor.getResults());
13577
			requestor.getResults());
13578
}
13578
}
13579
/*
13580
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=246832
13581
 * To test whether camel case completion works for imported static methods 
13582
 */
13583
public void testCamelCaseStaticMethodImport() throws JavaModelException {
13584
	this.oldOptions = JavaCore.getOptions();
13585
	this.workingCopies = new ICompilationUnit[2];
13586
	try {
13587
		Hashtable options = new Hashtable(this.oldOptions);
13588
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13589
		JavaCore.setOptions(options);
13590
13591
		this.workingCopies[0] = getWorkingCopy(
13592
				"/Completion/src/a/A.java",
13593
				"package a;\n" +
13594
				"public class A{\n" +
13595
				"public static void testMethodWithLongName(){}\n" +
13596
				"public static void testMethodWithLongName2(){}\n" +				
13597
				"}}");
13598
13599
		this.workingCopies[1] = getWorkingCopy(
13600
				"/Completion/src/b/B.java",
13601
				"import static a.A.testMethodWithLongName;\n" +
13602
				"public class B {\n" +
13603
				"public void b() {\n" +
13604
				"tMWLN \n" +
13605
				"}}");
13606
		
13607
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(
13608
				true);
13609
		String str = this.workingCopies[1].getSource();
13610
		String completeBehind = "tMWLN";
13611
		int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
13612
		this.workingCopies[1].codeComplete(cursorLocation, requestor, this.wcOwner);
13613
13614
			assertResults(
13615
					"testMethodWithLongName[METHOD_REF]{testMethodWithLongName(), La.A;, ()V, testMethodWithLongName, null, " +
13616
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", 
13617
					requestor.getResults());
13618
	} finally {
13619
		JavaCore.setOptions(this.oldOptions);
13620
	}
13621
}
13579
13622
13580
}
13623
}

Return to bug 246832