Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 91104 - [hovering] Javadoc hover does not show Javadoc of (type) parameters
Summary: [hovering] Javadoc hover does not show Javadoc of (type) parameters
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 minor with 1 vote (vote)
Target Milestone: 4.5 M4   Edit
Assignee: Noopur Gupta CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 269990 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-12 06:33 EDT by Tobias Widmer CLA
Modified: 2014-12-05 07:23 EST (History)
4 users (show)

See Also:
markus.kell.r: review+


Attachments
proof of concept (2.09 KB, patch)
2014-10-01 09:05 EDT, Markus Keller CLA
no flags Details | Diff
proof of concept v2 (15.17 KB, patch)
2014-10-01 15:02 EDT, Markus Keller CLA
no flags Details | Diff
Patch (31.80 KB, patch)
2014-12-01 07:05 EST, Noopur Gupta CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2005-04-12 06:33:42 EDT
I20050405-0800 + ZRH plugin export

The javadoc hover does not show javadoc associated with type parameters.

Steps to reproduce:
- Create cu
	/**
	 * Description of foo
	 * @param <T> description of type parameter
	 * @param t description of argument
	 */
	public final <T> void foo(T t) {
        }
- Hover over the type of the method argument 't'
-> No javadoc available
-> Same also happens for type parameters of classes
Comment 1 Dani Megert CLA 2005-04-13 08:36:40 EDT
Currently we show just "T"

We should show the signature as we do for parameters:
<T> void Cell.foo(T)

Additionally we could extract the Javadoc from the @param doc. If so, we should
do the same for the parameters.
Comment 2 Dani Megert CLA 2009-03-25 12:31:51 EDT
*** Bug 269990 has been marked as a duplicate of this bug. ***
Comment 3 Carl Manaster CLA 2009-03-25 12:37:56 EDT
Sorry for the duplicate; I did search before posting, and I even saw this one, but the <T> and the title had me thinking this was to do with generics, rather than simply about parameters.
Comment 4 Markus Keller CLA 2014-10-01 09:05:48 EDT
Created attachment 247534 [details]
proof of concept

Here's a proof of concept for how to add this to Javadoc hovers.

Doesn't work in the Javadoc view yet, and doesn't handle parameters for methods with attached Javadoc. It probably misses some error checking, and the handling of local variables that are not method parameters, needs to be cleaned up (need to see where to best do the check that skips those ILocalVariables and then remove unnecessary re-checking of the same later on).

I thought we could reuse more of the code that finds and renders the @param tags, but it looks like that would become quite complicated and not help much. Bug JavadocContentAccess2#parameterToHTML(..) at least reuses fJavadocLookup.getInheritedParamDescription(fMethod, i) to find the description of Sub#foo(..)'s "val" here:

public class Super {
    /**
     * Main desc.
     * 
     * @param value The value passed to {@link #foo(int, boolean)}
     * @param enable TODO
     * @return the value as String
     */
    public String foo(int value, boolean enable) {
        return String.valueOf(value);
    }
}

class Sub extends Super {
    @Override
    public String foo(int val, boolean enable) {
        return super.foo(val, enable);
    }
}
Comment 5 Markus Keller CLA 2014-10-01 15:02:51 EDT
Created attachment 247549 [details]
proof of concept v2

Sorry, first attachment was an unrelated patch.
Comment 6 Noopur Gupta CLA 2014-12-01 07:05:58 EST
Created attachment 249058 [details]
Patch

Enhanced the patch from comment #5.
- The check for local variables that are not method parameters is done at the beginning of JavadocContentAccess2.getHTMLContent(IJavaElement element, boolean useAttachedJavadoc).
- The javadoc of parameters for methods with attached javadoc is shown as the javadoc of the associated method itself, instead of trying to extract the parameter javadoc from the attached method javadoc.
- Inherited javadoc for type parameters was not handled earlier. Since Project > Generate Javadoc generates the inherited javadoc of a type parameter, implemented the same here.
- Added a separate tag title "Type Parameters:" similar to generated javadoc for type parameters.
- Updated header flags to be shown for type parameters in JavadocView.getHeaderFlags(IJavaElement element). We should probably replace this method with the existing JavadocHover.getHeaderFlags(IJavaElement element). It differs wrt the package javadoc flags, hence did not update.

Markus, please have a look.
Comment 7 Markus Keller CLA 2014-12-04 10:55:45 EST
(In reply to Noopur Gupta from comment #6)
Looks very good!

I found one tiny glitch: For methods with inherited type parameter descriptions, the type parameter name in the generated Javadoc was not enclosed in <>. Fixed in JavadocContentAccess2#handleParameterTags(..) and released with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=0d974018ed578a4e9b21cc31f3028688732f99da

> - Updated header flags to be shown for type parameters in
> JavadocView.getHeaderFlags(IJavaElement element). We should probably replace
> this method with the existing JavadocHover.getHeaderFlags(IJavaElement
> element). It differs wrt the package javadoc flags, hence did not update.

Feel free to unify the getHeaderFlags(..) methods. I think they already do the same, since ^ and & ~ do the same thing here (since the LHS always has all the RHS bits set).
Comment 8 Noopur Gupta CLA 2014-12-05 07:23:46 EST
(In reply to Markus Keller from comment #7)
> (In reply to Noopur Gupta from comment #6)
> > - Updated header flags to be shown for type parameters in
> > JavadocView.getHeaderFlags(IJavaElement element). We should probably replace
> > this method with the existing JavadocHover.getHeaderFlags(IJavaElement
> > element). It differs wrt the package javadoc flags, hence did not update.
> 
> Feel free to unify the getHeaderFlags(..) methods. I think they already do
> the same, since ^ and & ~ do the same thing here (since the LHS always has
> all the RHS bits set).

Released with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=64e811de299e3f52922f686dff8e1398e8c6e6c3