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 (-5 / +43 lines)
Lines 522-527 Link Here
522
	boolean assistNodeIsExtendedType;
522
	boolean assistNodeIsExtendedType;
523
	int  assistNodeInJavadoc = 0;
523
	int  assistNodeInJavadoc = 0;
524
	boolean assistNodeCanBeSingleMemberAnnotation = false;
524
	boolean assistNodeCanBeSingleMemberAnnotation = false;
525
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
526
	boolean assistNodeIsInsideCase = false;
525
	
527
	
526
	long targetedElement;
528
	long targetedElement;
527
	
529
	
Lines 1691-1696 Link Here
1691
		return true;
1693
		return true;
1692
	}
1694
	}
1693
1695
1696
	private boolean assistNodeIsInsideCase(ASTNode astNode, ASTNode astNodeParent) {
1697
		// To find whether we're completing inside the case expression in a 
1698
		// switch case construct (https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346)
1699
		if (astNodeParent instanceof SwitchStatement) {
1700
			CaseStatement[] cases = ((SwitchStatement) astNodeParent).cases;
1701
			for (int i = 0; i < ((SwitchStatement) astNodeParent).caseCount; i++) {
1702
				CompletionNodeDetector detector = new CompletionNodeDetector(astNode, cases[i]);
1703
				if (detector.containsCompletionNode()) {
1704
					return true;
1705
				}
1706
			}
1707
		}
1708
		return false;
1709
	}
1710
1694
	/**
1711
	/**
1695
	 * Ask the engine to compute a completion at the specified position
1712
	 * Ask the engine to compute a completion at the specified position
1696
	 * of the given compilation unit.
1713
	 * of the given compilation unit.
Lines 2898-2904 Link Here
2898
			(CompletionOnQualifiedNameReference) astNode;
2915
			(CompletionOnQualifiedNameReference) astNode;
2899
		this.completionToken = ref.completionIdentifier;
2916
		this.completionToken = ref.completionIdentifier;
2900
		long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
2917
		long completionPosition = ref.sourcePositions[ref.sourcePositions.length - 1];
2901
2918
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, this.parser.assistNodeParent);
2902
		if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
2919
		if (qualifiedBinding.problemId() == ProblemReasons.NotFound) {
2903
			setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition);
2920
			setSourceAndTokenRange((int) (completionPosition >>> 32), (int) completionPosition);
2904
			// complete field members with missing fields type
2921
			// complete field members with missing fields type
Lines 3041-3047 Link Here
3041
		this.assistNodeIsConstructor = ref.isConstructorType;
3058
		this.assistNodeIsConstructor = ref.isConstructorType;
3042
		this.assistNodeIsSuperType = ref.isSuperType();
3059
		this.assistNodeIsSuperType = ref.isSuperType();
3043
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3060
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3044
3061
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3045
		this.completionToken = ref.completionIdentifier;
3062
		this.completionToken = ref.completionIdentifier;
3046
		long completionPosition = ref.sourcePositions[ref.tokens.length];
3063
		long completionPosition = ref.sourcePositions[ref.tokens.length];
3047
3064
Lines 3101-3106 Link Here
3101
		CompletionOnSingleNameReference singleNameReference = (CompletionOnSingleNameReference) astNode;
3118
		CompletionOnSingleNameReference singleNameReference = (CompletionOnSingleNameReference) astNode;
3102
		this.completionToken = singleNameReference.token;
3119
		this.completionToken = singleNameReference.token;
3103
		SwitchStatement switchStatement = astNodeParent instanceof SwitchStatement ? (SwitchStatement) astNodeParent : null;
3120
		SwitchStatement switchStatement = astNodeParent instanceof SwitchStatement ? (SwitchStatement) astNodeParent : null;
3121
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3104
		if (switchStatement != null
3122
		if (switchStatement != null
3105
				&& switchStatement.expression.resolvedType != null
3123
				&& switchStatement.expression.resolvedType != null
3106
				&& switchStatement.expression.resolvedType.isEnum()) {
3124
				&& switchStatement.expression.resolvedType.isEnum()) {
Lines 3175-3181 Link Here
3175
		this.assistNodeIsConstructor = singleRef.isConstructorType;
3193
		this.assistNodeIsConstructor = singleRef.isConstructorType;
3176
		this.assistNodeIsSuperType = singleRef.isSuperType();
3194
		this.assistNodeIsSuperType = singleRef.isSuperType();
3177
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3195
		this.assistNodeIsExtendedType = assistNodeIsExtendedType(astNode, astNodeParent);
3178
3196
		this.assistNodeIsInsideCase = assistNodeIsInsideCase(astNode, astNodeParent);
3197
		
3179
		// can be the start of a qualified type name
3198
		// can be the start of a qualified type name
3180
		if (qualifiedBinding == null) {
3199
		if (qualifiedBinding == null) {
3181
			if (this.completionToken.length == 0 &&
3200
			if (this.completionToken.length == 0 &&
Lines 4086-4091 Link Here
4086
		return 0;
4105
		return 0;
4087
	}
4106
	}
4088
4107
4108
	private int computeRelevanceForFinal(boolean onlyFinal, boolean isFinal) {
4109
		if (onlyFinal && isFinal) {
4110
			return R_FINAL;
4111
		}
4112
		return 0;
4113
	}
4114
	
4089
	private long computeTargetedElement(CompletionOnAnnotationOfType fakeNode) {
4115
	private long computeTargetedElement(CompletionOnAnnotationOfType fakeNode) {
4090
		ASTNode annotatedElement = fakeNode.potentialAnnotatedNode;
4116
		ASTNode annotatedElement = fakeNode.potentialAnnotatedNode;
4091
4117
Lines 5947-5953 Link Here
5947
5973
5948
			if (this.options.checkVisibility
5974
			if (this.options.checkVisibility
5949
				&& !field.canBeSeenBy(receiverType, invocationSite, scope))	continue next;
5975
				&& !field.canBeSeenBy(receiverType, invocationSite, scope))	continue next;
5950
5976
			
5977
			// don't propose array types in case expression
5978
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
5979
			if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding)
5980
				continue next;
5981
			
5951
			boolean prefixRequired = false;
5982
			boolean prefixRequired = false;
5952
5983
5953
			for (int i = fieldsFound.size; --i >= 0;) {
5984
			for (int i = fieldsFound.size; --i >= 0;) {
Lines 6034-6039 Link Here
6034
			relevance += computeRelevanceForExpectingType(field.type);
6065
			relevance += computeRelevanceForExpectingType(field.type);
6035
			relevance += computeRelevanceForEnumConstant(field.type);
6066
			relevance += computeRelevanceForEnumConstant(field.type);
6036
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
6067
			relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
6068
			relevance += computeRelevanceForFinal(this.assistNodeIsInsideCase, field.isFinal());
6037
			relevance += computeRelevanceForQualification(prefixRequired);
6069
			relevance += computeRelevanceForQualification(prefixRequired);
6038
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6070
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
6039
			if (onlyStaticFields && this.insideQualifiedReference) {
6071
			if (onlyStaticFields && this.insideQualifiedReference) {
Lines 11312-11318 Link Here
11312
11344
11313
							if (local.isSecret())
11345
							if (local.isSecret())
11314
								continue next;
11346
								continue next;
11315
11347
							
11348
							// don't propose array types in case expression
11349
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
11350
							if (this.assistNodeIsInsideCase && local.type instanceof ArrayBinding)
11351
								continue next;
11352
							
11316
							for (int f = 0; f < localsFound.size; f++) {
11353
							for (int f = 0; f < localsFound.size; f++) {
11317
								LocalVariableBinding otherLocal =
11354
								LocalVariableBinding otherLocal =
11318
									(LocalVariableBinding) localsFound.elementAt(f);
11355
									(LocalVariableBinding) localsFound.elementAt(f);
Lines 11329-11334 Link Here
11329
							relevance += computeRelevanceForEnumConstant(local.type);
11366
							relevance += computeRelevanceForEnumConstant(local.type);
11330
							relevance += computeRelevanceForQualification(false);
11367
							relevance += computeRelevanceForQualification(false);
11331
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
11368
							relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable
11369
							relevance += computeRelevanceForFinal(this.assistNodeIsInsideCase, local.isFinal());
11332
							this.noProposal = false;
11370
							this.noProposal = false;
11333
							if(!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
11371
							if(!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) {
11334
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition);
11372
								InternalCompletionProposal proposal =  createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition);
(-)codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java (+2 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
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
57
	int R_FINAL = 3;
56
}
58
}
(-)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 21333-21336 Link Here
21333
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 +"], " + relevance1 + "}",
21329
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 +"], " + relevance1 + "}",
21334
			requestor.getResults());
21330
			requestor.getResults());
21335
}
21331
}
21332
21333
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
21334
// To verify that array types aren't proposed inside case, and also
21335
// that finals have a higher priority in suggestions inside case expressions.
21336
public void testBug195346a() throws JavaModelException {
21337
	this.workingCopies = new ICompilationUnit[1];
21338
	this.workingCopies[0] = getWorkingCopy(
21339
		"/Completion/src/test/CompletionAfterCase2.java",
21340
		"package test;\n" +
21341
		"public class CompletionAfterCase2 {\n" +
21342
		"	static char[] AN_ARRAY = new char[10];\n" +
21343
		"	static int AN_INT_VALUE = 0;\n" +
21344
		"	static final int AN_INT_VALUE2 = 0;\n" +
21345
		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
21346
		"	static final int[] AN_INT_ARRAY = null;\n" +
21347
		"	static final Object[] ANOTHER_ARRAY = null;\n" +
21348
		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
21349
		"		final int AN_INT_VAR = 1;\n" +
21350
		"		final int[] AN_ARRAY_VAR = {1};\n" +
21351
		"		int AN_INT_VAR2 = 1;\n" +
21352
		"		switch(i) {\n" +
21353
		"			case AN\n" +
21354
		"		}\n" +
21355
		"	}\n" +
21356
		"}\n");
21357
21358
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21359
	String str = this.workingCopies[0].getSource();
21360
	String completeBehind = "AN";
21361
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21362
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21363
21364
	assertResults(
21365
			"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" +
21366
			"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" +
21367
			"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" +
21368
			"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) + "}",
21369
			requestor.getResults());
21370
}
21371
21372
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
21373
// To verify that array types aren't proposed inside case, and also
21374
// that finals have a higher priority in suggestions inside case expressions.
21375
public void testBug195346b() throws JavaModelException {
21376
	this.workingCopies = new ICompilationUnit[1];
21377
	this.workingCopies[0] = getWorkingCopy(
21378
		"/Completion/src/test/CompletionAfterCase2.java",
21379
		"package test;\n" +
21380
		"public class CompletionAfterCase2 {\n" +
21381
		"	class AN_INNER_CLASS {\n" +
21382
		"		static final int abc = 1;\n" +
21383
		"	}\n" +
21384
		"	static char[] AN_ARRAY = new char[10];\n" +
21385
		"	static int AN_INT_VALUE = 0;\n" +
21386
		"	static final int AN_INT_VALUE2 = 0;\n" +
21387
		"	static final char[] AN_ARRAY2 = {'a','b'};\n" +
21388
		"	static final int[] AN_INT_ARRAY = null;\n" +
21389
		"	static final Object[] ANOTHER_ARRAY = null;\n" +
21390
		"	void foo(int i, final int [] AN_ARRAY_PARAM){\n" +
21391
		"		final int AN_INT_VAR = 1;\n" +
21392
		"		final int[] AN_ARRAY_VAR = {1};\n" +
21393
		"		int AN_INT_VAR2 = 1;\n" +
21394
		"		switch(i) {\n" +
21395
		"			case CompletionAfterCase2.AN\n" +
21396
		"		}\n" +
21397
		"	}\n" +
21398
		"}\n");
21399
21400
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21401
	String str = this.workingCopies[0].getSource();
21402
	String completeBehind = "AN";
21403
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21404
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21405
21406
	assertResults(
21407
			"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" +
21408
			"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" +
21409
			"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) + "}",
21410
			requestor.getResults());
21411
}
21336
}
21412
}

Return to bug 195346