Community
Participate
Working Groups
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
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.
*** Bug 269990 has been marked as a duplicate of this bug. ***
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.
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); } }
Created attachment 247549 [details] proof of concept v2 Sorry, first attachment was an unrelated patch.
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.
(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).
(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