Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 427362

Summary: [1.8][dom ast] ASTRewriteFormatter uses wrong "Insert new line after annotation" option for SingleVariableDeclaration
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: anchakrk, markus.kell.r, noopur_gupta, srikanth_sankaran
Version: 4.4   
Target Milestone: BETA J8   
Hardware: All   
OS: All   
Whiteboard:

Description Markus Keller CLA 2014-02-04 09:05:39 EST
From bug 425040 comment #1:

Consider the following example:
--------------------------------------------
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

public class X {
}

@Target(ElementType.TYPE_USE)
@interface Ann1 { }

class A {
	public void foo(X x, @Ann1 X arg) { }
}
--------------------------------------------
Move method #foo to X by choosing 'X x' as the receiver. It results in inserting a new line after annotation on the parameter as shown below:
--------------------------------------------
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

public class X {

	public void foo(@Ann1
	X arg) { }
}

@Target(ElementType.TYPE_USE)
@interface Ann1 { }

class A {
}
--------------------------------------------
It happens as the parameter (@Ann1 X arg) is considered as a SingleVariableDeclaration during AST rewrite and the formatter option "Insert new line after annotations on local variables" is enabled.
Comment 2 Srikanth Sankaran CLA 2014-02-04 09:08:30 EST
Thanks, I agree this should be fixed for Java 8 GA.
Comment 3 ANIRBAN CHAKRABORTY CLA 2014-02-21 04:57:02 EST
Verified as working for Eclipse + Java 8 RC1 using Kepler SR1 + Eclipse Java Development Tools Patch for Java 8 Support (BETA) 1.0.0.v20140220-2054