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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-2 / +41 lines)
Lines 523-528 Link Here
523
	boolean assistNodeIsInterfaceExcludingAnnotation; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423
523
	boolean assistNodeIsInterfaceExcludingAnnotation; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423
524
	int  assistNodeInJavadoc = 0;
524
	int  assistNodeInJavadoc = 0;
525
	boolean assistNodeCanBeSingleMemberAnnotation = false;
525
	boolean assistNodeCanBeSingleMemberAnnotation = false;
526
	boolean assistNodeIsInsideCase = false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
526
	
527
	
527
	long targetedElement;
528
	long targetedElement;
528
	
529
	
Lines 2860-2865 Link Here
2860
		return false;
2861
		return false;
2861
	}
2862
	}
2862
	
2863
	
2864
	private boolean assistNodeIsInsideCase(ASTNode astNode, ASTNode astNodeParent) {
2865
		// To find whether we're completing inside the case expression in a 
2866
		// switch case construct (https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346)
2867
		if (astNodeParent instanceof SwitchStatement) {
2868
			CaseStatement[] cases = ((SwitchStatement) astNodeParent).cases;
2869
			for (int i = 0, caseCount = ((SwitchStatement) astNodeParent).caseCount; i < caseCount; i++) {
2870
				CompletionNodeDetector detector = new CompletionNodeDetector(astNode, cases[i]);
2871
				if (detector.containsCompletionNode()) {
2872
					return true;
2873
				}
2874
			}
2875
		}
2876
		return false;
2877
	}
2878
2863
	private void completionOnQualifiedAllocationExpression(ASTNode astNode, Binding qualifiedBinding, Scope scope) {
2879
	private void completionOnQualifiedAllocationExpression(ASTNode astNode, Binding qualifiedBinding, Scope scope) {
2864
		setSourceAndTokenRange(astNode.sourceStart, astNode.sourceEnd, false);
2880
		setSourceAndTokenRange(astNode.sourceStart, astNode.sourceEnd, false);
2865
2881
Lines 2916-2921 Link Here
2916
			(CompletionOnQualifiedNameReference) astNode;
2932
			(CompletionOnQualifiedNameReference) astNode;
2917
		this.completionToken = ref.completionIdentifier;
2933
		this.completionToken = ref.completionIdentifier;
2918
		long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
2934
		long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
2935
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, this.parser.assistNodeParent);
2919
2936
2920
		if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
2937
		if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
2921
			setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition);
2938
			setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition);
Lines 3060-3066 Link Here
3060
		this.assistNodeIsSuperType = ref.isSuperType();
3077
		this.assistNodeIsSuperType = ref.isSuperType();
3061
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3078
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3062
		this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent);
3079
		this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent);
3063
3080
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3081
		
3064
		this.completionToken = ref.completionIdentifier;
3082
		this.completionToken = ref.completionIdentifier;
3065
		long completionPosition = ref.sourcePositions[ref.tokens.length];
3083
		long completionPosition = ref.sourcePositions[ref.tokens.length];
3066
3084
Lines 3120-3125 Link Here
3120
		CompletionOnSingleNameReference singleNameReference = (CompletionOnSingleNameReference) astNode;
3138
		CompletionOnSingleNameReference singleNameReference = (CompletionOnSingleNameReference) astNode;
3121
		this.completionToken = singleNameReference.token;
3139
		this.completionToken = singleNameReference.token;
3122
		SwitchStatement switchStatement = astNodeParent instanceof SwitchStatement ? (SwitchStatement) astNodeParent : null;
3140
		SwitchStatement switchStatement = astNodeParent instanceof SwitchStatement ? (SwitchStatement) astNodeParent : null;
3141
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3123
		if (switchStatement != null
3142
		if (switchStatement != null
3124
				&& switchStatement.expression.resolvedType != null
3143
				&& switchStatement.expression.resolvedType != null
3125
				&& switchStatement.expression.resolvedType.isEnum()) {
3144
				&& switchStatement.expression.resolvedType.isEnum()) {
Lines 3195-3201 Link Here
3195
		this.assistNodeIsSuperType = singleRef.isSuperType();
3214
		this.assistNodeIsSuperType = singleRef.isSuperType();
3196
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3215
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3197
		this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent);
3216
		this.assistNodeIsInterfaceExcludingAnnotation = assistNodeIsInterfaceExcludingAnnotation(astNode, astNodeParent);
3198
3217
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3218
		
3199
		// can be the start of a qualified type name
3219
		// can be the start of a qualified type name
3200
		if (qualifiedBinding == null) {
3220
		if (qualifiedBinding == null) {
3201
			if (this.completionToken.length == 0 &&
3221
			if (this.completionToken.length == 0 &&
Lines 4105-4110 Link Here
4105
		}
4125
		}
4106
		return 0;
4126
		return 0;
4107
	}
4127
	}
4128
	
4129
	private int computeRelevanceForFinal(boolean onlyFinal, boolean isFinal) {
4130
		if (onlyFinal && isFinal) {
4131
			return R_FINAL;
4132
		}
4133
		return 0;
4134
	}
4108
4135
4109
	private long computeTargetedElement(CompletionOnAnnotationOfType fakeNode) {
4136
	private long computeTargetedElement(CompletionOnAnnotationOfType fakeNode) {
4110
		ASTNode annotatedElement = fakeNode.potentialAnnotatedNode;
4137
		ASTNode annotatedElement = fakeNode.potentialAnnotatedNode;
Lines 5968-5973 Link Here
5968
			if (this.options.checkVisibility
5995
			if (this.options.checkVisibility
5969
				&& !field.canBeSeenBy(receiverType, invocationSite, scope))	continue next;
5996
				&& !field.canBeSeenBy(receiverType, invocationSite, scope))	continue next;
5970
			
5997
			
5998
			// don't propose array types in case expression
5999
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
6000
			if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding)
6001
				continue next;
6002
			
5971
			int ptr = this.uninterestingBindingsPtr;
6003
			int ptr = this.uninterestingBindingsPtr;
5972
			// Cases where the binding is uninteresting eg. for completion occurring inside a field declaration,
6004
			// Cases where the binding is uninteresting eg. for completion occurring inside a field declaration,
5973
			// the field binding is uninteresting and shouldn't be proposed.
6005
			// the field binding is uninteresting and shouldn't be proposed.
Lines 6064-6069 Link Here
6064
			relevance += computeRelevanceForExpectingType(field.type);
6096
			relevance += computeRelevanceForExpectingType(field.type);
6065
			relevance += computeRelevanceForEnumConstant(field.type);
6097
			relevance += computeRelevanceForEnumConstant(field.type);
6066
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
6098
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
6099
			relevance += computeRelevanceForFinal(this.assistNodeIsInsideCase, field.isFinal());
6067
			relevance += computeRelevanceForQualification(prefixRequired);
6100
			relevance += computeRelevanceForQualification(prefixRequired);
6068
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6101
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6069
			if (onlyStaticFields && this.insideQualifiedReference) {
6102
			if (onlyStaticFields && this.insideQualifiedReference) {
Lines 11353-11358 Link Here
11353
11386
11354
							if (local.isSecret())
11387
							if (local.isSecret())
11355
								continue next;
11388
								continue next;
11389
												
11390
							// don't propose array types in case expression
11391
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
11392
							if (this.assistNodeIsInsideCase && local.type instanceof ArrayBinding)
11393
								continue next;
11356
							
11394
							
11357
							int ptr = this.uninterestingBindingsPtr;
11395
							int ptr = this.uninterestingBindingsPtr;
11358
							// Cases where the binding is uninteresting eg. for completion occurring inside a local var
11396
							// Cases where the binding is uninteresting eg. for completion occurring inside a local var
Lines 11380-11385 Link Here
11380
							relevance += computeRelevanceForEnumConstant(local.type);
11418
							relevance += computeRelevanceForEnumConstant(local.type);
11381
							relevance += computeRelevanceForQualification(false);
11419
							relevance += computeRelevanceForQualification(false);
11382
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
11420
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
11421
							relevance += computeRelevanceForFinal(this.assistNodeIsInsideCase, local.isFinal());
11383
							this.noProposal = false;
11422
							this.noProposal = false;
11384
							if(!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
11423
							if(!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
11385
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition);
11424
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition);
(-)codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java (+1 lines)
Lines 53-56 Link Here
53
	int R_NO_PROBLEMS = 1;
53
	int R_NO_PROBLEMS = 1;
54
	int R_RESOLVED = 1;
54
	int R_RESOLVED = 1;
55
	int R_TARGET = 5;
55
	int R_TARGET = 5;
56
	int R_FINAL = 3; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
56
}
57
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-16 / +92 lines)
Lines 1897-1903 Link Here
1897
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1897
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1898
1898
1899
	assertResults(
1899
	assertResults(
1900
			"zzz[FIELD_REF]{zzz, LCompletionAfterCase1;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
1900
			"zzz[FIELD_REF]{zzz, LCompletionAfterCase1;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
1901
			requestor.getResults());
1901
			requestor.getResults());
1902
}
1902
}
1903
public void testCompletionAfterCase2() throws JavaModelException {
1903
public void testCompletionAfterCase2() throws JavaModelException {
Lines 1921-1927 Link Here
1921
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1921
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1922
1922
1923
	assertResults(
1923
	assertResults(
1924
			"zzz[FIELD_REF]{zzz, LCompletionAfterCase2;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
1924
			"zzz[FIELD_REF]{zzz, LCompletionAfterCase2;, I, zzz, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
1925
			requestor.getResults());
1925
			requestor.getResults());
1926
}
1926
}
1927
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
1927
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
Lines 1952-1964 Link Here
1952
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1952
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1953
1953
1954
	assertResults(
1954
	assertResults(
1955
			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.CompletionAfterCase2;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1955
			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.CompletionAfterCase2;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
1956
			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.CompletionAfterCase2;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1956
			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.CompletionAfterCase2;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
1957
			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.CompletionAfterCase2;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1957
			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.CompletionAfterCase2;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
1958
			"ZZZ5[FIELD_REF]{ZZZ5, Ltest.CompletionAfterCase2;, [I, ZZZ5, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1958
			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.CompletionAfterCase2;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
1959
			"ZZZ6[FIELD_REF]{ZZZ6, Ltest.CompletionAfterCase2;, [Ljava.lang.Object;, ZZZ6, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1959
			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.CompletionAfterCase2;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
1960
			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.CompletionAfterCase2;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1961
			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.CompletionAfterCase2;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
1962
			requestor.getResults());
1960
			requestor.getResults());
1963
}
1961
}
1964
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
1962
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111882
Lines 1995-2007 Link Here
1995
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1993
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1996
1994
1997
	assertResults(
1995
	assertResults(
1998
			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.TestConstants;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1996
			"ZZZ2[FIELD_REF]{ZZZ2, Ltest.TestConstants;, J, ZZZ2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
1999
			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.TestConstants;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1997
			"ZZZ3[FIELD_REF]{ZZZ3, Ltest.TestConstants;, D, ZZZ3, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
2000
			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.TestConstants;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1998
			"ZZZ4[FIELD_REF]{ZZZ4, Ltest.TestConstants;, Ljava.lang.Object;, ZZZ4, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
2001
			"ZZZ5[FIELD_REF]{ZZZ5, Ltest.TestConstants;, [I, ZZZ5, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
1999
			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.TestConstants;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}\n" +
2002
			"ZZZ6[FIELD_REF]{ZZZ6, Ltest.TestConstants;, [Ljava.lang.Object;, ZZZ6, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
2000
			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.TestConstants;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_QUALIFIED + R_NON_RESTRICTED + R_FINAL) + "}",
2003
			"ZZZ7[FIELD_REF]{ZZZ7, Ltest.TestConstants;, S, ZZZ7, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXPECTED_TYPE + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}\n" +
2004
			"ZZZ1[FIELD_REF]{ZZZ1, Ltest.TestConstants;, I, ZZZ1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED) + "}",
2005
			requestor.getResults());
2001
			requestor.getResults());
2006
}
2002
}
2007
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222080
2003
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=222080
Lines 21378-21381 Link Here
21378
			"myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, 57}",
21374
			"myVar1[LOCAL_VARIABLE_REF]{myVar1, null, I, myVar1, null, 57}",
21379
			requestor.getResults());
21375
			requestor.getResults());
21380
}
21376
}
21377
21378
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
21379
// To verify that array types aren't proposed inside case, and also
21380
// that finals have a higher priority in suggestions inside case expressions.
21381
public void testBug195346a() throws JavaModelException {
21382
	this.workingCopies = new ICompilationUnit[1];
21383
	this.workingCopies[0] = getWorkingCopy(
21384
		"/Completion/src/test/CompletionAfterCase2.java",
21385
		"package test;\n" +
21386
		"public class CompletionAfterCase2 {\n" +
21387
		"	static char[] AN_ARRAY = new char[10];\n" +
21388
		"	static int AN_INT_VALUE = 0;\n" +
21389
		"	static final int AN_INT_VALUE2 = 0;\n" +
21390
		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
21391
		"	static final int[] AN_INT_ARRAY = null;\n" +
21392
		"	static final Object[] ANOTHER_ARRAY = null;\n" +
21393
		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
21394
		"		final int AN_INT_VAR = 1;\n" +
21395
		"		final int[] AN_ARRAY_VAR = {1};\n" +
21396
		"		int AN_INT_VAR2 = 1;\n" +
21397
		"		switch(i) {\n" +
21398
		"			case AN\n" +
21399
		"		}\n" +
21400
		"	}\n" +
21401
		"}\n");
21402
21403
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21404
	String str = this.workingCopies[0].getSource();
21405
	String completeBehind = "AN";
21406
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21407
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21408
21409
	assertResults(
21410
			"AN_INT_VALUE[FIELD_REF]{AN_INT_VALUE, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
21411
			"AN_INT_VAR2[LOCAL_VARIABLE_REF]{AN_INT_VAR2, null, I, AN_INT_VAR2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
21412
			"AN_INT_VALUE2[FIELD_REF]{AN_INT_VALUE2, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}\n" +
21413
			"AN_INT_VAR[LOCAL_VARIABLE_REF]{AN_INT_VAR, null, I, AN_INT_VAR, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}",
21414
			requestor.getResults());
21415
}
21416
21417
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
21418
// To verify that array types aren't proposed inside case, and also
21419
// that finals have a higher priority in suggestions inside case expressions.
21420
public void testBug195346b() throws JavaModelException {
21421
	this.workingCopies = new ICompilationUnit[1];
21422
	this.workingCopies[0] = getWorkingCopy(
21423
		"/Completion/src/test/CompletionAfterCase2.java",
21424
		"package test;\n" +
21425
		"public class CompletionAfterCase2 {\n" +
21426
		"	class AN_INNER_CLASS {\n" +
21427
		"		static final int abc = 1;\n" +
21428
		"	}\n" +
21429
		"	static char[] AN_ARRAY = new char[10];\n" +
21430
		"	static int AN_INT_VALUE = 0;\n" +
21431
		"	static final int AN_INT_VALUE2 = 0;\n" +
21432
		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
21433
		"	static final int[] AN_INT_ARRAY = null;\n" +
21434
		"	static final Object[] ANOTHER_ARRAY = null;\n" +
21435
		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
21436
		"		final int AN_INT_VAR = 1;\n" +
21437
		"		final int[] AN_ARRAY_VAR = {1};\n" +
21438
		"		int AN_INT_VAR2 = 1;\n" +
21439
		"		switch(i) {\n" +
21440
		"			case CompletionAfterCase2.AN\n" +
21441
		"		}\n" +
21442
		"	}\n" +
21443
		"}\n");
21444
21445
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21446
	String str = this.workingCopies[0].getSource();
21447
	String completeBehind = "AN";
21448
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21449
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21450
21451
	assertResults(
21452
			"CompletionAfterCase2.AN_INNER_CLASS[TYPE_REF]{AN_INNER_CLASS, test, Ltest.CompletionAfterCase2$AN_INNER_CLASS;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
21453
			"AN_INT_VALUE[FIELD_REF]{AN_INT_VALUE, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" +
21454
			"AN_INT_VALUE2[FIELD_REF]{AN_INT_VALUE2, Ltest.CompletionAfterCase2;, I, AN_INT_VALUE2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE + R_FINAL) + "}",
21455
			requestor.getResults());
21456
}
21381
}
21457
}

Return to bug 195346