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

Bug 343534

Summary: [Formatter] adds newline after return statement
Product: [WebTools] JSDT Reporter: Markus Bauer <markusbauer>
Component: GeneralAssignee: Project Inbox <jsdt.javascript-inbox>
Status: NEW --- QA Contact: Chris Jaun <cmjaun>
Severity: normal    
Priority: P3 CC: cmjaun, jpadilla
Version: unspecifiedFlags: cmjaun: review+
Target Milestone: Future   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
force next token on the same line after a return statement none

Description Markus Bauer CLA 2011-04-21 09:53:45 EDT
Build Identifier: I20110310-1119

The formatter adds a newline after a return statement if the next token starts with "{". This changes the semantics and results in invalid JavaScript code.

Reproducible: Always

Steps to Reproduce:
1. Set [Preferences] -> [JavaScript] -> [Code Style] -> [Formatter] -> [Edit...] -> [Braces] -> [Object initializer] to "Next line"

2. Formatting the following example code:

test = function() {
	return {
		test : 1
	};
}


3. results in the following invalid code:

test = function() {
	return
	{
		test : 1
	};
}

After a return statement the "{" must always stay on the same line, no matter what the settings are.
Comment 1 Markus Bauer CLA 2011-04-21 09:57:58 EDT
Created attachment 193822 [details]
force next token on the same line after a return statement

The attached quick fix resolves the issue for me.
Comment 2 Jorge Padilla CLA 2013-06-19 13:44:59 EDT
Chris, I have reviewed this patch and validated it resolves this problem. I recommend it to be included in 3.5.1.  Could you officially complete 
this review?
Comment 3 Chris Jaun CLA 2013-06-26 17:54:31 EDT
Seems like a simple fix and does the job. Approved.
Comment 4 Chris Jaun CLA 2013-07-09 14:25:06 EDT
Markus,

Eclipse is putting in some updated policies regarding accepting patches.

See point #1 and #2 in the Bugzilla section at this link: http://wiki.eclipse.org/Development_Resources/Handling_Git_Contributions

If you haven't yet, you need to sign the Contributor License Agreement for us to pull in your patch.

Thanks,
Chris