Bug 237267 - Specific annotations formatting for method return parameters
Summary: Specific annotations formatting for method return parameters
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.5 M1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-16 08:23 EDT by Nicolas Damour CLA
Modified: 2008-08-06 13:00 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Damour CLA 2008-06-16 08:23:41 EDT
Build ID: I20080530-1730

Currently (Ganymede RC3, build id I20080530-1730), the Code Style formatter allows one to handle new lines after annotations in three specific ways depending on whether the annotated entity is a member, a parameter or a local variable (see bug #122247).

I would propose yet a fourth "entity category" in addition to the
three that we already have (MEMBER, PARAMETER, LOCAL_VARIABLE):
RETURN_PARAMETER.
This is the reason why: when annotating the return parameter of a method, I get
the following:

@MyAnnotation1
public @NonNull
Set getReturnValue(@NonNull String myParam1) {
  return this.returnValue;
}

I would actually rather have the following:

@MyAnnotation1
public @NonNull Set getReturnValue(@NonNull String myParam1) {
  return this.returnValue;
}

Which I find more legible.

Thank you,

Nicolas Damour.
Comment 1 Markus Keller CLA 2008-06-26 06:21:14 EDT
(Copy of bug 122247 comment 45)
Note that the Java language up to (including) 1.6 does not support annotations
on the return type. All annotations that appear before the return type of a
method belong to the whole method declaration.

> @MyAnnotation1
> public @NonNull Set getReturnValue(@NonNull String myParam1) {

From a language point of view, this is equivalent to 
  @NonNull
  @MyAnnotation1
  public Set getReturnValue(@NonNull String myParam1) {

I think we shouldn't change the formatter right now. We should only add a new category if Java 1.7 introduces annotations on all type references.
Comment 2 Nicolas Damour CLA 2008-06-26 06:29:00 EDT
Yeah, you're right.
I somehow overlooked what you explained, so that my request makes no sense at all.
Thank you for your contribution.
Nicolas.
Comment 3 Kent Johnson CLA 2008-08-06 13:00:36 EDT
Verified for 3.5M1 using I20080805-1307