Community
Participate
Working Groups
Bugzilla – Bug 24227
[misc] Javadoc support doesn't understand {@inheritDoc}
Last modified: 2008-07-03 03:49:55 EDT
JDK 1.4 has added an {@inheritDoc} tag that allows documentation to be copied down to an overridden method. JDT doesn't handle this tag. Also, this might be a better default than generating a @link or @see, or whatever is currently done, but only if the user is targeting 1.4 JDK.
this might affect more components but text for sure - moving there
Javadoc hovers show only a '{' character where they should copy the javadoc of overridden elements, which makes browsing code with {@inheritDoc} tags a pain.
*** Bug 53983 has been marked as a duplicate of this bug. ***
Changing from enhancement to normal. 1.4 is supported, so JavaDoc tags should be no exception. We use Checkstyle because the JDT compiler settings for javadoc are not flexible enough. But checkstyle is not perfect. It doesn't realize that is should ignore: /* * @see #superImplementation() */
OFF TOPIC: Is it possible to configure the Checkstyle check JavadocMethod to ignore the "missing" JavaDoc? I'm using the {@inheritDoc} code, but I want to use the JavaDoc comments in Eclipse, too.
I'm really frustrated, that this bug is not fixed yet. It is already 3 years old. As Randy said in Comment #4, this should be supported. Frustrated Ralf
Yes, please fix it.
*** Bug 118648 has been marked as a duplicate of this bug. ***
I've released initial support for Javadoc that only contains the {@inheritDoc} tag. This works in the hover and the Javadoc view.
*** Bug 119183 has been marked as a duplicate of this bug. ***
Any change this will be fixed in the near future?
>Any change this will be fixed in the near future? Probably not for 3.3 but we'd of course accept a good quality patch.
(In reply to comment #9) > I've released initial support for Javadoc that only contains the {@inheritDoc} > tag. This works in the hover and the Javadoc view. > This limited support does not appear to be working in 3.3 in either the Javadoc view or on hover.
Works for me. Have: /** * {@inheritDoc} */ void a() { } Then hover and Javadoc show the Javadoc of the overridden a().
Thanks Daniel for implementing this. Any chance that the support for inheritDoc will be expanded? I'd especially like to be able to combine the inherited doc with a sentence or two of my own or use inheritDoc for the main text body, but add for example an @see tag to the doc. Ideally, this would be where this functionality should be going: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#inheritingcomments
We hope to do something for 3.4 but not sure whether we have time.
Created attachment 80810 [details] Draft patch against 3.3.1 I've put together a preliminary patch for this. It implements both {@inheritDoc} and automatic inheritance pretty much exactly as in Sun's docs. It also adds and fixes a few other Javadoc problems: * It supports {@value} and {@value #member}. * It supports @version and @deprecated. * @tags now only operate at start of line. * Slightly tidied formatting. * It adds "Specified by" and "Overrides" headers (is this wanted? maybe for view but not hover?) If anyone wants to point out problems, or suggest a more efficient implementation, feel free. This is just a first draft. Efficiency is clearly a potential issue, particularly for automatic inheritance - the recursing up the docs is bound to take time, but I've tried to make sure it doesn't look up parent docs unless it really has to. I would appreciate a tip on how to implement {@value class#member} - how can I look up the class? All the JDT look-up APIs I've found so far are based around the editor interfaces.
Martin, can you take a look at the patch? Thanks.
Created attachment 80879 [details] Version 2 - against HEAD Here's an updated patch. Basically implementation tidying, and it's against HEAD this time.
Created attachment 80880 [details] mylyn/context/zip
Hmm, we have a concurreny issue ;-). I've added links to the Javadoc hovers and view, and thereby basically dumped JavaDoc2HTMLTextReader in favor of a new implementation based on the AST (because maintaining our own Javadoc parser is a dead end and the links need to parse into e.g. MethodRefs). Unfortunately, my code is not 100% ready yet, so I didn't release it. I suggest we put this patch on hold and examine it again once the AST-based Javadoc2HTML is released.
Sounds good. If you've hooked it up to a proper parser, much of the work is done - most of my patch was getting JavaDoc2HTMLTextReader to extract structure as well as the HTML stream. The one major item in my patch that's probably still useful as it stands is the JavaDocInheritance class, which implements the correct search rule for choosing which superclass or interface to inherit comments from. The lack of links in the Javadoc view was my other major bugbear as a newcomer to Eclipse - I've just been looking at that and was struck by how awkward the Browser widget is at handling links from in-memory documents. Glad you've made it work.
Created attachment 100427 [details] Partial solution for the AST-based version Biggest open issues: - @param / @throws / @exception resolution not completed - does not consider repeated {@inheritDoc} (where the inherited doc contains another {@inheritDoc})
See bug 232293 for a low-risk partial solution that just turns {@inheritDoc} in a Javadoc main description into a link. We will do the full solution for 3.5 (or maybe 3.4.1).
Setting target to 3.4.1 so we don't miss it.
Created attachment 106334 [details] Complete implementation (AST-based)
Released the patch from comment 26 to HEAD (3.5). The change became quite big, so we don't plan to backport this feature to 3.4.1.
(In reply to comment #27) > Released the patch from comment 26 to HEAD (3.5). > The change became quite big, so we don't plan to backport this feature to > 3.4.1. ... another whole year without this feature working... :-( Mauro.