my $rtokens = $line_of_tokens_old->{_rtokens};
my $jmax = @{$rtokens} - 1;
- return if ( $jmax < 0 ); # safety check; shouldn't happen
+ if ( $jmax < 0 ) {
+
+ # safety check; shouldn't happen
+ DEVEL_MODE && Fault("unexpected jmax=$jmax\n");
+ return;
+ }
my $line_number = $line_of_tokens_old->{_line_number};
my $rtoken_type = $line_of_tokens_old->{_rtoken_type};
if ( $line_type ne 'CODE' ) {
# shouldn't happen
+ DEVEL_MODE && Fault("unexpected line_type=$line_type\n");
next;
}
my $CODE_type = $line_of_tokens->{_code_type};
unless ( defined($Kfirst) && $rLL->[$Klast]->[_TYPE_] eq '#' ) {
# shouldn't happen
+ DEVEL_MODE && Fault("did not get a comment\n");
next;
}
next unless ( $Klast > $Kfirst ); # maybe HSC
#-----------------------------------------------------------------
foreach my $KK ( $Kfirst .. $Klast ) {
- # TODO: eliminate this closure var by passing directly to store_token
- # following pattern of store_tokens_to_go.
+ # TODO: consider eliminating this closure var by passing directly to
+ # store_token following pattern of store_tokens_to_go.
$Ktoken_vars = $KK;
my $rtoken_vars = $rLL->[$KK];
# Decide if a trailing comma rule is matched.
# Input parameter:
- # $KK = index of closing token in old ($rLL) token list
- # which starts a new line and is not preceded by a comma
+ # $KK = index of closing token in old ($rLL) token list which follows
+ # the location of a possible trailing comma. See diagram below.
# $Kfirst = (old) index of first token on the current line of input tokens
# $trailing_comma_rule = packed user control flags
# $if_add = true if adding comma, false if deleteing comma
# bless {
# _name => $name,
# _price => $price,
- # _rebate => $rebate <------ location of possible bare comma
+ # _rebate => $rebate <------ location of possible trailing comma
# }, $pkg;
- # ^-------------------closing token at index $KK on new line
+ # ^-------------------closing token at index $KK
return unless ($trailing_comma_rule);
my ( $trailing_comma_style, $paren_flag ) = @{$trailing_comma_rule};
# undef stable: do not change
# '0' never want trailing commas
# '* or 1' always want trailing commas
- # 'h' add a bare trailing comma to a stable list with about
- # one comma per line (such as Hash list of key=>value pairs).
- # 'b' want bare trailing commas ( followed by newline )
# 'm' want multiline trailing commas
# (i.e., opening and closing tokens are on different lines)
+ # 'b' want bare trailing commas ( followed by newline )
+ # 'h' add a bare trailing comma to a stable list with about
+ # one comma per line (such as Hash list of key=>value pairs).
- #-----------------------
- # undef : do not change
- #-----------------------
+ #-----------------------------------------
+ # No style defined : do not add or delete
+ #-----------------------------------------
if ( !defined($trailing_comma_style) ) { return !$if_add }
#----------------------------------------
#------------------------------------------------------------------
elsif ( $trailing_comma_style eq 'h' ) {
+ # This is a minimal style which can put trailing commas where
+ # they are most useful - at the end of simple lists which might,
+ # for example, need to be sorted.
+
return if ( !$is_bare_comma );
my $blank_line_count =
}
}
- # Unrecognized parameter, ignore. Should have been caught in input check
+ #-------------------------------------------------------------------------
+ # Unrecognized parameter. This should have been caught in the input check.
+ #-------------------------------------------------------------------------
else {
DEVEL_MODE && Fault("Unrecognized parameter '$trailing_comma_style'\n");
- # treat unknown parameter as stable
+ # do not add or delete
return !$if_add;
}
# shouldn't happen, but not a critical error
else {
- DEBUG_UNDOBP && do {
+ if (DEVEL_MODE) {
my ( $a, $b, $c ) = caller();
- print STDOUT
-"Program Bug: undo_forced_breakpoint from $a $c has i=$i but max=$max_index_to_go";
- };
+ Fault(<<EOM);
+Program Bug: undo_forced_breakpoint from $a $c has i=$i but max=$max_index_to_go
+EOM
+ }
}
}
return;
# shouldn't happen
$seqno = 'UNKNOWN';
+ DEVEL_MODE && Fault("unable to find sequence number\n");
}
}
# Do not recombine at comma which is following the
# input bias.
- # TODO: might be best to make a special flag
+ # NOTE: this could be controlled by a special flag,
+ # but it seems to work okay.
return if ( $old_breakpoint_to_go[$iend_1] );
# An isolated '},' may join with an identifier + ';'
}
else {
- ## TODO: verify that this equals closure var $type_sequence
+ # NOTE: $seqno will be equal to closure var $type_sequence here
my $seqno = $type_sequence_to_go[$i_opening];
$saw_opening_structure =
!$self->match_paren_control_flag( $seqno, $flag );
# shouldn't happen; non-critical error
else {
- 0 && do {
+ if (DEVEL_MODE) {
my ( $a, $b, $c ) = caller();
- print STDOUT
- "NOBREAK ERROR: from $a $c with i=$i j=$j max=$max_index_to_go\n";
- };
+ Fault(<<EOM);
+NOBREAK ERROR: from $a $c with i=$i j=$j max=$max_index_to_go
+EOM
+ }
}
return;
} ## end sub set_nobreaks
{
my $KK = $K_to_go[$ii];
$level = $radjusted_levels->[$KK];
- if ( $level < 0 ) { $level = 0 } # note: this should not happen
+ if ( $level < 0 ) {
+
+ # should not happen
+ DEVEL_MODE && Fault("unexpected level=$level\n");
+ $level = 0;
+ }
}
# get the top state from the stack if it has changed
# Skip an empty set of parens, such as after channel():
# my $exchange = $self->_channel()->exchange(
# This fixes issues b1318 b1322 b1323 b1328
- # TODO: maybe also skip parens with just one token?
my $is_empty_container;
if ( $ii_last_equals && $ii < $max_index_to_go ) {
my $seqno = $type_sequence_to_go[$ii];
else {
# shouldn't happen
+ DEVEL_MODE
+ && Fault("unexpected request for pad spaces = $pad_spaces\n");
return;
}
# $rindentation_list - reference to a list containing the indentation
# used for each line.
# $qw_seqno - optional sequence number to use if normal seqno not defined
- # (TODO: would be more general to just look this up from index i)
+ # (NOTE: would be more general to just look this up from index i)
#
# return:
# -the indentation of the line which contained the opening token