Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325341 - Incorrectly formatting if clause with one instruction that has no { }
Summary: Incorrectly formatting if clause with one instruction that has no { }
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-15 08:08 EDT by AntonioCS CLA
Modified: 2020-05-14 10:16 EDT (History)
3 users (show)

See Also:


Attachments
patch v1 (1.38 KB, patch)
2010-10-13 04:40 EDT, xu jiaxi CLA
no flags Details | Diff
patch v2 (2.19 KB, patch)
2010-10-26 04:12 EDT, xu jiaxi CLA
no flags Details | Diff
patch v3 (1.95 KB, patch)
2010-10-26 04:44 EDT, xu jiaxi CLA
no flags Details | Diff
patch (17.44 KB, patch)
2010-11-01 00:06 EDT, xu jiaxi CLA
no flags Details | Diff

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