This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Group Assignment Multiline Alignment doesn't work | ||
---|---|---|---|
Product: | php | Reporter: | arnolem |
Component: | Formatting & Indentation | Assignee: | Petr Pisl <ppisl> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | harunaga, pjiricka |
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | Previous post in ZIP format |
Description
arnolem
2010-06-17 14:03:06 UTC
Hmm, it looks like there is missing the rule in the formatter. I'm going to fix it. I think that, the rule which is now in the formatter should does something different. It should aligned the rest of expression under the '=' char. For example by the default the behavior should be: $i = 22 * 5; $very_long_name = 22 * 5; So the expression that is placed on the new line is indented with 8 spaces (continual indentation). When the option Multiline Alignment Assignment is swith on, then the expression should be indented on the position after = char, so the example should look like: $i = 22 * 5; $very_long_name = 22 * 5; This doesn't work correctly now and should be fixed. I think you expect that after formatting your code with Multiline Alignment Assignment option on the result should be: <?php $test = 'test1'; $param1 = 'test2'; $longParam = 'test2'; class test { const TEST = 't'; const LONG_CONST = 't'; } ?> I'm right? But this is not very easy to do. At first, it has to be clear which lines should be affected with this. Like the following code should be: $x = 10; $y = 20; $center = poin($x, $y); $some_rectangle = Rectangle(1,1,2,2); or $x = 10; $y = 20; $center = poin($x, $y); $some_rectangle = Rectangle(1,1,2,2); So at first we have to define the behavior, which blog of lines will be aligned. It's right. I think the rule should be: - Align all signs equal to the first sign of each grouping. - A group is defined by a line break or comment. - If an equal sign is beyond what is defined for the group, he retains his position Example : //group 1 $foo = 10; $x = 20; //group 2 $foo2 = 20; $y = 20; will be formatted as //group 1 $foo = 10; $x = 20; //group 2 $foo2 = 20; $y = 20; And $x = 10; $y = 20; $center = point($x, $y); $some_rectangle = Rectangle(1,1,2,2); will be formatted as $x = 10; $y = 20; $center = point($x, $y); $some_rectangle = Rectangle(1,1,2,2); This is a proposal but the ideal thing would be set based on user needs. Choose to align the first or the largest Thanks (In reply to comment #2) > I think that, the rule which is now in the formatter should does something > different. It should aligned the rest of expression under the '=' char. For > example by the default the behavior should be: > > $i = > 22 * 5; > $very_long_name = > 22 * 5; > > So the expression that is placed on the new line is indented with 8 spaces > (continual indentation). > > When the option Multiline Alignment Assignment is swith on, then the expression > should be indented on the position after = char, so the example should look > like: > > $i = > 22 * 5; > $very_long_name = > 22 * 5; > > This doesn't work correctly now and should be fixed. > > I think you expect that after formatting your code with Multiline Alignment > Assignment option on the result should be: > > <?php > > $test = 'test1'; > $param1 = 'test2'; > $longParam = 'test2'; > > class test > { > const TEST = 't'; > const LONG_CONST = 't'; > } > > ?> > > I'm right? But this is not very easy to do. At first, it has to be clear which > lines should be affected with this. Like the following code should be: > > $x = 10; > $y = 20; > $center = poin($x, $y); > > $some_rectangle = Rectangle(1,1,2,2); > > or > > $x = 10; > $y = 20; > $center = poin($x, $y); > > $some_rectangle = Rectangle(1,1,2,2); > > So at first we have to define the behavior, which blog of lines will be > aligned. Hi, Our internal coding standards: 1) Equals signs should be alinged across multiple lines within groupings. - Groupings defined by line breaks - Alignment is to the longest paramter. 2) Array seperators should be aligned (=>) across multiple lines. - Alignment is to the longest paramter. Hope this helps define a possible use case. Thanks, Ben Using: Netbeans (PHP v6.9) Still I have not had time to do it. :( Our development agency would benefit hugely from an implementation of bwaine@netbeans.org's suggestion: 1) Equals signs should be alinged across multiple lines within groupings. - Groupings defined by line breaks - Alignment is to the longest paramter. 2) Array seperators should be aligned (=>) across multiple lines. - Alignment is to the longest paramter. If I could get this one piece implemented then my entire team could begin using the formatter before all checkins, and thusly making everyone's life a bit easier. Thank you in advance for implementing such a useful feature. This bug can not be P1. It doesn't prevent to use the feature. I have added new "Group Mulitline Alignment" group of options. There are two options: Assignment and Array Initializer. The Assignment switches on/off the group alignment for assignments, fields inisializers, constant declarations. The group of line is limited to a block and empty lines as suggested. By default these options are switch off, so you have to switch on in the options. Please test it, whether it works ok. Thanks. The change http://hg.netbeans.org/web-main/rev/9023a454e522 Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/9023a454e522 User: Petr Pisl <ppisl@netbeans.org> Log: #187734 - Group Assignment Multiline Alignment doesn't work can we also have it for java code formatting? You have to ask "Java" component. Product Version: NetBeans IDE Dev (Build 2011-12-04_18-04-28 ) Java: 1.6.0_29; Java HotSpot(TM) Client VM 20.4-b02 System: Windows 7 version 6.1 running on x86; Cp1250; cs_CZ (nb) This is something what I am getting after code format: ORIGINAL: class Foo { public function getStylesheets() { $e = "\n"; $t = "\t"; $cond = null; $styleSheetsHTML = $e; for($i = 0; $i < sizeof($this->stylesheets); $i++) { // } } } FORMATTED: class Foo { public function getStylesheets() { $e = "\n"; $t = "\t"; $cond = null; $styleSheetsHTML = $e; for($i = 0; $i < sizeof($this->stylesheets); $i++) { // } } } Is does not seems correctly formatted and I am seeing big problem about formatting inside FOR parenthesis. This should be left intact by Group Multiline Alignment. Hoewer, it can be "solved" by leaving empty line above FOR, but i think this is should be formatted by Category->Spaces->Around Operators aftewards. I have option Category->Spaces->Around Operators->Assignment Operator set to TRUE. So I think, that Group Multiline Alignment should not be applied as the last formatter. Created attachment 113821 [details]
Previous post in ZIP format
Sorry, here is an attachment with above post, because is wrong represented by these web pages.
@Raazy: it's a bug, it would be better to open new issues and keep this closed. It should be easy to fix. 10 votes ... P2 The votes were there to implement this feature. As I wrote this issue should be closed (the feature is implemented) and the cases, where it doesn't work properly, there should be new issues. As Petr wrote, closing this "implemented" issue. New one for a bug is tracked here #209030 Happens to me reliably immediately after IDE is started. 9 duplicates so far. http://www.worldphoto.org/profile/RobertPattinson/ http://pinterest.com/googleclone/samsung-galaxy-note-cases/ http://director-ee.com/profile/cyberworldltd I have the following code block after formatted: class A extends B { protected $arr = ['a' => 1, 'aa' => 2, 'aaa' => 3, 'aaaa' => 4,] protected $arr1 = ['a' => [1, 2, 3, 4,], 'b' => ['b',],]; } in PHPStorm it will becomes class A extends B { protected $arr = ['a' => 1, 'aa' => 2, 'aaa' => 3, 'aaaa' => 4,] protected $arr1 = ['a' => [1, 2, 3, 4,], 'ab' => ['b',],]; } It looks much more smarter. How to do with Netbeans. I try some search but no luck. Does Netbeans support that ? It would be appreciated. @harunaga: Please, do not reopen fixed issues. Simply report a new one, provide information which NetBeans and JDK version you have, provide exact steps to reproduce and do not forget to attach your IDE log [1] once you reproduce your problem. Thanks. [1] http://wiki.netbeans.org/FaqLogMessagesFile |