Bug 281655

Summary: [formatter] "Never join lines" does not work for annotations.
Product: [Eclipse Project] JDT Reporter: egor s. kolesnikov <esk>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: LifarV, Olivier_Thomann, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.6 M6   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 282030    
Bug Blocks:    
Attachments:
Description Flags
Draft patch none

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