Bug 281655 - [formatter] "Never join lines" does not work for annotations.
Summary: [formatter] "Never join lines" does not work for annotations.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 282030
Blocks:
  Show dependency tree
 
Reported: 2009-06-26 09:07 EDT by egor s. kolesnikov CLA
Modified: 2010-03-09 03:26 EST (History)
3 users (show)

See Also:


Attachments
Draft patch (2.91 KB, patch)
2009-07-24 07:21 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description egor s. kolesnikov CLA 2009-06-26 09:07:39 EDT
Build ID: 20090621-0832

Steps To Reproduce:
1. Create a class with a long annotation and format it manually:
@MessageDriven(mappedName = "filiality/SchedulerMQService", 
		activationConfig = { 
			@ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0/10 * * * * ?") 
		})
@RunAs("admin")
@ResourceAdapter("quartz-ra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class EventProcessingScheduledBean implements Job {
}

2. CTRL + SHIFT + F

3. Result:

@MessageDriven(mappedName = "filiality/SchedulerMQService", activationConfig = { @ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0/10 * * * * ?") })
@RunAs("admin")
@ResourceAdapter("quartz-ra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class EventProcessingScheduledBean implements Job {
}


More information:
It is expected that Eclipse formatter will NOT join the lines within annotations when "never join lines" option is set for both code and comments.
Comment 1 Olivier Thomann CLA 2009-06-28 17:24:54 EDT
I believe this is due to the fact that there is no "alignment" for annotations.
Comment 2 Frederic Fusier CLA 2009-07-24 07:21:59 EDT
Created attachment 142504 [details]
Draft patch

First attempt to fix the problem. The proposed approach is minimalist (i.e. does not add any new preferences). It just creates a new alignment using the expressions in initializers preference value.

Using this patch the snippet would be formatted as follow:
@MessageDriven(mappedName = "filiality/SchedulerMQService",
		activationConfig = {
		@ActivationConfigProperty(propertyName = "cronTrigger",
		propertyValue = "0/10 * * * * ?")
		})
@RunAs("admin")
@ResourceAdapter("quartz-ra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class EventProcessingScheduledBean {
}

The question is: is this an acceptable behavior or do we think about adding new specific alignments for the annotations?

Olivier, what's your mind about this?
Comment 3 Frederic Fusier CLA 2010-02-19 09:21:09 EST
Comment on attachment 142504 [details]
Draft patch

The patch of bug 282030 will solve this issue...
Comment 4 Frederic Fusier CLA 2010-02-22 11:47:00 EST
Fixed by bug 282030 patch released for 3.6M6...
Comment 5 Srikanth Sankaran CLA 2010-03-09 03:26:30 EST
Verified for 3.6M6 using build I20100305-1011