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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (-11 / +110 lines)
Lines 3596-3602 Link Here
3596
				result.context);
3596
				result.context);
3597
		
3597
		
3598
		assertResults(
3598
		assertResults(
3599
				"RED[FIELD_REF]{RED, Ltest0136.Colors;, Ltest0136.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3599
				"RED[FIELD_REF]{RED, Ltest0136.Colors;, Ltest0136.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3600
				result.proposals);
3600
				result.proposals);
3601
	} finally {
3601
	} finally {
3602
		if(enumeration != null) {
3602
		if(enumeration != null) {
Lines 3635-3641 Link Here
3635
				result.context);
3635
				result.context);
3636
		
3636
		
3637
		assertResults(
3637
		assertResults(
3638
				"RED[FIELD_REF]{RED, Ltest0137.Colors;, Ltest0137.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3638
				"RED[FIELD_REF]{RED, Ltest0137.Colors;, Ltest0137.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3639
				result.proposals);
3639
				result.proposals);
3640
	} finally {
3640
	} finally {
3641
		if(enumeration != null) {
3641
		if(enumeration != null) {
Lines 3675-3681 Link Here
3675
				result.context);
3675
				result.context);
3676
		
3676
		
3677
		assertResults(
3677
		assertResults(
3678
				"RED[FIELD_REF]{RED, Ltest0138.Colors;, Ltest0138.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3678
				"RED[FIELD_REF]{RED, Ltest0138.Colors;, Ltest0138.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3679
				result.proposals);
3679
				result.proposals);
3680
	} finally {
3680
	} finally {
3681
		if(enumeration != null) {
3681
		if(enumeration != null) {
Lines 3714-3720 Link Here
3714
				result.context);
3714
				result.context);
3715
		
3715
		
3716
		assertResults(
3716
		assertResults(
3717
				"RED[FIELD_REF]{RED, Ltest0139.Colors;, Ltest0139.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3717
				"RED[FIELD_REF]{RED, Ltest0139.Colors;, Ltest0139.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3718
				result.proposals);
3718
				result.proposals);
3719
	} finally {
3719
	} finally {
3720
		if(enumeration != null) {
3720
		if(enumeration != null) {
Lines 3753-3759 Link Here
3753
				result.context);
3753
				result.context);
3754
		
3754
		
3755
		assertResults(
3755
		assertResults(
3756
				"RED[FIELD_REF]{RED, Ltest0140.Colors;, Ltest0140.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3756
				"RED[FIELD_REF]{RED, Ltest0140.Colors;, Ltest0140.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3757
				result.proposals);
3757
				result.proposals);
3758
	} finally {
3758
	} finally {
3759
		if(enumeration != null) {
3759
		if(enumeration != null) {
Lines 3835-3841 Link Here
3835
				result.context);
3835
				result.context);
3836
		
3836
		
3837
		assertResults(
3837
		assertResults(
3838
				"RED[FIELD_REF]{RED, Ltest0142.Colors;, Ltest0142.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM_CONSTANT) + "}",
3838
				"RED[FIELD_REF]{RED, Ltest0142.Colors;, Ltest0142.Colors;, RED, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED + R_ENUM + R_ENUM_CONSTANT + R_RESOLVED) + "}",
3839
				result.proposals);
3839
				result.proposals);
3840
	} finally {
3840
	} finally {
3841
		if(enumeration != null) {
3841
		if(enumeration != null) {
Lines 6713-6720 Link Here
6713
	            result.context);
6713
	            result.context);
6714
	    
6714
	    
6715
	    assertResults(
6715
	    assertResults(
6716
	            "BLACK[FIELD_REF]{BLACK, Lp.Colors;, Lp.Colors;, BLACK, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_ENUM + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
6716
	            "BLACK[FIELD_REF]{BLACK, Lp.Colors;, Lp.Colors;, BLACK, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_ENUM + R_ENUM_CONSTANT + R_UNQUALIFIED + R_NON_RESTRICTED + R_RESOLVED) + "}\n" +
6717
				"WHITE[FIELD_REF]{WHITE, Lp.Colors;, Lp.Colors;, WHITE, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_ENUM + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
6717
				"WHITE[FIELD_REF]{WHITE, Lp.Colors;, Lp.Colors;, WHITE, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_ENUM + R_ENUM_CONSTANT + R_UNQUALIFIED + R_NON_RESTRICTED + R_RESOLVED) + "}",
6718
	            result.proposals);
6718
	            result.proposals);
6719
	} finally {
6719
	} finally {
6720
		if(aType != null) {
6720
		if(aType != null) {
Lines 8244-8252 Link Here
8244
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8244
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
8245
8245
8246
	assertResults(
8246
	assertResults(
8247
			"bar[FIELD_REF]{bar, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
8247
			"bar[FIELD_REF]{bar, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_ENUM + R_ENUM_CONSTANT + R_NON_RESTRICTED + R_RESOLVED) + "}\n" +
8248
			"baz[FIELD_REF]{baz, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, baz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
8248
			"baz[FIELD_REF]{baz, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, baz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_ENUM + R_ENUM_CONSTANT + R_NON_RESTRICTED + R_RESOLVED) + "}\n" +
8249
			"foo[FIELD_REF]{foo, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
8249
			"foo[FIELD_REF]{foo, Lenumbug.EnumBug$Foo;, Lenumbug.EnumBug$Foo;, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_ENUM + R_ENUM_CONSTANT + R_NON_RESTRICTED + R_RESOLVED) + "}",
8250
			requestor.getResults());
8250
			requestor.getResults());
8251
}
8251
}
8252
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=128169
8252
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=128169
Lines 11689-11694 Link Here
11689
			"abs[METHOD_REF]{, Ltest.util.Math;, (I)I, abs, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11689
			"abs[METHOD_REF]{, Ltest.util.Math;, (I)I, abs, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11690
			requestor.getResults());
11690
			requestor.getResults());
11691
}
11691
}
11692
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=161030
11693
public void test0364() throws JavaModelException {
11694
	this.workingCopies = new ICompilationUnit[2];
11695
	this.workingCopies[0] = getWorkingCopy(
11696
		"/Completion/src/test/Test.java",
11697
		"package test;\n"+
11698
		"import test.p.MyEnum;\n"+
11699
		"public class Test {\n"+
11700
		"	void foo(MyEnum myEnumVar) {\n"+
11701
		"	  foo(MyEnu\n"+
11702
		"	}\n"+
11703
		"}\n");
11704
	
11705
	this.workingCopies[1] = getWorkingCopy(
11706
		"/Completion/src/test/p/Math.java",
11707
		"package test.p;\n"+
11708
		"public enum MyEnum {\n"+
11709
		"	MyEnum1, MyEnum2;\n"+
11710
		"}n");
11711
11712
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11713
	String str = this.workingCopies[0].getSource();
11714
	String completeBehind = "MyEnu";
11715
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11716
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11717
11718
	assertResults(
11719
			"myEnumVar[LOCAL_VARIABLE_REF]{myEnumVar, null, Ltest.p.MyEnum;, myEnumVar, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11720
			"MyEnum[TYPE_REF]{MyEnum, test.p, Ltest.p.MyEnum;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11721
			"MyEnum1[FIELD_REF]{MyEnum.MyEnum1, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
11722
			"MyEnum2[FIELD_REF]{MyEnum.MyEnum2, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
11723
			requestor.getResults());
11724
}
11725
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=161030
11726
public void test0365() throws JavaModelException {
11727
	this.workingCopies = new ICompilationUnit[2];
11728
	this.workingCopies[0] = getWorkingCopy(
11729
		"/Completion/src/test/Test.java",
11730
		"package test;\n"+
11731
		"import test.p.MyEnum;\n"+
11732
		"public class Test {\n"+
11733
		"	void foo(MyEnum myEnumVar) {\n"+
11734
		"	  foo(myEnu\n"+
11735
		"	}\n"+
11736
		"}\n");
11737
	
11738
	this.workingCopies[1] = getWorkingCopy(
11739
		"/Completion/src/test/p/Math.java",
11740
		"package test.p;\n"+
11741
		"public enum MyEnum {\n"+
11742
		"	MyEnum1, MyEnum2;\n"+
11743
		"}n");
11744
11745
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11746
	String str = this.workingCopies[0].getSource();
11747
	String completeBehind = "myEnu";
11748
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11749
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11750
11751
	assertResults(
11752
			"MyEnum[TYPE_REF]{MyEnum, test.p, Ltest.p.MyEnum;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_ENUM + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11753
			"MyEnum1[FIELD_REF]{MyEnum.MyEnum1, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
11754
			"MyEnum2[FIELD_REF]{MyEnum.MyEnum2, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
11755
			"myEnumVar[LOCAL_VARIABLE_REF]{myEnumVar, null, Ltest.p.MyEnum;, myEnumVar, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11756
			requestor.getResults());
11757
}
11758
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=161030
11759
public void test0366() throws JavaModelException {
11760
	this.workingCopies = new ICompilationUnit[2];
11761
	this.workingCopies[0] = getWorkingCopy(
11762
		"/Completion/src/test/Test.java",
11763
		"package test;\n"+
11764
		"import test.p.MyEnum;\n"+
11765
		"public class Test {\n"+
11766
		"	void foo(MyEnum MyEnumVar) {\n"+
11767
		"	  foo(MyEnu\n"+
11768
		"	}\n"+
11769
		"}\n");
11770
	
11771
	this.workingCopies[1] = getWorkingCopy(
11772
		"/Completion/src/test/p/Math.java",
11773
		"package test.p;\n"+
11774
		"public enum MyEnum {\n"+
11775
		"	MyEnum1, MyEnum2;\n"+
11776
		"}n");
11777
11778
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11779
	String str = this.workingCopies[0].getSource();
11780
	String completeBehind = "MyEnu";
11781
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11782
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11783
11784
	assertResults(
11785
			"MyEnum[TYPE_REF]{MyEnum, test.p, Ltest.p.MyEnum;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11786
			"MyEnum1[FIELD_REF]{MyEnum.MyEnum1, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
11787
			"MyEnum2[FIELD_REF]{MyEnum.MyEnum2, Ltest.p.MyEnum;, Ltest.p.MyEnum;, MyEnum2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
11788
			"MyEnumVar[LOCAL_VARIABLE_REF]{MyEnumVar, null, Ltest.p.MyEnum;, MyEnumVar, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ENUM + R_ENUM_CONSTANT + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11789
			requestor.getResults());
11790
}
11692
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
11791
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
11693
public void testEC001() throws JavaModelException {
11792
public void testEC001() throws JavaModelException {
11694
	this.workingCopies = new ICompilationUnit[1];
11793
	this.workingCopies = new ICompilationUnit[1];
(-)codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java (-1 / +1 lines)
Lines 24-30 Link Here
24
	int R_ENUM = 20;
24
	int R_ENUM = 20;
25
	int R_ANNOTATION = 20;
25
	int R_ANNOTATION = 20;
26
	int R_EXCEPTION = 20;
26
	int R_EXCEPTION = 20;
27
	int R_ENUM_CONSTANT = 20;
27
	int R_ENUM_CONSTANT = 5;
28
	int R_ABSTRACT_METHOD = 20;
28
	int R_ABSTRACT_METHOD = 20;
29
	int R_NON_STATIC = 11;
29
	int R_NON_STATIC = 11;
30
	int R_UNQUALIFIED = 3;
30
	int R_UNQUALIFIED = 3;
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-52 / +205 lines)
Lines 1107-1117 Link Here
1107
					&& switchStatement.expression.resolvedType.isEnum()) {
1107
					&& switchStatement.expression.resolvedType.isEnum()) {
1108
				if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
1108
				if (!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
1109
					this.assistNodeIsEnum = true;
1109
					this.assistNodeIsEnum = true;
1110
					this.findEnumConstant(this.completionToken, (SwitchStatement) astNodeParent);
1110
					this.findEnumConstantsFromSwithStatement(this.completionToken, (SwitchStatement) astNodeParent);
1111
				}
1111
				}
1112
			} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
1112
			} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
1113
				findTypesAndPackages(this.completionToken, scope, false, false, new ObjectVector());
1113
				findTypesAndPackages(this.completionToken, scope, false, false, new ObjectVector());
1114
			} else {
1114
			} else {
1115
				if (this.expectedTypesPtr > -1) {
1116
					this.assistNodeIsEnum = true;
1117
					done : for (int i = 0; i <= this.expectedTypesPtr; i++) {
1118
						if (!this.expectedTypes[i].isEnum()) {
1119
							this.assistNodeIsEnum = false;
1120
							break done;
1121
						}
1122
					}
1123
					
1124
				}
1115
				if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
1125
				if (scope instanceof BlockScope && !this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
1116
					char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, singleNameReference);
1126
					char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, singleNameReference);
1117
					
1127
					
Lines 2781-2787 Link Here
2781
			}
2791
			}
2782
		}
2792
		}
2783
	}
2793
	}
2784
	private void findEnumConstant(char[] enumConstantName, SwitchStatement switchStatement) {
2794
	private void findEnumConstantsFromSwithStatement(char[] enumConstantName, SwitchStatement switchStatement) {
2785
		TypeBinding expressionType = switchStatement.expression.resolvedType;
2795
		TypeBinding expressionType = switchStatement.expression.resolvedType;
2786
		if(expressionType != null && expressionType.isEnum()) {
2796
		if(expressionType != null && expressionType.isEnum()) {
2787
			ReferenceBinding enumType = (ReferenceBinding) expressionType;
2797
			ReferenceBinding enumType = (ReferenceBinding) expressionType;
Lines 2798-2853 Link Here
2798
				}
2808
				}
2799
			}
2809
			}
2800
			
2810
			
2801
			FieldBinding[] fields = enumType.fields();
2811
			findEnumConstants(
2802
			
2812
					enumConstantName,
2803
			int enumConstantLength = enumConstantName.length;
2813
					enumType,
2804
			next : for (int f = fields.length; --f >= 0;) {			
2814
					null /* doesn't need invocation scope */,
2805
				FieldBinding field = fields[f];
2815
					new ObjectVector(),
2806
2816
					alreadyUsedConstants,
2807
				if (field.isSynthetic()) continue next;
2817
					alreadyUsedConstantCount,
2808
2818
					false);
2809
				if ((field.modifiers & Flags.AccEnum) == 0) continue next;
2810
2811
				if (enumConstantLength > field.name.length) continue next;
2812
2813
				if (!CharOperation.prefixEquals(enumConstantName, field.name, false /* ignore case */)
2814
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(enumConstantName, field.name)))	continue next;
2815
				
2816
				char[] completion = field.name;
2817
				
2818
				for (int i = 0; i < alreadyUsedConstantCount; i++) {
2819
					if(CharOperation.equals(alreadyUsedConstants[i], completion)) continue next;
2820
				}
2821
2822
				int relevance = computeBaseRelevance();
2823
				relevance += computeRelevanceForInterestingProposal(field);
2824
				relevance += computeRelevanceForEnum();
2825
				relevance += computeRelevanceForCaseMatching(enumConstantName, field.name);
2826
				relevance += computeRelevanceForExpectingType(field.type);
2827
				relevance += computeRelevanceForQualification(false);
2828
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
2829
				
2830
				this.noProposal = false;
2831
				if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
2832
					CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
2833
					proposal.setDeclarationSignature(getSignature(field.declaringClass));
2834
					proposal.setSignature(getSignature(field.type));
2835
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
2836
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
2837
					proposal.setPackageName(field.type.qualifiedPackageName());
2838
					proposal.setTypeName(field.type.qualifiedSourceName()); 
2839
					proposal.setName(field.name);
2840
					proposal.setCompletion(completion);
2841
					proposal.setFlags(field.modifiers);
2842
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
2843
					proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
2844
					proposal.setRelevance(relevance);
2845
					this.requestor.accept(proposal);
2846
					if(DEBUG) {
2847
						this.printDebug(proposal);
2848
					}
2849
				}
2850
			}
2851
		}
2819
		}
2852
	}
2820
	}
2853
	
2821
	
Lines 3524-3529 Link Here
3524
			relevance += computeRelevanceForInterestingProposal(field);
3492
			relevance += computeRelevanceForInterestingProposal(field);
3525
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
3493
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
3526
			relevance += computeRelevanceForExpectingType(field.type);
3494
			relevance += computeRelevanceForExpectingType(field.type);
3495
			relevance += computeRelevanceForEnumConstant(field.type);
3527
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
3496
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
3528
			relevance += computeRelevanceForQualification(prefixRequired);
3497
			relevance += computeRelevanceForQualification(prefixRequired);
3529
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
3498
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
Lines 4437-4442 Link Here
4437
			relevance += computeRelevanceForInterestingProposal(field);
4406
			relevance += computeRelevanceForInterestingProposal(field);
4438
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
4407
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
4439
			relevance += computeRelevanceForExpectingType(field.type);
4408
			relevance += computeRelevanceForExpectingType(field.type);
4409
			relevance += computeRelevanceForEnumConstant(field.type);
4440
			relevance += computeRelevanceForStatic(true, true);
4410
			relevance += computeRelevanceForStatic(true, true);
4441
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4411
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4442
			
4412
			
Lines 5992-5997 Link Here
5992
			relevance += computeRelevanceForInterestingProposal();
5962
			relevance += computeRelevanceForInterestingProposal();
5993
			if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
5963
			if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
5994
			relevance += computeRelevanceForExpectingType(method.returnType);
5964
			relevance += computeRelevanceForExpectingType(method.returnType);
5965
			relevance += computeRelevanceForEnumConstant(method.returnType);
5995
			relevance += computeRelevanceForStatic(onlyStaticMethods, method.isStatic());
5966
			relevance += computeRelevanceForStatic(onlyStaticMethods, method.isStatic());
5996
			relevance += computeRelevanceForQualification(prefixRequired);
5967
			relevance += computeRelevanceForQualification(prefixRequired);
5997
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
5968
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
Lines 6251-6256 Link Here
6251
				relevance += computeRelevanceForInterestingProposal();
6222
				relevance += computeRelevanceForInterestingProposal();
6252
				if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
6223
				if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
6253
				relevance += computeRelevanceForExpectingType(method.returnType);
6224
				relevance += computeRelevanceForExpectingType(method.returnType);
6225
				relevance += computeRelevanceForEnumConstant(method.returnType);
6254
				relevance += computeRelevanceForStatic(true, method.isStatic());
6226
				relevance += computeRelevanceForStatic(true, method.isStatic());
6255
				relevance += computeRelevanceForQualification(true);
6227
				relevance += computeRelevanceForQualification(true);
6256
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6228
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
Lines 6522-6527 Link Here
6522
			relevance += computeRelevanceForInterestingProposal();
6494
			relevance += computeRelevanceForInterestingProposal();
6523
			relevance += computeRelevanceForCaseMatching(methodName, method.selector);
6495
			relevance += computeRelevanceForCaseMatching(methodName, method.selector);
6524
			relevance += computeRelevanceForExpectingType(method.returnType);
6496
			relevance += computeRelevanceForExpectingType(method.returnType);
6497
			relevance += computeRelevanceForEnumConstant(method.returnType);
6525
			relevance += computeRelevanceForStatic(true, method.isStatic());
6498
			relevance += computeRelevanceForStatic(true, method.isStatic());
6526
			relevance += computeRelevanceForQualification(false);
6499
			relevance += computeRelevanceForQualification(false);
6527
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6500
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
Lines 6643-6648 Link Here
6643
		}
6616
		}
6644
		return 0;
6617
		return 0;
6645
	}
6618
	}
6619
	private int computeRelevanceForEnumConstant(TypeBinding proposalType){
6620
		if(this.assistNodeIsEnum &&
6621
				proposalType != null &&
6622
				this.expectedTypes != null) {
6623
			for (int i = 0; i <= this.expectedTypesPtr; i++) {
6624
				if (proposalType.isEnum() &&
6625
						proposalType == this.expectedTypes[i]) {
6626
					return R_ENUM + R_ENUM_CONSTANT;
6627
				}
6628
			
6629
			}
6630
		} 
6631
		return 0;
6632
	}
6646
	private int computeRelevanceForException(){
6633
	private int computeRelevanceForException(){
6647
		if (this.assistNodeIsException) {
6634
		if (this.assistNodeIsException) {
6648
			return R_EXCEPTION;
6635
			return R_EXCEPTION;
Lines 8186-8191 Link Here
8186
							relevance += computeRelevanceForInterestingProposal(local);
8173
							relevance += computeRelevanceForInterestingProposal(local);
8187
							relevance += computeRelevanceForCaseMatching(token, local.name);
8174
							relevance += computeRelevanceForCaseMatching(token, local.name);
8188
							relevance += computeRelevanceForExpectingType(local.type);
8175
							relevance += computeRelevanceForExpectingType(local.type);
8176
							relevance += computeRelevanceForEnumConstant(local.type);
8189
							relevance += computeRelevanceForQualification(false);
8177
							relevance += computeRelevanceForQualification(false);
8190
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
8178
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
8191
							this.noProposal = false;
8179
							this.noProposal = false;
Lines 8329-8334 Link Here
8329
						fieldsFound,
8317
						fieldsFound,
8330
						methodsFound);
8318
						methodsFound);
8331
			}
8319
			}
8320
			
8321
			findEnumConstantsFromExpectedTypes(
8322
					token,
8323
					invocationScope,
8324
					fieldsFound);
8325
		}
8326
	}
8327
8328
	private void findEnumConstantsFromExpectedTypes(
8329
			char[] token,
8330
			Scope invocationScope,
8331
			ObjectVector fieldsFound) {
8332
		int length = this.expectedTypesPtr + 1;
8333
		for (int i = 0; i < length; i++) {
8334
			if (this.expectedTypes[i].isEnum()) {
8335
				findEnumConstants(
8336
						token,
8337
						(ReferenceBinding)this.expectedTypes[i],
8338
						invocationScope,
8339
						fieldsFound,
8340
						CharOperation.NO_CHAR_CHAR,
8341
						0,
8342
						true);
8343
			}
8344
		}
8345
		
8346
	}
8347
8348
	private void findEnumConstants(
8349
			char[] enumConstantName,
8350
			ReferenceBinding enumType,
8351
			Scope invocationScope,
8352
			ObjectVector fieldsFound,
8353
			char[][] alreadyUsedConstants,
8354
			int alreadyUsedConstantCount,
8355
			boolean needQualification) {
8356
		
8357
		FieldBinding[] fields = enumType.fields();
8358
			
8359
		int enumConstantLength = enumConstantName.length;
8360
		next : for (int f = fields.length; --f >= 0;) {			
8361
			FieldBinding field = fields[f];
8362
8363
			if (field.isSynthetic()) continue next;
8364
8365
			if ((field.modifiers & Flags.AccEnum) == 0) continue next;
8366
8367
			if (enumConstantLength > field.name.length) continue next;
8368
8369
			if (!CharOperation.prefixEquals(enumConstantName, field.name, false /* ignore case */)
8370
					&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(enumConstantName, field.name)))	continue next;
8371
			
8372
			char[] fieldName = field.name;
8373
			
8374
			for (int i = 0; i < alreadyUsedConstantCount; i++) {
8375
				if(CharOperation.equals(alreadyUsedConstants[i], fieldName)) continue next;
8376
			}
8377
			
8378
			int relevance = computeBaseRelevance();
8379
			relevance += computeRelevanceForResolution();
8380
			relevance += computeRelevanceForInterestingProposal(field);
8381
			relevance += computeRelevanceForCaseMatching(enumConstantName, field.name);
8382
			relevance += computeRelevanceForExpectingType(field.type);
8383
			relevance += computeRelevanceForEnumConstant(field.type);
8384
			relevance += computeRelevanceForQualification(needQualification);
8385
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
8386
			
8387
			this.noProposal = false;
8388
			if (!needQualification) {
8389
				char[] completion = fieldName;
8390
				
8391
				if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
8392
					CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
8393
					proposal.setDeclarationSignature(getSignature(field.declaringClass));
8394
					proposal.setSignature(getSignature(field.type));
8395
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
8396
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
8397
					proposal.setPackageName(field.type.qualifiedPackageName());
8398
					proposal.setTypeName(field.type.qualifiedSourceName()); 
8399
					proposal.setName(field.name);
8400
					proposal.setCompletion(completion);
8401
					proposal.setFlags(field.modifiers);
8402
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
8403
					proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
8404
					proposal.setRelevance(relevance);
8405
					this.requestor.accept(proposal);
8406
					if(DEBUG) {
8407
						this.printDebug(proposal);
8408
					}
8409
				}
8410
				
8411
			} else {
8412
				TypeBinding visibleType = invocationScope.getType(field.type.sourceName());
8413
				boolean needImport = visibleType == null || !visibleType.isValidBinding();
8414
				
8415
				char[] completion = CharOperation.concat(field.type.sourceName(), field.name, '.');
8416
				
8417
				if (!needImport) {
8418
					if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) {
8419
						CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
8420
						proposal.setDeclarationSignature(getSignature(field.declaringClass));
8421
						proposal.setSignature(getSignature(field.type));
8422
						proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
8423
						proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
8424
						proposal.setPackageName(field.type.qualifiedPackageName());
8425
						proposal.setTypeName(field.type.qualifiedSourceName()); 
8426
						proposal.setName(field.name);
8427
						proposal.setCompletion(completion);
8428
						proposal.setFlags(field.modifiers);
8429
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
8430
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
8431
						proposal.setRelevance(relevance);
8432
						this.requestor.accept(proposal);
8433
						if(DEBUG) {
8434
							this.printDebug(proposal);
8435
						}
8436
					}
8437
				} else {
8438
					if (!this.isIgnored(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT)) {
8439
						CompilationUnitDeclaration cu = this.unitScope.referenceContext;
8440
						int importStart = cu.types[0].declarationSourceStart;
8441
						int importEnd = importStart;
8442
						
8443
						ReferenceBinding fieldType = (ReferenceBinding)field.type;
8444
						
8445
						CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
8446
						proposal.setDeclarationSignature(getSignature(field.declaringClass));
8447
						proposal.setSignature(getSignature(field.type));
8448
						proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
8449
						proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
8450
						proposal.setPackageName(field.type.qualifiedPackageName());
8451
						proposal.setTypeName(field.type.qualifiedSourceName()); 
8452
						proposal.setName(field.name);
8453
						proposal.setCompletion(completion);
8454
						proposal.setFlags(field.modifiers);
8455
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
8456
						proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset);
8457
						proposal.setRelevance(relevance);
8458
						
8459
						char[] typeImportCompletion = createImportCharArray(CharOperation.concatWith(fieldType.compoundName, '.'), false, false);
8460
						
8461
						CompletionProposal typeImportProposal = this.createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition);
8462
						typeImportProposal.nameLookup = this.nameEnvironment.nameLookup;
8463
						typeImportProposal.completionEngine = this;
8464
						char[] packageName = fieldType.qualifiedPackageName();
8465
						typeImportProposal.setDeclarationSignature(packageName);
8466
						typeImportProposal.setSignature(getSignature(fieldType));
8467
						typeImportProposal.setPackageName(packageName);
8468
						typeImportProposal.setTypeName(fieldType.qualifiedSourceName());
8469
						typeImportProposal.setCompletion(typeImportCompletion);
8470
						typeImportProposal.setFlags(fieldType.modifiers);
8471
						typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
8472
						typeImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset);
8473
						typeImportProposal.setTokenRange(importStart - this.offset, importEnd - this.offset);
8474
						typeImportProposal.setRelevance(relevance);
8475
						
8476
						proposal.setRequiredProposals(new CompletionProposal[]{typeImportProposal});
8477
						
8478
						this.requestor.accept(proposal);
8479
						if(DEBUG) {
8480
							this.printDebug(proposal);
8481
						}
8482
					}
8483
				}
8484
			}
8332
		}
8485
		}
8333
	}
8486
	}
8334
8487

Return to bug 161030