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

Bug 489739

Summary: [formatting] Java condition (ternary) operator formatting error
Product: [Eclipse Project] JDT Reporter: Attila Molnar <amolnar>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: bsd, daniel_megert, dusisarath, manoj.palat, mateusz.matela
Version: 4.5.2   
Target Milestone: 4.6 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
format.xml
none
screenshot none

Description Attila Molnar CLA 2016-03-16 07:58:46 EDT
Hi!

Conditional (ternary) operator formatting become broken after updating to 5.4.2.
There is ALWAYS a new line before the "?", no matter what are the formatting settings.
Comment 1 Brian de Alwis CLA 2016-03-16 10:16:51 EDT
Sorry, but I can't reproduce on 4.5.2 with a simple Java project.  Please check your formatter settings.  Or attach a small test project with embedded formatter settings to reproduce.

public class FormatterTest {
	public static void main(String[] args) {
		String report = args.length > 0 ? args[0] : "";
	}
}
Comment 2 Attila Molnar CLA 2016-03-16 10:35:27 EDT
Created attachment 260345 [details]
format.xml
Comment 3 Attila Molnar CLA 2016-03-16 10:35:45 EDT
Created attachment 260346 [details]
screenshot
Comment 4 Attila Molnar CLA 2016-03-16 10:37:12 EDT
Attached the xml and the screenshot. 
Note, that even the preview is wrong not just the actual formatting.
Comment 5 Attila Molnar CLA 2016-03-16 10:39:50 EDT
Repoened (added format.xml and screenshot)
Comment 6 Mateusz Matela CLA 2016-03-19 07:44:44 EDT
The problem is "Force wrap" option - even though it looks disabled, it still affects the formatting. So you can change the wrapping policy to something else, uncheck "Force split" and change policy back to "Do not wrap".

*** This bug has been marked as a duplicate of bug 488898 ***
Comment 7 Dusi Sarath Chandra CLA 2016-04-27 05:49:29 EDT
Verified using Eclipse Version: Neon (4.6)
Build id: I20160425-1300