### 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.74 diff -u -r1.74 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 6 Apr 2007 11:07:11 -0000 1.74 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 27 Jun 2007 08:32:07 -0000 @@ -10,9 +10,11 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.model; +import java.io.File; import java.io.IOException; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.*; import junit.framework.*; @@ -1899,6 +1901,54 @@ elements ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=119434 +public void testDuplicateTypeDeclaration7() throws CoreException, IOException { + String jarName = "bug119434.jar"; + try { + String[] pathAndContents = new String[] { + "test/p/Type.java", + "package test.p;"+ + "public class Type {\n" + + "}\n" + }; + + addLibrary(jarName, "bug119434_src.zip", pathAndContents, JavaCore.VERSION_1_4); + + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;"+ + "import test.p.Type;"+ + "public class Test {\n" + + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Resolve/src/test/p/Type.java", + "package test.p;"+ + "public class Type {\n" + + "}\n"); + + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("Type"); + int length = "Type".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + + // The result should be "Type [in Type.class [in test.p [in src [in Resolve]]]]" but it is + // currently "Type [in Type.class [in test.p [in bug119434.jar [in Resolve]]]]". + // This is caused by the bug 194432 + // This test must be updated once bug 194432 will be fixed + assertElementsEqual( + "Unexpected elements", + "Type [in Type.class [in test.p [in bug119434.jar [in Resolve]]]]", + elements + ); + } finally { + removeLibraryEntry(this.currentProject, new Path(jarName)); + deleteFile(new File(jarName)); + } +} + public void testArrayParameterInsideParent1() throws JavaModelException { ICompilationUnit cu = getCompilationUnit("Resolve", "src", "", "ResolveArrayParameterInsideParent1.java"); #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/SelectionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java,v retrieving revision 1.71 diff -u -r1.71 SelectionRequestor.java --- model/org/eclipse/jdt/internal/core/SelectionRequestor.java 10 Apr 2007 19:03:10 -0000 1.71 +++ model/org/eclipse/jdt/internal/core/SelectionRequestor.java 27 Jun 2007 08:32:17 -0000 @@ -743,6 +743,13 @@ */ protected void addElement(IJavaElement element) { int elementLength = this.elementIndex + 1; + + for (int i = 0; i < elementLength; i++) { + if (this.elements[i].equals(element)) { + return; + } + } + if (elementLength == this.elements.length) { System.arraycopy(this.elements, 0, this.elements = new IJavaElement[(elementLength*2) + 1], 0, elementLength); }