View | Details | Raw Unified | Return to bug 123225
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-7 / +23 lines)
Lines 10485-10500 Link Here
10485
			requestor.getResults());
10485
			requestor.getResults());
10486
}
10486
}
10487
public void testCompletionAfterSupercall1() throws JavaModelException {
10487
public void testCompletionAfterSupercall1() throws JavaModelException {
10488
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10488
	this.workingCopies = new ICompilationUnit[1];
10489
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterSupercall1.java");
10489
	this.workingCopies[0] = getWorkingCopy(
10490
		"/Completion/src/CompletionAfterSupercall1.java",
10491
		"public class CompletionAfterSupercall1 extends CompletionAfterSupercall1_1 {\n" +
10492
		"	public void foo(){\n" +
10493
		"		super.foo\n" +
10494
		"	}\n" +
10495
		"}\n" +
10496
		"abstract class CompletionAfterSupercall1_1 extends CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
10497
		"	\n" +
10498
		"}\n" +
10499
		"class CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
10500
		"	public void foo(){}\n" +
10501
		"}\n" +
10502
		"interface CompletionAfterSupercall1_3 {\n" +
10503
		"	public void foo();\n" +
10504
		"}");
10490
10505
10491
	String str = cu.getSource();
10506
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10507
	String str = this.workingCopies[0].getSource();
10492
	String completeBehind = "super.foo";
10508
	String completeBehind = "super.foo";
10493
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
10509
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10494
	cu.codeComplete(cursorLocation, requestor);
10510
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10495
10511
10496
	assertEquals(
10512
	assertResults(
10497
			"element:foo    completion:foo()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC+ R_NON_RESTRICTED),
10513
			"foo[METHOD_REF]{foo(), LCompletionAfterSupercall1_2;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC+ R_NON_RESTRICTED) + "}",
10498
			requestor.getResults());
10514
			requestor.getResults());
10499
}
10515
}
10500
public void testCompletionPackageAndClass1() throws JavaModelException {
10516
public void testCompletionPackageAndClass1() throws JavaModelException {
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+154 lines)
Lines 9010-9015 Link Here
9010
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
9010
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}",
9011
			requestor.getResults());
9011
			requestor.getResults());
9012
}
9012
}
9013
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=123225
9014
public void test0291() throws JavaModelException {
9015
	this.workingCopies = new ICompilationUnit[5];
9016
	this.workingCopies[0] = getWorkingCopy(
9017
			"/Completion/src3/test/Test.java",
9018
			"package test;\n" +
9019
			"public class Test {\n" +
9020
			"  public void foo(){\n" +
9021
			"    new Test2<Test4>().foo\n" +
9022
			"  }\n" +
9023
			"}");
9024
	
9025
	this.workingCopies[1] = getWorkingCopy(
9026
			"/Completion/src3/test/Test1.java",
9027
			"package test;\n" +
9028
			"public class Test1<TTest1> {\n" +
9029
			"  public void foo(TTest1 t){}\n" +
9030
			"}");
9031
	
9032
	this.workingCopies[2] = getWorkingCopy(
9033
			"/Completion/src3/test/Test2.java",
9034
			"package test;\n" +
9035
			"public class Test2<TTest2 extends Test3> extends Test1<TTest2> {\n" +
9036
			"  public void foo(Test3 t){}\n" +
9037
			"}");
9038
	
9039
	this.workingCopies[3] = getWorkingCopy(
9040
			"/Completion/src3/test/Test3.java",
9041
			"package test;\n" +
9042
			"public class Test3 {\n" +
9043
			"}");
9044
	
9045
	this.workingCopies[4] = getWorkingCopy(
9046
			"/Completion/src3/test/Test4.java",
9047
			"package test;\n" +
9048
			"public class Test4 extends Test3 {\n" +
9049
			"}");
9050
	
9051
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9052
	String str = this.workingCopies[0].getSource();
9053
	String completeBehind = ".foo";
9054
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9055
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9056
9057
	assertResults(
9058
			"foo[METHOD_REF]{foo(), Ltest.Test2<Ltest.Test4;>;, (Ltest.Test3;)V, foo, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
9059
			requestor.getResults());
9060
}
9061
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=123225
9062
public void tes0292() throws JavaModelException {
9063
	this.workingCopies = new ICompilationUnit[6];
9064
	this.workingCopies[0] = getWorkingCopy(
9065
			"/Completion/src3/test/Test.java",
9066
			"package test;\n" +
9067
			"public class Test {\n" +
9068
			"  public void foo(){\n" +
9069
			"    new Test5().foo\n" +
9070
			"  }\n" +
9071
			"}");
9072
	
9073
	this.workingCopies[1] = getWorkingCopy(
9074
			"/Completion/src3/test/Test1.java",
9075
			"package test;\n" +
9076
			"public class Test1<TTest1> {\n" +
9077
			"  public void foo(TTest1 t){}\n" +
9078
			"}");
9079
	
9080
	this.workingCopies[2] = getWorkingCopy(
9081
			"/Completion/src3/test/Test2.java",
9082
			"package test;\n" +
9083
			"public class Test2<TTest2 extends Test3> extends Test1<TTest2> {\n" +
9084
			"  public void foo(Test3 t){}\n" +
9085
			"}");
9086
	
9087
	this.workingCopies[3] = getWorkingCopy(
9088
			"/Completion/src3/test/Test3.java",
9089
			"package test;\n" +
9090
			"public class Test3 {\n" +
9091
			"}");
9092
	
9093
	this.workingCopies[4] = getWorkingCopy(
9094
			"/Completion/src3/test/Test4.java",
9095
			"package test;\n" +
9096
			"public class Test4 extends Test3 {\n" +
9097
			"}");
9098
	
9099
	this.workingCopies[5] = getWorkingCopy(
9100
			"/Completion/src3/test/Test5.java",
9101
			"package test;\n" +
9102
			"public class Test5 extends Test2<Test4> {\n" +
9103
			"  public void foo(Test4 t){}\n" +
9104
			"}");
9105
	
9106
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9107
	String str = this.workingCopies[0].getSource();
9108
	String completeBehind = ".foo";
9109
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9110
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9111
9112
	assertResults(
9113
			"foo[METHOD_REF]{foo(), Ltest.Test2<Ltest.Test4;>;, (Ltest.Test3;)V, foo, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
9114
			"foo[METHOD_REF]{foo(), Ltest.Test5;, (Ltest.Test4;)V, foo, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
9115
			requestor.getResults());
9116
}
9117
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=123225
9118
public void test0293() throws JavaModelException {
9119
	this.workingCopies = new ICompilationUnit[5];
9120
	this.workingCopies[0] = getWorkingCopy(
9121
			"/Completion/src3/test/Test.java",
9122
			"package test;\n" +
9123
			"public class Test extends Test2<Test4> {\n" +
9124
			"  public void foo(Test4 t){}\n" +
9125
			"  public void bar(){\n" +
9126
			"    foo\n" +
9127
			"  }\n" +
9128
			"}");
9129
	
9130
	this.workingCopies[1] = getWorkingCopy(
9131
			"/Completion/src3/test/Test1.java",
9132
			"package test;\n" +
9133
			"public class Test1<TTest1> {\n" +
9134
			"  public void foo(TTest1 t){}\n" +
9135
			"}");
9136
	
9137
	this.workingCopies[2] = getWorkingCopy(
9138
			"/Completion/src3/test/Test2.java",
9139
			"package test;\n" +
9140
			"public class Test2<TTest2 extends Test3> extends Test1<TTest2> {\n" +
9141
			"  public void foo(Test3 t){}\n" +
9142
			"}");
9143
	
9144
	this.workingCopies[3] = getWorkingCopy(
9145
			"/Completion/src3/test/Test3.java",
9146
			"package test;\n" +
9147
			"public class Test3 {\n" +
9148
			"}");
9149
	
9150
	this.workingCopies[4] = getWorkingCopy(
9151
			"/Completion/src3/test/Test4.java",
9152
			"package test;\n" +
9153
			"public class Test4 extends Test3 {\n" +
9154
			"}");
9155
	
9156
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9157
	String str = this.workingCopies[0].getSource();
9158
	String completeBehind = "foo";
9159
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9160
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9161
9162
	assertResults(
9163
			"foo[METHOD_REF]{foo(), Ltest.Test2<Ltest.Test4;>;, (Ltest.Test3;)V, foo, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9164
			"foo[METHOD_REF]{foo(), Ltest.Test;, (Ltest.Test4;)V, foo, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
9165
			requestor.getResults());
9166
}
9013
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
9167
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
9014
public void testEC001() throws JavaModelException {
9168
public void testEC001() throws JavaModelException {
9015
	this.workingCopies = new ICompilationUnit[1];
9169
	this.workingCopies = new ICompilationUnit[1];
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-39 / +38 lines)
Lines 924-930 Link Here
924
						ref,
924
						ref,
925
						scope,
925
						scope,
926
						false,
926
						false,
927
						true);
927
						false);
928
				}
928
				}
929
929
930
				if (!isInsideAnnotationAttribute && !this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
930
				if (!isInsideAnnotationAttribute && !this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
Lines 942-948 Link Here
942
						scope,
942
						scope,
943
						false,
943
						false,
944
						false,
944
						false,
945
						true);
945
						false);
946
				}
946
				}
947
947
948
			} else if (qualifiedBinding instanceof PackageBinding) {
948
			} else if (qualifiedBinding instanceof PackageBinding) {
Lines 1030-1036 Link Here
1030
					scope,
1030
					scope,
1031
					false,
1031
					false,
1032
					messageSend.receiver instanceof SuperReference,
1032
					messageSend.receiver instanceof SuperReference,
1033
					true);
1033
					false);
1034
			}
1034
			}
1035
		} else if (astNode instanceof CompletionOnExplicitConstructorCall) {
1035
		} else if (astNode instanceof CompletionOnExplicitConstructorCall) {
1036
			if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
1036
			if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) {
Lines 2779-2785 Link Here
2779
				invocationSite,
2779
				invocationSite,
2780
				invocationScope,
2780
				invocationScope,
2781
				implicitCall,
2781
				implicitCall,
2782
				true);
2782
				false);
2783
		}
2783
		}
2784
2784
2785
		if(proposeMethod) {
2785
		if(proposeMethod) {
Lines 2797-2803 Link Here
2797
				invocationScope,
2797
				invocationScope,
2798
				implicitCall,
2798
				implicitCall,
2799
				superCall,
2799
				superCall,
2800
				true);
2800
				false);
2801
		}
2801
		}
2802
	}
2802
	}
2803
2803
Lines 3821-3865 Link Here
3821
				ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
3821
				ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
3822
				if (method == otherMethod && receiverType == otherReceiverType)
3822
				if (method == otherMethod && receiverType == otherReceiverType)
3823
					continue next;
3823
					continue next;
3824
3824
				
3825
				if (CharOperation.equals(method.selector, otherMethod.selector, true)
3825
				if (CharOperation.equals(method.selector, otherMethod.selector, true)) {
3826
					&& lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) {
3826
					if (receiverType == otherReceiverType) {
3827
3827
						if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) {
3828
					if (method.declaringClass.isSuperclassOf(otherMethod.declaringClass))
3828
							if (!superCall || !otherMethod.declaringClass.isInterface()) {
3829
						continue next;
3829
								continue next;
3830
3830
							}
3831
					if (otherMethod.declaringClass.isInterface()) {
3831
						}
3832
						if(method.declaringClass == scope.getJavaLangObject())
3832
					} else {
3833
							continue next;
3833
						if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) {
3834
						
3834
							if(receiverType.isAnonymousType()) continue next;
3835
						if (method.declaringClass.isInterface())
3835
							
3836
							continue next;
3836
							if(!superCall) {
3837
						
3837
								if(!canBePrefixed) continue next;
3838
						if (!superCall && method
3838
								
3839
							.declaringClass
3839
								prefixRequired = true;
3840
							.implementsInterface(otherMethod.declaringClass, true))
3840
							}
3841
							continue next;
3842
					}
3843
3844
					if (method.declaringClass.isInterface())
3845
						if(otherMethod
3846
							.declaringClass
3847
							.implementsInterface(method.declaringClass,true))
3848
							continue next;
3849
						
3850
					if(receiverType.isAnonymousType()) continue next;
3851
					
3852
					if(!superCall) {
3853
						if(canBePrefixed) {
3854
							prefixRequired = true;
3855
						} else {
3856
							continue next;
3857
						}
3841
						}
3858
					}
3842
					}
3859
				}
3843
				}
3860
			}
3844
			}
3861
3845
3862
			newMethodsFound.add(new Object[]{method, receiverType});
3846
			newMethodsFound.add(new Object[]{method, receiverType});
3847
			
3848
			ReferenceBinding superTypeWithSameErasure = (ReferenceBinding)receiverType.findSuperTypeWithSameErasure(method.declaringClass);
3849
			if (method.declaringClass != superTypeWithSameErasure) {
3850
				MethodBinding[] otherMethods = superTypeWithSameErasure.getMethods(method.selector);
3851
				for (int i = 0; i < otherMethods.length; i++) {
3852
					if(otherMethods[i].original() == method.original()) {
3853
						method = otherMethods[i];
3854
					}
3855
				}
3856
			}
3857
			
3863
			int length = method.parameters.length;
3858
			int length = method.parameters.length;
3864
			char[][] parameterPackageNames = new char[length][];
3859
			char[][] parameterPackageNames = new char[length][];
3865
			char[][] parameterTypeNames = new char[length][];
3860
			char[][] parameterTypeNames = new char[length][];
Lines 4720-4726 Link Here
4720
			} else {
4715
			} else {
4721
				hasPotentialDefaultAbstractMethods = false;
4716
				hasPotentialDefaultAbstractMethods = false;
4722
			}
4717
			}
4723
			currentType = currentType.superclass();
4718
			if(currentType.isParameterizedType()) {
4719
				currentType = ((ParameterizedTypeBinding)currentType).type.superclass();
4720
			} else {
4721
				currentType = currentType.superclass();
4722
			}
4724
		}
4723
		}
4725
	}
4724
	}
4726
	private char[][] findMethodParameterNames(MethodBinding method, char[][] parameterTypeNames){
4725
	private char[][] findMethodParameterNames(MethodBinding method, char[][] parameterTypeNames){

Return to bug 123225