### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.83 diff -u -r1.83 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 5 Nov 2007 14:29:24 -0000 1.83 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 5 Mar 2008 09:45:10 -0000 @@ -2345,4 +2345,52 @@ removeLibrary(this.currentProject, jarName, srcName); } } + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 +public void testInvalidField1() throws JavaModelException { + ICompilationUnit cu = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;"+ + "public class Event {\n" + + " public int x;\n" + + "\n" + + " public void handle(Event e) {\n" + + " e.x.e.foo();\n" + + " }\n" + + "}"); + String str = cu.getSource(); + + int start = str.indexOf("foo") + "fo".length(); + int length = 0; + IJavaElement[] elements = cu.codeSelect(start, length); + assertElementsEqual( + "Unexpected elements", + "", + elements + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 - variation +public void testInvalidField2() throws JavaModelException { + ICompilationUnit cu = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;"+ + "public class Event {\n" + + " public int x;\n" + + "\n" + + " public void handle(Event e) {\n" + + " this.x.e.foo();\n" + + " }\n" + + "}"); + String str = cu.getSource(); + + int start = str.indexOf("foo") + "fo".length(); + int length = 0; + IJavaElement[] elements = cu.codeSelect(start, length); + assertElementsEqual( + "Unexpected elements", + "", + elements + ); +} + } Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.176 diff -u -r1.176 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 26 Feb 2008 11:01:45 -0000 1.176 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 5 Mar 2008 09:45:10 -0000 @@ -18405,4 +18405,50 @@ "voidClass[TYPE_REF]{voidClass, test, Ltest.voidClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 +public void testInvalidField1() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Event {\n" + + " public int x;\n" + + "\n" + + " public void handle(Event e) {\n" + + " e.x.e.foo();\n" + + " }\n" + + "}"); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "e.x.e."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=221215 - variation +public void testInvalidField2() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Event {\n" + + " public int x;\n" + + "\n" + + " public void handle(Event e) {\n" + + " this.x.e.foo();\n" + + " }\n" + + "}"); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "this.x.e."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.367 diff -u -r1.367 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 22 Feb 2008 09:49:37 -0000 1.367 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 5 Mar 2008 09:45:12 -0000 @@ -3049,7 +3049,8 @@ int id = IProblem.UndefinedField; switch (field.problemId()) { case ProblemReasons.NotFound : - if ((field.declaringClass.tagBits & TagBits.HasMissingType) != 0) { + TypeBinding declaringClass = field.declaringClass; + if (declaringClass != null && (declaringClass.tagBits & TagBits.HasMissingType) != 0) { this.handle( IProblem.UndefinedType, new String[] {new String(field.declaringClass.readableName())},