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

Bug 279359

Summary: [formatter] Formatter with 'never join lines' produces extra level of indent
Product: [Eclipse Project] JDT Reporter: Robert Munteanu <robert.munteanu>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, frederic_fusier, ge0ffrey.spam, markus.kell.r, Olivier_Thomann, satyam.kandula, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.6 M1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Correct output - Eclipse [built-in] formatter
none
Incorrect output - modified formatter
none
Proposed patch none

Description Robert Munteanu CLA 2009-06-06 16:18:06 EDT
Using the built-in Eclipse profile and ticking 'Never join lines' creates an extra level of indent when formatting the following code:

import java.util.concurrent.Executors;

public class Formatter {

	public static void main(String[] args) {

		Executors.newCachedThreadPool().execute(new Runnable() {

			public void run() {
				throw new UnsupportedOperationException("stub");
			}

		});

	}
}

Screenshot will be attached.


-- Configuration Details --
Product: Eclipse Platform 3.3.200.v200905282000 (org.eclipse.platform.ide)
Installed Features:
 org.eclipse.jdt 3.5.0.v20090527-2000-7r88FEeFJePyvYe69JGnUag1
Comment 1 Robert Munteanu CLA 2009-06-06 16:19:46 EDT
Created attachment 138488 [details]
Correct output - Eclipse [built-in] formatter
Comment 2 Robert Munteanu CLA 2009-06-06 16:22:32 EDT
Created attachment 138489 [details]
Incorrect output - modified formatter

This is the output of the built-in formatter with the 'Never join lines' option checked.
Comment 3 Frederic Fusier CLA 2009-06-16 11:13:30 EDT
Created attachment 139303 [details]
Proposed patch

Do not add indentation on a closing brace which most of times means the end of a block, hence the indentation will be set while visiting the parent node...
Comment 4 Frederic Fusier CLA 2009-06-16 11:13:56 EDT
Released for 3.6M1 in HEAD stream.
Comment 5 Srikanth Sankaran CLA 2009-08-04 00:13:00 EDT
Verified for 3.6M1 using build I20090802-2000
Comment 6 Geoffrey De Smet CLA 2009-09-15 03:03:10 EDT
Can the fix also be released as a hotfix in 3.5.1?
"Never join lines" (= "respect my new lines") is unusable due to this bug and we 'd like to use such a handy feature before june 2010 :)
Comment 7 Frederic Fusier CLA 2009-09-15 04:26:05 EDT
(In reply to comment #6)
> Can the fix also be released as a hotfix in 3.5.1?
> "Never join lines" (= "respect my new lines") is unusable due to this bug and
> we 'd like to use such a handy feature before june 2010 :)

This fix was finally reverted as it did not completely fix all cases (see bug 283467, bug 286601 and bug 286668). We also realized that side effects were also introduced on previous formatter behavior while trying to fix these issues (see bug 286912) as well as some regression (see bug 287462)...

So this is a long story and this definitely cannot be fixed for 3.5.1 which is now in a freeze state.

Satyam could you prepare a patch for the R_3_5_maintenance stream and attach it to the bug then Olivier can look at it and decide whether it could be an acceptable fix for 3.5.2?
Comment 8 Olivier Thomann CLA 2009-09-15 10:28:36 EDT
Satyam, please prepare a patch for 3.5 maintenance stream.
We will target 3.5.2. It is definitely too late for 3.5.1.