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

Bug 420908

Summary: [Code Formatter] having one line ifs leads to badly formatted code when a synchronized block follows
Product: [Eclipse Project] JDT Reporter: Palmer Eldritch <the.ubik>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
my formatting profile none

Description Palmer Eldritch CLA 2013-11-01 16:04:04 EDT
Created attachment 237136 [details]
my formatting profile

Paste this :

public class Snippet {

	private Object upload_path;

	public void init() {
		if (upload_path == null)
			synchronized (Snippet.class) {
				if (upload_path == null) {
					System.out.println("yada");
				}
			}
	}
}

edit the line :


			synchronized (Snippet.class) { // add a comment for instance

hit Control+S. Result :

	public void init() {
		if (upload_path == null)
 synchronized (Snippet.class) { // add a comment
				if (upload_path == null) {
					System.out.println("yada");
				}
			}
	}

I attach my formatting profile. Save actions : http://www.bild.me/bild.php?file=6372064FormatingIf.jpg

Maybe "format edited lines only" ?
Comment 1 Palmer Eldritch CLA 2013-11-14 10:30:06 EST
This is not only with synchronized blocks - what happens is that the line "tries" to move to the previous line and fails, remaining on the line it was - albeit in the beginning of it.
Comment 2 Eclipse Genie CLA 2020-05-13 07:10:54 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.