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

(-)src/org/eclipse/jdt/core/tests/model/ResolveTests.java (+48 lines)
Lines 2345-2348 Link Here
2345
		removeLibrary(this.currentProject, jarName, srcName);
2345
		removeLibrary(this.currentProject, jarName, srcName);
2346
	}
2346
	}
2347
}
2347
}
2348
2349
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215
2350
public void testInvalidField1() throws JavaModelException {
2351
	ICompilationUnit cu = getWorkingCopy(
2352
		"/Resolve/src/test/Test.java",
2353
		"package test;"+
2354
		"public class Event {\n" + 
2355
		"        public int x;\n" + 
2356
		"\n" + 
2357
		"        public void handle(Event e) {\n" + 
2358
		"                e.x.e.foo();\n" + 
2359
		"        }\n" + 
2360
		"}");
2361
	String str = cu.getSource();
2362
	
2363
	int start = str.indexOf("foo") + "fo".length();
2364
	int length = 0;
2365
	IJavaElement[] elements = cu.codeSelect(start, length);
2366
	assertElementsEqual(
2367
		"Unexpected elements",
2368
		"",
2369
		elements
2370
	);
2371
}
2372
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 - variation
2373
public void testInvalidField2() throws JavaModelException {
2374
	ICompilationUnit cu = getWorkingCopy(
2375
		"/Resolve/src/test/Test.java",
2376
		"package test;"+
2377
		"public class Event {\n" + 
2378
		"        public int x;\n" + 
2379
		"\n" + 
2380
		"        public void handle(Event e) {\n" + 
2381
		"                this.x.e.foo();\n" + 
2382
		"        }\n" + 
2383
		"}");
2384
	String str = cu.getSource();
2385
	
2386
	int start = str.indexOf("foo") + "fo".length();
2387
	int length = 0;
2388
	IJavaElement[] elements = cu.codeSelect(start, length);
2389
	assertElementsEqual(
2390
		"Unexpected elements",
2391
		"",
2392
		elements
2393
	);
2394
}
2395
2348
}
2396
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+46 lines)
Lines 18405-18408 Link Here
18405
			"voidClass[TYPE_REF]{voidClass, test, Ltest.voidClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
18405
			"voidClass[TYPE_REF]{voidClass, test, Ltest.voidClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
18406
			requestor.getResults());
18406
			requestor.getResults());
18407
}
18407
}
18408
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215
18409
public void testInvalidField1() throws JavaModelException {
18410
	this.workingCopies = new ICompilationUnit[1];
18411
	this.workingCopies[0] = getWorkingCopy(
18412
		"/Completion/src/test/Test.java",
18413
		"package test;"+
18414
		"public class Event {\n" + 
18415
		"        public int x;\n" + 
18416
		"\n" + 
18417
		"        public void handle(Event e) {\n" + 
18418
		"                e.x.e.foo();\n" + 
18419
		"        }\n" + 
18420
		"}");
18421
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
18422
	String str = this.workingCopies[0].getSource();
18423
	String completeBehind = "e.x.e.";
18424
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
18425
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
18426
18427
	assertResults(
18428
			"",
18429
			requestor.getResults());
18430
}
18431
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 - variation
18432
public void testInvalidField2() throws JavaModelException {
18433
	this.workingCopies = new ICompilationUnit[1];
18434
	this.workingCopies[0] = getWorkingCopy(
18435
		"/Completion/src/test/Test.java",
18436
		"package test;"+
18437
		"public class Event {\n" + 
18438
		"        public int x;\n" + 
18439
		"\n" + 
18440
		"        public void handle(Event e) {\n" + 
18441
		"                this.x.e.foo();\n" + 
18442
		"        }\n" + 
18443
		"}");
18444
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
18445
	String str = this.workingCopies[0].getSource();
18446
	String completeBehind = "this.x.e.";
18447
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
18448
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
18449
18450
	assertResults(
18451
			"",
18452
			requestor.getResults());
18453
}
18408
}
18454
}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +2 lines)
Lines 3049-3055 Link Here
3049
	int id = IProblem.UndefinedField;
3049
	int id = IProblem.UndefinedField;
3050
	switch (field.problemId()) {
3050
	switch (field.problemId()) {
3051
		case ProblemReasons.NotFound :
3051
		case ProblemReasons.NotFound :
3052
			if ((field.declaringClass.tagBits & TagBits.HasMissingType) != 0) {
3052
			TypeBinding declaringClass = field.declaringClass;
3053
			if (declaringClass != null && (declaringClass.tagBits & TagBits.HasMissingType) != 0) {
3053
				this.handle(
3054
				this.handle(
3054
						IProblem.UndefinedType,
3055
						IProblem.UndefinedType,
3055
						new String[] {new String(field.declaringClass.readableName())},
3056
						new String[] {new String(field.declaringClass.readableName())},

Return to bug 221215