Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325412 - [formatter] Add newline after annotations on ... also adds newlines for each annotation
Summary: [formatter] Add newline after annotations on ... also adds newlines for each ...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-16 04:18 EDT by Dani Megert CLA
Modified: 2020-01-25 11:32 EST (History)
6 users (show)

See Also:


Attachments
possible fix (1.82 KB, patch)
2011-04-14 06:19 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2010-09-16 04:18:31 EDT
R3.6.

The 'Add newline after annotations on ...' option also adds newlines for each annotation if enabled.

Have this:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE)
public @interface Documented {
}

Format
==> it also puts each annotation on a new line.

Either we have to rename the options or add a new preference that controls forced wrapping of annotations.
Comment 1 Frederic Fusier CLA 2010-12-27 04:48:06 EST
Ayush, can you take a look at this?
Thanks
Comment 2 paul stanton CLA 2011-03-01 13:04:49 EST
i think i was about to log a duplicate ...

i want to be able to format so that multiple annotations on the same element (method, field, parameter) all appear on the same line, however a new line is inserted after the last annotation, ie:

	@Override @SuppressWarnings("all") @FeedTheCat
	public static final synchronized void goDoSomeWork(Person me)
	{}

I guess wrapping might be important too.
Comment 3 Ayushman Jain CLA 2011-04-14 05:12:09 EDT
I think we should have another option under New Lines>Annotation
[x] Insert new line after each annotation

Iff this option is selected, we will put each annotation on a fresh line, otherwise we will leave the formatting(specifically wrapping) between annotations as it is, while still cleaning up useless whitespaces, etc.

The other alternative is to leave wrapping between annotations untouched and add no new option.

Dani, what do you think?
Comment 4 Dani Megert CLA 2011-04-14 05:41:16 EDT
> The other alternative is to leave wrapping between annotations untouched and
> add no new option.
This is not an option since the current behavior doesn't match what the UI says.

>[x] Insert new line after each annotation
This would be a contradiction to the other options. Better:
[x] Insert new line between annotations

Given API freeze we could consider to adjust the UI for 3.7:

"Add newline after annotations on ..."
==>
"Add newline after and between annotations on ...'
Comment 5 Ayushman Jain CLA 2011-04-14 06:01:31 EDT
(In reply to comment #4)
> Given API freeze we could consider to adjust the UI for 3.7:
> 
> "Add newline after annotations on ..."
> ==>
> "Add newline after and between annotations on ...'

or "Add newline after each annotation on ..."

So, i'll change the target for this bug to 3.8 and we can have the UI fix for 3.7. 
For 3.8, we'll change the UI back to what it is now and add the new option "Insert new line between annotations".
Comment 6 Ayushman Jain CLA 2011-04-14 06:07:36 EDT
(In reply to comment #4)
> > The other alternative is to leave wrapping between annotations untouched and
> > add no new option.
> This is not an option since the current behavior doesn't match what the UI
> says.

Btw, with that statement I basically meant changing the behaviour so that formatting the code 

@Documented @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE) public @interface Documented {}

leads to

@Documented @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Documented {}

(i.e. new line inserted only after the last annotation)

Why is this not acceptable?
Comment 7 Ayushman Jain CLA 2011-04-14 06:19:00 EDT
Created attachment 193239 [details]
possible fix

A fix illustrating comment 6.

IMO, this is better than changing the UI because this does exactly what the UI says right now i.e. insert new line after annotation*s* on xxxx.
Comment 8 Dani Megert CLA 2011-04-14 07:17:15 EDT
(In reply to comment #7)
> Created attachment 193239 [details] [diff]
> possible fix
> 
> A fix illustrating comment 6.
> 
> IMO, this is better than changing the UI because this does exactly what the UI
> says right now i.e. insert new line after annotation*s* on xxxx.

No it is not better: the annotations are wrapped since 3.1. Changing that after 5 years is just not an option.

And since the bug is in there since 3.1 we won't update the UI for 3.7.
Comment 9 Ayushman Jain CLA 2011-04-14 07:52:25 EDT
(In reply to comment #8)
> [..]
> No it is not better: the annotations are wrapped since 3.1. Changing that after
> 5 years is just not an option.
> 
> And since the bug is in there since 3.1 we won't update the UI for 3.7.

Hmm, will target the new option for 3.8 then.
Comment 10 Srikanth Sankaran CLA 2012-03-20 11:33:19 EDT
If you plan to include a fix for this in 3.8 M7, please adjust the
target suitably, so it becomes easier to track.
Comment 11 Satyam Kandula CLA 2012-03-21 01:21:17 EDT
Do we want to really target this for 3.8? I believe it is late and we could probably push it.
Comment 12 Dani Megert CLA 2012-03-21 04:29:41 EDT
I'm OK moving this to 3.9.
Comment 13 Eclipse Genie CLA 2019-10-13 17:57:39 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 14 Jitendra Kumar CLA 2020-01-25 11:32:17 EST
Hi Guys

Is there any update on this? I would love to have this option of putting annotations on one line.