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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+5 lines)
Lines 3430-3435 Link Here
3430
			if(binding != null) {
3430
			if(binding != null) {
3431
				if(!(variable.initialization instanceof ArrayInitializer)) {
3431
				if(!(variable.initialization instanceof ArrayInitializer)) {
3432
					addExpectedType(binding, scope);
3432
					addExpectedType(binding, scope);
3433
				} else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747
3434
					// If the variable is of type X[], and we're in the initializer
3435
					// we should have X as the expected type for the variable initializers.
3436
					binding = binding.leafComponentType();
3437
					addExpectedType(binding, scope);
3433
				}
3438
				}
3434
			}
3439
			}
3435
		} else if(parent instanceof Assignment) {
3440
		} else if(parent instanceof Assignment) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-2 lines)
Lines 876-883 Link Here
876
					this.expressionLengthPtr--;
876
					this.expressionLengthPtr--;
877
				}
877
				}
878
878
879
				this.lastCheckPoint = this.scanner.currentPosition;
880
881
				if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_ARRAY_CREATION) {
879
				if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_ARRAY_CREATION) {
882
					ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
880
					ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
883
					pushOnGenericsLengthStack(0);
881
					pushOnGenericsLengthStack(0);
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+52 lines)
Lines 21303-21308 Link Here
21303
			requestor.getResults());
21303
			requestor.getResults());
21304
}
21304
}
21305
21305
21306
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747
21307
// To verify that we get correctly sorted proposals inside an array initializers
21308
// and we dont get comment strings as proposals
21309
public void testBug310747() throws JavaModelException {
21310
	this.workingCopies = new ICompilationUnit[1];
21311
	this.workingCopies[0] = getWorkingCopy(
21312
		"/Completion/src/test/X.java",
21313
		"package test;" +
21314
		"class X {\n" +
21315
		"	public X memberGet() {\n" +
21316
		"		return new X();\n" +
21317
		"	}\n" +
21318
		"	public X memberField;\n" +
21319
		"	public X[] memberArray = {\n" +
21320
		"	/**///completion here shouldnt give dubious proposals\n" +
21321
		"	};\n" +
21322
		"}\n");
21323
21324
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, true, true, true);
21325
	requestor.allowAllRequiredProposals();
21326
	String str = this.workingCopies[0].getSource();
21327
	String completeBehind = "/**/";
21328
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21329
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21330
21331
	int relevance1 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE;
21332
	int relevance2 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC;
21333
	int relevance3 = R_RESOLVED + R_CASE + R_NON_STATIC;
21334
	int start1 = str.lastIndexOf("/**/") + "".length();
21335
	int end1 = start1 + "/**/".length();
21336
	assertResults(
21337
			"expectedTypesSignatures={Ltest.X;}\n" +
21338
			"expectedTypesKeys={Ltest/X;}",
21339
			requestor.getContext());
21340
	assertResults(
21341
			"X[TYPE_REF]{X, test, Ltest.X;, null, null, null, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21342
			"memberField[FIELD_REF]{memberField, Ltest.X;, Ltest.X;, null, null, memberField, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21343
			"memberGet[METHOD_REF]{memberGet(), Ltest.X;, ()Ltest.X;, null, null, memberGet, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21344
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21345
			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21346
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, null, null, getClass, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21347
			"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21348
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21349
			"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21350
			"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21351
			"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21352
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21353
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21354
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}",
21355
			requestor.getReversedResults());
21356
}
21357
21306
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=261534
21358
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=261534
21307
// To verify that autocast works correctly even when instanceof expression
21359
// To verify that autocast works correctly even when instanceof expression
21308
// and completion node are in the same binary expression, related by &&
21360
// and completion node are in the same binary expression, related by &&

Return to bug 310747