@levels_to_go
@leading_spaces_to_go
@reduced_spaces_to_go
- @matching_token_to_go
@mate_index_to_go
@ci_levels_to_go
@nesting_depth_to_go
@summed_lengths_to_go = (); # line length to start of ith token
@token_lengths_to_go = ();
@levels_to_go = ();
- @matching_token_to_go = ();
@mate_index_to_go = ();
@ci_levels_to_go = ();
@nesting_depth_to_go = (0);
$container_environment_to_go[$max_index_to_go] = $container_environment;
$ci_levels_to_go[$max_index_to_go] = $ci_level;
$mate_index_to_go[$max_index_to_go] = -1;
- $matching_token_to_go[$max_index_to_go] = '';
$bond_strength_to_go[$max_index_to_go] = 0;
# Note: negative levels are currently retained as a diagnostic so that
my $rindentation_list = [0]; # ref to indentations for each line
- # define the array @matching_token_to_go for the output tokens
+ # define the array @{$ralignment_type_to_go} for the output tokens
# which will be non-blank for each special token (such as =>)
# for which alignment is required.
- set_vertical_alignment_markers( $ri_first, $ri_last );
+ my $ralignment_type_to_go =
+ $self->set_vertical_alignment_markers( $ri_first, $ri_last );
# flush if necessary to avoid unwanted alignment
my $must_flush = 0;
my $ibeg = $ri_first->[$n];
my $iend = $ri_last->[$n];
- delete_needless_alignments( $ibeg, $iend );
+ $self->delete_needless_alignments( $ibeg, $iend,
+ $ralignment_type_to_go );
my ( $rtokens, $rfields, $rpatterns ) =
- make_alignment_patterns( $ibeg, $iend );
+ $self->make_alignment_patterns( $ibeg, $iend,
+ $ralignment_type_to_go );
# Set flag to show how much level changes between this line
# and the next line, if we have it.
}
sub delete_needless_alignments {
- my ( $ibeg, $iend ) = @_;
+ my ( $self, $ibeg, $iend, $ralignment_type_to_go ) = @_;
- # Remove unwanted alignments. This routine is a place to remove alignments
- # which might cause problems at later stages. There are currently
- # two types of fixes:
+ # Remove unwanted alignments. This routine is a place to remove
+ # alignments which might cause problems at later stages. There are
+ # currently two types of fixes:
# 1. Remove excess parens
# 2. Remove alignments within 'elsif' conditions
my @imatch_list;
for my $i ( $ibeg .. $iend ) {
- if ( $matching_token_to_go[$i] ne '' ) {
+ if ( $ralignment_type_to_go->[$i] ne '' ) {
# Patch #2: undo alignment within elsif parens
if ( $i > $i_elsif_open && $i < $i_elsif_close ) {
- $matching_token_to_go[$i] = '';
+ $ralignment_type_to_go->[$i] = '';
next;
}
push @imatch_list, $i;
&& ( $ibeg > 1 || @imatch_list > 1 )
&& $imate > $i_good_paren )
{
- $matching_token_to_go[$imate] = '';
+ $ralignment_type_to_go->[$imate] = '';
pop @imatch_list;
}
}
# @patterns - a modified list of token types, one for each alignment
# field. These should normally each match before alignment is
# allowed, even when the alignment tokens match.
- my ( $ibeg, $iend ) = @_;
+ my ( $self, $ibeg, $iend, $ralignment_type_to_go ) = @_;
my @tokens = ();
my @fields = ();
my @patterns = ();
# matches.
# if we are not aligning on this paren...
- if ( $matching_token_to_go[$i] eq '' ) {
+ if ( $ralignment_type_to_go->[$i] eq '' ) {
# Sum length from previous alignment
my $len = token_sequence_length( $i_start, $i - 1 );
# if we find a new synchronization token, we are done with
# a field
- if ( $i > $i_start && $matching_token_to_go[$i] ne '' ) {
+ if ( $i > $i_start && $ralignment_type_to_go->[$i] ne '' ) {
- my $tok = my $raw_tok = $matching_token_to_go[$i];
+ my $tok = my $raw_tok = $ralignment_type_to_go->[$i];
# map similar items
my $tok_map = $operator_map{$tok};
# vertical alignment markers (such as an '=').
#
# Method: We look at each token $i in this output batch and set
- # $matching_token_to_go[$i] equal to those tokens at which we would
+ # $ralignment_type_to_go->[$i] equal to those tokens at which we would
# accept vertical alignment.
- my ( $ri_first, $ri_last ) = @_;
+ my ( $self, $ri_first, $ri_last ) = @_;
+
+ my $ralignment_type_to_go;
+ for my $i ( 0 .. $max_index_to_go ) {
+ $ralignment_type_to_go->[$i] = '';
+ }
# nothing to do if we aren't allowed to change whitespace
if ( !$rOpts_add_whitespace ) {
- for my $i ( 0 .. $max_index_to_go ) {
- $matching_token_to_go[$i] = '';
- }
- return;
+ return $ralignment_type_to_go;
}
# remember the index of last nonblank token before any sidecomment
my $block_type = $block_type_to_go[$i];
my $token = $tokens_to_go[$i];
- # check for flag indicating that we should not align
- # this token
- if ( $matching_token_to_go[$i] ) {
- $matching_token_to_go[$i] = '';
- next;
- }
-
# do not align tokens at lower level then start of line
# except for side comments
if ( $levels_to_go[$i] < $levels_to_go[$ibeg]
&& $types_to_go[$i] ne '#' )
{
- $matching_token_to_go[$i] = '';
+ $ralignment_type_to_go->[$i] = '';
next;
}
#--------------------------------------------------------
# then store the value
#--------------------------------------------------------
- $matching_token_to_go[$i] = $alignment_type;
+ $ralignment_type_to_go->[$i] = $alignment_type;
if ( $type ne 'b' ) {
$vert_last_nonblank_type = $type;
$vert_last_nonblank_token = $token;
}
}
}
- return;
+ return $ralignment_type_to_go;
}
}
my $i_break = $rcomma_index->[0];
set_forced_breakpoint($i_break);
${$rdo_not_break_apart} = 1;
- set_non_alignment_flags( $comma_count, $rcomma_index );
return;
}
${$rdo_not_break_apart} = 1;
}
}
- set_non_alignment_flags( $comma_count, $rcomma_index );
return;
}
${$rdo_not_break_apart} = 1;
}
}
- set_non_alignment_flags( $comma_count, $rcomma_index );
}
return;
}
}
}
-sub set_non_alignment_flags {
-
- # set flag which indicates that these commas should not be
- # aligned
- my ( $comma_count, $rcomma_index ) = @_;
- foreach ( 0 .. $comma_count - 1 ) {
- $matching_token_to_go[ $rcomma_index->[$_] ] = 1;
- }
- return;
-}
-
sub study_list_complexity {
# Look for complex tables which should be formatted with one term per line.
regex => [ $ws, $pod_or_DATA, $id, $exql ],
string => [ $ws, $pod_or_DATA, $id, $exql ],
code => [
- $ws, { DONT_MATCH => $pod_or_DATA },
+ $ws, { DONT_MATCH => $pod_or_DATA },
$variable, $id, { DONT_MATCH => \&extract_quotelike }
],
code_no_comments => [
{ DONT_MATCH => $comment },
- $ncws, { DONT_MATCH => $pod_or_DATA },
+ $ncws, { DONT_MATCH => $pod_or_DATA },
$variable, $id, { DONT_MATCH => \&extract_quotelike }
],
executable => [ $ws, { DONT_MATCH => $pod_or_DATA } ],
regex => [ $ws, $pod_or_DATA, $id, $exql ],
string => [ $ws, $pod_or_DATA, $id, $exql ],
code => [
- $ws, { DONT_MATCH => $pod_or_DATA },
+ $ws, { DONT_MATCH => $pod_or_DATA },
$variable, $id, { DONT_MATCH => \&extract_quotelike }
],
code_no_comments => [
{ DONT_MATCH => $comment },
- $ncws, { DONT_MATCH => $pod_or_DATA },
+ $ncws, { DONT_MATCH => $pod_or_DATA },
$variable, $id, { DONT_MATCH => \&extract_quotelike }
],
executable => [ $ws, { DONT_MATCH => $pod_or_DATA } ],