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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java (-1 / +1 lines)
Lines 386-392 Link Here
386
			next : for (int i = 0; i < size; i++) {
386
			next : for (int i = 0; i < size; i++) {
387
				try {
387
				try {
388
					LocalVariableBinding binding = (LocalVariableBinding) this.visibleLocalVariables.elementAt(i);
388
					LocalVariableBinding binding = (LocalVariableBinding) this.visibleLocalVariables.elementAt(i);
389
					if (assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next;
389
					if (binding.type == null || assignableTypeBinding != null && !binding.type.isCompatibleWith(assignableTypeBinding)) continue next;
390
					JavaElement localVariable = getJavaElement(binding);
390
					JavaElement localVariable = getJavaElement(binding);
391
					if (localVariable != null) result[elementCount++] = localVariable;
391
					if (localVariable != null) result[elementCount++] = localVariable;
392
				} catch(AbortCompilation e) {
392
				} catch(AbortCompilation e) {
(-)src/org/eclipse/jdt/core/tests/model/CompletionContextTests_1_5.java (-1 / +77 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1370-1373 Link Here
1370
		"completion token location=UNKNOWN",
1370
		"completion token location=UNKNOWN",
1371
		result.context);
1371
		result.context);
1372
}
1372
}
1373
1374
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=311022
1375
public void testBug311022a() throws JavaModelException {
1376
	this.workingCopies = new ICompilationUnit[3];
1377
	this.workingCopies[0] = getWorkingCopy(
1378
		"/Completion/src3/test/X.java",
1379
		"package test;\n" +
1380
		"public class X {\n" +
1381
		"    void foo(Object o) {}\n" +
1382
		"	 <T> void bar() {\n" +
1383
		"    	T<T> loc = 12;\n" +
1384
		"    	foo\n" +
1385
		"    }\n" +
1386
		"}");
1387
1388
	String str = this.workingCopies[0].getSource();
1389
	int tokenStart = str.lastIndexOf("foo");
1390
	int tokenEnd = tokenStart + "foo".length() - 1;
1391
	int cursorLocation = str.lastIndexOf("foo") + "foo".length();
1392
1393
	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true, "Ljava.lang.Object;");
1394
	String jclPath = getExternalJCLPathString("1.5");
1395
	assertResults(
1396
		"completion offset="+(cursorLocation)+"\n" +
1397
		"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
1398
		"completion token=\"foo\"\n" +
1399
		"completion token kind=TOKEN_KIND_NAME\n" +
1400
		"expectedTypesSignatures=null\n" +
1401
		"expectedTypesKeys=null\n" +
1402
		"completion token location={STATEMENT_START}\n" +
1403
		"enclosingElement=bar() {key=Ltest/X;.bar<T:Ljava/lang/Object;>()V} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" +
1404
		"visibleElements={\n" +
1405
		"	toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1406
		"	getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class<+Ljava/lang/Object;>;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1407
		"	clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1408
		"}",
1409
		result.context);
1410
}
1411
1412
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=311022
1413
public void testBug311022b() throws JavaModelException {
1414
	this.workingCopies = new ICompilationUnit[3];
1415
	this.workingCopies[0] = getWorkingCopy(
1416
		"/Completion/src3/test/X.java",
1417
		"package test;\n" +
1418
		"public class X<A1,A2> {\n" +
1419
		"    void foo(Object 0) {}\n" +
1420
		"	 <T> void bar() {\n" +
1421
		"    	X<String, String, String> x;\n" +
1422
		"    	foo\n" +
1423
		"    }\n" +
1424
		"}");
1425
1426
	String str = this.workingCopies[0].getSource();
1427
	int tokenStart = str.lastIndexOf("foo");
1428
	int tokenEnd = tokenStart + "foo".length() - 1;
1429
	int cursorLocation = str.lastIndexOf("foo") + "foo".length();
1430
1431
	CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true, "Ljava.lang.Object;");
1432
	String jclPath = getExternalJCLPathString("1.5");
1433
	assertResults(
1434
			"completion offset="+(cursorLocation)+"\n" +
1435
			"completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" +
1436
			"completion token=\"foo\"\n" +
1437
			"completion token kind=TOKEN_KIND_NAME\n" +
1438
			"expectedTypesSignatures=null\n" +
1439
			"expectedTypesKeys=null\n" +
1440
			"completion token location={STATEMENT_START}\n" +
1441
			"enclosingElement=bar() {key=Ltest/X;.bar<T:Ljava/lang/Object;>()V} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" +
1442
			"visibleElements={\n" +
1443
			"	toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1444
			"	getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class<+Ljava/lang/Object;>;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1445
			"	clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" +
1446
			"}",
1447
			result.context);
1448
}
1373
}
1449
}

Return to bug 311022