]> git.donarmstrong.com Git - perltidy.git/commitdiff
eliminate variable 'level_jump' from vertical aligner
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 3 Aug 2021 02:44:03 +0000 (19:44 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 3 Aug 2021 02:44:03 +0000 (19:44 -0700)
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/VerticalAligner.pm

index 5c801e73b5b19c76547d1192e3be812fdcad86cf..33bc9f89de1fa01589e64f67c0a6ce859ae43e21 100644 (file)
@@ -19165,10 +19165,7 @@ sub send_lines_to_vertical_aligner {
         my $Kend_code =
           $batch_CODE_type && $batch_CODE_type ne 'VER' ? undef : $Kend;
 
-        # We need two slightly different definitions of level jump:
-        #  $level_jump is the 'slevel' jump across line starts for valign
         #  $ljump is a level jump needed by 'sub set_adjusted_indentation'
-        my $level_jump = 0;
         my $ljump      = 0;
 
         # Get some vars on line [n+1], if any:
@@ -19179,8 +19176,6 @@ sub send_lines_to_vertical_aligner {
             $token_beg_next = $rLL->[$Kbeg_next]->[_TOKEN_];
             $type_end_next  = $rLL->[$Kend_next]->[_TYPE_];
             $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
-            $level_jump =
-              $rLL->[$Kbeg_next]->[_SLEVEL_] - $rLL->[$Kbeg]->[_SLEVEL_];
         }
         else {
 
@@ -19190,8 +19185,6 @@ sub send_lines_to_vertical_aligner {
             if ( defined($Kbeg_next) ) {
                 $ljump =
                   $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
-                $level_jump =
-                  $rLL->[$Kbeg_next]->[_SLEVEL_] - $rLL->[$Kbeg]->[_SLEVEL_];
             }
         }
 
@@ -19349,7 +19342,6 @@ EOM
         $rvalign_hash->{outdent_long_lines}        = $outdent_long_lines;
         $rvalign_hash->{is_terminal_ternary}       = $is_terminal_ternary;
         $rvalign_hash->{rvertical_tightness_flags} = $rvertical_tightness_flags;
-        $rvalign_hash->{level_jump}                = $level_jump;
         $rvalign_hash->{rfields}                   = $rfields;
         $rvalign_hash->{rpatterns}                 = $rpatterns;
         $rvalign_hash->{rtokens}                   = $rtokens;
index a5223e5447bb820b45172395e13b4663e417f0ce..206fc83546ee976adc614c141cceeaa8f7a75669 100644 (file)
@@ -406,7 +406,6 @@ sub valign_input {
     my $outdent_long_lines        = $rline_hash->{outdent_long_lines};
     my $is_terminal_ternary       = $rline_hash->{is_terminal_ternary};
     my $rvertical_tightness_flags = $rline_hash->{rvertical_tightness_flags};
-    my $level_jump                = $rline_hash->{level_jump};
     my $rfields                   = $rline_hash->{rfields};
     my $rtokens                   = $rline_hash->{rtokens};
     my $rpatterns                 = $rline_hash->{rpatterns};
@@ -421,9 +420,6 @@ sub valign_input {
     # The index '$Kend' is a value which passed along with the line text to sub
     # 'write_code_line' for a convergence check.
 
-    # NOTE: the coding has been revised to avoid use of '$level_jump'.
-    # Eventually it can be eliminated as a call parameter.
-
     # number of fields is $jmax
     # number of tokens between fields is $jmax-1
     my $jmax = @{$rfields} - 1;
@@ -503,7 +499,7 @@ sub valign_input {
         if (   $cached_line_type == 3
             && !$self->group_line_count()
             && $cached_line_flag < 2
-            && !$is_balanced_line )    ##&& $level_jump != 0 )
+            && !$is_balanced_line )
         {
             set_cached_line_valid(0);
         }
@@ -581,7 +577,7 @@ sub valign_input {
     # alignment of the '{'.
     if (   $rfields->[0] eq 'else '
         && @{$rgroup_lines}
-        && $is_balanced_line )    ##&& $level_jump == 0 )
+        && $is_balanced_line )
     {
 
         $j_terminal_match =
@@ -712,12 +708,6 @@ sub valign_input {
         $self->_flush_group_lines(-1);
     }
 
-    ## OLD CODING:
-    ## Force break after jump to lower level
-    ## if ( $level_jump < 0 ) {
-    ##    $self->_flush_group_lines($level_jump);
-    ## }
-
     # --------------------------------------------------------------------
     # Some old debugging stuff
     # --------------------------------------------------------------------
@@ -1386,6 +1376,7 @@ sub _flush_group_lines {
 
     # $level_jump = $next_level-$group_level, if known
     #             = undef if not known
+    # Note: only the sign of the jump is needed
 
     my $rgroup_lines = $self->[_rgroup_lines_];
     return unless ( @{$rgroup_lines} );