Bug 201276 - [5.0][navigation] Add display of Java 5 annotations to Java Outline view
Summary: [5.0][navigation] Add display of Java 5 annotations to Java Outline view
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 341477 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-08-27 11:33 EDT by Leho Nigul CLA
Modified: 2018-04-13 06:36 EDT (History)
16 users (show)

See Also:
eclipse.sprigogin: review? (markus.kell.r)


Attachments
Mock up for what would be nice to see (4.65 KB, image/gif)
2007-08-28 10:00 EDT, Leho Nigul CLA
no flags Details
screenshot: new appearance preferences (42.72 KB, image/png)
2014-08-29 23:03 EDT, Steven Spungin CLA
no flags Details
screenshot: annotations without parameters (454.30 KB, image/png)
2014-08-29 23:05 EDT, Steven Spungin CLA
no flags Details
screenshot: annotations with parameters (480.02 KB, image/png)
2014-08-29 23:06 EDT, Steven Spungin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leho Nigul CLA 2007-08-27 11:33:27 EDT
Build ID: I20070625-1500

Steps To Reproduce:
Annotations often contain information which is important to the user. It would be beneficial, if the annotations (and values of the annotation attributes) are displayed in the Outline view

More information:
Comment 1 Dani Megert CLA 2007-08-28 02:15:24 EDT
We already show some e.g. if you add @Deprecated. Can you provide an example and also provide a mockup on how you'd like to see this in the Outline view?
Comment 2 Leho Nigul CLA 2007-08-28 10:00:22 EDT
Created attachment 77131 [details]
Mock up for what would be nice to see
Comment 3 Leho Nigul CLA 2007-08-28 10:01:22 EDT
This is for @Stateless annotation defined on the type TT level
Comment 4 Dani Megert CLA 2007-08-29 08:26:51 EDT
So - the proposal is to display all the annotations for a member directly above it?
Comment 5 Dani Megert CLA 2011-03-31 09:53:39 EDT
*** Bug 341477 has been marked as a duplicate of this bug. ***
Comment 6 Ralf Stuckert CLA 2011-04-01 01:21:40 EDT
The solution introduced by Bug 341477 would be very nice, but you should be able to ignore certain standard annotations like Override and SuppressWarnings (e.g. via preferences). I guess most people are usually interested in annotations with application-specific meaning.
Comment 7 maarten meijer CLA 2013-12-05 12:40:19 EST
THis bug is more relevant than ever:
- e4 is annotation based, so outline should show @PostConstruct, @PreDestroy and @Focus
- JUnit4 is annotation based so these should be shown as well

I think the annotation should be appended to the item in the Outline view and should be filterable.
Comment 8 Lars Vogel CLA 2014-08-29 07:36:17 EDT
As the Eclipse 4 programming model is primary using annotations to define the relevant methods, that feature request would be really helpful.
Comment 9 Steven Spungin CLA 2014-08-29 07:51:02 EDT
(In reply to Lars Vogel from comment #8)
> As the Eclipse 4 programming model is primary using annotations to define
> the relevant methods, that feature request would be really helpful.

+1 on this 7-year-bug.  It would be nice to organize by these nodes:

Members
 injected members

Methods
 injected methods
 injected context methods
 injected broker methods

Command
 @Execute
 @CanExecute

LifeCycle
 @PostConstruct
 @PreDestroy
 @Persist

Application LifeCycle
 @PostContextCreate 
 @ProcessAdditions 
 @ProcessRemovals
 @PreSave
 @PostContextCreate


Also show @optional and @named values / parameters in the outline.
Comment 10 Lars Vogel CLA 2014-08-29 08:15:40 EDT
(In reply to Steven Spungin from comment #9)
> (In reply to Lars Vogel from comment #8)
> > As the Eclipse 4 programming model is primary using annotations to define
> > the relevant methods, that feature request would be really helpful.
> 
> +1 on this 7-year-bug.  It would be nice to organize by these nodes:

Maybe you could provide a Gerrit review for this feature?  I assume JDT would support any set of annotation and would not be able to implement any e4 based sorting.
Comment 11 Steven Spungin CLA 2014-08-29 08:53:05 EDT
(In reply to Lars Vogel from comment #10)
> (In reply to Steven Spungin from comment #9)
> > (In reply to Lars Vogel from comment #8)
> > > As the Eclipse 4 programming model is primary using annotations to define
> > > the relevant methods, that feature request would be really helpful.
> > 
> > +1 on this 7-year-bug.  It would be nice to organize by these nodes:
> 
> Maybe you could provide a Gerrit review for this feature?  I assume JDT
> would support any set of annotation and would not be able to implement any
> e4 based sorting.

With time willing, I will provide a review to e4 tools project.  I will make it extensible enough so JDT can reuse/pull-up the core.

Should we re-file a bug on e4 tools?
Comment 12 Lars Vogel CLA 2014-08-29 08:57:55 EDT
(In reply to Steven Spungin from comment #11)
> With time willing, I will provide a review to e4 tools project.  I will make
> it extensible enough so JDT can reuse/pull-up the core.
> 
> Should we re-file a bug on e4 tools?

+1

Just to clarify that, displayed annotations in the JDT outline view would benefit lots of users, e.g. JPA, Java EE, e4, etc.
Comment 13 Steven Spungin CLA 2014-08-29 23:03:51 EDT
Created attachment 246566 [details]
screenshot: new appearance preferences
Comment 14 Steven Spungin CLA 2014-08-29 23:05:37 EDT
Created attachment 246567 [details]
screenshot: annotations without parameters
Comment 15 Steven Spungin CLA 2014-08-29 23:06:11 EDT
Created attachment 246568 [details]
screenshot: annotations with parameters
Comment 16 Steven Spungin CLA 2014-08-29 23:40:28 EDT
https://git.eclipse.org/r/#/c/32584/
Comment 17 Lars Vogel CLA 2014-09-09 09:28:14 EDT
(In reply to Steven Spungin from comment #16)
> https://git.eclipse.org/r/#/c/32584/

Thanks a lot Steven, I think this looks awesome.

I'm not a JDT developer but in platform.ui we try to keep changes as focused as possible. That makes review easier and later corrections if required. 

Can you rework this Gerrit change to only enable the annotation display in the Outline view and create a new Gerrit review for the filter and add it to Bug 443101?
Comment 18 Steven Spungin CLA 2014-12-08 21:45:14 EST
The filter has been removed from latest Gerrit patch.
Comment 19 Stephan Herrmann CLA 2015-07-14 08:49:41 EDT
While this bug states "Java 5 annotations" - and perhaps should remain focussed on that for now - do you have some thoughts how this will extend to Java 8 type annotations?

I assume with TYPE_USE annotation @Nullable this declaration ...
  @Optional
  @Nullable String field;

... will be rendered as ...
  field : @Nullable String [@Optional]

... right?
  

(In reply to Steven Spungin from comment #13)
> Created attachment 246566 [details]
> screenshot: new appearance preferences

I don't see anything new here, was this cropped more than intended?
Comment 20 Steven Spungin CLA 2015-07-14 09:49:20 EDT
The display of annotations does not distinguish between Java 7, Java 8, etc.  An annotation is an annotation.

> I assume with TYPE_USE annotation @Nullable this declaration ...
>   @Optional
>   @Nullable String field;
> 
> ... will be rendered as ...
>   field : @Nullable String [@Optional]
> 
> ... right?
>   
> 

field: String [@Optional @Nullable]
see screenshot https://bugs.eclipse.org/bugs/attachment.cgi?id=246567


> (In reply to Steven Spungin from comment #13)
> > Created attachment 246566 [details]
> > screenshot: new appearance preferences
> 
> I don't see anything new here, was this cropped more than intended?

I think bugzilla had an issue when that image was uploaded. I don't have the source image any more, and unfortunately we have temporary given up trying to contribute any of our code to the JDT project, so you will just have to use your imagination or pull down the patch from gerrit and see for yourself :)
Comment 21 Stephan Herrmann CLA 2015-07-14 09:58:37 EDT
(In reply to Steven Spungin from comment #20)
> The display of annotations does not distinguish between Java 7, Java 8, etc.
> An annotation is an annotation.

Annotations do have different @Target;s. Annotations with @Target(TYPE_USE) are different from those available in Java 5.
 
> > I assume with TYPE_USE annotation @Nullable this declaration ...
> >   @Optional
> >   @Nullable String field;
> > 
> > ... will be rendered as ...
> >   field : @Nullable String [@Optional]
> > 
> > ... right?
> >   
> > 
> 
> field: String [@Optional @Nullable]
> see screenshot https://bugs.eclipse.org/bugs/attachment.cgi?id=246567

That would be wrong, because a TYPE_USE annotation in this position is bound to the type, not to the field.

For illustration: Eventually, we will also need to handle things like:
   List<@NonNull String> field;

Nevermind, I guess we can handle the TYPE_USE case in a subsequent bug.
Comment 22 Steven Spungin CLA 2015-07-14 10:10:41 EDT
> Annotations do have different @Target;s. Annotations with @Target(TYPE_USE)
> are different from those available in Java 5.
>  

I see.  Thanks for the insight.

Is "field : @Nullable String [@Optional]" how you would desire to see the annotation?
Comment 23 Stephan Herrmann CLA 2016-05-04 18:56:00 EDT
(In reply to Stephan Herrmann from comment #21)
> (In reply to Steven Spungin from comment #20)
> > field: String [@Optional @Nullable]
> > see screenshot https://bugs.eclipse.org/bugs/attachment.cgi?id=246567
> 
> That would be wrong, because a TYPE_USE annotation in this position is bound
> to the type, not to the field.
> 
> For illustration: Eventually, we will also need to handle things like:
>    List<@NonNull String> field;
> 
> Nevermind, I guess we can handle the TYPE_USE case in a subsequent bug.

For javadoc hover & view this has been implemented via bug 403917.