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 163254 Details for
Bug 304394
IJavaElement#getAttachedJavadoc(IProgressMonitor) should support referenced entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch
patch_304394.txt (text/plain), 8.20 KB, created by
Jay Arthanareeswaran
on 2010-03-29 07:48:20 EDT
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2010-03-29 07:48:20 EDT
Size:
8.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/JavaElement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java,v >retrieving revision 1.137 >diff -u -r1.137 JavaElement.java >--- model/org/eclipse/jdt/internal/core/JavaElement.java 4 Mar 2010 02:55:13 -0000 1.137 >+++ model/org/eclipse/jdt/internal/core/JavaElement.java 29 Mar 2010 11:46:00 -0000 >@@ -649,42 +649,30 @@ > } > > if (root.getKind() == IPackageFragmentRoot.K_BINARY) { >- IClasspathEntry entry= root.getRawClasspathEntry(); >- if (entry == null) { >- return null; >- } >- if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { >- entry= getRealClasspathEntry(root.getJavaProject(), entry.getPath(), root.getPath()); >- if (entry == null) { >+ IClasspathEntry entry= null; >+ try { >+ entry= root.getResolvedClasspathEntry(); >+ URL url = getLibraryJavadocLocation(entry); >+ if (url != null) { >+ return url; >+ } >+ } >+ catch(JavaModelException jme) { >+ // Proceed with raw classpath >+ } >+ >+ entry= root.getRawClasspathEntry(); >+ switch (entry.getEntryKind()) { >+ case IClasspathEntry.CPE_LIBRARY: >+ case IClasspathEntry.CPE_VARIABLE: >+ return getLibraryJavadocLocation(entry); >+ default: > return null; >- } >- } >- return getLibraryJavadocLocation(entry); >+ } > } > return null; > } > >- private static IClasspathEntry getRealClasspathEntry(IJavaProject jproject, IPath containerPath, IPath libPath) throws JavaModelException { >- IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); >- if (container != null) { >- IClasspathEntry[] entries= container.getClasspathEntries(); >- for (int i= 0; i < entries.length; i++) { >- IClasspathEntry curr = entries[i]; >- if (curr == null) { >- if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { >- JavaModelManager.getJavaModelManager().verbose_missbehaving_container(jproject, containerPath, entries); >- } >- break; >- } >- IClasspathEntry resolved= JavaCore.getResolvedClasspathEntry(curr); >- if (resolved != null && libPath.equals(resolved.getPath())) { >- return curr; // return the real entry >- } >- } >- } >- return null; // not found >- } >- > protected static URL getLibraryJavadocLocation(IClasspathEntry entry) throws JavaModelException { > switch(entry.getEntryKind()) { > case IClasspathEntry.CPE_LIBRARY : >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java,v >retrieving revision 1.36 >diff -u -r1.36 AttachedJavadocTests.java >--- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 2 Mar 2010 15:58:18 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 29 Mar 2010 11:46:03 -0000 >@@ -20,6 +20,7 @@ > > import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.jdt.core.IClassFile; > import org.eclipse.jdt.core.IClasspathAttribute; >@@ -580,4 +581,110 @@ > } > } > } >+ /** >+ * @bug 304394: IJavaElement#getAttachedJavadoc(IProgressMonitor) should support referenced entries >+ * Test that javadoc is picked up from the referenced classpath entry if present >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=139160" >+ * @throws Exception >+ */ >+ public void testBug304394() throws Exception { >+ setJavadocLocationAttribute("specialDoc"); >+ IClasspathEntry[] savedEntries = null; >+ try { >+ IClasspathEntry[] entries = this.project.getRawClasspath(); >+ savedEntries = (IClasspathEntry[]) entries.clone(); >+ IClasspathEntry chainedJar = null; >+ int max = entries.length; >+ for (int i = 0; i < max; i++) { >+ final IClasspathEntry entry = entries[i]; >+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY >+ && entry.getContentKind() == IPackageFragmentRoot.K_BINARY >+ && "/AttachedJavadocProject/lib/test6.jar".equals(entry.getPath().toString())) { //$NON-NLS-1$ >+ >+ chainedJar = entries[i]; >+ addLibrary(this.project, "/lib/chaining.jar", null, new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: test6.jar\n", >+ }, >+ JavaCore.VERSION_1_4); >+ IPath jarPath = this.project.getPath().append("lib").append("chaining.jar"); >+ entries[i] = JavaCore.newLibraryEntry(jarPath, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath()); >+ break; >+ } >+ } >+ >+ this.project.setRawClasspath(entries, new IClasspathEntry[]{chainedJar}, this.project.getOutputLocation(), null); >+ waitForAutoBuild(); >+ >+ IPackageFragment packageFragment = this.root.getPackageFragment("p1.p2"); //$NON-NLS-1$ >+ IClassFile classFile = packageFragment.getClassFile("X.class"); //$NON-NLS-1$ >+ IType type = classFile.getType(); >+ IMethod method = type.getMethod("foo", new String[] {"I", "J", "Ljava.lang.String;"}); //$NON-NLS-1$ >+ String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$ >+ assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$ >+ } finally { >+ // restore classpath >+ if (savedEntries != null) { >+ this.project.setRawClasspath(savedEntries, null); >+ } >+ removeLibrary(this.project, "/lib/chaining.jar", null); >+ } >+ } >+ /** >+ * Additional test for bug 304394. >+ * Test that javadoc is picked up from the raw classpath entry when the referenced entry doesn't >+ * contain the javadoc location. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=139160" >+ * @throws Exception >+ */ >+ public void testBug304394a() throws Exception { >+ setJavadocLocationAttribute("specialDoc"); >+ IClasspathEntry[] savedEntries = null; >+ try { >+ IClasspathEntry[] entries = this.project.getRawClasspath(); >+ savedEntries = (IClasspathEntry[]) entries.clone(); >+ IClasspathEntry chainedJar = null; >+ int max = entries.length; >+ for (int i = 0; i < max; i++) { >+ final IClasspathEntry entry = entries[i]; >+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY >+ && entry.getContentKind() == IPackageFragmentRoot.K_BINARY >+ && "/AttachedJavadocProject/lib/test6.jar".equals(entry.getPath().toString())) { //$NON-NLS-1$ >+ >+ chainedJar = entries[i]; >+ addLibrary(this.project, "/lib/chaining.jar", null, new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: test6.jar\n", >+ }, >+ JavaCore.VERSION_1_4); >+ IPath jarPath = this.project.getPath().append("lib").append("chaining.jar"); >+ entries[i] = JavaCore.newLibraryEntry(jarPath, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); >+ break; >+ } >+ } >+ >+ chainedJar = JavaCore.newLibraryEntry(chainedJar.getPath(), null, null, null, null, chainedJar.isExported()); >+ this.project.setRawClasspath(entries, new IClasspathEntry[]{chainedJar}, this.project.getOutputLocation(), null); >+ waitForAutoBuild(); >+ >+ IPackageFragment packageFragment = this.root.getPackageFragment("p1.p2"); //$NON-NLS-1$ >+ IClassFile classFile = packageFragment.getClassFile("X.class"); //$NON-NLS-1$ >+ IType type = classFile.getType(); >+ IMethod method = type.getMethod("foo", new String[] {"I", "J", "Ljava.lang.String;"}); //$NON-NLS-1$ >+ String javadoc = method.getAttachedJavadoc(new NullProgressMonitor()); //$NON-NLS-1$ >+ assertNotNull("Should have a javadoc", javadoc); //$NON-NLS-1$ >+ } finally { >+ // restore classpath >+ if (savedEntries != null) { >+ this.project.setRawClasspath(savedEntries, null); >+ } >+ removeLibrary(this.project, "/lib/chaining.jar", null); >+ } >+ } > }
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 304394
:
162633
| 163254