Bug 5702

Summary: "Keep else if on the same line" appears to do the reverse
Product: [Eclipse Project] JDT Reporter: Jon Skeet <skeet>
Component: UIAssignee: Martin Aeschlimann <martinae>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Jon Skeet CLA 2001-11-09 05:29:59 EST
In the "new lines" settings, I have:

Insert new line before opening brace
Insert new line in control statement
Insert a new line inside an empty block

That formats the sample code as:

{

	if (size < currentSize)
	{
		try
		{
			size = inStream.available();
		}
		catch (IOException e)
		{
		}
	}
	else if (size == currentSize)
	{
		++size;
	}
	else
	{
		--size;
	}

}

Note that "else if" is on the same line. If I tick "Keep else if on the same 
line", I get:

{

	if (size < currentSize)
	{
		try
		{
			size = inStream.available();
		}
		catch (IOException e)
		{
		}
	}
	else
		if (size == currentSize)
		{
			++size;
		}
		else
		{
			--size;
		}

}

Note that now the "else if" is split - ie not on the same line.

Jon
Comment 1 Erich Gamma CLA 2001-11-12 09:03:37 EST
is the UI presenting this option properly?
Comment 2 Jon Skeet CLA 2001-11-12 09:32:42 EST
Could you clarify exactly what you mean?

If you're asking whether the code formatter in the editor itself exhibits the 
same, behaviour, the answer is yes: with the option to keep the else-if on the 
same line ticked, the "if" appears on the next line.
Comment 3 Martin Aeschlimann CLA 2001-11-20 09:04:30 EST
Label has been changed (-> Insert new line between 'else if')

>111106