File Coverage

blib/lib/Perl/Tidy/VerticalAligner/Line.pm
Criterion Covered Total %
statement 36 41 87.8
branch 7 12 58.3
condition n/a
subroutine 9 9 100.0
pod 0 5 0.0
total 52 67 77.6


line stmt bran cond sub pod time code
1             #####################################################################
2             #
3             # The Perl::Tidy::VerticalAligner::Line class supplies an object to
4             # contain a single output line. It allows manipulation of the
5             # alignment columns on that line.
6             #
7             #####################################################################
8              
9             package Perl::Tidy::VerticalAligner::Line;
10 39     39   284 use strict;
  39         84  
  39         1216  
11 39     39   211 use warnings;
  39         97  
  39         1049  
12 39     39   207 use English qw( -no_match_vars );
  39         84  
  39         230  
13             our $VERSION = '20230912';
14              
15             sub AUTOLOAD {
16              
17             # Catch any undefined sub calls so that we are sure to get
18             # some diagnostic information. This sub should never be called
19             # except for a programming error.
20 2996     2996   5967 our $AUTOLOAD;
21 2996 50       45940 return if ( $AUTOLOAD =~ /\bDESTROY$/ );
22 0         0 my ( $pkg, $fname, $lno ) = caller();
23 0         0 my $my_package = __PACKAGE__;
24 0         0 print {*STDERR} <<EOM;
  0         0  
25             ======================================================================
26             Error detected in package '$my_package', version $VERSION
27             Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
28             Called from package: '$pkg'
29             Called from File '$fname' at line '$lno'
30             This error is probably due to a recent programming change
31             ======================================================================
32             EOM
33 0         0 exit 1;
34             } ## end sub AUTOLOAD
35              
36             {
37              
38             # Constructor may be called as a class method
39             sub new {
40 3066     3066 0 8644 my ( $class, $ri ) = @_;
41 3066         7006 my $self = bless $ri, $class;
42 3066         7889 return $self;
43             }
44              
45             sub get_column {
46 2640     2640 0 4868 my ( $self, $j ) = @_;
47 2640         4580 my $alignment = $self->{ralignments}->[$j];
48 2640 50       5478 return unless defined($alignment);
49 2640         6930 return $alignment->get_column();
50             } ## end sub get_column
51              
52             sub current_field_width {
53 3435     3435 0 5915 my ( $self, $j ) = @_;
54 3435         4883 my $col_j = 0;
55 3435         4757 my $col_jm = 0;
56              
57 3435         5535 my $alignment_j = $self->{ralignments}->[$j];
58 3435 50       8909 $col_j = $alignment_j->get_column() if defined($alignment_j);
59              
60 3435 100       7349 if ( $j > 0 ) {
61 2441         4841 my $alignment_jm = $self->{ralignments}->[ $j - 1 ];
62 2441 50       6518 $col_jm = $alignment_jm->get_column() if defined($alignment_jm);
63             }
64 3435         7378 return $col_j - $col_jm;
65             } ## end sub current_field_width
66              
67             sub increase_field_width {
68              
69 2669     2669 0 5011 my ( $self, $j, $pad ) = @_;
70 2669         4479 my $jmax = $self->{jmax};
71 2669         5407 foreach ( $j .. $jmax ) {
72 6368         9705 my $alignment = $self->{ralignments}->[$_];
73 6368 50       11515 if ( defined($alignment) ) {
74 6368         12617 $alignment->increment_column($pad);
75             }
76             }
77 2669         5090 return;
78             } ## end sub increase_field_width
79              
80             sub get_available_space_on_right {
81 1564     1564 0 3179 my $jmax = $_[0]->{jmax};
82 1564         4532 return $_[0]->{maximum_line_length} - $_[0]->get_column($jmax);
83             }
84             }
85              
86             1;