Bug 279359 - [formatter] Formatter with 'never join lines' produces extra level of indent
Summary: [formatter] Formatter with 'never join lines' produces extra level of indent
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-06 16:18 EDT by Robert Munteanu CLA
Modified: 2009-10-05 06:06 EDT (History)
7 users (show)

See Also:


Attachments
Correct output - Eclipse [built-in] formatter (10.95 KB, image/png)
2009-06-06 16:19 EDT, Robert Munteanu CLA
no flags Details
Incorrect output - modified formatter (11.14 KB, image/png)
2009-06-06 16:22 EDT, Robert Munteanu CLA
no flags Details
Proposed patch (3.09 KB, patch)
2009-06-16 11:13 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.