Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 423949 - [code formatting] if clause jumps into previous line in if statement followed by else
Summary: [code formatting] if clause jumps into previous line in if statement followed...
Status: VERIFIED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.9 M2   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.9 M2
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-12 13:34 EST by Palmer Eldritch CLA
Modified: 2018-08-01 09:43 EDT (History)
3 users (show)

See Also:


Attachments
formatter profile (30.45 KB, text/xml)
2013-12-12 13:34 EST, Palmer Eldritch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Palmer Eldritch CLA 2013-12-12 13:34:37 EST
Created attachment 238298 [details]
formatter profile

Reproducer :

public class Snippet {

	public class Editor {

		public void apply() {}

		public void commit() {}
	}

	{
		final Editor ed = new Editor();
		int android_os_Build_VERSION_SDK_INT = 0;
		int Build_VERSION_CODES_GINGERBREAD = 0;
		if (android_os_Build_VERSION_SDK_INT >= Build_VERSION_CODES_GINGERBREAD)
			ed.apply();
		// else ed.commit();
	}
}

All fine.

Now uncomment // else ed.commit(); - select all - hit Ctrl+shift+F

get :

-		if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
-			ed.apply();
+		if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) ed
+			.apply();


Notice that GINGERBREAD) ends exactly at column 80 - maybe a fencepost error ? Have seen something similar - will try to dig it up

Related probably to my formatter profile requiring simple if statements to be on the same line
Comment 1 Palmer Eldritch CLA 2013-12-28 20:44:19 EST
Another example

	void instanceMethod(int intExtra) {
		String msg = null;
		int WifiManager_WIFI_STATE_DISABLING = 0;
		int WifiManager_WIFI_STATE_DISABLED = 0;
		if (intExtra == WifiManager_WIFI_STATE_DISABLING) msg = "Wireless disabling";
		else if (intExtra == WifiManager_WIFI_STATE_DISABLED)
			msg = "Wireless disabled";
	}

Notice else is just right
Comment 2 Mateusz Matela CLA 2018-07-18 17:16:46 EDT
This problem no longer occurs, probably after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 3 Vikas Chandra CLA 2018-08-01 09:43:59 EDT
verified
Version: 4.9
Build id: I20180731-1305