my $iline_ic = $inner_closing->[_LINE_INDEX_];
- # DO-NOT-WELD RULE 2:
- # Do not weld an opening paren to an inner one line brace block
+ # DO-NOT-WELD RULE 2a:
+ # Do not weld an opening paren to an inner one line sub block
# We will just use old line numbers for this test and require
# iterations if necessary for convergence
my $token_oo = $outer_opening->[_TOKEN_];
my $block_type_io = $inner_opening->[_BLOCK_TYPE_];
my $token_io = $inner_opening->[_TOKEN_];
- $do_not_weld ||= $token_oo eq '(' && $token_io eq '{';
+ my $type_io = $inner_opening->[_TYPE_];
+ $do_not_weld ||=
+ $token_oo eq '('
+ && $token_io eq '{'
+ && $block_type_io =~ /$SUB_PATTERN/
+ || $block_type_io =~ /$ASUB_PATTERN/;
+ }
+
+ # DO-NOT-WELD RULE 2b:
+ # Do not weld to open hash brace which is not separated from its closing
+ # brace by two lines. We want to avoid something like this
+ # foreach
+ # (@{$numbers{$num}->{$num . $rowcode . $colcode}})
+ # and prefer this:
+ # $Self->_Add(
+ # $SortOrderDisplay{$Field->GenerateFieldForSelectSQL()});
+ # instead of this:
+ # $Self->_Add($SortOrderDisplay{$Field
+ # ->GenerateFieldForSelectSQL()});
+ if ( $iline_ic - $iline_io < 2 ) {
+ my $type_io = $inner_opening->[_TYPE_];
+ $do_not_weld ||= $type_io eq 'L';
}
# DO-NOT-WELD RULE 3:
# $a->$b($c);
$binary_bond_strength{'i'}{'->'} = 1.45 * STRONG;
+ # Note that the following alternative strength would make the break at the
+ # '->' rather than opening the '('. Both have advantages and disadvantages.
+ # $binary_bond_strength{'i'}{'->'} = 0.5*STRONG + 0.5 * NOMINAL; #
+
$binary_bond_strength{'))'}{'->'} = 0.1 * STRONG + 0.9 * NOMINAL;
$binary_bond_strength{']]'}{'->'} = 0.1 * STRONG + 0.9 * NOMINAL;
$binary_bond_strength{'})'}{'->'} = 0.1 * STRONG + 0.9 * NOMINAL;
--- /dev/null
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add(
+ $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+ );
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f(
+ do { 1; !!( my $x = bless [] ); }
+ );
--- /dev/null
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add(
+ $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+ );
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f( do { 1; !!( my $x = bless [] ); } );
../snippets9.t rt98902.def
../snippets9.t rt98902.rt98902
../snippets9.t rt99961.def
+../snippets17.t wn7.def
+../snippets17.t wn7.wn
--- /dev/null
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add($SortOrderDisplay{$Field
+ ->GenerateFieldForSelectSQL()});
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f(
+ do { 1; !!(my $x = bless []); }
+ );
#3 signature.def
#4 rperl.def
#5 rperl.rperl
+#6 wn7.def
+#7 wn7.wn
# To locate test #13 you can search for its name or the string '#13'
'def' => "",
'rperl' => "-l=0",
'rt132059' => "-dac",
+ 'wn' => "-wn",
};
############################
my $subref = sub ( $cat, $id = do { state $auto_id = 0; $auto_id++ } ) {
...;
};
+----------
+
+ 'wn7' => <<'----------',
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add($SortOrderDisplay{$Field
+ ->GenerateFieldForSelectSQL()});
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f(
+ do { 1; !!(my $x = bless []); }
+ );
----------
};
}
#5...........
},
+
+ 'wn7.def' => {
+ source => "wn7",
+ params => "def",
+ expect => <<'#6...........',
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add(
+ $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+ );
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f(
+ do { 1; !!( my $x = bless [] ); }
+ );
+#6...........
+ },
+
+ 'wn7.wn' => {
+ source => "wn7",
+ params => "wn",
+ expect => <<'#7...........',
+ # illustrate wn rule 2b: do not weld to opening hash brace
+ # if closing brace is not >=2 lines away
+ $Self->_Add(
+ $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+ );
+
+ # rule 2a forerly applied to all blocks, but now only
+ # applies to subs, so this weld is now okay with -wn
+ f( do { 1; !!( my $x = bless [] ); } );
+#7...........
+ },
};
my $ntests = 0 + keys %{$rtests};