| 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
|
44
|
|
|
44
|
|
248
|
use strict; |
|
|
44
|
|
|
|
|
4105
|
|
|
|
44
|
|
|
|
|
3336
|
|
|
11
|
44
|
|
|
44
|
|
1215
|
use warnings; |
|
|
44
|
|
|
|
|
488
|
|
|
|
44
|
|
|
|
|
2939
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '20260204'; |
|
14
|
44
|
|
|
44
|
|
355
|
use English qw( -no_match_vars ); |
|
|
44
|
|
|
|
|
67
|
|
|
|
44
|
|
|
|
|
215
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
|
17
|
|
|
|
|
|
|
# List of hash keys to prevent -duk from listing them. |
|
18
|
|
|
|
|
|
|
my @unique_hash_keys_uu = qw( maximum_line_length ); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Catch any undefined sub calls so that we are sure to get |
|
24
|
|
|
|
|
|
|
# some diagnostic information. This sub should never be called |
|
25
|
|
|
|
|
|
|
# except for a programming error. |
|
26
|
0
|
|
|
0
|
|
0
|
our $AUTOLOAD; |
|
27
|
0
|
0
|
|
|
|
0
|
return if ( $AUTOLOAD =~ /\bDESTROY$/ ); |
|
28
|
0
|
|
|
|
|
0
|
my ( $pkg, $fname, $lno ) = caller(); |
|
29
|
0
|
|
|
|
|
0
|
my $my_package = __PACKAGE__; |
|
30
|
0
|
|
|
|
|
0
|
print {*STDERR} <<EOM; |
|
|
0
|
|
|
|
|
0
|
|
|
31
|
|
|
|
|
|
|
====================================================================== |
|
32
|
|
|
|
|
|
|
Error detected in package '$my_package', version $VERSION |
|
33
|
|
|
|
|
|
|
Received unexpected AUTOLOAD call for sub '$AUTOLOAD' |
|
34
|
|
|
|
|
|
|
Called from package: '$pkg' |
|
35
|
|
|
|
|
|
|
Called from File '$fname' at line '$lno' |
|
36
|
|
|
|
|
|
|
This error is probably due to a recent programming change |
|
37
|
|
|
|
|
|
|
====================================================================== |
|
38
|
|
|
|
|
|
|
EOM |
|
39
|
0
|
|
|
|
|
0
|
exit 1; |
|
40
|
|
|
|
|
|
|
} ## end sub AUTOLOAD |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
0
|
|
|
sub DESTROY { |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# required to avoid call to AUTOLOAD in some versions of perl |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Constructor may be called as a class method |
|
48
|
|
|
|
|
|
|
sub new { |
|
49
|
|
|
|
|
|
|
|
|
50
|
3589
|
|
|
3589
|
0
|
7406
|
my ( $class, $rhash ) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Create a new VerticalAligner::Line object |
|
53
|
|
|
|
|
|
|
# Given: |
|
54
|
|
|
|
|
|
|
# $rhash = ref to hash for a Line |
|
55
|
|
|
|
|
|
|
# This hash contains parameters describing one line. |
|
56
|
|
|
|
|
|
|
# The parameters currently used by this object are: |
|
57
|
|
|
|
|
|
|
# {ralignments} = ref to array of vertical alignment columns |
|
58
|
|
|
|
|
|
|
# {jmax} = max index of {ralignments} |
|
59
|
|
|
|
|
|
|
# {maximum_line_length} = maximum number of spaces for this line |
|
60
|
|
|
|
|
|
|
|
|
61
|
3589
|
|
|
|
|
6560
|
my $self = bless $rhash, $class; |
|
62
|
3589
|
|
|
|
|
7714
|
return $self; |
|
63
|
|
|
|
|
|
|
} ## end sub new |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_column { |
|
66
|
|
|
|
|
|
|
|
|
67
|
3022
|
|
|
3022
|
0
|
4231
|
my ( $self, $j ) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Return the current column number of alignment $j |
|
70
|
|
|
|
|
|
|
|
|
71
|
3022
|
|
|
|
|
4288
|
my $alignment = $self->{ralignments}->[$j]; |
|
72
|
3022
|
50
|
|
|
|
4998
|
return unless ( defined($alignment) ); |
|
73
|
3022
|
|
|
|
|
6386
|
return $alignment->get_column(); |
|
74
|
|
|
|
|
|
|
} ## end sub get_column |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub current_field_width { |
|
77
|
|
|
|
|
|
|
|
|
78
|
4014
|
|
|
4014
|
0
|
5495
|
my ( $self, $j ) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Return number of columns of space between alignments $j and $j-1 |
|
81
|
|
|
|
|
|
|
|
|
82
|
4014
|
|
|
|
|
5087
|
my $alignment_j = $self->{ralignments}->[$j]; |
|
83
|
4014
|
50
|
|
|
|
7505
|
my $col_j = defined($alignment_j) ? $alignment_j->get_column() : 0; |
|
84
|
4014
|
100
|
|
|
|
7153
|
return $col_j if ( $j == 0 ); |
|
85
|
|
|
|
|
|
|
|
|
86
|
2873
|
|
|
|
|
6385
|
my $alignment_jm = $self->{ralignments}->[ $j - 1 ]; |
|
87
|
2873
|
50
|
|
|
|
5425
|
my $col_jm = defined($alignment_jm) ? $alignment_jm->get_column() : 0; |
|
88
|
2873
|
|
|
|
|
4546
|
return $col_j - $col_jm; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} ## end sub current_field_width |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub increase_field_width { |
|
93
|
|
|
|
|
|
|
|
|
94
|
3043
|
|
|
3043
|
0
|
4535
|
my ( $self, $j, $pad ) = @_; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Increase the width of alignment field $j by $pad spaces. |
|
97
|
|
|
|
|
|
|
# So we must increase the widths of the higher alignments by $pad spaces. |
|
98
|
3043
|
|
|
|
|
3976
|
my $jmax = $self->{jmax}; |
|
99
|
3043
|
|
|
|
|
4624
|
foreach ( $j .. $jmax ) { |
|
100
|
7191
|
|
|
|
|
8269
|
my $alignment = $self->{ralignments}->[$_]; |
|
101
|
7191
|
50
|
|
|
|
9879
|
if ( defined($alignment) ) { |
|
102
|
7191
|
|
|
|
|
11067
|
$alignment->increment_column($pad); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
3043
|
|
|
|
|
4321
|
return; |
|
106
|
|
|
|
|
|
|
} ## end sub increase_field_width |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_available_space_on_right { |
|
109
|
1801
|
|
|
1801
|
0
|
2565
|
my $self = shift; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Return the number of unused columns to the right of the last alignment |
|
112
|
1801
|
|
|
|
|
2701
|
my $jmax = $self->{jmax}; |
|
113
|
1801
|
|
|
|
|
4391
|
return $self->{maximum_line_length} - $self->get_column($jmax); |
|
114
|
|
|
|
|
|
|
} ## end sub get_available_space_on_right |
|
115
|
|
|
|
|
|
|
1; |