View | Details | Raw Unified | Return to bug 96604
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+303 lines)
Lines 11289-11294 Link Here
11289
			"Test<T>.Member<U>[TYPE_REF]{Member, test, Ltest.Test<TT;>.Member<TU;>;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING  + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11289
			"Test<T>.Member<U>[TYPE_REF]{Member, test, Ltest.Test<TT;>.Member<TU;>;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING  + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11290
			requestor.getResults());
11290
			requestor.getResults());
11291
}
11291
}
11292
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11293
public void test0351() throws JavaModelException {
11294
	this.workingCopies = new ICompilationUnit[2];
11295
	this.workingCopies[0] = getWorkingCopy(
11296
		"/Completion/src/test/Test.java",
11297
		"package test;\n"+
11298
		"import test.util.List;\n"+
11299
		"public class X<U, V extends List<U>> {\n"+
11300
		"	V v;\n"+
11301
		"	void foo(X<String, ?> x1, X<Object, ?> x2) {\n"+
11302
		"		x1.v.get\n");
11303
	
11304
	this.workingCopies[1] = getWorkingCopy(
11305
		"/Completion/src/test/util/Test.java",
11306
		"package test.util;\n"+
11307
		"public interface List<T> {\n"+
11308
		"	public T get(int i);\n"+
11309
		"}n");
11310
11311
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11312
	String str = this.workingCopies[0].getSource();
11313
	String completeBehind = "x1.v.get";
11314
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11315
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11316
11317
	assertResults(
11318
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
11319
			"get[METHOD_REF]{get(), Ltest.util.List<Ljava.lang.String;>;, (I)Ljava.lang.String;, get, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
11320
			requestor.getResults());
11321
}
11322
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11323
public void test0352() throws JavaModelException {
11324
	this.workingCopies = new ICompilationUnit[2];
11325
	this.workingCopies[0] = getWorkingCopy(
11326
		"/Completion/src/test/Test.java",
11327
		"package test;\n"+
11328
		"import test.util.List;\n"+
11329
		"public class X<U, V extends List<U>> {\n"+
11330
		"	V v;\n"+
11331
		"	void foo(X<String, ?> x1, X<Object, ?> x2) {\n"+
11332
		"		x1.v.get\n");
11333
	
11334
	this.workingCopies[1] = getWorkingCopy(
11335
		"/Completion/src/test/util/Test.java",
11336
		"package test.util;\n"+
11337
		"public class List<T> {\n"+
11338
		"	public T get(int i) {return null;}\n"+
11339
		"}n");
11340
11341
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11342
	String str = this.workingCopies[0].getSource();
11343
	String completeBehind = "x1.v.get";
11344
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11345
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11346
11347
	assertResults(
11348
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
11349
			"get[METHOD_REF]{get(), Ltest.util.List<Ljava.lang.String;>;, (I)Ljava.lang.String;, get, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
11350
			requestor.getResults());
11351
}
11352
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11353
public void test0353() throws JavaModelException {
11354
	this.workingCopies = new ICompilationUnit[2];
11355
	this.workingCopies[0] = getWorkingCopy(
11356
		"/Completion/src/test/Test.java",
11357
		"package test;\n"+
11358
		"import test.util.List;\n"+
11359
		"public class X<U, V extends List<U>> {\n"+
11360
		"	X<?,?> foo(X<String, ?> xxxxx) {\n"+
11361
		"		xxxxx // the type should not be captured\n"+
11362
		"	}\n"+
11363
		"}\n");
11364
	
11365
	this.workingCopies[1] = getWorkingCopy(
11366
		"/Completion/src/test/util/Test.java",
11367
		"package test.util;\n"+
11368
		"public interface List<T> {\n"+
11369
		"	public T get(int i);\n"+
11370
		"}n");
11371
11372
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11373
	String str = this.workingCopies[0].getSource();
11374
	String completeBehind = "xxxxx";
11375
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11376
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11377
11378
	assertResults(
11379
			"xxxxx[LOCAL_VARIABLE_REF]{xxxxx, null, Ltest.X<Ljava.lang.String;*>;, xxxxx, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11380
			requestor.getResults());
11381
}
11382
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11383
public void test0354() throws JavaModelException {
11384
	this.workingCopies = new ICompilationUnit[2];
11385
	this.workingCopies[0] = getWorkingCopy(
11386
		"/Completion/src/test/Test.java",
11387
		"package test;\n"+
11388
		"import test.util.List;\n"+
11389
		"public class X<U, V extends List<U>> {\n"+
11390
		"	X<?,?> foo(X<String, ?> xxxxx) {\n"+
11391
		"		Object o = (List<String>) xxxxx // the type should not be captured\n"+
11392
		"	}\n"+
11393
		"}\n");
11394
	
11395
	this.workingCopies[1] = getWorkingCopy(
11396
		"/Completion/src/test/util/Test.java",
11397
		"package test.util;\n"+
11398
		"public interface List<T> {\n"+
11399
		"	public T get(int i);\n"+
11400
		"}n");
11401
11402
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11403
	String str = this.workingCopies[0].getSource();
11404
	String completeBehind = "xxxxx";
11405
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11406
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11407
11408
	assertResults(
11409
			"xxxxx[LOCAL_VARIABLE_REF]{xxxxx, null, Ltest.X<Ljava.lang.String;*>;, xxxxx, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11410
			requestor.getResults());
11411
}
11412
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11413
public void test0355() throws JavaModelException {
11414
	this.workingCopies = new ICompilationUnit[2];
11415
	this.workingCopies[0] = getWorkingCopy(
11416
		"/Completion/src/test/Test.java",
11417
		"package test;\n"+
11418
		"import test.util.List;\n"+
11419
		"public class X<U, V extends List<U>> {\n"+
11420
		"	X<?,?> foo(X<String, ?> xxxxx) {\n"+
11421
		"		return xxxxx;// the type should not be captured\n"+
11422
		"	}\n"+
11423
		"}\n");
11424
	
11425
	this.workingCopies[1] = getWorkingCopy(
11426
		"/Completion/src/test/util/Test.java",
11427
		"package test.util;\n"+
11428
		"public interface List<T> {\n"+
11429
		"	public T get(int i);\n"+
11430
		"}n");
11431
11432
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11433
	String str = this.workingCopies[0].getSource();
11434
	String completeBehind = "xxxxx";
11435
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11436
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11437
11438
	assertResults(
11439
			"xxxxx[LOCAL_VARIABLE_REF]{xxxxx, null, Ltest.X<Ljava.lang.String;*>;, xxxxx, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11440
			requestor.getResults());
11441
}
11442
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11443
public void test0356() throws JavaModelException {
11444
	this.workingCopies = new ICompilationUnit[2];
11445
	this.workingCopies[0] = getWorkingCopy(
11446
		"/Completion/src/test/Test.java",
11447
		"package test;\n"+
11448
		"import test.util.List;\n"+
11449
		"public class X<T, U extends List<U>> {\n"+
11450
		"	U get() { return null; }\n"+
11451
		"	void foo(X<String, ?> x) {\n"+
11452
		"		x.get().get // should show capture\n"+
11453
		"	}\n"+
11454
		"}\n");
11455
	
11456
	this.workingCopies[1] = getWorkingCopy(
11457
		"/Completion/src/test/util/Test.java",
11458
		"package test.util;\n"+
11459
		"public interface List<T> {\n"+
11460
		"	public T get(int i);\n"+
11461
		"}n");
11462
11463
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11464
	String str = this.workingCopies[0].getSource();
11465
	String completeBehind = "get().get";
11466
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11467
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11468
11469
	assertResults(
11470
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
11471
			"get[METHOD_REF]{get(), Ltest.util.List<!*>;, (I)!*, get, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
11472
			requestor.getResults());
11473
}
11474
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11475
public void test0357() throws JavaModelException {
11476
	this.workingCopies = new ICompilationUnit[2];
11477
	this.workingCopies[0] = getWorkingCopy(
11478
		"/Completion/src/test/Test.java",
11479
		"package test;\n"+
11480
		"import test.util.List;\n"+
11481
		"public class X<U extends X<U>> {\n"+
11482
		"	U get() { return null; }\n"+
11483
		"	X<?> foo(X<?> x) {\n"+
11484
		"		x.get().get // should show capture\n"+
11485
		"	}\n"+
11486
		"}\n");
11487
	
11488
	this.workingCopies[1] = getWorkingCopy(
11489
		"/Completion/src/test/util/Test.java",
11490
		"package test.util;\n"+
11491
		"public interface List<T> {\n"+
11492
		"	public T get(int i);\n"+
11493
		"}n");
11494
11495
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11496
	String str = this.workingCopies[0].getSource();
11497
	String completeBehind = "get().get";
11498
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11499
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11500
11501
	assertResults(
11502
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
11503
			"get[METHOD_REF]{get(), Ltest.X<!*>;, ()!*, get, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
11504
			requestor.getResults());
11505
}
11506
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11507
public void test0358() throws JavaModelException {
11508
	this.workingCopies = new ICompilationUnit[2];
11509
	this.workingCopies[0] = getWorkingCopy(
11510
		"/Completion/src/test/Test.java",
11511
		"package test;\n"+
11512
		"import test.util.List;\n"+
11513
		"public class X<U, V extends List<U>> {\n"+
11514
		"	V v() {return null;}\n"+
11515
		"	void foo(X<String, ?> x1, X<Object, ?> x2) {\n"+
11516
		"		x1.v().get\n");
11517
	
11518
	this.workingCopies[1] = getWorkingCopy(
11519
		"/Completion/src/test/util/Test.java",
11520
		"package test.util;\n"+
11521
		"public interface List<T> {\n"+
11522
		"	public T get(int i);\n"+
11523
		"}n");
11524
11525
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11526
	String str = this.workingCopies[0].getSource();
11527
	String completeBehind = "x1.v().get";
11528
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11529
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11530
11531
	assertResults(
11532
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<+Ljava.lang.Object;>;, getClass, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}\n" +
11533
			"get[METHOD_REF]{get(), Ltest.util.List<Ljava.lang.String;>;, (I)Ljava.lang.String;, get, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
11534
			requestor.getResults());
11535
}
11536
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11537
public void test0359() throws JavaModelException {
11538
	this.workingCopies = new ICompilationUnit[2];
11539
	this.workingCopies[0] = getWorkingCopy(
11540
		"/Completion/src/test/Test.java",
11541
		"package test;\n"+
11542
		"import test.util.List;\n"+
11543
		"public class X<U, V extends List<U>> {\n"+
11544
		"	V v;\n"+
11545
		"	void foo(X<String, ?> x1, X<Object, ?> x2) {\n"+
11546
		"		x1.v.new Inner(\n");
11547
	
11548
	this.workingCopies[1] = getWorkingCopy(
11549
		"/Completion/src/test/util/Test.java",
11550
		"package test.util;\n"+
11551
		"public class List<T> {\n"+
11552
		"	public class Inner { }\n"+
11553
		"}n");
11554
11555
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11556
	String str = this.workingCopies[0].getSource();
11557
	String completeBehind = "Inner(";
11558
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11559
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11560
11561
	assertResults(
11562
			"Inner[METHOD_REF<CONSTRUCTOR>]{, Ltest.util.List<Ljava.lang.String;>.Inner;, ()V, Inner, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11563
			"List<java.lang.String>.Inner[ANONYMOUS_CLASS_DECLARATION]{, Ltest.util.List<Ljava.lang.String;>.Inner;, ()V, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED) + "}",
11564
			requestor.getResults());
11565
}
11566
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=96604
11567
public void test0360() throws JavaModelException {
11568
	this.workingCopies = new ICompilationUnit[2];
11569
	this.workingCopies[0] = getWorkingCopy(
11570
		"/Completion/src/test/Test.java",
11571
		"package test;\n"+
11572
		"import test.util.List;\n"+
11573
		"public class X<U, V extends List<U>> {\n"+
11574
		"	V v;\n"+
11575
		"	void foo(X<String, ?> x1, X<Object, ?> x2) {\n"+
11576
		"		x1.v.get(\n");
11577
	
11578
	this.workingCopies[1] = getWorkingCopy(
11579
		"/Completion/src/test/util/Test.java",
11580
		"package test.util;\n"+
11581
		"public interface List<T> {\n"+
11582
		"	public T get(int i);\n"+
11583
		"}n");
11584
11585
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11586
	String str = this.workingCopies[0].getSource();
11587
	String completeBehind = "x1.v.get(";
11588
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11589
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11590
11591
	assertResults(
11592
			"get[METHOD_REF]{, Ltest.util.List<Ljava.lang.String;>;, (I)Ljava.lang.String;, get, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11593
			requestor.getResults());
11594
}
11292
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
11595
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
11293
public void testEC001() throws JavaModelException {
11596
public void testEC001() throws JavaModelException {
11294
	this.workingCopies = new ICompilationUnit[1];
11597
	this.workingCopies = new ICompilationUnit[1];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java (-3 / +5 lines)
Lines 577-583 Link Here
577
		while (currentIndex < length) {
577
		while (currentIndex < length) {
578
			ReferenceBinding typeBinding = (ReferenceBinding) binding;
578
			ReferenceBinding typeBinding = (ReferenceBinding) binding;
579
			char[] nextName = compoundName[currentIndex++];
579
			char[] nextName = compoundName[currentIndex++];
580
			if ((binding = findField(typeBinding, nextName, invocationSite, true /*resolve*/)) != null) {
580
			TypeBinding receiverType = typeBinding.capture(this, invocationSite.sourceEnd());
581
			if ((binding = findField(receiverType, nextName, invocationSite, true /*resolve*/)) != null) {
581
				if (!binding.isValidBinding()) {
582
				if (!binding.isValidBinding()) {
582
					return new ProblemFieldBinding(
583
					return new ProblemFieldBinding(
583
						(FieldBinding) binding,
584
						(FieldBinding) binding,
Lines 619-629 Link Here
619
				CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
620
				CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
620
				ProblemReasons.NotFound);
621
				ProblemReasons.NotFound);
621
		}
622
		}
622
		variableBinding = findField(typeBinding, compoundName[currentIndex++], invocationSite, true /*resolve*/);
623
		TypeBinding receiverType = typeBinding.capture(this, invocationSite.sourceEnd());
624
		variableBinding = findField(receiverType, compoundName[currentIndex++], invocationSite, true /*resolve*/);
623
		if (variableBinding == null) {
625
		if (variableBinding == null) {
624
			return new ProblemFieldBinding(
626
			return new ProblemFieldBinding(
625
				null,
627
				null,
626
				typeBinding instanceof ReferenceBinding ? (ReferenceBinding) typeBinding : null,
628
				receiverType instanceof ReferenceBinding ? (ReferenceBinding) receiverType : null,
627
				CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
629
				CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
628
				ProblemReasons.NotFound);
630
				ProblemReasons.NotFound);
629
		}
631
		}

Return to bug 96604