Bug 343534 - [Formatter] adds newline after return statement
Summary: [Formatter] adds newline after return statement
Status: NEW
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: Project Inbox CLA
QA Contact: Chris Jaun CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 09:53 EDT by Markus Bauer CLA
Modified: 2014-05-29 13:55 EDT (History)
2 users (show)

See Also:
cmjaun: review+


Attachments
force next token on the same line after a return statement (2.14 KB, patch)
2011-04-21 09:57 EDT, Markus Bauer CLA
no flags Details | Diff

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