Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 190241 Details for
Bug 338006
IJavaProject#getPackageFragmentRoots() should return roots in order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated ptch
bug_338006.txt (text/plain), 6.83 KB, created by
Jay Arthanareeswaran
on 2011-03-03 03:03:07 EST
(
hide
)
Description:
Updated ptch
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2011-03-03 03:03:07 EST
Size:
6.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/IJavaProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java,v >retrieving revision 1.106 >diff -u -r1.106 IJavaProject.java >--- model/org/eclipse/jdt/core/IJavaProject.java 24 Feb 2011 16:51:58 -0000 1.106 >+++ model/org/eclipse/jdt/core/IJavaProject.java 3 Mar 2011 07:51:21 -0000 >@@ -520,7 +520,9 @@ > * does not include package fragment roots in other projects referenced > * on this project's classpath. > * >- * <p>NOTE: This is equivalent to <code>getChildren()</code>. >+ * <p>The package fragment roots appear in the order they are defined >+ * by the classpath. >+ * </p> > * > * @return all of the package fragment roots contained in this > * project, identified on this project's resolved classpath >Index: model/org/eclipse/jdt/internal/core/DeltaProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java,v >retrieving revision 1.341 >diff -u -r1.341 DeltaProcessor.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 2 Dec 2010 07:51:52 -0000 1.341 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 3 Mar 2011 07:51:21 -0000 >@@ -282,8 +282,56 @@ > if (parent != null && parent.isOpen()) { > try { > OpenableElementInfo info = (OpenableElementInfo) parent.getElementInfo(); >- info.addChild(child); >- } catch (JavaModelException e) { >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=338006 >+ // Insert the package fragment roots in the same order as the classpath order. >+ iterate: if (child instanceof IPackageFragmentRoot) { >+ IJavaElement[] roots = info.getChildren(); >+ if (roots.length == 0) >+ break iterate; >+ >+ IPackageFragmentRoot root = (IPackageFragmentRoot) child; >+ IClasspathEntry[] resolvedClasspath = ((JavaProject)root.getJavaProject()).getResolvedClasspath(); >+ IClasspathEntry currentEntry = root.getResolvedClasspathEntry(); >+ >+ int indexToInsert = -1; >+ int lastComparedIndex = -1; >+ for (int i =0, j=0; i < roots.length && j < resolvedClasspath.length; ) { >+ >+ // If the new root is already among the children, no need to proceed further. Just return. >+ // This condition will be checked even if indexToInsert has already been found >+ if(roots[i].getPath().equals(child.getPath())) { >+ return; >+ } >+ >+ if (indexToInsert == -1) { >+ if ( lastComparedIndex != j && currentEntry.getPath().equals(resolvedClasspath[j].getPath())) { >+ indexToInsert = i; >+ break; >+ } >+ lastComparedIndex = j; >+ >+ IClasspathEntry rootEntry = ((IPackageFragmentRoot)roots[i]).getResolvedClasspathEntry(); >+ if (rootEntry.getPath().equals(resolvedClasspath[j].getPath())) >+ i++; >+ else >+ j++; >+ } >+ } >+ if (indexToInsert >= 0) { >+ int newSize = roots.length + 1; >+ IPackageFragmentRoot[] newChildren = new IPackageFragmentRoot[newSize]; >+ >+ if(indexToInsert > 0) >+ System.arraycopy(roots, 0, newChildren, 0, indexToInsert); >+ >+ newChildren[indexToInsert] = (IPackageFragmentRoot)child; >+ System.arraycopy(roots, indexToInsert, newChildren, indexToInsert+1, (newSize - indexToInsert -1)); >+ info.setChildren(newChildren); >+ return; >+ } >+ } >+ info.addChild(child); >+ } catch (JavaModelException e) { > // do nothing - we already checked if open > } > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.243 >diff -u -r1.243 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 21 Feb 2011 00:53:28 -0000 1.243 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 3 Mar 2011 07:51:25 -0000 >@@ -955,6 +955,25 @@ > } > assertEquals(expected, actual); > } >+ protected void assertPackageFragmentRootsEqual(IPackageFragmentRoot[] roots, String expected) { >+ String actual; >+ if (roots == null) { >+ actual = "<null>"; >+ } else { >+ StringBuffer buffer = new StringBuffer(); >+ int length = roots.length; >+ for (int i=0; i<length; i++) { >+ buffer.append(roots[i]); >+ if (i < length-1) >+ buffer.append('\n'); >+ } >+ actual = buffer.toString(); >+ } >+ if (!actual.equals(expected)) { >+ System.out.print(displayString(actual, 2)); >+ } >+ assertEquals(expected, actual); >+ } > /** > * Ensures the element is present after creation. > */ >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.223 >diff -u -r1.223 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 14 Feb 2011 04:50:05 -0000 1.223 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 3 Mar 2011 07:51:26 -0000 >@@ -6912,4 +6912,45 @@ > } > } > >+ /** >+ * @bug 338006: IJavaProject#getPackageFragmentRoots() should return roots in order >+ * >+ * Test whether the {@link IJavaProject#getPackageFragmentRoots()} returns the package fragment >+ * roots in the same order as defined by the .classpath even when the elements are added in a >+ * different order. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=338006" >+ */ >+ public void testBug338006() throws Exception { >+ try { >+ IJavaProject p = this >+ .createJavaProject("P", new String[] {}, "bin"); >+ >+ String content = new String( >+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" >+ + "<classpath>\n" >+ + "<classpathentry kind=\"src\" path=\"src a\"/>\n" >+ + "<classpathentry kind=\"src\" path=\"src x\"/>\n" >+ + "<classpathentry kind=\"lib\" path=\"" >+ + getExternalJCLPath() >+ + "\"/>\n" >+ + "<classpathentry kind=\"output\" path=\"bin\"/>\n" >+ + "</classpath>\n"); >+ >+ editFile("/P/.classpath", content); >+ p.open(null); >+ createFolder("/P/src x"); >+ createFolder("/P/src a"); >+ >+ IPackageFragmentRoot[] roots = p.getPackageFragmentRoots(); >+ assertPackageFragmentRootsEqual(roots, >+ "src a (not open) [in P]\n" + >+ "src x (not open) [in P]\n" + >+ ""+ getExternalJCLPathString() + " (not open)"); >+ >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 338006
:
189914
|
190241
|
190348
|
190364
|
190377