Bug 236850 - [misc] Show Java Annotations in the Javadoc hover and view
Summary: [misc] Show Java Annotations in the Javadoc hover and view
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P2 enhancement with 2 votes (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 133345 171214 200817 289966 (view as bug list)
Depends on: 248309 249844
Blocks: 72139
  Show dependency tree
 
Reported: 2008-06-12 08:33 EDT by Troy Taillefer CLA
Modified: 2010-04-29 10:42 EDT (History)
11 users (show)

See Also:


Attachments
annotation placement variants (91.85 KB, image/png)
2008-10-08 08:29 EDT, Markus Keller CLA
no flags Details
work in progress 1 (29.41 KB, patch)
2008-10-08 08:33 EDT, Markus Keller CLA
no flags Details | Diff
Fix (30.30 KB, patch)
2010-04-24 18:46 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Troy Taillefer CLA 2008-06-12 08:33:12 EDT
I would like there to be a way to get eclipse to
display annotations (that the required retention policy) to be visible in package explorer, in the outline and text editor as a pop up the way the javadoc comments are seen.  Since annotations can be reflected I don't see why eclipse does not have an option to display them the way it can display javadoc comments. This would allow developers to communicate infromation through annotations.
Comment 1 Jerome Lanneluc CLA 2008-06-16 08:03:00 EDT
Moving to JDT/UI
Comment 2 Martin Aeschlimann CLA 2008-06-16 08:30:57 EDT
Showing the annotation in the hover is a good idea, I think. Ok, if I change the title of the request to 'Seeing Java Annotations in the hover'?
Comment 3 Troy Taillefer CLA 2008-06-16 09:33:21 EDT
In the unlikely case that you were asking me, your sugested change is fine with me.

Comment 4 Martin Aeschlimann CLA 2008-06-16 10:03:38 EDT
I actually meant you, Troy :-) (You filed the bug, so before I change the title of the bug I rather ask..)

Moving to Platform/Text
Comment 5 Dani Megert CLA 2008-06-16 10:32:07 EDT
Just to clarify: this means you would only see it inside the Java editor when hovering over an element. Not in Package Explorer's or Outline's hover.
Comment 6 Dani Megert CLA 2008-06-16 11:00:53 EDT
We should do the same as javadoc tool generates. This means we should show those annotations in the hover that have the @Documented annotation.
Comment 7 Dani Megert CLA 2008-06-16 11:02:25 EDT
*** Bug 200817 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2008-08-19 11:47:14 EDT
*** Bug 171214 has been marked as a duplicate of this bug. ***
Comment 9 luke w patterson CLA 2008-09-12 14:09:40 EDT
My use case of annotations would really benefit from this feature.

I create proxies of interfaces which include i18-related methods like this:

@MessageFormatPattern("Element {0,number,integer} is null of {1}.")
String nullArrayElement(int index, String name);

My proxy impl uses that message pattern along with the method arguments.  The property keys are the fully qualified method names.  An apt-based build tool plugin generates the default properties file.  

Anyways, with this enhancement my i18n messages would be automatically documented in the javadoc hover.
Comment 10 Markus Keller CLA 2008-10-08 08:29:00 EDT
Created attachment 114538 [details]
annotation placement variants

Where in the hover would you expect annotations to show up? I made some experiments (see attached image), but I'm not sure where and how to put the annotations.

The problem is that annotations can become long, and putting them in front of the header line would move the header image and label far away from where users expect them. Putting them between the header and the description potentially moves the description out of sight.

Any opinions? I'm tending towards solution 4 (between header and description, with visible links).
Comment 11 Markus Keller CLA 2008-10-08 08:33:03 EDT
Created attachment 114539 [details]
work in progress 1
Comment 12 luke w patterson CLA 2008-10-08 10:48:08 EDT
Number 4 looks good.  The content ordering seems natural.  Having the annotations linkable is really useful.

Thanks for the great work Markus.
Comment 13 luke w patterson CLA 2008-10-08 11:26:09 EDT
Just a sidenote:

I am not that familiar with GWT, but it looks like the GWT i18n framework users will really find this enhancement useful.

Check out the "Complete Annotations Example" section of the com.google.gwt.i18n.client.Messages javadoc - 

http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/i18n/client/Messages.html
Comment 14 Markus Keller CLA 2008-10-17 09:50:26 EDT
Are annotation that important in practice? I fear that showing annotations at the beginning of the Javadoc hover (also proposed solution 4 between header and description) would too often move the really important parts (main description and parameter descriptions) out of sight.

Would it be a big problem if we moved the annotations to the very end of the Javadoc? That would in fact show them at the same place as they are in source (i.e. after the /** Javadoc */ block).

Tip: If you want to quickly see the annotations of something, just use the Source hover ('Shift + hover' by default, modifier can be configured on the 'Hovers' preference page).
Comment 15 Jerome Lanneluc CLA 2008-10-23 10:50:10 EDT
I'm not sure to understand why bug 245689 blocks this one.
Comment 16 Dani Megert CLA 2008-10-23 10:54:47 EDT
>I'm not sure to understand why bug 245689 blocks this one.
Maybe because the problem appears more often with annotations? Will have to wait for Markus for the answer.
Comment 17 Markus Keller CLA 2008-11-04 07:21:53 EST
> >I'm not sure to understand why bug 245689 blocks this one.
> Maybe because the problem appears more often with annotations?

Yep, if links don't work in standard annotations, this bug cannot be completely FIXED.

(In reply to bug 245689 comment #1)
> The same problem occurs in I20080930-0921 when I open
> javax.annotation.Generated from jdk6 and try to resolve "Documented",
> "Retention", etc. which are imported with "import java.lang.annotation.*;".
Comment 18 Markus Keller CLA 2008-11-04 08:30:48 EST
>I'm not sure to understand why bug 245689 blocks this one.

Actually, the latest work in progress does not to resolve annotation types from source names any more (I need bindings for other reasons, so I can also generate the resolved links from the bindings). Removing bug 245689 from blocking bugs.
Comment 19 Markus Keller CLA 2009-04-30 12:34:03 EDT
Sorry, I ran out of time for 3.5. The fix needs to create more ASTs than normal Javadoc hovers, and I don't want to risk breaking or delaying the hovers at this stage.
Comment 20 Dani Megert CLA 2009-09-21 05:16:39 EDT
*** Bug 289966 has been marked as a duplicate of this bug. ***
Comment 21 Markus Keller CLA 2010-04-24 18:46:53 EDT
Created attachment 166009 [details]
Fix
Comment 22 Markus Keller CLA 2010-04-24 18:47:44 EDT
Fixed in HEAD.
Comment 23 Deepak Azad CLA 2010-04-27 05:54:41 EDT
Verified for 3.6 M7 with I20100426-0852.
Comment 24 Markus Keller CLA 2010-04-29 10:42:36 EDT
*** Bug 133345 has been marked as a duplicate of this bug. ***