### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests2.java,v retrieving revision 1.4 diff -u -r1.4 ResolveTests2.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests2.java 9 Oct 2008 13:15:21 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests2.java 22 Oct 2008 13:04:19 -0000 @@ -1016,4 +1016,96 @@ this.deleteProject("PS2"); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249027 +public void testBug249027a() throws Exception { + try { + // create P1 + this.createJavaProject( + "P1", + new String[]{"src"}, + new String[]{}, + "bin"); + + this.createFolder("/P1/src/p1"); + this.createFile( + "/P1/src/p1/C1.java", + "package p1;\n"+ + "public class C1 {\n" + + "}"); + + this.createFolder("/P1/src/p1/C1"); + this.createFile( + "/P1/src/p1/C1/C2.java", + "package p1.C1;\n"+ + "public class C2 {\n" + + " C1 f;\n" + + "}"); + + waitUntilIndexesReady(); + + // do code select + ICompilationUnit cu= getCompilationUnit("P1", "src", "p1.C1", "C2.java"); + + String str = cu.getSource(); + + String selection = "C1"; + int start = str.lastIndexOf(selection); + int length = selection.length(); + IJavaElement[] elements = cu.codeSelect(start, length); + + assertElementsEqual( + "Unexpected elements", + "C1 [in C1.java [in p1 [in src [in P1]]]]", + elements + ); + } finally { + this.deleteProject("P1"); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249027 +public void testBug249027b() throws Exception { + try { + // create P1 + this.createJavaProject( + "P1", + new String[]{"src"}, + new String[]{}, + "bin"); + + this.createFolder("/P1/src/p1"); + this.createFile( + "/P1/src/p1/C1.java", + "package p1;\n"+ + "public class C1 {\n" + + "}"); + + this.createFolder("/P1/src/p2"); + this.createFile( + "/P1/src/p2/C2.java", + "package p3;\n"+ + "public class C2 {\n" + + " C1 f;\n" + + "}"); + + waitUntilIndexesReady(); + + // do code select + ICompilationUnit cu= getCompilationUnit("P1", "src", "p2", "C2.java"); + + String str = cu.getSource(); + + String selection = "C1"; + int start = str.lastIndexOf(selection); + int length = selection.length(); + IJavaElement[] elements = cu.codeSelect(start, length); + + assertElementsEqual( + "Unexpected elements", + "C1 [in C1.java [in p1 [in src [in P1]]]]", + elements + ); + } finally { + this.deleteProject("P1"); + } +} } #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java,v retrieving revision 1.62 diff -u -r1.62 Engine.java --- codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 27 Jun 2008 16:04:06 -0000 1.62 +++ codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 22 Oct 2008 13:04:20 -0000 @@ -100,7 +100,14 @@ ImportBinding[] importBindings = this.unitScope.imports; int length = importBindings == null ? 0 : importBindings.length; - this.currentPackageName = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.'); + if (this.unitScope.fPackage != null) { + this.currentPackageName = CharOperation.concatWith(this.unitScope.fPackage.compoundName, '.'); + } else if (this.unitScope.referenceContext != null && + this.unitScope.referenceContext.currentPackage != null) { + this.currentPackageName = CharOperation.concatWith(this.unitScope.referenceContext.currentPackage.tokens, '.'); + } else { + this.currentPackageName = CharOperation.NO_CHAR; + } for (int i = 0; i < length; i++) { ImportBinding importBinding = importBindings[i];