Bug 24227 - [misc] Javadoc support doesn't understand {@inheritDoc}
[misc] Javadoc support doesn't understand {@inheritDoc}
Status: RESOLVED FIXED
Product: JDT
Classification: Eclipse
Component: Text
2.0
PC Windows 2000
: P3 normal with 33 votes (vote)
: 3.5 M1
Assigned To: Markus Keller CLA Friend
:
: 53983 119183 (view as bug list)
Depends on:
Blocks: 216477
  Show dependency tree
 
Reported: 2002-09-30 12:58 EDT by Randy Hudson CLA Friend
Modified: 2008-07-03 03:49 EDT (History)
24 users (show)

See Also:


Attachments
Draft patch against 3.3.1 (45.62 KB, patch)
2007-10-19 18:02 EDT, Kevin Bracey CLA Friend
no flags Details | Diff
Version 2 - against HEAD (45.28 KB, patch)
2007-10-22 11:04 EDT, Kevin Bracey CLA Friend
no flags Details | Diff
mylyn/context/zip (27.70 KB, application/octet-stream)
2007-10-22 11:04 EDT, Kevin Bracey CLA Friend
no flags Details
Partial solution for the AST-based version (14.39 KB, patch)
2008-05-15 08:53 EDT, Markus Keller CLA Friend
no flags Details | Diff
Complete implementation (AST-based) (44.36 KB, patch)
2008-07-02 14:03 EDT, Markus Keller CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA Friend 2002-09-30 12:58:04 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.
Comment 1 Adam Kiezun CLA Friend 2002-09-30 13:29:32 EDT
this might affect more components but text for sure - moving there
Comment 2 Markus Keller CLA Friend 2004-01-26 06:39:56 EST
Javadoc hovers show only a '{' character where they should copy the javadoc of
overridden elements, which makes browsing code with {@inheritDoc} tags a pain.
Comment 3 Dani Megert CLA Friend 2004-03-09 06:19:13 EST
*** Bug 53983 has been marked as a duplicate of this bug. ***
Comment 4 Randy Hudson CLA Friend 2004-06-17 11:31:51 EDT
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()
 */
Comment 5 Martin Burger CLA Friend 2005-06-29 11:46:58 EDT
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.
Comment 6 Ralf Schandl CLA Friend 2005-10-03 08:19:51 EDT
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
Comment 7 Chris Dennett CLA Friend 2005-10-03 08:58:15 EDT
Yes, please fix it.
Comment 8 Dani Megert CLA Friend 2005-12-02 02:58:04 EST
*** Bug 118648 has been marked as a duplicate of this bug. ***
Comment 9 Dani Megert CLA Friend 2005-12-02 03:34:20 EST
I've released initial support for Javadoc that only contains the {@inheritDoc} tag. This works in the hover and the Javadoc view.
Comment 10 Dani Megert CLA Friend 2005-12-04 13:08:31 EST
*** Bug 119183 has been marked as a duplicate of this bug. ***
Comment 11 Dennis Daems CLA Friend 2006-09-08 10:15:04 EDT
Any change this will be fixed in the near future?
Comment 12 Dani Megert CLA Friend 2006-09-08 10:47:40 EDT
>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.
Comment 13 Micah Hainline CLA Friend 2007-07-31 11:51:19 EDT
(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.  
Comment 14 Dani Megert CLA Friend 2007-08-02 06:01:11 EDT
Works for me. Have:
	/**
	 * {@inheritDoc}
	 */
	void a() {
	}

Then hover and Javadoc show the Javadoc of the overridden a().
Comment 15 Johannes Ruthenberg CLA Friend 2007-09-24 12:08:11 EDT
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
Comment 16 Dani Megert CLA Friend 2007-09-24 12:19:44 EDT
We hope to do something for 3.4 but not sure whether we have time.
Comment 17 Kevin Bracey CLA Friend 2007-10-19 18:02:31 EDT
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.
Comment 18 Dani Megert CLA Friend 2007-10-22 10:50:52 EDT
Martin, can you take a look at the patch? Thanks.
Comment 19 Kevin Bracey CLA Friend 2007-10-22 11:04:13 EDT
Created attachment 80879 [details]
Version 2 - against HEAD

Here's an updated patch. Basically implementation tidying, and it's against HEAD this time.
Comment 20 Kevin Bracey CLA Friend 2007-10-22 11:04:20 EDT
Created attachment 80880 [details]
mylyn/context/zip
Comment 21 Markus Keller CLA Friend 2007-10-22 11:24:54 EDT
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.
Comment 22 Kevin Bracey CLA Friend 2007-10-22 11:48:27 EDT
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.
Comment 23 Markus Keller CLA Friend 2008-05-15 08:53:57 EDT
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})
Comment 24 Markus Keller CLA Friend 2008-05-15 08:58:04 EDT
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).
Comment 25 Dani Megert CLA Friend 2008-05-15 09:08:09 EDT
Setting target to 3.4.1 so we don't miss it.
Comment 26 Markus Keller CLA Friend 2008-07-02 14:03:04 EDT
Created attachment 106334 [details]
Complete implementation (AST-based)
Comment 27 Markus Keller CLA Friend 2008-07-02 14:10:08 EDT
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.
Comment 28 Mauro Molinari CLA Friend 2008-07-03 03:49:55 EDT
(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.