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 3387-3392 Link Here
3387
			if(binding != null) {
3387
			if(binding != null) {
3388
				if(!(variable.initialization instanceof ArrayInitializer)) {
3388
				if(!(variable.initialization instanceof ArrayInitializer)) {
3389
					addExpectedType(binding, scope);
3389
					addExpectedType(binding, scope);
3390
				} else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747
3391
					// If the variable is of type X[], and we're in the initializer
3392
					// we should have X as the expected type for the variable initializers.
3393
					binding = binding.leafComponentType();
3394
					addExpectedType(binding, scope);
3390
				}
3395
				}
3391
			}
3396
			}
3392
		} else if(parent instanceof Assignment) {
3397
		} else if(parent instanceof Assignment) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-2 lines)
Lines 875-882 Link Here
875
					this.expressionLengthPtr--;
875
					this.expressionLengthPtr--;
876
				}
876
				}
877
877
878
				this.lastCheckPoint = this.scanner.currentPosition;
879
880
				if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_ARRAY_CREATION) {
878
				if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_ARRAY_CREATION) {
881
					ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
879
					ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
882
					pushOnGenericsLengthStack(0);
880
					pushOnGenericsLengthStack(0);
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+53 lines)
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 + "}",
21333
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + start1 + ", " + end1 + "], token[" + start1 + ", " + end1 +"], " + relevance1 + "}",
21334
			requestor.getResults());
21334
			requestor.getResults());
21335
}
21335
}
21336
21337
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310747
21338
// To verify that we get correctly sorted proposals inside an array initializers
21339
// and we dont get comment strings as proposals
21340
public void testBug310747() throws JavaModelException {
21341
	this.workingCopies = new ICompilationUnit[1];
21342
	this.workingCopies[0] = getWorkingCopy(
21343
		"/Completion/src/test/X.java",
21344
		"package test;" +
21345
		"class X {\n" +
21346
		"	public X[] memberArray = {\n" +
21347
		"	/**///completion here shouldnt give dubious proposals\n" +
21348
		"	};\n" +
21349
		"	public X memberGet() {\n" +
21350
		"		return new X();\n" +
21351
		"	}\n" +
21352
		"	public X memberField;\n" +
21353
		"}\n");
21354
21355
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, true, true, true);
21356
	requestor.allowAllRequiredProposals();
21357
	String str = this.workingCopies[0].getSource();
21358
	String completeBehind = "/**/";
21359
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21360
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21361
21362
	int relevance1 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE;
21363
	int relevance2 = R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC;
21364
	int relevance3 = R_RESOLVED + R_CASE + R_NON_STATIC;
21365
	int start1 = str.lastIndexOf("/**/") + "".length();
21366
	int end1 = start1 + "/**/".length();
21367
	assertResults(
21368
			"expectedTypesSignatures={Ltest.X;}\n" +
21369
			"expectedTypesKeys={Ltest/X;}",
21370
			requestor.getContext());
21371
	assertResults(
21372
			"X[TYPE_REF]{X, test, Ltest.X;, null, null, null, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21373
			"memberField[FIELD_REF]{memberField, Ltest.X;, Ltest.X;, null, null, memberField, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21374
			"memberGet[METHOD_REF]{memberGet(), Ltest.X;, ()Ltest.X;, null, null, memberGet, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance1 + "}\n" +
21375
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, null, null, clone, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21376
			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, null, null, equals, (obj), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21377
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, null, null, getClass, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21378
			"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, null, null, hashCode, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21379
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, null, null, toString, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance2 + "}\n" +
21380
			"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, null, null, finalize, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21381
			"memberArray[FIELD_REF]{memberArray, Ltest.X;, [Ltest.X;, null, null, memberArray, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21382
			"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, null, null, notify, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21383
			"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, null, null, notifyAll, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21384
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, null, null, wait, (millis, nanos), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21385
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, null, null, wait, (millis), replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}\n" +
21386
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, null, null, wait, null, replace[" + end1 + ", " + end1 + "], token[" + end1 + ", " + end1 +"], " + relevance3 + "}",
21387
			requestor.getReversedResults());
21388
}
21336
}
21389
}

Return to bug 310747