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

Bug 325341

Summary: Incorrectly formatting if clause with one instruction that has no { }
Product: z_Archived Reporter: AntonioCS <antoniocs>
Component: PDTAssignee: PHP Core <php.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: ganoro, kalin.a, zhaozhongwei
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
patch v1
none
patch v2
none
patch v3
none
patch none

Description AntonioCS CLA 2010-09-15 08:08:25 EDT
Build Identifier: 20100617-1415

Eclipse format code option doesn't properly format code in if's.
I have the following lines of code:

		$cfile = sha1($keyname);
		$cpath = $this->_cache_dir;

		if (isset($options['subdir']))
			$cpath .= $options['subdir']; 

		return $cpath . $cfile;



The line after the if statement doesn't get the tab it should have. It becomes like this:

		if (isset($options['subdir']))
		$cpath .= $options['subdir'];




Reproducible: Always

Steps to Reproduce:
1. Have code that has if clause with only one instruction and no { }
2. Click Source > Format
3. See how it's not correctly tabbed
Comment 1 xu jiaxi CLA 2010-10-13 04:40:21 EDT
Created attachment 180741 [details]
patch v1

It does not work for the code below

<?php
if(true)
if(true)
echo a;

but works for

<?php
if(true)
echo a;

Can anyone give me some advise?
Comment 2 xu jiaxi CLA 2010-10-26 04:12:32 EDT
Created attachment 181701 [details]
patch v2

some small changes.
still does not work for

if(true)
if(true)
echo $a;
Comment 3 xu jiaxi CLA 2010-10-26 04:44:24 EDT
Created attachment 181702 [details]
patch v3
Comment 4 xu jiaxi CLA 2010-11-01 00:06:36 EDT
Created attachment 182127 [details]
patch

Changes a lot for indentation. So there may be some regressions.
We need more tests.
Comment 5 Roy Ganor CLA 2010-11-01 10:26:37 EDT
Can you please suggest a way to deliver unit tests along with this patch?
As you said this may yield regression issues and it will be nice to start unit tests it now.

10x!
Comment 6 xu jiaxi CLA 2010-11-03 04:57:57 EDT
the last patch fails in some cases.
So I think I need to rethink about this bug.
Comment 7 Zhongwei Zhao CLA 2011-09-06 11:56:44 EDT
fixed in head
Comment 8 Kalin CLA 2011-10-18 03:27:23 EDT
Verified.
Closing...