Bug 237267

Summary: Specific annotations formatting for method return parameters
Product: [Eclipse Project] JDT Reporter: Nicolas Damour <nicolas.damour>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED INVALID QA Contact:
Severity: enhancement    
Priority: P3 CC: markus.kell.r
Version: 3.4   
Target Milestone: 3.5 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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