"Fossies" - the Fresh Open Source Software Archive

Member "Perl-Tidy-20210717/lib/Perl/Tidy/VerticalAligner/Line.pm" (14 Jul 2021, 7879 Bytes) of package /linux/misc/Perl-Tidy-20210717.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Line.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 20210402_vs_20210717.

    1 #####################################################################
    2 #
    3 # the Perl::Tidy::VerticalAligner::Line class supplies an object to
    4 # contain a single output line
    5 #
    6 #####################################################################
    7 
    8 package Perl::Tidy::VerticalAligner::Line;
    9 use strict;
   10 use warnings;
   11 our $VERSION = '20210717';
   12 
   13 BEGIN {
   14     my $i = 0;
   15     use constant {
   16         _jmax_                      => $i++,
   17         _rtokens_                   => $i++,
   18         _rfields_                   => $i++,
   19         _rfield_lengths_            => $i++,
   20         _rpatterns_                 => $i++,
   21         _indentation_               => $i++,
   22         _leading_space_count_       => $i++,
   23         _outdent_long_lines_        => $i++,
   24         _list_seqno_                => $i++,
   25         _list_type_                 => $i++,
   26         _is_hanging_side_comment_   => $i++,
   27         _ralignments_               => $i++,
   28         _maximum_line_length_       => $i++,
   29         _rvertical_tightness_flags_ => $i++,
   30         _is_terminal_ternary_       => $i++,
   31         _j_terminal_match_          => $i++,
   32         _end_group_                 => $i++,
   33         _Kend_                      => $i++,
   34         _ci_level_                  => $i++,
   35         _level_                     => $i++,
   36         _level_end_                 => $i++,
   37         _imax_pair_                 => $i++,
   38     };
   39 }
   40 
   41 sub AUTOLOAD {
   42 
   43     # Catch any undefined sub calls so that we are sure to get
   44     # some diagnostic information.  This sub should never be called
   45     # except for a programming error.
   46     our $AUTOLOAD;
   47     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
   48     my ( $pkg, $fname, $lno ) = caller();
   49     my $my_package = __PACKAGE__;
   50     print STDERR <<EOM;
   51 ======================================================================
   52 Error detected in package '$my_package', version $VERSION
   53 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
   54 Called from package: '$pkg'  
   55 Called from File '$fname'  at line '$lno'
   56 This error is probably due to a recent programming change
   57 ======================================================================
   58 EOM
   59     exit 1;
   60 }
   61 
   62 {
   63 
   64     ##use Carp;
   65 
   66     # Constructor may be called as a class method
   67     sub new {
   68         my ( $class, $ri ) = @_;
   69         my $self = bless [], $class;
   70 
   71         $self->[_jmax_]                      = $ri->{jmax};
   72         $self->[_rtokens_]                   = $ri->{rtokens};
   73         $self->[_rfields_]                   = $ri->{rfields};
   74         $self->[_rfield_lengths_]            = $ri->{rfield_lengths};
   75         $self->[_rpatterns_]                 = $ri->{rpatterns};
   76         $self->[_indentation_]               = $ri->{indentation};
   77         $self->[_leading_space_count_]       = $ri->{leading_space_count};
   78         $self->[_outdent_long_lines_]        = $ri->{outdent_long_lines};
   79         $self->[_list_type_]                 = $ri->{list_type};
   80         $self->[_list_seqno_]                = $ri->{list_seqno};
   81         $self->[_is_hanging_side_comment_]   = $ri->{is_hanging_side_comment};
   82         $self->[_maximum_line_length_]       = $ri->{maximum_line_length};
   83         $self->[_rvertical_tightness_flags_] = $ri->{rvertical_tightness_flags};
   84         $self->[_is_terminal_ternary_]       = $ri->{is_terminal_ternary};
   85         $self->[_j_terminal_match_]          = $ri->{j_terminal_match};
   86         $self->[_end_group_]                 = $ri->{end_group};
   87         $self->[_Kend_]                      = $ri->{Kend};
   88         $self->[_ci_level_]                  = $ri->{ci_level};
   89         $self->[_level_]                     = $ri->{level};
   90         $self->[_level_end_]                 = $ri->{level_end};
   91         $self->[_imax_pair_]                 = $ri->{imax_pair};
   92 
   93         $self->[_ralignments_] = [];
   94 
   95         return $self;
   96     }
   97 
   98     sub get_jmax { return $_[0]->[_jmax_] }
   99 
  100     sub get_rtokens        { return $_[0]->[_rtokens_] }
  101     sub get_rfields        { return $_[0]->[_rfields_] }
  102     sub get_rfield_lengths { return $_[0]->[_rfield_lengths_] }
  103     sub get_rpatterns      { return $_[0]->[_rpatterns_] }
  104     sub get_indentation    { return $_[0]->[_indentation_] }
  105     sub get_Kend           { return $_[0]->[_Kend_] }
  106     sub get_ci_level       { return $_[0]->[_ci_level_] }
  107     sub get_level          { return $_[0]->[_level_] }
  108     sub get_level_end      { return $_[0]->[_level_end_] }
  109     sub get_list_seqno     { return $_[0]->[_list_seqno_] }
  110 
  111     sub get_imax_pair { return $_[0]->[_imax_pair_] }
  112 
  113     sub set_imax_pair {
  114         my ( $self, $val ) = @_;
  115         $self->[_imax_pair_] = $val;
  116         return;
  117     }
  118 
  119     sub get_j_terminal_match {
  120         return $_[0]->[_j_terminal_match_];
  121     }
  122 
  123     sub set_j_terminal_match {
  124         my ( $self, $val ) = @_;
  125         $self->[_j_terminal_match_] = $val;
  126         return;
  127     }
  128 
  129     sub get_is_terminal_ternary {
  130         return $_[0]->[_is_terminal_ternary_];
  131     }
  132 
  133     sub get_leading_space_count {
  134         return $_[0]->[_leading_space_count_];
  135     }
  136 
  137     sub get_outdent_long_lines {
  138         return $_[0]->[_outdent_long_lines_];
  139     }
  140     sub get_list_type { return $_[0]->[_list_type_] }
  141 
  142     sub get_is_hanging_side_comment {
  143         return $_[0]->[_is_hanging_side_comment_];
  144     }
  145 
  146     sub get_rvertical_tightness_flags {
  147         return $_[0]->[_rvertical_tightness_flags_];
  148     }
  149 
  150     sub get_alignment {
  151         my ( $self, $j ) = @_;
  152         return $self->[_ralignments_]->[$j];
  153     }
  154     sub get_alignments { return @{ $_[0]->[_ralignments_] } }
  155 
  156     sub get_column {
  157         ##my ( $self, $j ) = @_;
  158         my $alignment = $_[0]->[_ralignments_]->[ $_[1] ];
  159         return unless defined($alignment);
  160         return $alignment->get_column();
  161     }
  162 
  163     sub set_alignments {
  164         my ( $self, @args ) = @_;
  165         @{ $self->[_ralignments_] } = @args;
  166         return;
  167     }
  168 
  169     sub current_field_width {
  170         my ( $self, $j ) = @_;
  171         my $col_j  = 0;
  172         my $col_jm = 0;
  173 
  174         my $alignment_j = $self->[_ralignments_]->[$j];
  175         $col_j = $alignment_j->get_column() if defined($alignment_j);
  176 
  177         if ( $j > 0 ) {
  178             my $alignment_jm = $self->[_ralignments_]->[ $j - 1 ];
  179             $col_jm = $alignment_jm->get_column() if defined($alignment_jm);
  180         }
  181         return $col_j - $col_jm;
  182     }
  183 
  184     sub increase_field_width {
  185 
  186         my ( $self, $j, $pad ) = @_;
  187         my $jmax = $self->[_jmax_];
  188         foreach ( $j .. $jmax ) {
  189             my $alignment = $self->[_ralignments_]->[$_];
  190             if ( defined($alignment) ) {
  191                 $alignment->increment_column($pad);
  192             }
  193         }
  194         return;
  195     }
  196 
  197     sub get_available_space_on_right {
  198         my $jmax = $_[0]->[_jmax_];
  199         return $_[0]->[_maximum_line_length_] - $_[0]->get_column($jmax);
  200     }
  201 
  202     sub set_jmax { my ( $self, $val ) = @_; $self->[_jmax_] = $val; return }
  203 
  204     sub set_rtokens {
  205         my ( $self, $val ) = @_;
  206         $self->[_rtokens_] = $val;
  207         return;
  208     }
  209 
  210     sub set_rfields {
  211         my ( $self, $val ) = @_;
  212         $self->[_rfields_] = $val;
  213         return;
  214     }
  215 
  216     sub set_rfield_lengths {
  217         my ( $self, $val ) = @_;
  218         $self->[_rfield_lengths_] = $val;
  219         return;
  220     }
  221 
  222     sub set_rpatterns {
  223         my ( $self, $val ) = @_;
  224         $self->[_rpatterns_] = $val;
  225         return;
  226     }
  227 
  228     sub set_list_type {
  229         my ( $self, $val ) = @_;
  230         $self->[_list_type_] = $val;
  231         return;
  232     }
  233 
  234     sub set_is_hanging_side_comment {
  235         my ( $self, $val ) = @_;
  236         $self->[_is_hanging_side_comment_] = $val;
  237         return;
  238     }
  239 
  240     sub set_alignment {
  241         my ( $self, $j, $val ) = @_;
  242         $self->[_ralignments_]->[$j] = $val;
  243         return;
  244     }
  245 
  246     sub get_end_group { return $_[0]->[_end_group_] }
  247 
  248     sub set_end_group {
  249         my ( $self, $val ) = @_;
  250         $self->[_end_group_] = $val;
  251         return;
  252     }
  253 }
  254 
  255 1;