Bug 336334 - IJavaElement#getAttachedJavadoc(..) should also work if source is attached
Summary: IJavaElement#getAttachedJavadoc(..) should also work if source is attached
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 178071
  Show dependency tree
 
Reported: 2011-02-04 06:43 EST by Markus Keller CLA
Modified: 2011-03-07 06:43 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-02-04 06:43:22 EST
HEAD

For bug 178071, IJavaElement#getAttachedJavadoc(IProgressMonitor) should also work when source is attached (currently always returns null).

I suggest a new constant IClasspathAttribute#JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME.
If the attribute is set to "true", then IJavaElement#getAttachedJavadoc(..) should also fetch and return Javadoc for source elements.
Comment 1 Olivier Thomann CLA 2011-02-04 08:51:13 EST
Jay, please investigate for M6 as this requires a new API.

The javadoc of this method actually states that it always returns null for source elements.
	/**
	 * <p>Returns the Javadoc as an html source if this element has an attached javadoc,
	 * null otherwise.</p>
	 * <p>This should be used only for binary elements. Source elements will always return null.</p>
	 * <p>The encoding used to read the javadoc is the one defined by the content type of the
	 * file. If none is defined, then the project's encoding of this java element is used. If the project's
	 * encoding cannot be retrieved, then the platform encoding is used.</p>
	 * <p>In case of the javadoc doesn't exist for this element, null is returned.</p>

We need to see if existing users can be broken by changing this behavior.
Comment 2 Jay Arthanareeswaran CLA 2011-02-07 05:00:35 EST
(In reply to comment #1)
> We need to see if existing users can be broken by changing this behavior.

Are we not going to keep the same behavior for source elements? The change would  only be for the binary elements whose Javadoc need to be looked up either from the attached source or Javadoc, isn't it?
Comment 3 Jay Arthanareeswaran CLA 2011-02-07 09:02:57 EST
Markus,

I am looking at JavadocContentAccess2#getHTMLContent and it looks like this is where we look at the source attachment for Javadoc before going to javadoc location. This is the code that is used by hover, which means by the time IJavaElement#getAttachedJavadoc() is invoked, we already know that Javadoc is not available from source attachment.

Could you please confirm if I am looking at the correct place?
Comment 4 Markus Keller CLA 2011-02-07 09:46:27 EST
Sorry, I didn't debug this closely enough before filing this request. Actually, IJavaElement#getAttachedJavadoc(..) already works for binary elements with source attachments, but we currently don't use it in JavadocContentAccess2#getHTMLContent(..).

We can fix the original bug 178071 on the UI side (but we would still need a classpath attribute name to configure this, and that's best declared in IClasspathAttribute).

Reading the UI requests again, I found that nobody actually requests using attached Javadoc for source elements at all, so we will not invest into that.

The only thing we'd need from Core is
IClasspathAttribute#JAVADOC_LOCATION_PREFERRED_ATTRIBUTE_NAME. However, I looked into bug 178071 and found it's too much work for a quick fix and also requires API elsewhere, so it's unlikely we will tackle this for 3.7.

I'm closing this bug for now.
Comment 5 Satyam Kandula CLA 2011-03-07 06:43:52 EST
Verified for 3.7M6